Esempio n. 1
0
        public CRMUser CRMGetUser(CRMUser crmUser)
        {
            CRMState returnEntities = new CRMState();
            CRMUser  ret            = new CRMUser();

            string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                          <entity name='systemuser'>
                            <attribute name='fullname' />
                            <attribute name='businessunitid' />
                            <attribute name='title' />
                            <attribute name='address1_telephone1' />
                            <attribute name='systemuserid' />
                            <order attribute='fullname' descending='false' />
                            <filter type='and'>
                              <condition attribute='domainname' operator='eq' value='"
                              + crmUser.UserFQN + "' />"
                              + "</filter>"
                              + "</entity>"
                              + "</fetch>";

            CRMFetchXML fx = new CRMFetchXML();

            fx.FetchXML = fetchxml;
            List <CRMState> user = CRMGetEntities(fx).Entities;

            if (user.Count > 0)
            {
                crmUser.UserId = user[0].EntityId;
            }
            return(crmUser);
        }
Esempio n. 2
0
        public CRMWorkflow CRMStartWorkflow(CRMWorkflow crmWF)
        {
            string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
                              + "<entity name='workflow'>"
                              + "<attribute name='workflowid' />"
                              + "<attribute name='workflowidunique' />"
                              + "<attribute name='name' />"
                              + "<attribute name='category' />"
                              + "<attribute name='primaryentity' />"
                              + "<attribute name='statecode' />"
                              + "<attribute name='createdon' />"
                              + "<attribute name='ownerid' />"
                              + "<attribute name='owningbusinessunit' />"
                              + "<attribute name='type' />"
                              + "<attribute name='parentworkflowid' />"
                              + "<order attribute='name' descending='false' />"
                              + "<filter type='and'>"
                              + "<condition attribute='statecode' operator='eq' value='1' />"
                              + "<condition attribute='name' operator='eq' value='" + crmWF.WorkflowName + "' />"
                              + " <condition attribute='parentworkflowid' operator='null' />"
                              + "</filter>"
                              + "</entity>"
                              + "</fetch>";

            CRMFetchXML fx = new CRMFetchXML();

            fx.FetchXML = fetchxml;
            List <CRMState> wf = CRMGetEntities(fx).Entities;

            if (wf.Count > 0)
            {
                crmWF.WorkflowId = wf[0].EntityId;
                CRMStartWorkflowByID(crmWF);
            }

            return(crmWF);
        }
Esempio n. 3
0
        public CRMFetchXML CRMGetEntities(CRMFetchXML crmFetchXML)
        {
            OrganizationServiceProxy _serviceProxy;
            IOrganizationService     _service;
            string          res            = "";
            List <CRMState> returnEntities = new List <CRMState>();

            using (_serviceProxy = GetCRMConnection())
            {
                // This statement is required to enable early-bound type support.
                _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

                _service = (IOrganizationService)_serviceProxy;

                try
                {
                    EntityCollection result = _serviceProxy.RetrieveMultiple(new FetchExpression(crmFetchXML.FetchXML));

                    if (result.Entities.Count > 0)
                    {
                        foreach (var entity in result.Entities)
                        {
                            CRMState cEntity = new CRMState();
                            cEntity.Entity   = entity.LogicalName;
                            cEntity.EntityId = entity.Id.ToString();
                            returnEntities.Add(cEntity);
                        }
                    }
                    crmFetchXML.Entities = returnEntities;
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return(crmFetchXML);
        }
    public CRMFetchXML CRMGetEntities(CRMFetchXML crmFetchXML)
    {
        CRMFunctions function = new CRMFunctions(crmFetchXML.Config);
        return function.CRMGetEntities(crmFetchXML);

    }
        public CRMWorkflow CRMStartWorkflow(CRMWorkflow crmWF)
        {
            string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
          + "<entity name='workflow'>"
            + "<attribute name='workflowid' />"
            + "<attribute name='workflowidunique' />"
            + "<attribute name='name' />"
            + "<attribute name='category' />"
            + "<attribute name='primaryentity' />"
            + "<attribute name='statecode' />"
            + "<attribute name='createdon' />"
            + "<attribute name='ownerid' />"
            + "<attribute name='owningbusinessunit' />"
            + "<attribute name='type' />"
            + "<attribute name='parentworkflowid' />"
            + "<order attribute='name' descending='false' />"
            + "<filter type='and'>"
              + "<condition attribute='statecode' operator='eq' value='1' />"
              + "<condition attribute='name' operator='eq' value='" + crmWF.WorkflowName + "' />"
              + " <condition attribute='parentworkflowid' operator='null' />"
            + "</filter>"
          + "</entity>"
        + "</fetch>";

            CRMFetchXML fx = new CRMFetchXML();
            fx.FetchXML = fetchxml;
            List<CRMState> wf = CRMGetEntities(fx).Entities;

            if (wf.Count > 0)
            {
                crmWF.WorkflowId = wf[0].EntityId;
                CRMStartWorkflowByID(crmWF);
            }

            return crmWF;
        }
        public CRMUser CRMGetUser(CRMUser crmUser)
        {
            CRMState returnEntities = new CRMState();
            CRMUser ret = new CRMUser();

            string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                          <entity name='systemuser'>
                            <attribute name='fullname' />
                            <attribute name='businessunitid' />
                            <attribute name='title' />
                            <attribute name='address1_telephone1' />
                            <attribute name='systemuserid' />
                            <order attribute='fullname' descending='false' />
                            <filter type='and'>
                              <condition attribute='domainname' operator='eq' value='"
                                   + crmUser.UserFQN + "' />"
                                + "</filter>"
                              + "</entity>"
                            + "</fetch>";

            CRMFetchXML fx = new CRMFetchXML();
            fx.FetchXML = fetchxml;
            List<CRMState> user = CRMGetEntities(fx).Entities;

            if (user.Count > 0)
            {
                crmUser.UserId = user[0].EntityId;
            }
            return crmUser;
        }
        public CRMFetchXML CRMGetEntities(CRMFetchXML crmFetchXML)
        {
            OrganizationServiceProxy _serviceProxy;
            IOrganizationService _service;
            string res = "";
            List<CRMState> returnEntities = new List<CRMState>();

            using (_serviceProxy = GetCRMConnection())
            {
                // This statement is required to enable early-bound type support.
                _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

                _service = (IOrganizationService)_serviceProxy;

                try
                {
                    EntityCollection result = _serviceProxy.RetrieveMultiple(new FetchExpression(crmFetchXML.FetchXML));

                    if (result.Entities.Count > 0)
                    {
                        foreach (var entity in result.Entities)
                        {
                            CRMState cEntity = new CRMState();
                            cEntity.Entity = entity.LogicalName;
                            cEntity.EntityId = entity.Id.ToString();
                            returnEntities.Add(cEntity);
                        }
                    }
                    crmFetchXML.Entities = returnEntities;
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return crmFetchXML;
        }