Ejemplo n.º 1
0
 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()));
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }
Ejemplo n.º 4
0
 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()));
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 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()));
 }
Ejemplo n.º 7
0
 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()));
 }
Ejemplo n.º 8
0
        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());
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        public int CountStaleMaterialeBehov(Func <string, string> getResourcePath)
        {
            string path = getResourcePath("Dynamics/Crm/FetchXml/Materiale/CountStaleMaterialeBehov.xml");

            XDocument xDocument = XDocument.Load(path);

            xDocument.Element("fetch").Element("entity").Element("link-entity").Element("filter").Element("condition").Attribute("value").Value = Id.ToString();

            int staleMaterialeCount = StaticCrm.CountByFetchXml(Connection, xDocument, "new_materialebehovidcount");

            return(staleMaterialeCount);
        }
Ejemplo n.º 12
0
        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());
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        public static List <dynamic> ReadFromFetchXml(IDynamicsCrmConnection dynamicsCrmConnection, string entityName, List <string> fields, Dictionary <string, string> keyContent, int?maxCount, PagingInformation pagingInformation)
        {
            XDocument xDocument = new XDocument(
                new XElement("fetch",
                             new XElement("entity", new XAttribute("name", entityName),
                                          new XElement("filter"))));

            if (maxCount.HasValue)
            {
                xDocument.Element("fetch").Add(new XAttribute("count", maxCount.Value));
            }

            xDocument.Element("fetch").Element("entity").Add(StaticCrm.GetAttributeElements(fields.ToList()));
            xDocument.Element("fetch").Element("entity").Element("filter").Add(StaticCrm.GetConditionElements(keyContent));

            List <dynamic> crmObjects = ReadFromFetchXml(dynamicsCrmConnection, xDocument, pagingInformation);

            return(crmObjects);
        }
Ejemplo n.º 19
0
        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());
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
 public static bool Exists(IDynamicsCrmConnection dynamicsCrmConnection, Dictionary <string, string> keyContent)
 {
     return(StaticCrm.Exists <Contact>(dynamicsCrmConnection, keyContent));
 }
Ejemplo n.º 22
0
 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()));
 }
Ejemplo n.º 23
0
        public static List <Annotation> ReadLatest(IDynamicsCrmConnection connection, DateTime lastSearchDate, int?maximumNumberOfAnnotations = null)
        {
            List <Annotation> annotations = StaticCrm.ReadLatest(connection, "annotation", ColumnSetAnnotation, lastSearchDate, (lConnection, entity) => new Annotation(lConnection, entity), maximumNumberOfAnnotations);

            return(annotations);
        }
Ejemplo n.º 24
0
        public static int CountIndsamlingshjaelper(IDynamicsCrmConnection dynamicsCrmConnection, Func <string, string> getResourcePath)
        {
            string path = getResourcePath("Dynamics/Crm/FetchXml/Account/CountIndsamlingshjaelper.xml");

            return(StaticCrm.CountByFetchXml(dynamicsCrmConnection, path, "accounts"));
        }
Ejemplo n.º 25
0
        public static SystemUser ReadByDomainname(IDynamicsCrmConnection connection, string domainname)
        {
            List <SystemUser> users = StaticCrm.ReadByAttribute(connection, "systemuser", ColumnSetUser, "domainname", domainname, (lConnection, entity) => new SystemUser(lConnection, entity));

            return(users.Single());
        }
Ejemplo n.º 26
0
        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());
        }
Ejemplo n.º 27
0
        public static List <Contact> ReadLatest(IDynamicsCrmConnection connection, DateTime lastSearchDate, int?maximumNumberOfContacts = null)
        {
            List <Contact> contacts = StaticCrm.ReadLatest(connection, "contact", ColumnSetContact, lastSearchDate, (lConnection, entity) => new Contact(lConnection, entity), maximumNumberOfContacts);

            return(contacts);
        }
Ejemplo n.º 28
0
        public static int CountForventetAntalIndsamlere2016(IDynamicsCrmConnection dynamicsCrmConnection, Func <string, string> getResourcePath)
        {
            string path = getResourcePath("Dynamics/Crm/FetchXml/Account/CountForventetAntalIndsamlere2016.xml");

            return(StaticCrm.CountByFetchXml(dynamicsCrmConnection, path, "accounts"));
        }
Ejemplo n.º 29
0
        public static List <Account> ReadLatest(IDynamicsCrmConnection connection, DateTime lastSearchDate, int?maximumNumberOfAccounts = null)
        {
            List <Account> accounts = StaticCrm.ReadLatest(connection, "account", ColumnSetAccount, lastSearchDate, (lConnection, entity) => new Account(lConnection, entity), maximumNumberOfAccounts);

            return(accounts);
        }
Ejemplo n.º 30
0
        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());
        }