/// <summary> /// Starts the request the delegate. /// </summary> /// <param name="requestMode">The request mode.</param> /// <param name="_theDelegate">The delegate.</param> /// <returns>True, if success</returns> public override bool StartRequest(UPOfflineRequestMode requestMode, UPOfflineRequestDelegate _theDelegate) { this.OfflineRequestDelegate = _theDelegate; string maxUploadFileSize = this.Configuration.ConfigValueDefaultValue("Sync.DocumentUploadMaxSize", null); bool canUploadDocument = true; if (!string.IsNullOrEmpty(maxUploadFileSize)) { int configMaxSize = Convert.ToInt32(maxUploadFileSize) * 1024; if (configMaxSize < 0 || this.Data.Length > configMaxSize) { canUploadDocument = false; } } if (canUploadDocument) { IDatabase database = this.Storage.Database; if (this.RequestMode == UPOfflineRequestMode.Offline) { this.StoreRequest(database); this.OfflineRequestDelegate?.OfflineRequestDidFinishWithResult(this, null, false, null, null); return(true); } if (ServerSession.CurrentSession.ConnectionWatchDog.LastServerReachabilityStatus == ReachabilityStatus.ReachableViaWiFi || (!this.NeedsWLANForSync && ServerSession.CurrentSession.ConnectionWatchDog.LastServerReachabilityStatus == ReachabilityStatus.ReachableViaWWAN)) { if (this.StoreBeforeRequest) { this.StoreRequest(database); } UploadDocument document = new UploadDataDocument(this.Data, this.FileName, this.MimeType); this.UploadServerOperation = new UploadDocumentServerOperation(document, this.RecordIdentification, this.FieldId, this.NoD3Link, this); ServerSession.CurrentSession.ExecuteRequest(this.UploadServerOperation); return(true); } if (requestMode == UPOfflineRequestMode.OnlineOnly) { return(false); } this.StoreRequest(database); this.OfflineRequestDelegate?.OfflineRequestDidFinishWithResult(this, null, false, null, null); return(true); } Exception error = new Exception("Document can not be uploaded as the size exceeds the maximum limit"); this.OfflineRequestDelegate?.OfflineRequestDidFailWithError(this, null, null, error); return(false); }
/// <summary> /// Starts the synchronize always perform. /// </summary> /// <param name="_delegate">The delegate.</param> /// <param name="alwaysPerform">if set to <c>true</c> [always perform].</param> /// <returns>True, if success</returns> public override bool StartSync(UPOfflineRequestDelegate _delegate, bool alwaysPerform) { if (this.RequestNr < 0 || (!this.ApplicationRequest && !this.Loaded && !this.LoadFromOfflineStorage())) { return(false); } this.OfflineRequestDelegate = _delegate; UploadDocument document = new UploadDataDocument(this.Data, this.FileName, this.MimeType); this.UploadServerOperation = new UploadDocumentServerOperation(document, this.RecordIdentification, this.FieldId, this); this.UploadServerOperation.AlwaysPerform = alwaysPerform; ServerSession.CurrentSession.ExecuteRequest(this.UploadServerOperation); return(true); }