private EmailsDocumentCollection GetEmailsCollectionFromCustomer(Emails emails, DeleteHistoryDataset history, Token lastToken, string crmUser) { EmailsDocumentCollection emailCollection = new EmailsDocumentCollection(); EmailDocument email; foreach (DeleteHistoryDataset.DeleteHistoryRow dr in history.DeleteHistory) { if (dr.DeleteUser == crmUser) continue; if (dr.DeleteID <= lastToken.SequenceNumber) continue; email = new EmailDocument(); email.Id = dr.Identity; email.LogState = LogState.Deleted; emailCollection.Add(email); } int index = 0; foreach (Emails.CustomerEmailsRow er in emails.CustomerEmails) { email = new EmailDocument(); if ((er.CreateUser != crmUser) && (er.CreateID > lastToken.SequenceNumber)) email.LogState = LogState.Created; else if ((er.ModifyUser != crmUser) && (er.ModifyID > lastToken.SequenceNumber)) email.LogState = LogState.Updated; email.Id = er.ID.ToString(); try { email.emailaddress.Value = er.Email; if (index == 0) email.type.Value = "Business"; if (index == 1) email.type.Value = "Private"; index++; } catch (StrongTypingException) { email.emailaddress.Value = null; } emailCollection.Add(email); } return emailCollection; }
private Document GetDocument(Emails.CustomerEmailsRow row, Token lastToken, NorthwindConfig config) { EmailDocument doc; string id; id = row.ID.ToString(); doc = new EmailDocument(); doc.Id = id; if (lastToken.InitRequest) doc.LogState = LogState.Created; else if (row.IsCreateIDNull() || row.IsModifyIDNull() || row.IsCreateUserNull() || row.IsModifyUserNull()) doc.LogState = LogState.Created; else if ((row.CreateID > lastToken.SequenceNumber) && (row.CreateUser != config.CrmUser)) doc.LogState = LogState.Created; else if ((row.CreateID == lastToken.SequenceNumber) && (row.CreateUser != config.CrmUser) && (id.CompareTo(lastToken.Id.Id) > 0)) doc.LogState = LogState.Created; else if ((row.ModifyID >= lastToken.SequenceNumber) && (row.ModifyUser != config.CrmUser)) doc.LogState = LogState.Updated; doc.emailaddress.Value = row.IsEmailNull() ? null : row.Email; doc.type.Value = Constants.DefaultValues.Email.Type; return doc; }