示例#1
0
        public async Task <bool> Resolve(int currentIndex, int maxCount, Guid incidentId, bool isPrintingProgress)
        {
            bool isOperationSuccessfull = false;

            var ctx           = DcrmConnectorFactory.GetContext();
            var dcrmConnector = DcrmConnectorFactory.Get();
            var srv           = dcrmConnector.GetService();
            var incident      = new EntityReference(Incident.EntityLogicalName, incidentId);

            IncidentResolution incidentResolution = new IncidentResolution
            {
                IncidentId = incident,
                StatusCode = new OptionSetValue(5)
            };

            CloseIncidentRequest closeIncidentReq = new CloseIncidentRequest()
            {
                IncidentResolution = incidentResolution,
                Status             = new OptionSetValue(5)
            };

            try
            {
                ctx.Execute(closeIncidentReq);
                if (isPrintingProgress)
                {
                    MiscHelper.DisplayProgression(maxCount);
                }

                isOperationSuccessfull = true;
            }
            catch (Exception ex)
            {
                var message = string.Format($"Could not close the incident : {incidentId} : {ex.Message} ");
                MiscHelper.PrintMessage(message);
            }

            return(isOperationSuccessfull);
        }
示例#2
0
        public async Task <bool> CreateIncident(int currentIndex, int maxCount, bool isCallingResolve)
        {
            var isOperationSuccessfull = false;

            var  ctx           = DcrmConnectorFactory.GetContext();
            var  dcrmConnector = DcrmConnectorFactory.Get();
            var  srv           = dcrmConnector.GetService();
            Guid incidentId    = Guid.Empty;

            var createIncidentTimer = new MiscHelper();

            createIncidentTimer.StartTimeWatch();

            var accountId = this.IncidentWriteDict[HEADER_ACCOUNT_ID];

            if (string.IsNullOrEmpty(accountId))
            {
                var accountNumber = this.IncidentWriteDict[HEADER_CUSTOMER_ID];
                MiscHelper.PrintMessage($"GUID for account : {accountNumber} won't be created");

                return(isOperationSuccessfull);
            }

            var targetIncident = new Entity("incident");

            targetIncident["customerid"] = new EntityReference(Account.EntityLogicalName, new Guid(accountId));

            targetIncident["crm_custcode"]               = this.IncidentWriteDict[HEADER_CUSTCODE];
            targetIncident["crm_customer_id"]            = this.IncidentWriteDict[HEADER_CUSTOMER_ID];
            targetIncident["crm_contrat"]                = this.IncidentWriteDict[HEADER_CONTRAT];
            targetIncident["crm_numero_ligne_concernee"] = this.IncidentWriteDict[HEADER_MSISDN];

            targetIncident["title"]       = this.IncidentWriteDict[HEADER_TITRE];
            targetIncident["description"] = this.IncidentWriteDict[HEADER_DESCRIPTION];

            var guidTheme1   = new Guid(this.IncidentWriteDict[GUID_THEME1]);
            var theme1Entity = new EntityReference("crm_themeniveau1", guidTheme1);

            targetIncident["crm_theme_niveau_1_id"] = theme1Entity;

            var guidTheme2   = new Guid(this.IncidentWriteDict[GUID_THEME2]);
            var theme2Entity = new EntityReference("crm_themeniveau2", guidTheme2);

            targetIncident["crm_theme_niveau_2_id"] = theme2Entity;

            var guidTheme3   = new Guid(this.IncidentWriteDict[GUID_THEME3]);
            var theme3Entity = new EntityReference("crm_themeniveau3", guidTheme3);

            targetIncident["crm_theme_niveau_3_id"] = theme3Entity;

            var teamId = new Guid(this.IncidentWriteDict[HEADER_OWNER]);

            targetIncident["ownerid"] = new EntityReference(Team.EntityLogicalName, teamId);

            await Task <bool> .Run(() =>
            {
                incidentId = srv.Create(targetIncident);
                if (isCallingResolve)
                {
                    isOperationSuccessfull = Resolve(currentIndex, maxCount, incidentId, false).Result;
                }

                MiscHelper.DisplayProgression(maxCount);
            });

            createIncidentTimer.StopTimeWatch();

            return(isOperationSuccessfull);
        }