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


C# IOrganizationService.Create方法代码示例

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


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

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

示例2: CreateCrmAccount

 /// <summary>
 /// Creates a new account with a given name using the supplied organization service
 /// </summary>
 /// <param name="accountName">account name</param>
 /// <param name="service">organization service</param>
 /// <returns>id of the new account</returns>
 public static Guid CreateCrmAccount(string accountName, IOrganizationService service)
 {
     Entity account = new Entity("account");
     account["name"] = accountName;
     Guid newId = service.Create(account);
     return newId;
 }
开发者ID:milos01,项目名称:Crm-Sample-Code,代码行数:13,代码来源:Sample01.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: CreateCrmAccount2

        /// <summary>
        /// Creates a new account with a given name and then creates a follow-up task linked to the account
        /// </summary>
        /// <param name="accountName">account name</param>
        /// <param name="service">organization service</param>
        public static void CreateCrmAccount2(string accountName, IOrganizationService service)
        {
            //create the account
            Entity account = new Entity("account");
            account["name"] = accountName;
            Guid newId = service.Create(account);

            //get the account number
            account = service.Retrieve("account", newId, new Microsoft.Xrm.Sdk.Query.ColumnSet(new string[] { "name", "accountid", "accountnumber" }));
            string accountNumber = account["accountnumber"].ToString();

            //create the task
            Entity task = new Entity("task");
            task["subject"] = "Finish account set up for " + accountName + " - " + accountNumber;
            task["regardingobjectid"] = new Microsoft.Xrm.Sdk.EntityReference("account", newId);
            service.Create(task);
        }
开发者ID:milos01,项目名称:Crm-Sample-Code,代码行数:22,代码来源:Sample02.cs

示例5: CreateAnnotation

        public static MsCrmResult CreateAnnotation(Annotation note, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();
            try
            {
                Entity ent = new Entity("annotation");

                if (note.AttachmentFile != null)
                {
                    ent["objectid"] = note.AttachmentFile;
                }

                if (!string.IsNullOrEmpty(note.Subject))
                {
                    ent["subject"] = note.Subject;
                }

                if (!string.IsNullOrEmpty(note.File))
                {
                    ent["documentbody"] = note.File;
                }

                if (!string.IsNullOrEmpty(note.FileName))
                {
                    ent["filename"] = note.FileName;
                }

                if (!string.IsNullOrEmpty(note.MimeType))
                {
                    ent["mimetype"] = note.MimeType;
                }

                if (!string.IsNullOrEmpty(note.Text))
                {
                    ent["notetext"] = note.Text;
                }

                returnValue.CrmId = service.Create(ent);
                returnValue.Success = true;
                returnValue.Result = "Dosya Ekleme başarıyla gerçekleşti.";
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:48,代码来源:AnnotationHelper.cs

示例6: Update

        public void Update(IOrganizationService service, List<Entity> profiles)
        {
            foreach (var profile in profiles)
            {
                var field = Fields.FirstOrDefault(
                        f => f.GetAttributeValue<EntityReference>("fieldsecurityprofileid").Id == profile.Id);

                if (field == null)
                {
                    field = new Entity("fieldpermission");
                    field["fieldsecurityprofileid"] = profile.ToEntityReference();
                    field["canread"] = new OptionSetValue(0);
                    field["cancreate"] = new OptionSetValue(0);
                    field["canupdate"] = new OptionSetValue(0);
                    field["entityname"] = Entity;
                    field["attributelogicalname"] = Attribute;
                }

                if (CanRead.HasValue)
                {
                    field["canread"] = new OptionSetValue(CanRead.Value ? 4 : 0);
                }

                if (CanCreate.HasValue)
                {
                    field["cancreate"] = new OptionSetValue(CanCreate.Value ? 4 : 0);
                }

                if (CanUpdate.HasValue)
                {
                    field["canupdate"] = new OptionSetValue(CanUpdate.Value ? 4 : 0);
                }

                if (field.Id == Guid.Empty)
                {
                    field.Id = service.Create(field);
                    Fields.Add(field);
                }
                else
                {
                    service.Update(field);
                }
            }
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:44,代码来源:SecureFieldInfo.cs

示例7: CreateDiscoveryForm

        public static MsCrmResult CreateDiscoveryForm(DiscoveryForm discoveryForm, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = discoveryForm.ToCrmEntity();

                returnValue.CrmId = service.Create(ent);
                returnValue.Success = true;
                returnValue.Result = "Form kaydedildi.";
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:19,代码来源:DiscoveryFormHelper.cs

示例8: CreateUserGiftRequest

        public static MsCrmResult CreateUserGiftRequest(UserGiftRequest userGiftRequest, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = userGiftRequest.ToCrmEntity();

                returnValue.CrmId = service.Create(ent);
                returnValue.Success = true;
                returnValue.Result = userGiftRequest.Point.ToString() + " puana sahip hediye talebiniz alınmıştır.";
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:19,代码来源:GiftHelper.cs

示例9: CreateUserCodeUsage

        public static MsCrmResult CreateUserCodeUsage(UserCodeUsage userCodeUsage, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = userCodeUsage.ToCrmEntity();

                returnValue.CrmId = service.Create(ent);
                returnValue.Success = true;
                returnValue.Result = userCodeUsage.Point.ToString() + " puan kazandınız.";
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:19,代码来源:PointCodeHelper.cs

示例10: CreateAssemblyRequest

        public static MsCrmResult CreateAssemblyRequest(AssemblyRequestInfo requestInfo, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = requestInfo.ToCrmEntity();

                returnValue.CrmId = service.Create(ent);
                returnValue.Success = true;
                returnValue.Result = "Talep kaydedildi.";
            }
            catch (Exception ex)
            {
                returnValue.HasException = true;
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:20,代码来源:AssemblyRequestHelper.cs

示例11: addTaskToUser

        public void addTaskToUser(Marketer myMarketer, AccountBase myAccount, IOrganizationService myCRMService)
        {
            //myMarketer.sCrmEntityName = "user";
            //myMarketer.sCrmEntityGuidFieldName = "systemuserid";
            //myMarketer.sCrmAttributeName = "domainname";
            myMarketer.sCrmFilterAttributeValue = myMarketer.sCrmUsername;
            myMarketer.FindGuidForObject(myCRMService);

            //myAccount.sCrmEntityName = "account";
            //myAccount.sCrmEntityName = "accountid";
            //myAccount.sCrmAttributeName = "accountnumber";
            myAccount.sCrmFilterAttributeValue = myAccount.sCustomerNumber;
            myAccount.FindGuidForObject(myCRMService);

            var newTask = new Entity("task");
            newTask["ownerid"] = myMarketer.crmGuidId;
            newTask["regardingobjectid"] = myAccount.crmGuidId;
            newTask["description"] = sMessage;
            newTask["scheduledend"] = sDuedate;
            newTask["subject"] = myAccount.sAccountName;
            myCRMService.Create(newTask);
        }
开发者ID:anthonied,项目名称:CRM,代码行数:22,代码来源:TaskBase.cs

示例12: CreateScore

        public static MsCrmResult CreateScore(Score score, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = new Entity("new_score");
                ent["new_name"] = score.ScoreType.ToString() + "-" + score.User.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy HH:mm");
                ent["new_portalid"] = score.Portal;
                ent["new_userid"] = score.User;
                ent["new_point"] = score.Point;
                ent["new_scoretype"] = new OptionSetValue((int)score.ScoreType);

                returnValue.CrmId = service.Create(ent);
                returnValue.Success = true;
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:23,代码来源:ScoreHelper.cs

示例13: DislikeEntity

        public static MsCrmResult DislikeEntity(Guid portalId, Guid portalUserId, Guid entityId, string entityName, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = new Entity("new_likerecord");
                ent["new_name"] = DateTime.Now.ToString("dd.MM.yyyy HH:mm");
                ent["new_portalid"] = new EntityReference("new_portal", portalId);
                ent["new_userid"] = new EntityReference("new_user", portalUserId);
                ent["new_liketype"] = false;
                ent[entityName + "id"] = new EntityReference(entityName, entityId);

                returnValue.CrmId = service.Create(ent);
                returnValue.Result = "M055";
                returnValue.Success = true;
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
开发者ID:volkanytu,项目名称:Portal,代码行数:23,代码来源:LikeHelper.cs

示例14: GetNumber

        private string GetNumber(IOrganizationService service)
        {
            int suffix = 0;
            string contractNumber = string.Empty;
            QueryExpression query = new QueryExpression("ivg_autonumber");

            FilterExpression filter = new FilterExpression(LogicalOperator.And);

            filter.AddCondition("ivg_contactnumber", ConditionOperator.Equal, "contractnumber");
            filter.AddCondition("ivg_year", ConditionOperator.Equal, DateTime.Now.Year.ToString().Substring(2));
            filter.AddCondition("ivg_month", ConditionOperator.Equal, DateTime.Now.Month.ToString());
            query.Criteria.AddFilter(filter);

            query.ColumnSet = new ColumnSet(true);
            EntityCollection collection = null;
            try
            {
                collection = service.RetrieveMultiple(query);

                if (collection != null && collection.Entities.Count > 0)
                {
                    contractNumber = null;
                    string MM = collection.Entities[0].Attributes["ivg_month"].ToString();
                    if (MM.Length == 1)
                        MM = "0" + MM;
                    suffix = int.Parse(collection.Entities[0].Attributes["ivg_number"].ToString()) + 1;
                    string suffixString = suffix.ToString("0000");
                    //if (suffixString.Length == 1)
                    //    suffixString = "000" + suffixString;
                    //if (suffixString.Length == 2)
                    //    suffixString = "00" + suffixString;
                    //if (suffixString.Length == 3)
                    //    suffixString = "0" + suffixString;
                    contractNumber = collection.Entities[0].Attributes["ivg_year"].ToString() + MM + "-" + suffixString;

                    #region update auto number entity
                    Guid autonumberId = collection.Entities[0].Id;
                    Entity ivg_autonumber = new Entity("ivg_autonumber");
                    ivg_autonumber.Id = autonumberId;
                    ivg_autonumber.Attributes["ivg_number"] = suffix.ToString();

                    service.Update(ivg_autonumber);

                    #endregion
                }
                else
                {
                    suffix = 1;
                    Entity ivg_autonumber = new Entity("ivg_autonumber");
                    ivg_autonumber.Attributes["ivg_number"] = suffix.ToString();
                    ivg_autonumber.Attributes["ivg_contactnumber"] = "contractnumber";
                    ivg_autonumber.Attributes["ivg_year"] = DateTime.Now.Year.ToString().Substring(2);
                    ivg_autonumber.Attributes["ivg_month"] = DateTime.Now.Month.ToString();

                    service.Create(ivg_autonumber);
                    string MM = DateTime.Now.Month.ToString();
                    if (MM.Length == 1)
                        MM = "0" + MM;
                    contractNumber = DateTime.Now.Year.ToString().Substring(2) + MM + "-0001";
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.StackTrace);
            }
            return contractNumber;
        }
开发者ID:hoanhtnb,项目名称:dynamics-crm-2015-plugin,代码行数:67,代码来源:BusinessLogic.cs

示例15: TransferViews

        public static List<Tuple<string, string>> TransferViews(List<Entity> sourceViews, IOrganizationService sourceService, IOrganizationService targetService, EntityMetadata savedQueryMetadata)
        {
            var errors = new List<Tuple<string, string>>();
            try
            {
                foreach (var sourceView in sourceViews)
                {
                    // Identifiy ownerid domainname if userquery
                    string userDomainName = null;
                    if (sourceView.LogicalName == "userquery")
                    {
                        var sourceUser = sourceService.Retrieve("systemuser", sourceView.GetAttributeValue<EntityReference>("ownerid").Id,
                            new ColumnSet("domainname"));
                        userDomainName = sourceUser.GetAttributeValue<string>("domainname");
                    }

                    var targetViewQuery = new QueryExpression(sourceView.LogicalName);
                    targetViewQuery.ColumnSet = new ColumnSet { AllColumns = true };
                    targetViewQuery.Criteria.AddCondition(sourceView.LogicalName + "id", ConditionOperator.Equal, sourceView.Id);
                    var targetViews = targetService.RetrieveMultiple(targetViewQuery);

                    if (targetViews.Entities.Count > 0)
                    {
                        // We need to update the existing view
                        var targetView = CleanEntityForUpdate(savedQueryMetadata, sourceView);

                        // Replace ObjectTypeCode in layoutXml
                        ReplaceLayoutXmlObjectTypeCode(targetView, targetService);

                        try
                        {
                            targetService.Update(targetView);
                        }
                        catch (Exception error)
                        {
                            errors.Add(new Tuple<string, string>(targetView["name"].ToString(), error.Message));
                        }
                    }
                    else
                    {
                        // We need to create the view
                        var targetView = CleanEntityForCreate(savedQueryMetadata, sourceView);

                        if (targetView.LogicalName == "userquery")
                        {
                            // Let's find the user based on systemuserid or domainname
                            var targetUser = targetService.RetrieveMultiple(new QueryExpression("systemuser")
                            {
                                Criteria = new FilterExpression(LogicalOperator.Or)
                                {
                                    Conditions =
                                    {
                                        new ConditionExpression("domainname", ConditionOperator.Equal, userDomainName ?? "dummyValueNotExpectedAsDomainNameToAvoidSystemAccount"),
                                        new ConditionExpression("systemuserid", ConditionOperator.Equal,
                                            sourceView.GetAttributeValue<EntityReference>("ownerid").Id),
                                    }
                                }
                            }).Entities.FirstOrDefault();

                            if (targetUser != null)
                            {
                                targetView["ownerid"] = targetUser.ToEntityReference();
                            }
                            else
                            {
                                throw new Exception(string.Format(
                                    "Unable to find a user in the target organization with domain name '{0}' or id '{1}'",
                                    userDomainName,
                                    sourceView.GetAttributeValue<EntityReference>("ownerid").Id));
                            }
                        }

                        // Replace ObjectTypeCode in layoutXml
                        ReplaceLayoutXmlObjectTypeCode(targetView, targetService);

                        try
                        {
                            targetService.Create(targetView);
                        }
                        catch (Exception error)
                        {
                            errors.Add(new Tuple<string, string>(sourceView["name"].ToString(), error.Message));
                        }
                    }
                }
                return errors;
            }
            catch (Exception error)
            {
                string errorMessage = CrmExceptionHelper.GetErrorMessage(error, false);

                throw new Exception("Error while transfering views: " + errorMessage);
            }
        }
开发者ID:NielsMinnee,项目名称:XrmToolBox,代码行数:94,代码来源:ViewHelper.cs


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