Ejemplo n.º 1
0
        internal static queryContainer transformFetch(CrmServiceClient service, SchemaEntities listOfEntities_DS, string fetch, bool excludeFromResults)
        {
            QueryExpression mainQuery = CrmHelper.fetchToQuery(service, fetch);
            queryContainer  root      = new queryContainer
            {
                isRoot             = true,
                expression         = mainQuery,
                entityLogicalName  = mainQuery.EntityName,
                ExcludeFromResults = excludeFromResults
            };

            return(root);
        }
Ejemplo n.º 2
0
        internal static List <TreeNode> fromQuery(CrmServiceClient service, queryContainer container, string fetchXml)
        {
            List <TreeNode> result = new List <TreeNode>();

            result.Add(nodeBasedOnFetch(fetchXml));
            if (!ReferenceEquals(container.linkedExpressions, null) && container.linkedExpressions.Count > 0)
            {
                foreach (queryContainer query in container.linkedExpressions)
                {
                    result.Add(nodeBasedOnFetch(CrmHelper.queryToFetch(service, query.expression)));
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        internal static List <Guid> executeAttachmentsCopyBasedMasterEntity(CrmServiceClient crmSource, CrmServiceClient crmTarget, string datafilePath, bool includeNotes, string logPath, out int webFilesCount)
        {
            List <Guid> result = new List <Guid>();

            webFilesCount = 0;

            DataEntities entities = IOHelper.DeserializeXmlFromFile <DataEntities>(datafilePath); //web files

            foreach (DataEntity de in entities.entities)
            {
                webFilesCount += de.RecordsCollection.Count;
                //get attachment per entity record, files only, get lates
                foreach (Record rec in de.RecordsCollection)
                {
                    Entity latestAttacnment = CrmHelper.getLattestAttachmentByEntity(crmSource, new Guid(rec.id), de.name, includeNotes);
                    if (ReferenceEquals(latestAttacnment, null))
                    {
                        continue;
                    }

                    //check is target has same entity
                    Entity targetMaster = crmTarget.Retrieve(de.name, new Guid(rec.id), new ColumnSet());
                    if (ReferenceEquals(targetMaster, null))
                    {
                        continue;
                    }

                    //copy to target
                    try
                    {
                        Guid?newNote = CrmHelper.cloneAnnotation(crmTarget, latestAttacnment);
                        if (newNote.HasValue)
                        {
                            result.Add(newNote.Value);
                        }
                    }
                    catch (Exception ex)
                    {
                        IOHelper.appendLogFile(logPath, ex.Message);
                        continue;
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 4
0
        internal static List <Guid> executeAttachmentsCopyBasedOnWebFileName(CrmServiceClient crmSource, CrmServiceClient crmTarget, List <CrmEntityContainer> source, List <CrmEntityContainer> target, bool includeNotes, string logPath)
        {
            List <Guid> result = new List <Guid>();

            foreach (CrmEntityContainer enSource in source)
            {
                //get single web file with same name, skip if plural
                List <CrmEntityContainer> enTargets = target.Where(e => e.name == enSource.name).ToList();
                if (ReferenceEquals(enTargets, null) || enTargets.Count == 0)
                {
                    continue;
                }

                Entity latestAttacnment = getLattestAttachmentByEntity(crmSource, enSource.id, enSource.logicalName, includeNotes);
                if (ReferenceEquals(latestAttacnment, null))
                {
                    continue;
                }

                //copy to all found target webfiles
                foreach (CrmEntityContainer enTarget in enTargets)
                {
                    try
                    {
                        Guid?newNote = CrmHelper.cloneAnnotationForSpecificID(crmTarget, latestAttacnment, enTarget.crmEntityRef);
                        if (newNote.HasValue)
                        {
                            result.Add(newNote.Value);
                        }
                    }
                    catch (Exception ex)
                    {
                        IOHelper.appendLogFile(logPath, ex.Message);
                        continue;
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Depricated
        /// </summary>
        /// <param name="service"></param>
        /// <param name="listOfEntities_DS"></param>
        /// <param name="fetch"></param>
        /// <param name="exequteAsSeparateLinkedQueries"></param>
        /// <param name="collectAllReferences"></param>
        /// <param name="excludeFromResults"></param>
        /// <returns></returns>
        internal static queryContainer transformFetch(CrmServiceClient service, SchemaEntities listOfEntities_DS, string fetch, bool exequteAsSeparateLinkedQueries, bool collectAllReferences, bool excludeFromResults)
        {
            QueryExpression mainQuery = CrmHelper.fetchToQuery(service, fetch);
            queryContainer  root      = new queryContainer
            {
                isRoot            = true,
                expression        = mainQuery,
                entityLogicalName = mainQuery.EntityName,
                ExequteAsSeparateLinkedQueries = exequteAsSeparateLinkedQueries,
                CollectAllReferences           = collectAllReferences,
                ExcludeFromResults             = excludeFromResults
            };

            //return whole query
            if (!exequteAsSeparateLinkedQueries)
            {
                return(root);
            }


            return(transformToSeparateQueries(service, listOfEntities_DS, root));
        }