public static List <Lead> ReadAllLeadIds(IDynamicsCrmConnection dynamicsCrmConnection) { return(StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, new List <string>() { "leadid" }, new Dictionary <string, string>(), null, (connection, entity) => new Lead(connection, entity), new PagingInformation())); }
public void RemoveStaleMaterialeBehov(Func <string, string> getResourcePath, Action <int> updateProgress, int updateProgressFrequency) { string path = getResourcePath("Dynamics/Crm/FetchXml/Materiale/FindStaleMaterialeBehov.xml"); XDocument xDocument = XDocument.Load(path); xDocument.Element("fetch").Element("entity").Element("link-entity").Element("filter").Element("condition").Attribute("value").Value = Id.ToString(); List <MaterialeBehov> materialeBehovList = StaticCrm.ReadFromFetchXml(Connection, xDocument, (connection, entity) => new MaterialeBehov(connection, entity), new PagingInformation()); int updateProgressCounter = 0; int deletedCount = 0; foreach (MaterialeBehov materialeBehov in materialeBehovList) { updateProgressCounter++; deletedCount++; materialeBehov.Delete(); if (updateProgressCounter >= updateProgressFrequency) { updateProgressCounter = 0; updateProgress(deletedCount); } } }
public static List <Campaign> ReadAllCampaignsWithIdAndLeadtarget(IDynamicsCrmConnection dynamicsCrmConnection) { return(StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, new List <string>() { "campaignid", "new_leadtarget" }, new Dictionary <string, string>(), null, (connection, entity) => new Campaign(connection, entity), new PagingInformation())); }
public static List <Campaign> ReadCampaignsToImportStubDataTo(IDynamicsCrmConnection dynamicsCrmConnection) { return(StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, new List <string>() { "campaignid", "new_redirecttarget", "new_collecttype", "new_mailrelaygroupid", "name", "ownerid" }, new Dictionary <string, string>(), null, (connection, entity) => new Campaign(connection, entity), new PagingInformation())); }
public static IEnumerable <Indbetaling> GetIndbetalingOnIban(IDynamicsCrmConnection dynamicsCrmConnection, string iban) { XDocument xDocument = new XDocument( new XElement("fetch", new XElement("entity", new XAttribute("name", "new_indbetaling"), new XElement("attribute", new XAttribute("name", "new_amount")), new XElement("attribute", new XAttribute("name", "new_bankid")), new XElement("attribute", new XAttribute("name", "new_byarbejdeid")), new XElement("attribute", new XAttribute("name", "new_campaignid")), new XElement("attribute", new XAttribute("name", "new_indsamlingskoordinatorid")), new XElement("attribute", new XAttribute("name", "new_indsamlingsstedid")), new XElement("attribute", new XAttribute("name", "new_kilde")), new XElement("attribute", new XAttribute("name", "new_kontoid")), new XElement("link-entity", new XAttribute("name", "new_konto"), new XAttribute("from", "new_kontoid"), new XAttribute("to", "new_kontoid"), new XAttribute("link-type", "inner"), new XElement("filter", new XAttribute("type", "and"), new XElement("condition", new XAttribute("attribute", "new_iban"), new XAttribute("operator", "eq"), new XAttribute("value", iban)) ) ) ) ) ); IEnumerable <Indbetaling> indbetalingCollection = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (lDynamicsCrmConnection, entity) => new Indbetaling(lDynamicsCrmConnection, entity)); return(indbetalingCollection); }
private static decimal GetOptaltbeloebSum(IDynamicsCrmConnection dynamicsCrmConnection, XElement filter) { XDocument xDocument = new XDocument ( new XElement("fetch", new XAttribute("aggregate", "true"), new XElement("entity", new XAttribute("name", "account"), new XElement("attribute", new XAttribute("name", "new_optaltbeloeb"), new XAttribute("alias", "value"), new XAttribute("aggregate", "sum")) ) ) ); if (filter != null) { xDocument.Element("fetch").Element("entity").Add(filter); } IEnumerable <Money> sums = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (lDynamicsCrmConnection, entity) => new SingleValueEntity <Money>(lDynamicsCrmConnection, entity, "account", "accountid")).Select(valueEntity => valueEntity.value); if (sums.Any() == false) { return(0); } Money sum = sums.SingleOrDefault(); if (sum == null) { return(0); } return(sum.Value); }
public static List <Field> ReadAllFields(IDynamicsCrmConnection dynamicsCrmConnection) { return(StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, new List <string>() { "new_fieldid", "new_entity" }, new Dictionary <string, string>(), null, (connection, entity) => new Field(connection, entity), new PagingInformation())); }
public static MarketingList GetListForMailrelayUpdate(IDynamicsCrmConnection dynamicsCrmConnection, PagingInformation pagingInformation, Guid?crmListId) { List <string> fields = new List <string>() { "new_mailrelaygroupid", "listname", "query", "new_mailrelaycheck", "createdfromcode", }; Dictionary <string, string> search = new Dictionary <string, string>() { { "new_controlmailrelaygroup", true.ToString() } }; if (crmListId.HasValue) { search.Add("listid", crmListId.Value.ToString()); } IEnumerable <MarketingList> lists = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, "list", fields, search, 1, (connection, entity) => new MarketingList(connection, entity), pagingInformation); return(lists.SingleOrDefault()); }
public static Materiale ReadCalculationNeed(IDynamicsCrmConnection dynamicsCrmConnection, Func <string, string> getResourcePath) { string path = getResourcePath("Dynamics/Crm/FetchXml/Materiale/MaterialeNeedingUpdate.xml"); Materiale materiale = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, path, (connection, entity) => new Materiale(connection, entity), new PagingInformation()).FirstOrDefault(); return(materiale); }
public static List <MaterialeBehovDefinition> FindMaterialeBehovDefinitionPerMateriale(IDynamicsCrmConnection dynamicsCrmConnection, Guid materialeId, Func <string, string> getResourcePath, PagingInformation pagingInformation) { string path = getResourcePath("Dynamics/Crm/FetchXml/MaterialeBehovDefinition/FindMaterialeBehovDefinitionPerMateriale.xml"); XDocument xDocument = XDocument.Load(path); xDocument.Element("fetch").Element("entity").Element("filter").Element("condition").Attribute("value").Value = materialeId.ToString(); List <MaterialeBehovDefinition> definitioner = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (connection, lEntity) => new MaterialeBehovDefinition(connection, lEntity), pagingInformation); return(definitioner); }
public static MailrelayInformation GetInformationNotInMailrelayFromContact(IDynamicsCrmConnection dynamicsCrmConnection, Func <string, string> getResourcePath, Guid contactId) { string path = getResourcePath("Dynamics/Crm/FetchXml/Mailrelay/GetMailrelayFromContact.xml"); XDocument xDocument = XDocument.Load(path); XmlHelper.AddCondition(xDocument, "contactid", "eq", contactId.ToString()); List <MailrelayInformation> informations = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (connection, entity) => new MailrelayInformation(connection, entity), new PagingInformation()); return(informations.Single()); }
private List <KeyValueEntity <Guid, int?> > GetCrmIdsAndSubscriberIds() { XDocument xDocument = XDocument.Parse(query); XmlHelper.RemoveAllAttributes(xDocument); XmlHelper.AddAliasedValue(xDocument, "contactid", "key"); XmlHelper.AddAliasedValue(xDocument, "new_mailrelaysubscriberid", "value"); XmlHelper.AddCondition(xDocument, "new_mailrelaysubscriberid", "not-null"); List <KeyValueEntity <Guid, int?> > keyValueEntities = StaticCrm.ReadFromFetchXml(Connection, xDocument, (dynamicsCrmConnection, entity) => new KeyValueEntity <Guid, int?>(dynamicsCrmConnection, entity, targetEntityName, targetIdName), new PagingInformation()); return(keyValueEntities); }
public static List <Account> GetIndsamlingshjaelper(IDynamicsCrmConnection dynamicsCrmConnection, int maxCount, Guid owningbusinessunit, Func <string, string> getResourcePath, PagingInformation pagingInformation) { string path = getResourcePath("Dynamics/Crm/FetchXml/Account/GetIndsamlingshjaelper.xml"); XDocument xDocument = XDocument.Load(path); xDocument.Element("fetch").Element("entity").Element("filter").Elements("condition"). Where(element => element.Attribute("attribute").Value == "owningbusinessunit").Single(). Attribute("value").Value = owningbusinessunit.ToString(); xDocument.Element("fetch").Attribute("count").Value = maxCount.ToString(); List <Account> accounts = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (connection, lEntity) => new Account(connection, lEntity), pagingInformation); return(accounts); }
public static MailrelayInformation GetMailrelayFromLead(IDynamicsCrmConnection dynamicsCrmConnection, Func <string, string> getResourcePath, string email, Guid campaignId) { string path = getResourcePath("Dynamics/Crm/FetchXml/Mailrelay/GetMailrelayFromLead.xml"); XDocument xDocument = XDocument.Load(path); xDocument.Element("fetch").Element("entity").Element("filter").Element("condition").Attribute("value").Value = email; xDocument.Element("fetch").Element("entity").Elements("link-entity").Single(element => element.Attribute("name").Value == "campaign").Element("filter").Element("condition").Attribute("value").Value = campaignId.ToString(); List <MailrelayInformation> informations = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (connection, entity) => new MailrelayInformation(connection, entity), new PagingInformation()); MailrelayInformation information = informations.OrderByDescending(lInformation => lInformation.createdon).FirstOrDefault(); return(information); }
private IEnumerable <Guid> GetContentIdsForNonMailrelaySubscribers() { XDocument xDocument = XDocument.Parse(query); XmlHelper.RemoveAllAttributes(xDocument); XmlHelper.AddAliasedValue(xDocument, "contactid", "value"); XmlHelper.AddCondition(xDocument, "new_mailrelaysubscriberid", "null"); XmlHelper.AddCondition(xDocument, "emailaddress1", "not-null"); XmlHelper.SetCount(xDocument, 100); IEnumerable <Guid> contentIds = StaticCrm.ReadFromFetchXml(Connection, xDocument, (dynamicsCrmConnection, entity) => new SingleValueEntity <Guid>(dynamicsCrmConnection, entity, targetEntityName, targetIdName)).Select(valueEntity => valueEntity.value); return(contentIds); }
public static List <MailrelayInformation> GetMailrelayFromContact(IDynamicsCrmConnection dynamicsCrmConnection, Func <string, string> getResourcePath, PagingInformation pagingInformation, int pageSize, Guid?contactId) { string path = getResourcePath("Dynamics/Crm/FetchXml/Mailrelay/GetMailrelayFromContact.xml"); XDocument xDocument = XDocument.Load(path); xDocument.Element("fetch").Attribute("count").Value = pageSize.ToString(); if (contactId.HasValue) { XmlHelper.AddCondition(xDocument, "contactid", "eq", contactId.Value.ToString()); } XmlHelper.AddCondition(xDocument, "new_mailrelaysubscriberid", "not-null"); List <MailrelayInformation> informations = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (connection, entity) => new MailrelayInformation(connection, entity), pagingInformation); return(informations); }
public static Konto ReadFromIban(IDynamicsCrmConnection dynamicsCrmConnection, string iban) { XDocument xDocument = new XDocument( new XElement("fetch", new XElement("entity", new XAttribute("name", "new_konto"), new XElement("attribute", new XAttribute("name", "new_kontoid")), new XElement("attribute", new XAttribute("name", "new_iban")), new XElement("attribute", new XAttribute("name", "new_campaignid")), new XElement("attribute", new XAttribute("name", "ownerid")), new XElement("filter", new XAttribute("type", "and"), new XElement("condition", new XAttribute("attribute", "new_iban"), new XAttribute("operator", "eq"), new XAttribute("value", iban)) ) ) ) ); IEnumerable <Konto> kontoCollection = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (lDynamicsCrmConnection, entity) => new Konto(lDynamicsCrmConnection, entity)); return(kontoCollection.SingleOrDefault()); }
public static IEnumerable <Indbetaling> GetIndbetalingValue(IDynamicsCrmConnection dynamicsCrmConnection) { XDocument xDocument = new XDocument( new XElement("fetch", new XElement("entity", new XAttribute("name", "new_indbetaling"), new XElement("attribute", new XAttribute("name", "new_amount")), new XElement("attribute", new XAttribute("name", "new_byarbejdeid")), new XElement("attribute", new XAttribute("name", "new_campaignid")), new XElement("attribute", new XAttribute("name", "new_indsamlingsstedid")), new XElement("attribute", new XAttribute("name", "new_kontoid")), new XElement("attribute", new XAttribute("name", "new_kilde")), new XElement("link-entity", new XAttribute("name", "account"), new XAttribute("from", "accountid"), new XAttribute("to", "new_indsamlingsstedid"), new XAttribute("link-type", "outer"), new XElement("attribute", new XAttribute("name", "new_bykoordinatorid"), new XAttribute("alias", "new_bykoordinatorid")), new XElement("attribute", new XAttribute("name", "new_omraadekoordinatorid"), new XAttribute("alias", "new_omraadekoordinatorid")) ) ) ) ); IEnumerable <Indbetaling> indbetalingCollection = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (lDynamicsCrmConnection, entity) => new Indbetaling(lDynamicsCrmConnection, entity)); return(indbetalingCollection); }
public static List <ValueType> GetAll(IDynamicsCrmConnection dynamicsCrmConnection, XDocument xDocument, string entityName, string entityIdName) { IEnumerable <ValueType> entities = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (lDynamicsCrmConnection, entity) => new SingleValueEntity <ValueType>(lDynamicsCrmConnection, entity, entityName, entityIdName)).Select(valueEntity => valueEntity.value); return(entities.ToList()); }
public static List <Lead> ReadFromFetchXml(IDynamicsCrmConnection dynamicsCrmConnection, List <string> fields, Dictionary <string, string> keyContent) { return(StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, fields, keyContent, null, (connection, contactEntity) => new Lead(connection, contactEntity), new PagingInformation())); }
public static List <KeyValuePair <KeyType, ValueType> > GetAll(IDynamicsCrmConnection dynamicsCrmConnection, XDocument xDocument, string entityName, string entityIdName) { List <KeyValueEntity <KeyType, ValueType> > keyValueEntities = StaticCrm.ReadFromFetchXml(dynamicsCrmConnection, xDocument, (LDynamicsCrmConnection, entity) => new KeyValueEntity <KeyType, ValueType>(dynamicsCrmConnection, entity, entityName, entityIdName), new PagingInformation()); return(keyValueEntities.Select(keyValue => new KeyValuePair <KeyType, ValueType>(keyValue.key, keyValue.value)).ToList()); }