Example #1
0
		public void sendUploadPhotoRequest(bool inConference, Guid bookingId, HttpRequestFileMetadata fileMetaData, Action<string> successful, Action<string> failure)
		{
			JsonObject jsonRequest = new JsonObject ();
			jsonRequest.Add (Constants.pInConference,inConference);
			jsonRequest.Add (Constants.pBookingId,bookingId);
			jsonRequest.Add (Constants.pUploadFile, fileMetaData);
			TCServices.sendUploadPhoto (jsonRequest, successful, failure);
		}
Example #2
0
		public void sendPhoto (bool pInConference, Guid bookingId, UIImage imageUpload, string name)
		{
			Action<string> successful = (response => {
			
				this.parentController.InvokeOnMainThread (delegate {	
					if (this.Delegate != null) {

						PhotoDTO photoDTO = CoreSystem.ParseDataHelper.parseResponseUploadPhoto(response);

						string message = "";
						string title = TCLocalizabled.getText("TitleAlertUpload");
						if (photoDTO.status) {
							message = TCLocalizabled.getText("TextMessageUploadSuccess");
						} else if (photoDTO.message == null || photoDTO.message.Equals("")) {
							message = TCLocalizabled.getText("TextRequestFail");
						} else {
							message = photoDTO.message;
						}
							
						this.Delegate.sendPhotoResult (this, photoDTO, title, message);
					}
				});
			});

			Action<string> failure = (response => {
				#if DEBUG
				Console.WriteLine ("FAILURE");
				#endif
				this.parentController.InvokeOnMainThread (delegate {	

					if (this.Delegate != null) {
						this.Delegate.sendPhotoResult (this, new PhotoDTO(), TCLocalizabled.getText("TitleNetworkStatus"), TCLocalizabled.getText("TextConnectionFailed"));
					}
				});
			});
				
			byte[] myByteImage = MUtils.UIImageToByteArray (imageUpload);

			HttpRequestFileMetadata fileMetadata = new HttpRequestFileMetadata (myByteImage, name);
			DataHelperRequest.getInstance ().sendUploadPhotoRequest (pInConference, bookingId, fileMetadata, successful, failure);
		}
Example #3
0
		private void sendUploadPhotoRequest (bool isInconference, Guid bookingId, byte[] bImages, string fileName)
		{
			actionUploadPhotoDelegate.onSendingUpload ();
			Action<string> successful = (response => {
				PhotoDTO photoDTO = ParseDataHelper.parseResponseUploadPhoto(response);
				_activity.RunOnUiThread (()=>{
					if(photoDTO.status){
						actionUploadPhotoDelegate.onUploadSuccess(photoDTO);
					} else {
						actionUploadPhotoDelegate.onUploadFail();
						if(photoDTO.message != null && !photoDTO.message.Equals("")){
							PopupNoticeInfomation popup = new PopupNoticeInfomation(_activity);
							popup.showNoticeDialog(_activity.GetString(Resource.String.upfile_title), photoDTO.message);
						}
						else {
							PopupNoticeInfomation popup = new PopupNoticeInfomation(_activity);
							popup.showNoticeDialog(_activity.GetString(Resource.String.upfile_title), _activity.GetString(Resource.String.uploadPhotoFail));
						}
					}
				});
			});
			Action<string> failure = (response => {
				_activity.RunOnUiThread (()=>{
					actionUploadPhotoDelegate.onUploadFail();
					PopupNoticeInfomation popup = new PopupNoticeInfomation(_activity);
					popup.showNoticeDialog(_activity.GetString(Resource.String.title_notice), _activity.GetString(Resource.String.connection_fail));
				});
			});
			if (fileName == null || fileName.Equals("")) {
				fileName = Utils.RandomString (20) + ".png";
			}
			HttpRequestFileMetadata metaData = new HttpRequestFileMetadata (bImages, fileName);
			DataHelperRequest.getInstance ().sendUploadPhotoRequest (isInconference, bookingId, metaData, successful, failure);
		}