Private voidLikemyworkevent (editedimg img,BOOLIslike)//Like your own work . { if(Applicationmodel.userinfo! =NULL) {OffLineController.Instance.OffLine (); return; } if(Img.workid = =NULL|| Img.workid = ="")//This work does not have its own work ID and needs to be uploaded first{Uploadusereditedfileco (img, image={likemyworkevent (image, Islike);}); } Else{NetLoadcontroller.Instance.RequestUrlWidthMethodGet (applicationmodel.host+"/image/like?uid="+ ApplicationModel.userInfo.Uid +"&authoruid="+ ApplicationModel.userInfo.Uid +"&workid="+ Img.workid +"&action="+ Getactionstrbybool (islike) +"&sessionid="+ApplicationModel.userInfo.SessionId, (JSON, issuccess)={likerequestcallback (JSON, issuccess);} ); } }
PublicIEnumerator Uploadusereditedfileco (editedimg img, action<editedimg>calback) { yield return Newwaitforseconds (2f); //Todo:daiwanchengWwwform Postform =getpostformbyeditedimg (IMG); WWW Upload=NewWWW (Applicationmodel.host +"/image/savework", Postform); yield returnupload; NetLoadcontroller.Instance.RequestUrlWidthMethodPost (Applicationmodel.host+"/image/savework", Postform, (JSON, issuccess)={uploadusereditedfilecallback (JSON, Issuccess, IMG, calback);} ); }
Privatewwwform getpostformbyeditedimg (editedimg img) {wwwform postform=NewWwwform (); Postform.addfield ("imageId", Img.imageid); Postform.addbinarydata ("Clickpos", Getclickposfromimg (Img.imageid). Encodetopng (), Img.imageid +"_pos"); Postform.addbinarydata ("Palette", Getpalettefromimg (Img.imageid). Encodetopng (), Img.imageid +"_ed"); Postform.addfield ("deviceId", applicationmodel.device_id); Postform.addfield ("UID", ApplicationModel.userInfo.Uid); Postform.addbinarydata ("finalimg", Gettex2dfromimg (Img.imageid). Encodetopng (), Img.imageid); Postform.addfield ("sessionId", ApplicationModel.userInfo.SessionId); returnPostform; }
Private voidUploadusereditedfilecallback (stringJsonBOOLIssuccess, editedimg img, action<editedimg>calback) { if(issuccess) {Uploadeditedfilereturnjson Uploadeditedfilereturnjson= jsonconvert.deserializeobject<uploadeditedfilereturnjson>(JSON); if(Uploadeditedfilereturnjson.status = =0) {Img.workid=uploadEditedFileReturnJson.data.workId; Calback (IMG); } } Else { //: Upload failed } }
A piece of code written in C # that's pretty good.