/// <summary> /// Loads the folder state i.e. SelectionState, UploadedMailCount, /// FailedMailCount, LastUploadedMailId. Then it recurses on the /// sub folders. /// </summary> void LoadFolderModelState(XmlElement folderXmlElement, FolderModel folderModel) { LKGStatePersistor.LoadSelectedState( folderXmlElement, folderModel); foreach (XmlNode childXmlNode in folderXmlElement.ChildNodes) { XmlElement childXmlElement = childXmlNode as XmlElement; if (childXmlElement == null) { continue; } if (childXmlElement.Name != LKGStatePersistor.MailElementName) { continue; } string mailId = childXmlElement.GetAttribute(LKGStatePersistor.MailIdAttrName); if (mailId == null || mailId.Length == 0) { continue; } string failureReason = childXmlElement.GetAttribute( LKGStatePersistor.FailureReasonAttrName); if (failureReason == null || failureReason.Length == 0) { folderModel.SuccessfullyUploaded(mailId); } else { FailedMailDatum failedMailDatum = new FailedMailDatum(childXmlElement.InnerText, failureReason); folderModel.FailedToUpload(mailId, failedMailDatum); } } this.LoadFolderModelsState( folderXmlElement.ChildNodes, folderModel.Children); }
public void FailedToUpload(string emailId, FailedMailDatum failedMailDatum) { this.failedMailCount++; if (emailId == null || emailId.Length == 0) { return; } if (this.mailUploadData.ContainsKey(emailId)) { return; } this.mailUploadData.Add(emailId, failedMailDatum); }
internal bool MoveToNextMail() { while (true) { this.DisposeCurrentMail(); if (this.currentFolderEnumerator == null || !this.currentFolderEnumerator.MoveNext()) { if (!this.MoveToNextNonEmptySelectedFolder()) { return false; } } this.currentMail = (IMail)this.currentFolderEnumerator.Current; if (this.currentFolderModel.IsUploaded(this.currentMail.MailId)) { continue; } byte[] rfcByteBuffer = this.currentMail.Rfc822Buffer; if (rfcByteBuffer.Length >= 0 && rfcByteBuffer.Length <= GoogleEmailUploaderConfig.MaximumBatchSize) { return true; } this.failedMailIncrementDelegate(); string mailHead = MailBatch.GetMailHeader(this.currentMail); FailedMailDatum failedMailDatum = new FailedMailDatum( mailHead, string.Format( "This email is larger than {0}MB and could not be uploaded", GoogleEmailUploaderConfig.MaximumBatchSize/1024/1024)); this.currentFolderModel.FailedToUpload(this.currentMail.MailId, failedMailDatum); } }
void ProcessUploadMailBatchData(MailBatch mailBatch) { Debug.Assert(this.modelState == ModelState.UploadingPause || this.modelState == ModelState.Uploading); foreach (MailBatchDatum batchDatum in mailBatch.MailBatchData) { if (batchDatum.Uploaded) { batchDatum.FolderModel.SuccessfullyUploaded(batchDatum.MailId); this.uploadedEmailCount++; } else { FailedMailDatum failedMailDatum = new FailedMailDatum(batchDatum.MessageHead, batchDatum.FailedReason); batchDatum.FolderModel.FailedToUpload(batchDatum.MailId, failedMailDatum); this.failedEmailCount++; } } this.lkgStatePersistor.SaveLKGState(this); }