Beispiel #1
0
        //INT-CHQ-2-013
        public AmxPeruTicketRemedyResponseDTO ModificarTicket(IOrganizationService _service, AmxPeruTicketRemedyRequestDTO requestDTO, string url)
        {
            //string requestToJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestDTO);
            Util util = new Util();
            AmxPeruTicketRemedyResponseDTO response = new AmxPeruTicketRemedyResponseDTO();

            try
            {
                string request;
                request  = @"{
                            ""request"":{
                            ""$type"":""AmxPeruPSBActivities.Activities.External.AmxPeruTicketRemedyRequestDTO, AmxPeruPSBActivities""" + ",";
                request += "\"userId\": " + "\"" + requestDTO.request.userId + "\"" + ",";
                request += "\"password\": " + "\"" + requestDTO.request.password + "\"" + ",";
                request += "\"ticketId\": " + "\"" + requestDTO.request.ticketId + "\"" + ",";
                request += "\"ticketDesc\": " + "\"" + requestDTO.request.ticketDesc + "\"" + ",";
                request += "\"reason\": " + "\"" + requestDTO.request.reason + "\"" + ",";
                request += "\"ticketState\":" + "\"" + requestDTO.request.ticketState + "\"" + "}" + "}";

                response = Newtonsoft.Json.JsonConvert.DeserializeObject <AmxPeruTicketRemedyResponseDTO>(util.SendRestRequest(_service, request, url));

                #region 07_HardCode
                //response.CurrentBookmark = false;
                //response.Output.response.troubleTicketId = "INC000001077426";
                //response.Output.response.Status = 0;
                //response.Output.response.CodeResponse = "0";
                //response.Output.response.DescriptionResponse = "Transaccion OK";
                //response.Output.response.ErrorLocation = "";
                //response.CanRollback = false;
                //response.RunDate= Convert.ToDateTime("2018-04-18T07:56:54.6699868Z");
                //response.InstanceId= "548d7e62-fac8-4345-893f-05881a833af1";
                //response.WorkflowName= "AmxPeruTicketRemedy";
                //response.WorkflowVersion= "1.0.0.0";
                //response.Status = 4;
                #endregion

                return(response);
            }
            catch (Exception)
            {
                //TO DO:Manejo de excepciones o logging.
                throw;
            }
        }
Beispiel #2
0
        public void Execute(IServiceProvider serviceProvider)
        {
            IPluginExecutionContext     context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

            service = factory.CreateOrganizationService(context.UserId);

            IOrganizationService iServices = ((IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory))).CreateOrganizationService(new Guid?(context.UserId));

            myTrace = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

            try
            {
                if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    if (context.MessageName == "Update")
                    {
                        //Variables Locales
                        string strCode         = null;
                        string strTicketId     = null;
                        string strTicketDesc   = null;
                        string strTicketStatus = null;
                        Entity eTarget         = (Entity)context.InputParameters["Target"];
                        string stageId         = null;

                        #region Prueba de servicios
                        //foreach (var i in eTarget.Attributes)
                        //{
                        //    myTrace.Trace("key: " + i.Key);
                        //    myTrace.Trace("val: " + i.Value);
                        //}

                        //AmxPeruTicketRemedyResponseDTO response = CallPsbServiceAmxPeruTicketRemedy(strTicketId, strTicketDesc, strTicketStatus);
                        //throw new InvalidPluginExecutionException("Estuvo bien el servicio " + response.Output.response.Status);

                        #endregion

                        Entity target = (Entity)context.InputParameters["Target"];

                        if (target.Attributes.Contains("ust_remedyticketid") && target["ust_remedyticketid"] != null)
                        {
                            strTicketId = target["ust_remedyticketid"].ToString();
                        }

                        if (target.Attributes.Contains("ust_remedyticketanswer") && target["ust_remedyticketanswer"] != null)
                        {
                            strTicketDesc = target["ust_remedyticketanswer"].ToString();
                        }

                        if (target.Attributes.Contains("ust_remedyticketstatus") && target["ust_remedyticketstatus"] != null)
                        {
                            strTicketStatus = target["ust_remedyticketstatus"].ToString();
                        }

                        if (target.Attributes.Contains("stageid") && target["stageid"] != null)
                        {
                            stageId = target.Attributes["stageid"].ToString();

                            myTrace.Trace(Util.GetProcessStageName(service, new Guid(stageId)));

                            Entity incident = service.Retrieve("incident", eTarget.Id, new ColumnSet("amxperu_casetype", "ust_remedyticketid", "ust_remedyticketanswer", "ust_remedyticketstatus"));

                            if (strTicketId == null)
                            {
                                if (incident.Attributes.Contains("ust_remedyticketid") && incident["ust_remedyticketid"] != null)
                                {
                                    strTicketId = incident["ust_remedyticketid"].ToString();
                                }
                                //TO DO: Enable this part 17/07
                                //else
                                //    return; //Si no hay un incidente id entonces no debe entrar al plugIn.
                            }

                            if (strTicketDesc == null)
                            {
                                if (incident.Attributes.Contains("ust_remedyticketanswer") && incident["ust_remedyticketanswer"] != null)
                                {
                                    strTicketDesc = incident["ust_remedyticketanswer"].ToString();
                                }
                                //TO DO: Enable this part 17/07
                                //else
                                //    return; //Si no hay un desc entonces no debe entrar al plugIn.
                            }

                            if (strTicketStatus == null)
                            {
                                if (incident.Attributes.Contains("ust_remedyticketstatus") && incident["ust_remedyticketstatus"] != null)
                                {
                                    strTicketStatus = incident["ust_remedyticketid"].ToString();
                                }
                                //TO DO: Enable this part 17/07
                                //else
                                //    return; //Si no hay un incidente id entonces no debe entrar al plugIn.
                            }

                            //BUSINESS LOGIC
                            if (incident.Attributes.Contains("amxperu_casetype") && incident["amxperu_casetype"] != null)
                            {
                                Guid idCaseType = ((EntityReference)incident.Attributes["amxperu_casetype"]).Id;

                                Entity caseType = service.Retrieve("amxperu_casetype", idCaseType, new ColumnSet("ust_code"));

                                if (caseType != null)
                                {
                                    if (caseType.Attributes.Contains("ust_code") && caseType["ust_code"] != null)
                                    {
                                        strCode = caseType.Attributes["ust_code"].ToString();
                                    }
                                }
                                if (strCode == "004") //Reclamo OSIPTEL
                                {
                                    string PhaseNameEN = Util.GetCrmConfiguration(service, "NameFaseNotifyCustomerEnglish");
                                    string PhaseNameES = Util.GetCrmConfiguration(service, "NameFaseNotifyCustomerSpanish");
                                    string stageName   = Util.GetProcessStageName(service, new Guid(stageId));

                                    //TO DO: Buscar el stagename by stageid
                                    if (stageName == PhaseNameEN || stageName == PhaseNameES) //Notify Customer
                                    {
                                        AmxPeruTicketRemedyResponseDTO response = CallPsbServiceAmxPeruTicketRemedy(strTicketId, strTicketDesc, strTicketStatus);
                                        target.Attributes["ust_remedyticketstatus"] = response.Output.response.Status;

                                        //if (response != null)
                                        //    if (response.Output != null)
                                        //        if (response.Output.response != null)
                                        //            if (response.Output.response.Status != 0)
                                        //                throw new Exception("Estuvo mal el servicio: " + response.Output.response.DescriptionResponse);
                                        //            else
                                        //                throw new Exception("Estuvo bien el servicio: " + response.Output.response.DescriptionResponse);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }