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


C# IOrganizationService类代码示例

本文整理汇总了C#中IOrganizationService的典型用法代码示例。如果您正苦于以下问题:C# IOrganizationService类的具体用法?C# IOrganizationService怎么用?C# IOrganizationService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: PreValidateContactCreate

        /// <summary>
        /// Pre-Validation method will default the values of contact preference fields
        /// </summary>
        private static void PreValidateContactCreate(IPluginExecutionContext context, IOrganizationService service)
        {
            Entity contactEntity = (Entity)context.InputParameters["Target"];
            OptionSetValue doNotAllow = new OptionSetValue(1);

            contactEntity.SetAttribute("donotemail", doNotAllow);
            contactEntity.SetAttribute("donotpostalmail", doNotAllow);
            contactEntity.SetAttribute("donotbulkemail", doNotAllow);
            contactEntity.SetAttribute("donotfax", doNotAllow);

            // Get a count of child phone call entities associated with this Contact
            QueryExpression query = new QueryExpression();
            query.EntityName = "phonecall";
            query.ColumnSet = new ColumnSet(allColumns: true);
            query.Criteria = new FilterExpression();
            query.Criteria.AddCondition(new ConditionExpression("regardingobjectid", ConditionOperator.Equal, context.PrimaryEntityId));

            RetrieveMultipleRequest request = new RetrieveMultipleRequest();
            request.Query = query;
            IEnumerable<Entity> results = ((RetrieveMultipleResponse)service.Execute(request)).EntityCollection.Entities;
            if (results.Any())
            {
                // Do not default contact preference for phone if there are already some associated phone calls
                // Why? Because! Testing!
                contactEntity.SetAttribute("donotphone", doNotAllow);
            }
        }
开发者ID:tswann,项目名称:CrmPluginTesting,代码行数:30,代码来源:ContactPlugin.cs

示例2: UpdateRank

        public static int UpdateRank(IOrganizationService service, Entity workflow)
        {
            var wf = service.Retrieve("workflow", workflow.Id, new ColumnSet("statecode"));
            if (wf.GetAttributeValue<OptionSetValue>("statecode").Value != 0)
            {
                service.Execute(new SetStateRequest
                {
                    EntityMoniker = wf.ToEntityReference(),
                    State = new OptionSetValue(0),
                    Status = new OptionSetValue(-1)
                });
            }

            workflow.Attributes.Remove("statecode");
            workflow.Attributes.Remove("statuscode");
            service.Update(workflow);

            if (wf.GetAttributeValue<OptionSetValue>("statecode").Value != 0)
            {
                service.Execute(new SetStateRequest
                {
                    EntityMoniker = wf.ToEntityReference(),
                    State = new OptionSetValue(1),
                    Status = new OptionSetValue(-1)
                });
            }
            return workflow.GetAttributeValue<int>("rank");
        }
开发者ID:RazDynamics,项目名称:XrmToolBox,代码行数:28,代码来源:WorkflowHelper.cs

示例3: CreateAccountTask

        /// <summary>
        /// Code to create account task for new accounts
        /// </summary>
        /// <param name="service">crm service</param>
        /// <param name="accountEntity">entity of the newly created account</param>
        public void CreateAccountTask(IOrganizationService service, Entity accountEntity)
        {
            try
            {

                //create new task for account set in 2 weeks in the future
                Microsoft.Xrm.Sdk.Entity contactAccountTask = new Entity("task");
                contactAccountTask["subject"] = "Check new account is happy";
                contactAccountTask["description"] =
                "Make contact with new customer. See if they are happy with service and resolve any issues.";
                contactAccountTask["scheduledstart"] = DateTime.Now.AddDays(14);
                contactAccountTask["scheduledend"] = DateTime.Now.AddDays(14);
                Microsoft.Xrm.Sdk.EntityReference entRef = new EntityReference("account", accountEntity.Id);
                contactAccountTask["regardingobjectid"] = entRef;

                // Create the task and this should be linked to the new account record
                service.Create(contactAccountTask);

            }

            catch (FaultException ex)
            {
                throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
            }
        }
开发者ID:shobanvuppala,项目名称:CRM,代码行数:30,代码来源:AccountCreateFollowUp.cs

示例4: ScheduleWF

 public ScheduleWF(IOrganizationService service, new_incidentservice target,
     new_incidentserviceparameter paramters,
     new_flightoccurrence orginalFlightOccurrence,
     IEmailTemplate iEmailTemplate)
     : base(service, target, paramters, orginalFlightOccurrence, iEmailTemplate)
 {
 }
开发者ID:liorg,项目名称:DesignPatternsForXrm,代码行数:7,代码来源:ScheduleWF.cs

示例5: 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

示例6: Import

        public void Import(ExcelWorksheet sheet, List<EntityMetadata> emds, IOrganizationService service)
        {
            var rmds = new List<OneToManyRelationshipMetadata>();

            foreach (var row in sheet.Rows.Where(r => r.Index != 0).OrderBy(r => r.Index))
            {
                var rmd = rmds.FirstOrDefault(r => r.MetadataId == new Guid(row.Cells[1].Value.ToString()));
                if (rmd == null)
                {
                    var currentEntity = emds.FirstOrDefault(e => e.LogicalName == row.Cells[0].Value.ToString());
                    if (currentEntity == null)
                    {
                        var request = new RetrieveEntityRequest
                        {
                            LogicalName = row.Cells[0].Value.ToString(),
                            EntityFilters = EntityFilters.Relationships
                        };

                        var response = ((RetrieveEntityResponse) service.Execute(request));
                        currentEntity = response.EntityMetadata;

                        emds.Add(currentEntity);
                    }

                    rmd =
                        currentEntity.OneToManyRelationships.FirstOrDefault(
                            r => r.SchemaName == row.Cells[2].Value.ToString());
                    if (rmd == null)
                    {
                        rmd =
                            currentEntity.ManyToOneRelationships.FirstOrDefault(
                                r => r.SchemaName == row.Cells[2].Value.ToString());
                    }

                    rmds.Add(rmd);
                }

                int columnIndex = 4;

                rmd.AssociatedMenuConfiguration.Label = new Label();

                while (row.Cells[columnIndex].Value != null)
                {
                    rmd.AssociatedMenuConfiguration.Label.LocalizedLabels.Add(
                        new LocalizedLabel(row.Cells[columnIndex].Value.ToString(),
                            int.Parse(sheet.Cells[0, columnIndex].Value.ToString())));

                    columnIndex++;
                }
            }

            foreach (var rmd in rmds)
            {
                var request = new UpdateRelationshipRequest
                {
                    Relationship = rmd,
                };
                service.Execute(request);
            }
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:60,代码来源:RelationshipTranslation.cs

示例7: 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

示例8: Import

        public void Import(ExcelWorksheet sheet, IOrganizationService service)
        {
            var rowsCount = sheet.Dimension.Rows;

            for (var rowI = 1; rowI < rowsCount; rowI++)
            {
                var xml = new StringBuilder(string.Format("<LocLabel Id=\"{0}\"><Titles>", ZeroBasedSheet.Cell(sheet, rowI, 2).Value));

                var columnIndex = 3;

                while (ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value != null)
                {
                    xml.Append(string.Format("<Title description=\"{0}\" languagecode=\"{1}\"/>",
                                             ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value,
                                             int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString())));

                    columnIndex++;
                }

                xml.Append("</Titles></LocLabel>");

                var ribbonDiff = new Entity("ribbondiff") { Id = new Guid(ZeroBasedSheet.Cell(sheet, rowI, 0).Value.ToString()) };
                ribbonDiff["rdx"] = xml.ToString();

                service.Update(ribbonDiff);
            }
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:27,代码来源:RibbonTranslation.cs

示例9: SubAreaControl

        public SubAreaControl(List<EntityMetadata> emds, List<Entity> imageCache, List<Entity> htmlCache, IOrganizationService service)
        {
            InitializeComponent();

            this.emds = emds;
            this.imageCache = imageCache;
            this.htmlCache = htmlCache;
            this.service = service;

            collec = new Dictionary<string, string>();

            tip = new ToolTip();
            tip.ToolTipTitle = "Information";
            tip.SetToolTip(chkSubAreaAvailableOffline, "Controls whether SubArea is available offline.");
            tip.SetToolTip(chkSubAreaPassParams, "Specifies whether information about the organization and language context are passed to the URL.");
            tip.SetToolTip(txtOutlookShortcutIcon, "Specifies the icon to display in Microsoft Dynamics CRM for Microsoft Office Outlook.");
            tip.SetToolTip(txtSubAreaEntity, "Specifies the name for the entity. If a Url is not specified, the default view of the specified entity will be displayed.");
            tip.SetToolTip(txtSubAreaGetStartedPanePath, "Specifies the path to the Get Started page for this subarea.");
            tip.SetToolTip(txtSubAreaGetStartedPanePathAdmin, "Specifies the path to the Get Started page for this subarea if the user is logged in as an administrator.");
            tip.SetToolTip(txtSubAreaGetStartedPanePathAdminOutlook, "Specifies the path to the Get Started page for this subarea if the user is logged in as an administrator and Microsoft Dynamics CRM for Outlook is in use.");
            tip.SetToolTip(txtSubAreaGetStartedPanePathOutlook, "Specifies the path to the Get Started page for this subarea when Microsoft Dynamics CRM for Outlook is in use.");
            tip.SetToolTip(txtSubAreaIcon, "Specifies a URL for an 18x18 pixel image to display for the SubArea.");
            tip.SetToolTip(txtSubAreaId, "A unique identifier for this SubArea element.\r\n\r\nValid values: a-z, A-Z, 0-9, and underscore (_)");
            tip.SetToolTip(txtSubAreaUrl, "Specifies a URL or HTML Web Resource for a page to display in the main frame of the application when this subarea is selected.");
            tip.SetToolTip(txtSubAreaTitle, "Deprecated. Use the <Titles> (SiteMap) and <Title> (SiteMap) elements.");
            tip.SetToolTip(txtSubAreaDescription, "Deprecated. Use the <Description> (SiteMap) element.");
            tip.SetToolTip(txtDefaultDashboardId, "This functionality is introduced in Microsoft Dynamics CRM 2013 and the Microsoft Dynamics CRM Online Fall '13 Service Update. \r\nSpecifies the GUID for default dashboard to be displayed for this subarea.");
        }
开发者ID:yodelmas,项目名称:XrmToolBox,代码行数:28,代码来源:SubAreaControl.cs

示例10: ApplyImagesToEntities

        public static void ApplyImagesToEntities(List<EntityImageMap> mappings, IOrganizationService service)
        {
            foreach (var mapping in mappings)
            {
                if (mapping.ImageSize == 16)
                {
                    mapping.Entity.IconSmallName = mapping.WebResourceName;
                }
                else
                {
                    mapping.Entity.IconMediumName = mapping.WebResourceName;
                }

                var request = new UpdateEntityRequest { Entity = mapping.Entity };
                service.Execute(request);
            }

            string parameter = mappings.Aggregate(string.Empty, (current, mapping) => current + ("<entity>" + mapping.Entity.LogicalName + "</entity>"));

            string parameterXml = string.Format("<importexportxml ><entities>{0}</entities></importexportxml>",
                                                parameter);

            var publishRequest = new PublishXmlRequest { ParameterXml = parameterXml };
            service.Execute(publishRequest);
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:25,代码来源:MetadataManager.cs

示例11: PublisherSelector

        public PublisherSelector(IOrganizationService service, string selectedPrefixes)
        {
            InitializeComponent();

            this.service = service;
            this.SelectedPrefixes = selectedPrefixes.Split(';').ToList();
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:7,代码来源:PublisherSelector.cs

示例12: 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

示例13: GetAttribute

 public static AttributeMetadata GetAttribute(IOrganizationService service, string entity, string attribute)
 {
     // TODO: If AliasedValue, look up actual entity and attribute name to return correct metadata
     if (!entities.ContainsKey(entity))
     {
         var response = LoadEntityDetails(service, entity);
         if (response != null && response.EntityMetadata != null && response.EntityMetadata.Count == 1 && response.EntityMetadata[0].LogicalName == entity)
         {
             entities.Add(entity, response.EntityMetadata[0]);
         }
     }
     if (entities != null && entities.ContainsKey(entity))
     {
         if (entities[entity].Attributes != null)
         {
             foreach (var metaattribute in entities[entity].Attributes)
             {
                 if (metaattribute.LogicalName == attribute)
                 {
                     return metaattribute;
                 }
             }
         }
     }
     return null;
 }
开发者ID:Innofactor,项目名称:CRMWinForm,代码行数:26,代码来源:MetadataHelper.cs

示例14: ComputeMainClientID

        private static string ComputeMainClientID(string AccountName, IOrganizationService orgservice)
        {
            var result = new StringBuilder();
            var counter = 1;
            var maxClientIdLength = 35;

            //Change string to all lowercase
            AccountName = AccountName.ToLower();

            //Cycle through the string and remove all non alpha-numeric characters
            for (int i = 0; i <= AccountName.Length - 1; i++)
            {
                var c = AccountName[i];
                if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
                    result.Append(c);
            }

            //Make sure the string is between 2 and maxClientIdLength characters long, If it is over maxClientIdLength truncate it and if it is below 2 add padding
            if (result.Length > maxClientIdLength)
                result = result.Remove(maxClientIdLength, result.Length - maxClientIdLength);
            else if (result.Length < 2)
                result.Append("_");

            //Check existing accounts to make sure that the string is currently not already used in ergo_clientid
            //We append an incremental digit to the end of the string until we find a suitable clientid
            while(isDuplicate(result.ToString(), orgservice))
            {
                if (counter != 1 | result.Length + counter.ToString().Length > maxClientIdLength) 
                    result.Length = result.Length - counter.ToString().Length;
                result.Append(counter);
                counter++;
            }

            return result.ToString();
        }
开发者ID:bigleg127,项目名称:ClientIDPlugin,代码行数:35,代码来源:ClientIdPlugin.cs

示例15: AnswerSurvey

        public static MsCrmResult AnswerSurvey(SurveyAnswer answer, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = new Entity("new_surveyanswer");
                ent["new_name"] = answer.PortalUser.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy HH:mm");
                ent["new_portalid"] = answer.Portal;
                ent["new_userid"] = answer.PortalUser;
                ent["new_surveyid"] = answer.Survey;
                ent["new_surveychoiceid"] = answer.SurveyChoice;

                returnValue.CrmId = service.Create(ent);

                returnValue.Success = true;
                returnValue.Result = "M053"; //"Anket cevabınız alınmıştır. <br /> Katılımınız için teşekkür ederiz.";

            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:25,代码来源:SurveyHelper.cs


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