当前位置: 首页>>代码示例>>C#>>正文


C# IOrganizationService.RetrieveMultiple方法代码示例

本文整理汇总了C#中IOrganizationService.RetrieveMultiple方法的典型用法代码示例。如果您正苦于以下问题:C# IOrganizationService.RetrieveMultiple方法的具体用法?C# IOrganizationService.RetrieveMultiple怎么用?C# IOrganizationService.RetrieveMultiple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOrganizationService的用法示例。


在下文中一共展示了IOrganizationService.RetrieveMultiple方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AssignAdminRole

        private void AssignAdminRole(IOrganizationService service, Guid id)
        {
            string adminRoleName = "System Administrator";
            try
            {
                QueryExpression query = new QueryExpression
                {
                    EntityName = "role",
                    ColumnSet = new ColumnSet("name"),
                    Criteria = new FilterExpression
                {
                    Conditions =
                    {
                        new ConditionExpression
                        {
                                AttributeName = "name",
                                Operator = ConditionOperator.Equal,
                                Values = {adminRoleName}
                        }
                    }
                }
                };
                EntityCollection roles = service.RetrieveMultiple(query);
                EntityReferenceCollection entityRefCln = new EntityReferenceCollection();
                foreach (Entity entity in roles.Entities)
                {
                        entityRefCln.Add(entity.ToEntityReference());
                }
                service.Associate("team", id, new Relationship("teamroles_association"), entityRefCln);
            }
            catch (Exception ex)
            {

            }
        }
开发者ID:Sujith88,项目名称:Sujith-MS-CRM-Sample-code,代码行数:35,代码来源:Sujith+Plug-in.cs

示例2: getSecurityRoleGuidBySecurityRoleName

        public void getSecurityRoleGuidBySecurityRoleName(IOrganizationService securityRoleCrmWebservice)
        {
            var myQuery = new QueryExpression
            {
                EntityName = "role",
                ColumnSet = new ColumnSet("roleid"),
                Criteria = new FilterExpression
                {
                    Conditions =
                    {
                        new ConditionExpression
                        {
                          AttributeName  =  "name",
                          Operator = ConditionOperator.Equal,
                          Values = {"roleName"}
                        }
                    }
                }
            };

            //DataCollection<Entity> securityRoleResult = CrmWebservice.RetrieveMultiple(myQuery).Entities;
            DataCollection<Entity> securityRoleResult = securityRoleCrmWebservice.RetrieveMultiple(myQuery).Entities;
            if (securityRoleResult.Count > 0)
                this.guidSecurityRoleId = (Guid)securityRoleResult[0]["roleid"];
        }
开发者ID:anthonied,项目名称:CRM,代码行数:25,代码来源:SecurityRoleBase.cs

示例3: RetrieveBusinessRules

        public static IEnumerable<BusinessRules> RetrieveBusinessRules(IOrganizationService service)
        {
            var businessRules = service.RetrieveMultiple(new FetchExpression(@"
            <fetch>
                <entity name='workflow' >
                <attribute name='triggeroncreate' />
                <attribute name='createdon' />
                <attribute name='primaryentity' />
                <attribute name='triggerondelete' />
                <attribute name='triggeronupdateattributelist' />
                <attribute name='processorder' />
                <attribute name='modifiedon' />
                <attribute name='name' />
                <filter>
                    <condition attribute='type' operator='eq' value='1' />
                    <condition attribute='category' operator='eq' value='2' />
                </filter>
                </entity>
            </fetch>"));

            var q = from e in businessRules.Entities
                    orderby e.GetAttributeValue<string>("primaryentity"), e.GetAttributeValue<DateTime>("modifiedon")
                    select new BusinessRules(e);
            return q;
        }
开发者ID:RazDynamics,项目名称:XrmToolBox,代码行数:25,代码来源:BusinessRules.cs

示例4: GetSolutions

        /// <summary>
        /// Получаем набор неуправляемых решений для организации
        /// </summary>
        /// <param name="service">сервис</param>
        /// <returns></returns>
        public static EntityCollection GetSolutions(IOrganizationService service)
        {
            var solutions = new EntityCollection();

            QueryExpression q = new QueryExpression("solution");
            //Берем только неуправляемые решения
            q.Criteria.AddCondition(new ConditionExpression("ismanaged", ConditionOperator.Equal, false));
            //не берем специальные CRMные солюшены
            q.Criteria.AddCondition(new ConditionExpression("friendlyname", ConditionOperator.NotEqual, "Active Solution"));
            q.Criteria.AddCondition(new ConditionExpression("friendlyname", ConditionOperator.NotEqual, "Default Solution"));
            q.Criteria.AddCondition(new ConditionExpression("friendlyname", ConditionOperator.NotEqual, "Basic Solution"));
            q.Orders.Add(new OrderExpression("createdon", OrderType.Descending));
            q.ColumnSet = new ColumnSet("friendlyname", "uniquename", "version", "installedon");
            q.PageInfo = new PagingInfo()
            {
                Count = 200,
                PageNumber = 1
            };

            EntityCollection ec;
            do
            {
                ec = service.RetrieveMultiple(q);
                solutions.Entities.AddRange(ec.Entities);
                q.PageInfo.PageNumber++;
                q.PageInfo.PagingCookie = ec.PagingCookie;
            } while (ec.MoreRecords);

            return solutions;
        }
开发者ID:helekon,项目名称:MergeCustomization,代码行数:35,代码来源:DataHandler.cs

示例5: FindGuidForObject

        public void FindGuidForObject(IOrganizationService myCRMWebservice)
        {
            var myQuery = new QueryExpression
            {
                EntityName = this.sCrmEntityName,
                ColumnSet = new ColumnSet(this.sCrmEntityGuidFieldName),
                Criteria = new FilterExpression
                {
                    Conditions =
                    {
                        new ConditionExpression
                        {
                          AttributeName  =  this.sCrmFilterAttributeName,
                          Operator = ConditionOperator.Equal,
                          Values = {this.sCrmFilterAttributeValue}
                        }
                    }
                }

            };

            DataCollection<Entity> accountResult = myCRMWebservice.RetrieveMultiple(myQuery).Entities;
            if (accountResult.Count > 0)
                this.crmGuidId = (Guid)accountResult[0][this.sCrmEntityGuidFieldName];
        }
开发者ID:anthonied,项目名称:CRM,代码行数:25,代码来源:BaseContainer.cs

示例6: RetrieveEntityFormList

        /// <summary>
        /// Retrieves main forms for the specified entity
        /// </summary>
        /// <param name="logicalName">Entity logical name</param>
        /// <param name="oService">Crm organization service</param>
        /// <returns>Document containing all forms definition</returns>
        public static IEnumerable<Entity> RetrieveEntityFormList(string logicalName, IOrganizationService oService)
        {
            var qe = new QueryExpression("systemform")
            {
                ColumnSet = new ColumnSet(true),
                Criteria = new FilterExpression
                {
                    Conditions =
                    {
                        new ConditionExpression("objecttypecode", ConditionOperator.Equal, logicalName),
                        new ConditionExpression("type", ConditionOperator.In, new[] {2,7}),
                    }
                }
            };

            try
            {
                return oService.RetrieveMultiple(qe).Entities;
            }
            catch
            {
                qe.Criteria.Conditions.RemoveAt(qe.Criteria.Conditions.Count - 1);
                return oService.RetrieveMultiple(qe).Entities;
            }
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:31,代码来源:MetadataHelper.cs

示例7: GetItems

        public static EntityCollection GetItems(string fetchXml, IOrganizationService service)
        {
            // Check if businessunitid attribute is contained in attriburtes
            var xDoc = XDocument.Parse(fetchXml);
            AddMissingCrmAttribute(xDoc, "businessunitid");

            var entityElement = xDoc.Descendants("entity").FirstOrDefault();
            if (entityElement == null)
            {
                throw new Exception("Cannot find node 'entity' in FetchXml");
            }

            switch (entityElement.Attribute("name").Value)
            {
                case "systemuser":
                {
                    AddMissingCrmAttribute(xDoc, "firstname");
                    AddMissingCrmAttribute(xDoc, "lastname");
                }
                break;
                case "team":
                {
                    AddMissingCrmAttribute(xDoc, "name");
                }
                break;
            }

            return service.RetrieveMultiple(new FetchExpression(xDoc.ToString()));
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:29,代码来源:QueryHelper.cs

示例8: RetrieveViews

        /// <summary>
        /// Retrieve the list of views for a specific entity
        /// </summary>
        /// <param name="entityDisplayName">Logical name of the entity</param>
        /// <param name="entitiesCache">Entities cache</param>
        /// <param name="service">Organization Service</param>
        /// <returns>List of views</returns>
        public static List<Entity> RetrieveViews(string entityLogicalName, List<EntityMetadata> entitiesCache, IOrganizationService service)
        {
            try
            {
                EntityMetadata currentEmd = entitiesCache.Find(delegate(EntityMetadata emd) { return emd.LogicalName == entityLogicalName; });

                QueryByAttribute qba = new QueryByAttribute
                                           {
                                               EntityName = "savedquery",
                                               ColumnSet = new ColumnSet(true)
                                           };

                qba.Attributes.Add("returnedtypecode");
                qba.Values.Add(currentEmd.ObjectTypeCode.Value);

                EntityCollection views = service.RetrieveMultiple(qba);

                List<Entity> viewsList = new List<Entity>();

                foreach (Entity entity in views.Entities)
                {
                    viewsList.Add(entity);
                }

                return viewsList;
            }
            catch (Exception error)
            {
                string errorMessage = CrmExceptionHelper.GetErrorMessage(error, false);
                throw new Exception("Error while retrieving views: " + errorMessage);
            }
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:39,代码来源:ViewHelper.cs

示例9: SiteMapManager

        public SiteMapManager(IOrganizationService service)
        {
            var qe = new QueryExpression("sitemap") { ColumnSet = new ColumnSet(true) };

            EntityCollection ec = service.RetrieveMultiple(qe);

            siteMapDoc = new XmlDocument();
            siteMapDoc.LoadXml(ec[0]["sitemapxml"].ToString());
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:9,代码来源:SiteMapManager.cs

示例10: Run

        /// <summary>
        /// This method first connects to the Organization service. Afterwards,
        /// basic create, retrieve, update, and delete entity operations are performed.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete)
        {
            try
            {

                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    _service = (IOrganizationService)_serviceProxy;

                    CreateRequiredRecords();

                    //<snippetQueryByAttribute1>
                    //  Create query using QueryByAttribute.
                    QueryByAttribute querybyattribute = new QueryByAttribute("account");
                    querybyattribute.ColumnSet = new ColumnSet("name", "address1_city", "emailaddress1");

                    //  Attribute to query.
                    querybyattribute.Attributes.AddRange("address1_city");

                    //  Value of queried attribute to return.
                    querybyattribute.Values.AddRange("Redmond");

                    //  Query passed to service proxy.
                    EntityCollection retrieved = _service.RetrieveMultiple(querybyattribute);

                    System.Console.WriteLine("Query Using QueryByAttribute");
                    System.Console.WriteLine("===============================");

                    //  Iterate through returned collection.
                    foreach (var c in retrieved.Entities)
                    {
                        System.Console.WriteLine("Name: " + c.Attributes["name"]);
                        
                        if( c.Attributes.Contains("address1_city") )
                            System.Console.WriteLine("Address: " + c.Attributes["address1_city"]);

                        if( c.Attributes.Contains("emailaddress1") )
                            System.Console.WriteLine("E-mail: " + c.Attributes["emailaddress1"]);
                    }
                    System.Console.WriteLine("===============================");
                    //</snippetQueryByAttribute1>

                    DeleteRequiredRecords(promptforDelete);
                }
            }
            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:64,代码来源:QueryByAttribute.cs

示例11: Export

        public void Export(List<int> languages, ExcelWorksheet sheet, bool onlyUnmanaged, IOrganizationService service)
        {
            var qe = new QueryByAttribute("ribbondiff") { ColumnSet = new ColumnSet(true) };

            if (onlyUnmanaged)
            {
                qe.Attributes.AddRange("difftype", "ismanaged");
                qe.Values.AddRange(3, false);
            }
            else
            {
                qe.Attributes.AddRange("difftype");
                qe.Values.AddRange(3);
            }
            qe.AddOrder("entity", OrderType.Ascending);

            var records = service.RetrieveMultiple(qe);

            var line = 1;

            AddHeader(sheet, languages);

            foreach (var record in records.Entities)
            {
                var cell = 0;

                ZeroBasedSheet.Cell(sheet, line, cell++).Value = record.Id.ToString("B");
                ZeroBasedSheet.Cell(sheet, line, cell++).Value = record.GetAttributeValue<string>("entity");
                ZeroBasedSheet.Cell(sheet, line, cell++).Value = record.GetAttributeValue<string>("diffid");

                var xml = new XmlDocument();
                xml.LoadXml(record.GetAttributeValue<string>("rdx"));

                foreach (var lcid in languages)
                {
                    var labelNode = xml.SelectSingleNode(string.Format("LocLabel/Titles/Title[@languagecode='{0}']", lcid));
                    ZeroBasedSheet.Cell(sheet, line, cell++).Value = labelNode == null ? string.Empty : labelNode.Attributes["description"].Value;
                }

                line++;
            }

            // Applying style to cells
            for (int i = 0; i < (3 + languages.Count); i++)
            {
                StyleMutator.TitleCell(ZeroBasedSheet.Cell(sheet, 0, i).Style);
            }

            for (int i = 1; i < line; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    StyleMutator.HighlightedCell(ZeroBasedSheet.Cell(sheet, i, j).Style);
                }
            }
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:56,代码来源:RibbonTranslation.cs

示例12: RetrieveEntityFormList

        /// <summary>
        /// Retrieves main forms for the specified entity
        /// </summary>
        /// <param name="logicalName">Entity logical name</param>
        /// <param name="oService">Crm organization service</param>
        /// <returns>Document containing all forms definition</returns>
        public static IEnumerable<Entity> RetrieveEntityFormList(string logicalName, IOrganizationService oService)
        {
            var qba = new QueryByAttribute("systemform");
            qba.Attributes.AddRange("objecttypecode", "type");
            qba.Values.AddRange(logicalName, 2);
            qba.ColumnSet = new ColumnSet(true);

            var ec = oService.RetrieveMultiple(qba);

            return ec.Entities;
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:17,代码来源:MetadataHelper.cs

示例13: RetrievePluginSteps

        public static IEnumerable<SynchronousWorkflow> RetrievePluginSteps(IOrganizationService service)
        {
            var qba = new QueryByAttribute("workflow")
            {
                Attributes = { "mode", "type", "category" },
                Values = { 1, 1, 0 },
                ColumnSet = new ColumnSet(true)
            };

            var steps = service.RetrieveMultiple(qba);

            return steps.Entities.Select(e => new SynchronousWorkflow(e));
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:13,代码来源:SynchronousWorkflow.cs

示例14: GetChartsByEntity

 public static EntityCollection GetChartsByEntity(string entityLogicalName, IOrganizationService service)
 {
     return service.RetrieveMultiple(new QueryExpression("savedqueryvisualization")
     {
         ColumnSet = new ColumnSet(true),
         Criteria = new FilterExpression
         {
             Conditions =
             {
                 new ConditionExpression("primaryentitytypecode", ConditionOperator.Equal, entityLogicalName)
             }
         }
     });
 }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:14,代码来源:ChartHelper.cs

示例15: GetDefinitions

        private static IEnumerable<Entity> GetDefinitions(Entity email, IOrganizationService service)
        {
            var subject = (string)email.Attributes["subject"];
            if (subject == null) throw new ArgumentNullException("email");

            var epmappings = new QueryExpression("new_emailparserdefinition");
            var cols = new ColumnSet("new_name", "new_emailparserdefinitionid", "new_crmentityname", "new_subjectpattern", "new_senderaddress");
            epmappings.ColumnSet = cols;
            epmappings.Criteria.AddCondition(new ConditionExpression("statecode", ConditionOperator.Equal, "Active"));
            IEnumerable<Entity> result = service.RetrieveMultiple(epmappings).Entities;

            return result
                .Where(element => Regex.IsMatch(subject, (string)element.Attributes["new_subjectpattern"]))
                    .Select(element => element);
        }
开发者ID:bigleg127,项目名称:EmailParser,代码行数:15,代码来源:EmailParser.cs


注:本文中的IOrganizationService.RetrieveMultiple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。