/// <summary> /// Persists the store selection state, and state of all the subfolders. /// </summary> void SaveStoreModelState(XmlElement clientXmlElement, StoreModel storeModel) { XmlElement storeXmlElement = this.xmlDocument.CreateElement(LKGStatePersistor.StoreElementName); clientXmlElement.AppendChild(storeXmlElement); storeXmlElement.SetAttribute( LKGStatePersistor.DisplayNameAttrName, storeModel.Store.DisplayName); storeXmlElement.SetAttribute( LKGStatePersistor.PersistNameAttrName, storeModel.Store.PersistName); storeXmlElement.SetAttribute( LKGStatePersistor.SelectionStateAttrName, storeModel.IsSelected.ToString()); this.SaveContactsState(storeXmlElement, storeModel); foreach (FolderModel folderModel in storeModel.Children) { this.SaveFolderModelState( storeXmlElement, folderModel); } }
internal ContactGemuTreeNode(StoreModel storeModel) : base(storeModel) { this.Text = string.Format(Resources.ContactsTemplateText, storeModel.Store.ContactCount); this.Checked = storeModel.IsContactSelected; this.cummulativeCount = storeModel.Store.ContactCount; }
/// <summary> /// Loads the selection state of the store, and then loads all the /// state of all the subfolders. /// </summary> void LoadStoreModelState(XmlElement storeXmlElement, StoreModel storeModel) { LKGStatePersistor.LoadSelectedState( storeXmlElement, storeModel); foreach (XmlNode childXmlNode in storeXmlElement.ChildNodes) { XmlElement childXmlElement = childXmlNode as XmlElement; if (childXmlElement == null) { continue; } if (childXmlElement.Name != LKGStatePersistor.ContactsElementName) { continue; } this.LoadContactsState(childXmlElement, storeModel); break; } this.LoadFolderModelsState( storeXmlElement.ChildNodes, storeModel.Children); }
/// <summary> /// Saves the contact state within the given store. /// </summary> void SaveContactsState(XmlElement storeXmlElement, StoreModel storeModel) { XmlElement contactsXmlElement = this.xmlDocument.CreateElement(LKGStatePersistor.ContactsElementName); storeXmlElement.AppendChild(contactsXmlElement); contactsXmlElement.SetAttribute( LKGStatePersistor.SelectionStateAttrName, storeModel.IsContactSelected.ToString()); foreach (string contactId in storeModel.ContactUploadData.Keys) { XmlElement uploadedContactXmlElement = this.xmlDocument.CreateElement( LKGStatePersistor.ContactElementName); contactsXmlElement.AppendChild(uploadedContactXmlElement); uploadedContactXmlElement.SetAttribute( LKGStatePersistor.ContactIdAttrName, contactId); FailedContactDatum failedContactDatum = (FailedContactDatum)storeModel.ContactUploadData[contactId]; if (failedContactDatum != null) { // In case of failure to upload we set the reason, otherwise not. uploadedContactXmlElement.SetAttribute( LKGStatePersistor.FailureReasonAttrName, failedContactDatum.FailureReason); uploadedContactXmlElement.InnerText = failedContactDatum.ContactName; } } }
/// <summary> /// Loads the selection state of the contacts in the given store. /// </summary> void LoadContactsState(XmlElement contactsXmlElement, StoreModel storeModel) { if (contactsXmlElement.GetAttribute( LKGStatePersistor.SelectionStateAttrName) == bool.FalseString) { storeModel.IsContactSelected = false; } else { storeModel.IsContactSelected = true; } foreach (XmlNode childXmlNode in contactsXmlElement.ChildNodes) { XmlElement childXmlElement = childXmlNode as XmlElement; if (childXmlElement == null) { continue; } if (childXmlElement.Name != LKGStatePersistor.ContactElementName) { continue; } string contactId = childXmlElement.GetAttribute(LKGStatePersistor.ContactIdAttrName); if (contactId == null || contactId.Length == 0) { continue; } string failureReason = childXmlElement.GetAttribute( LKGStatePersistor.FailureReasonAttrName); if (failureReason == null || failureReason.Length == 0) { storeModel.SuccessfullyUploaded(contactId); } else { FailedContactDatum failedContactDatum = new FailedContactDatum(childXmlElement.InnerText, failureReason); storeModel.FailedToUpload(contactId, failedContactDatum); } } }
bool MoveToNextNonEmptySelectedStore() { this.DisposeCurrentEnumerator(); while (this.storeIterationIndex < this.storeModelFlatList.Count) { this.currentStoreModel = (StoreModel)this.storeModelFlatList[this.storeIterationIndex]; this.storeIterationIndex++; if (!this.currentStoreModel.IsContactSelected || this.currentStoreModel.Store.ContactCount == 0) { continue; } this.currentStoreEnumerator = this.currentStoreModel.Store.Contacts.GetEnumerator(); if (!this.currentStoreEnumerator.MoveNext()) { // We reached the end of the folder // so dispose enumerator and continue with the next folder. this.DisposeCurrentEnumerator(); continue; } // There are mails and current points to the mail to be uploaded. return true; } this.currentStoreModel = null; return false; }
public StoreModel OpenStore(string fileName) { IStore store = this.Client.OpenStore(fileName); if (store == null) { return null; } StoreModel storeModel = new StoreModel(this, store, this.GoogleEmailUploaderModel); this.storeModels.Add(storeModel); return storeModel; }
internal IContact GetNextContactEntry(out StoreModel storeModel) { Debug.Assert(this.modelState == ModelState.Uploading || this.modelState == ModelState.UploadingPause); try { GoogleEmailUploaderTrace.EnteringMethod( "GoogleEmailUploaderModel.GetNextContactEntry()"); storeModel = null; if (this.contactIterator.MoveToNextContact()) { if (this.ContactReadingEvent != null) { this.ContactReadingEvent(this.contactIterator.CurrentContact); } storeModel = this.contactIterator.CurrentStoreModel; return this.contactIterator.CurrentContact; } return null; } finally { GoogleEmailUploaderTrace.ExitingMethod( "GoogleEmailUploaderModel.GetNextContactEntry()"); } }
internal void SetContact(IContact contact, StoreModel storeModel) { this.contact = contact; this.storeModel = storeModel; this.uploaded = false; this.failedReason = null; this.updateUrl = null; this.ContactToXml(contact.Title, contact.OrganizationName, contact.OrganizationTitle, contact.HomePageUrl, contact.Notes, contact.EmailAddresses, contact.IMIdentities, contact.PhoneNumbers, contact.PostalAddresses); }