• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# OrganizationService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FindPluginAssembly

        private static Guid FindPluginAssembly(OrganizationService service, string assemblyName)
        {
            var query = new QueryExpression
            {
                EntityName = "pluginassembly",
                ColumnSet = null,
                Criteria = new FilterExpression()
            };
            query.Criteria.AddCondition("name", ConditionOperator.Equal, assemblyName);

            var request = new RetrieveMultipleRequest
            {
                Query = query
            };

            var response = (RetrieveMultipleResponse)service.Execute(request);

            if (response.EntityCollection.Entities.Count == 1)
            {
                var id = response.EntityCollection[0].GetAttributeValue<Guid>("pluginassemblyid");
                _logger.Log(LogLevel.Debug, () => string.Format("Found id {0} for assembly", id));

                return id;
            }

            return Guid.Empty;
        }
开发者ID:skfd,项目名称:PluginAssemblyLoader,代码行数:27,代码来源:Program.cs


示例2: Validate

        public override DTSExecResult Validate(IDTSInfoEvents infoEvents)
        {
            // プロパティが一つでも空だったらエラーとする
            if (!PropertiesValidate(infoEvents, URL, Domain, UserName, Password))
            {
                return DTSExecResult.Failure;
            }

            // 接続テスト
            try
            {
                var con = CrmConnection.Parse(ConnectionString);
                con.Timeout = TimeSpan.FromSeconds(30);
                using (var service = new OrganizationService(con))
                {
                    service.Execute<WhoAmIResponse>(new WhoAmIRequest());
                }
            }
            catch (Exception e)
            {
                infoEvents.FireError(0, "Dynamics CRM 2011 接続マネージャー", e.Message, string.Empty, 0);
                return DTSExecResult.Failure;
            }


            return DTSExecResult.Success;
        }
开发者ID:RisingK,项目名称:snippets,代码行数:27,代码来源:CrmConnectionManagerComponent.cs


示例3: Export

        private static void Export()
        {
            var service = new OrganizationService(CrmConnection.Parse("Url=http://dev-crm/SCAMPROD;"));

            //var doc = new WordDocumentDocX();
            //doc.Settings = new GenerationSettings
            //{
            //    FilePath = @"c:\temp\doc.docx",
            //    AddAuditInformation = true,
            //    AddEntitiesSummary = true,
            //    AddFieldSecureInformation = true,
            //    AddFormLocation = true,
            //    AddRequiredLevelInformation = true,
            //    AddValidForAdvancedFind = true,
            //    AttributesSelection = AttributeSelectionOption.AllAttributes,
            //    DisplayNamesLangugageCode = 1033,
            //    EntitiesToProceed = new List<EntityItem>{new EntityItem
            //    {
            //        Name = "scam_repartition"
            //    }},
            //    IncludeOnlyAttributesOnForms = false,
            //    OutputDocumentType = Output.Word,
            //};
            //doc.Generate(service);
        }
开发者ID:NORENBUCH,项目名称:XrmToolBox,代码行数:25,代码来源:Program.cs


示例4: btnTest_Click

        /// <summary>
        /// 接続テスト
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ev"></param>
        private void btnTest_Click(object sender, EventArgs ev)
        {
            var connectionString = CreateConnectionString
                    (
                        Url => txbURL.Text,
                        Domain => txbDomain.Text,
                        Username => txbUserName.Text,
                        Password => txbPassword.Text
                    );

            // connection test
            try
            {
                var con = CrmConnection.Parse(connectionString);
                con.Timeout = TimeSpan.FromSeconds(30);
                using (var service = new OrganizationService(con))
                {
                    service.Execute<WhoAmIResponse>(new WhoAmIRequest());
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            MessageBox.Show("OK", "確認", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
开发者ID:RisingK,项目名称:snippets,代码行数:33,代码来源:CrmConnectionManagerForm.cs


示例5: Connect

 public virtual void Connect()
 {
     string CrmConnectionString = string.Format("Url={0}; Username={1}; Password={2};",
                                                Url, Username, Password);
     crmConnection = CrmConnection.Parse(CrmConnectionString);
     service = new OrganizationService(crmConnection);
 }
开发者ID:rexghadaffi,项目名称:TE-System,代码行数:7,代码来源:ContextHelpers.cs


示例6: GetUserRoles

        /// <summary>
        /// retrieves a list of CRM roles assigned to a specific user
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="service"></param>
        /// <returns></returns>
        private List<string> GetUserRoles(Guid userid, OrganizationService service)
        {
            List<string> roles = new List<string>();

            string fetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
              <entity name='role'>
                <attribute name='name' />
                <attribute name='businessunitid' />
                <attribute name='roleid' />
                <order attribute='name' descending='false' />
                <link-entity name='systemuserroles' from='roleid' to='roleid' visible='false' intersect='true'>
                  <link-entity name='systemuser' from='systemuserid' to='systemuserid' alias='af'>
                    <filter type='and'>
                      <condition attribute='systemuserid' operator='eq' uitype='systemuser' value='{$USERID}' />
                    </filter>
                  </link-entity>
                </link-entity>
              </entity>
            </fetch>";
            fetchXml = fetchXml.Replace("$USERID", userid.ToString());
            EntityCollection results = service.RetrieveMultiple(new FetchExpression(fetchXml));
            foreach (Entity entity in results.Entities)
            {
                roles.Add((string)entity["name"]);
            }
            return roles;
        }
开发者ID:milos01,项目名称:Crm-Sample-Code,代码行数:33,代码来源:CrmUsernamePasswordValidator.cs


示例7: IsAuthenticated

        public async Task<bool> IsAuthenticated(PortalUser user)
        {
            string Url = ConfigurationManager.AppSettings["URL"].ToString();
            string CrmConnectionString = string.Format("Url={0}; Username={1}; Password={2}",
                                                              Url, user.Username, user.Password);
          
            ClientCredentials credential = new ClientCredentials();          
            
            credential.UserName.UserName = user.Username;
            credential.UserName.Password = user.Password;


            CrmConnection crmConnection = CrmConnection.Parse(CrmConnectionString);
            crmConnection.ClientCredentials = credential;
            OrganizationService service = new OrganizationService(crmConnection);

            QueryExpression qe = new QueryExpression("systemuser");
            qe.ColumnSet = new ColumnSet();
            qe.ColumnSet.AddColumn("systemuserid");
            qe.ColumnSet.AddColumn("fullname");
            qe.Criteria = new FilterExpression();
            qe.Criteria.AddCondition("domainname", ConditionOperator.Equal, user.Username);

            EntityCollection collection = service.RetrieveMultiple(qe);

            if (collection.Entities.Count == 0)
            {
                return false;   
            }
            return true;
        }
开发者ID:rexghadaffi,项目名称:TE-System,代码行数:31,代码来源:CrmAuthentication.cs


示例8: GetYelpAccounts

        private EntityCollection GetYelpAccounts()
        {
            CrmConnection connection = CrmConnection.Parse(_connection);
            using (_orgService = new OrganizationService(connection))
            {
                var query = new QueryExpression
                {
                    EntityName = "account",
                    ColumnSet = new ColumnSet("test9_yelpid"),
                    Criteria = new FilterExpression
                    {
                        Conditions =
                        {
                            new ConditionExpression
                            {
                                AttributeName = "test9_yelpid",
                                Operator = ConditionOperator.NotNull
                            }
                        }
                    }
                };

                return _orgService.RetrieveMultiple(query);
            }
        }
开发者ID:zoluo,项目名称:CRMWebAPIYelpExample,代码行数:25,代码来源:AccountEnrichmentController.cs


示例9: PublishInCRM

        public void PublishInCRM(ServiceRequest serviceRequest)
        {
            //Connects to the database and Logs the User In
            var connection = ConnectToDatabase();
            var service = new OrganizationService(connection);
            var context = new CrmOrganizationServiceContext(connection);

            //const int hour = 60;

            EventLog.saveMessage("PublishIssue SRID:" + serviceRequest.SRID);

            //Creating the new Case
            Entity incident = new Entity("incident");

            try
            {
                //Filling the Data for the new case
                incident["createdon"] = serviceRequest.RegistrationDate;
                incident["description"] = serviceRequest.LongDescription;
                incident["statuscode"] = ReturnStatusCode(serviceRequest.ServiceRequestStatus);
                incident["subjectid"] = ReturnRequestType(serviceRequest.ServiceRequestType);
                incident["new_moduleoptionset"] = ReturnModuleCode("TS");
                //incident["ownerid"] = new EntityReference("systemuser", findConsultantID(serviceRequest.AssignedPerson, service));
                incident["new_caseasignedto"] = serviceRequest.AssignedPerson;
                incident["new_statushistory"] = serviceRequest.CommentsMatricia;
                incident["casetypecode"] = returnRequestKind(serviceRequest.ServiceRequestKind);
                incident["followupby"] = serviceRequest.DueDate;
                incident["new_supportrequestid"] = serviceRequest.SRID;
                incident["title"] = serviceRequest.AssignedToClient + " " + serviceRequest.SRID + " " + serviceRequest.companyName;
                //incident["customerid"] = new EntityReference("account", findCustomer((string)serviceRequest.companyName, service));
                incident["customerid"] = new EntityReference("account", findCustomerID(serviceRequest.companyName));
                incident["new_statushistory"] = serviceRequest.ShortDescription;
                incident["new_assignedfrom"] = serviceRequest.CreatedBy;

                Guid consultantID = findConsultantID(serviceRequest.AssignedPerson, service);

                
                //Adding the created case to CRM;
                var incidentGuid = service.Create(incident);

                //Assign a case!
                EventLog.saveMessage("Start of Assignment! to :" + consultantID);
                AssignRequest assignRequest = new AssignRequest();
                assignRequest.Assignee = new EntityReference("systemuser", consultantID);
                assignRequest.Target = new EntityReference(incident.LogicalName, incidentGuid);

                service.Execute(assignRequest);
            }
            catch (Exception)
            {
                EventLog.saveMessage("This case was not created in CRM " + serviceRequest.CreatedBy + "'" + serviceRequest.SRID); ;
            }



        }
开发者ID:borisov90,项目名称:Projects,代码行数:56,代码来源:WebService1.asmx.cs


示例10: Main

        static void Main(string[] args)
        {
            CrmConnection connection = CrmConnection.Parse(
                ConfigurationManager.ConnectionStrings["CRMConnectionString"].ConnectionString);

            using (_orgService = new OrganizationService(connection))
            {
                //Do stuff
            }
        }
开发者ID:kwechsler,项目名称:CRMDeveloperExtensions,代码行数:10,代码来源:Program.cs


示例11: TestSiteMapCacheRequest

        public void TestSiteMapCacheRequest()
        {
            IOrganizationService service = new OrganizationService(new CrmConnection("CRM"));

            StringWriter mapJson = new StringWriter();
            SiteMapLoader loader = new SiteMapLoader(1033);
            ITracingService tace = new debugTrace();
            loader.ParseSiteMapToJson(service,tace, mapJson);
            Console.WriteLine(mapJson.ToString());
        }
开发者ID:DeBiese,项目名称:SparkleXrm,代码行数:10,代码来源:SiteMapCachePluginTests.cs


示例12: TestMethod1

        public void TestMethod1()
        {
            IOrganizationService service = new OrganizationService(new CrmConnection("CRM"));

            RetrieveFormXmlRequest request = new RetrieveFormXmlRequest();
            request.EntityName = "contact";
            
            var response = service.Execute<RetrieveFormXmlResponse>(request);
            Console.WriteLine(response.FormXml);

        }
开发者ID:DeBiese,项目名称:SparkleXrm,代码行数:11,代码来源:TestFormMetadataRetrieve.cs


示例13: DynamicsCls

        /// <summary>
        /// コンストラクタ。dynamicsとの接続を確立する。
        /// </summary>
        /// <param name="user"></param>
        /// <param name="pass"></param>
        /// <param name="url"></param>
        public DynamicsCls(string user, string pass, string url)
        {
            string connetString = String.Format("Url={0}; Username={1}; Password={2};",
                url,
                user,
                pass);

            CrmConnection connection = CrmConnection.Parse(connetString);
            _service = new OrganizationService(connection);

            WhoAmIResponse res = (WhoAmIResponse)_service.Execute(new WhoAmIRequest());
        }
开发者ID:gk0909c,项目名称:DynamicsDataExplorer,代码行数:18,代码来源:DynamicsCls.cs


示例14: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            var myConnection = new CrmConnection("Xrm");
            using (var myService = new OrganizationService(myConnection))
            using (var myContext = new Xrm.XRMServiceContext(myService))
            {
                var accounts = myContext.bro_managetemplateSet.ToList();
            }
        }
    }
开发者ID:prem1942,项目名称:CRMSAMPLES,代码行数:13,代码来源:Default.aspx.cs


示例15: DeleteInactiveProfiles

    public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
    {
        //MAS
        using (OrganizationService service = new OrganizationService(OurConnect()))
        {
            ConditionExpression appCondition = new ConditionExpression();
            ConditionExpression authenticationCondition = new ConditionExpression();

            appCondition.AttributeName = consts.appname;
            appCondition.Operator = ConditionOperator.Equal;
            appCondition.Values.Add(_ApplicationName);

            switch (authenticationOption)
            {
                case ProfileAuthenticationOption.Anonymous:
                    authenticationCondition.AttributeName = consts.isanonymous;
                    authenticationCondition.Operator = ConditionOperator.Equal;
                    authenticationCondition.Values.Add(true);
                    break;
                case ProfileAuthenticationOption.Authenticated:
                    authenticationCondition.AttributeName = consts.isanonymous;
                    authenticationCondition.Operator = ConditionOperator.Equal;
                    authenticationCondition.Values.Add(false);
                    break;
                default:
                    break;
            }

            FilterExpression filter = new FilterExpression();
            filter.Conditions.Add(appCondition);
            filter.Conditions.Add(authenticationCondition);

            QueryExpression query = new QueryExpression(consts.userprofile);
            query.ColumnSet.AddColumn(consts.username);
            query.Criteria.AddFilter(filter);
            EntityCollection collection = service.RetrieveMultiple(query);

            string[] usersToDelete = null;
            int j = 0;
            for(int i=0;i<collection.TotalRecordCount;i++)
            {
                if (DateTime.Compare(lastActivity((string)collection.Entities[i][consts.username], String.Empty), userInactiveSinceDate) < 0)
                {
                    usersToDelete[j] = (string)collection.Entities[i][consts.username];
                    j++;
                }
            }

            return DeleteProfiles(usersToDelete);
        }
    }
开发者ID:RosettaMktg,项目名称:CrmProvider,代码行数:51,代码来源:CustomProfileProvider.cs


示例16: Validate

        /// <summary>
        /// Validate method to attempt to connect to CRM with supplied username/password and then execute a whoami request
        /// </summary>
        /// <param name="username">crm username</param>
        /// <param name="password">crm password</param>
        public override void Validate(string username, string password)
        {
            //get the httpcontext so we can store the user guid for impersonation later
            HttpContext context = HttpContext.Current;

            //if username or password are null, obvs we can't continue
            if (null == username || null == password)
            {
                throw new ArgumentNullException();
            }

            //get the crm connection
            Microsoft.Xrm.Client.CrmConnection connection = CrmUtils.GetCrmConnection(username, password);

            //try the whoami request
            //if it fails (user can't be authenticated, is disabled, etc.), the client will get a soap fault message
            using (OrganizationService service = new OrganizationService(connection))
            {
                try
                {
                    WhoAmIRequest req = new WhoAmIRequest();
                    WhoAmIResponse resp = (WhoAmIResponse)service.Execute(req);
                    Entity systemuser = CrmUtils.GetSystemUser(resp.UserId, service);

                    CrmIdentity crmIdentity = new CrmIdentity();
                    crmIdentity.Name = (string)systemuser["fullname"];
                    crmIdentity.FirstName = (string)systemuser["firstname"];
                    crmIdentity.LastName = (string)systemuser["lastname"];
                    crmIdentity.Email = (string)systemuser["internalemailaddress"];
                    crmIdentity.UserId = resp.UserId;
                    crmIdentity.SetAuthenticated(true);

                    List<string> roles = CrmUtils.GetUserRoles(resp.UserId, service);
                    foreach (string role in roles)
                    {
                        crmIdentity.AddRole(role);
                    }

                    context.User = new GenericPrincipal(crmIdentity, roles.ToArray());
                }
                catch (System.ServiceModel.Security.MessageSecurityException ex)
                {
                    throw new FaultException(ex.Message);
                }
                catch (Exception ex)
                {
                    throw new FaultException(ex.Message);
                }
            }
        }
开发者ID:rrrainville,项目名称:DieselXrmWrapper,代码行数:55,代码来源:CrmUsernamePasswordValidator.cs


示例17: Get

        public void Get()
        {
            _connection = ConfigurationManager.ConnectionStrings["CRMOnlineO365"].ConnectionString;
            CrmConnection connection = CrmConnection.Parse(_connection);

            EntityCollection results = GetYelpAccounts();
            if (!results.Entities.Any()) return;

            using (_orgService = new OrganizationService(connection))
            {
                foreach (Entity entity in results.Entities)
                {
                    GetYelpData(entity.Id, entity.GetAttributeValue<string>("test9_yelpid"));
                }
            }
        }
开发者ID:zoluo,项目名称:CRMWebAPIYelpExample,代码行数:16,代码来源:AccountEnrichmentController.cs


示例18: AddRemarksForEntry

        public void AddRemarksForEntry(Guid entryID,  Annotation data, string Username, string Password)
        {
            Entity note = new Entity("annotation");

            note["objectid"] = new EntityReference("gsc_timeentry", entryID);
            note["subject"] = data.Subject;
            note["notetext"] = data.NoteText;

            string Url = ConfigurationManager.AppSettings["Url"].ToString();
            string CrmConnectionString = string.Format("Url={0}; Username={1}; Password={2}",
                                                        Url, Username, Password);
            CrmConnection crmConnection = null;
            crmConnection = CrmConnection.Parse(CrmConnectionString);
            OrganizationService service = new OrganizationService(crmConnection);

            service.Create(note);
        }
开发者ID:rexghadaffi,项目名称:TE-System,代码行数:17,代码来源:AnnotationContext.cs


示例19: Create

        public void Create(string entityName, [FromBody] JObject objStructure)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["CRMConnectionString"].ConnectionString;
            
            CrmConnection crmConnection = CrmConnection.Parse(connectionString);
            using (OrganizationService service = new OrganizationService(crmConnection))
            {
                if (objStructure != null)
                {
                    Entity entity = new Entity(entityName);
                    Guid guidValue;

                    foreach (var attribute in objStructure)
                    {
                        if (Guid.TryParse(attribute.Value.ToString(), out guidValue))
                        {
                            RetrieveAttributeRequest attributeRequest = new RetrieveAttributeRequest
                            {
                                EntityLogicalName = entityName,
                                LogicalName = attribute.Key.ToString(),
                                RetrieveAsIfPublished = true
                            };

                            // Execute the request
                            RetrieveAttributeResponse attributeResponse =
                                (RetrieveAttributeResponse)service.Execute(attributeRequest);

                            if (attributeResponse.AttributeMetadata.AttributeType == AttributeTypeCode.Lookup)
                            {
                                string relatedEntityName =
                                    ((LookupAttributeMetadata)(attributeResponse.AttributeMetadata)).Targets[0];

                                EntityReference eref = new EntityReference(relatedEntityName, guidValue);
                                entity[attribute.Key.ToString()] = eref;
                                continue;
                            }
                        }

                        entity[attribute.Key.ToString()] = attribute.Value.ToString();
                    }

                    service.Create(entity);
                }
            }
        }
开发者ID:sudarsanan-krishnan,项目名称:DynamicsCRMConnector,代码行数:45,代码来源:CRMEntityController.cs


示例20: Main

        static void Main(string[] args)
        {
            try
            {
                CrmConnection connection = CrmConnection.Parse(
                    ConfigurationManager.ConnectionStrings["CRMConnectionString"].ConnectionString);

                using (_orgService = new OrganizationService(connection))
                {
                    //Do stuff
                }
            }
            catch (FaultException<OrganizationServiceFault> ex)
            {
                string message = ex.Message;
                throw;
            }
        }
开发者ID:amburin,项目名称:CRMDeveloperExtensions,代码行数:18,代码来源:Program.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# OrganizationServiceProxy类代码示例发布时间:2022-05-24
下一篇:
C# OrganizationMembersClient类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap