//INT-CHQ-2-010 public AmxPeruCrearDisputaResponseDTO CrearDisputa(IOrganizationService _service, AmxPeruCrearDisputaRequestDTO requestDTO, string url) { //string requestToJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestDTO); Util util = new Util(); AmxPeruCrearDisputaResponseDTO response = new AmxPeruCrearDisputaResponseDTO(); try { string request; request = @"{ ""request"":{ ""$type"":""AmxPeruPSBActivities.Activities.External.AmxPeruCrearDisputaRequestDTO, AmxPeruPSBActivities""" + ","; request += "\"CustomerID\": " + "\"" + requestDTO.request.CustomerID + "\"" + ","; request += "\"ProblemID\": " + "\"" + requestDTO.request.ProblemID + "\"" + ","; request += "\"PartyAccountID\": " + "\"" + requestDTO.request.PartyAccountID + "\"" + ","; request += "\"BillingAmountUnit\": " + "\"" + requestDTO.request.BillingAmountUnit + "\"" + ","; request += "\"BillingAmount\": " + "\"" + requestDTO.request.BillingAmount + "\"" + ","; request += "\"ServiceSpecTypeName\": " + "\"" + requestDTO.request.ServiceSpecTypeName + "\"" + ","; request += "\"EntitySpecType\": " + "\"" + requestDTO.request.EntitySpecType + "\"" + ","; request += "\"EntitySpecID\": " + "\"" + requestDTO.request.EntitySpecID + "\"" + ","; request += "\"IntStartDate\": " + "\"" + requestDTO.request.IntStartDate + "\"" + ","; request += "\"Description\": " + "\"" + requestDTO.request.Description + "\"" + ","; request += "\"BusinessIntTypeName\": " + "\"" + requestDTO.request.BusinessIntTypeName + "\"" + ","; request += "\"ReasonCode\": " + "\"" + requestDTO.request.ReasonCode + "\"" + ","; request += "\"Reson\":" + "\"" + requestDTO.request.Reson + "\"" + "}" + "}"; response = Newtonsoft.Json.JsonConvert.DeserializeObject <AmxPeruCrearDisputaResponseDTO>(util.SendRestRequest(_service, request, url)); #region 03_HardCode //response.CurrentBookmark = false; //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 = "2018-05-21T09:36:32.3418282Z"; //response.InstanceId = "8819c4a2-ed9d-4d2c-979a-91e45917f9e7"; //response.WorkflowName = "AmxPeruTransaccionDisputas"; //response.WorkflowVersion = "1.0.0.0"; //response.Status = 4; #endregion return(response); } catch (Exception) { //TO DO:Manejo de excepciones o logging. throw; } }
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("EntityMoniker") && context.InputParameters["EntityMoniker"] is EntityReference) { OptionSetValue oState = (OptionSetValue)context.InputParameters["State"]; EntityReference erTargetMoniker = (EntityReference)context.InputParameters["EntityMoniker"]; String strLogicalName = erTargetMoniker.LogicalName.ToLower(); //If this plugIn doesnt trigger in "Reactivate Incident". if (strLogicalName != "incident" || oState.Value != 0) { return; } string strComplaintId = null; Entity incident = service.Retrieve("incident", erTargetMoniker.Id, new ColumnSet("amxperu_casetype", "ust_osiptelcomplaintid")); if (incident.Attributes.Contains("ust_osiptelcomplaintid") && incident["ust_osiptelcomplaintid"] != null) { strComplaintId = incident["ust_osiptelcomplaintid"].ToString(); } 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) { string strCode = caseType.Attributes["ust_code"].ToString(); /* This is the only one case type which send an email: * • Reclamo OSIPTEL * • Si tiene Monto en disputa * • Si no se ha enviado antes una comunicación de cobranzas */ if (strCode == "004" && HasAmountInDispute(service, erTargetMoniker.Id) && !IsSentBeforeToOAC(service, erTargetMoniker.Id)) { string value = ""; AmxPeruCrearDisputaResponseDTO response = CallPsbServiceAmxPeruCrearDisputa(strComplaintId, value, value, value, value, value, value, value, value, value, value, value); //throw new InvalidPluginExecutionException("Servicio: " + response.Output.response.DescriptionResponse); } } } } } } catch (ApplicationException ex) { throw new InvalidPluginExecutionException(ex.Message); } catch (InvalidPluginExecutionException ex) { throw new InvalidPluginExecutionException(ex.Message); } catch (EndpointNotFoundException ex) { throw new EndpointNotFoundException(ex.Message); } catch (FaultException <OrganizationServiceFault> ex) { throw new InvalidPluginExecutionException(ex.Message); } catch (Exception ex) { throw new InvalidPluginExecutionException(ex.Message, ex); } }
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)); //ust_amounttobereturned try { if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity target = (Entity)context.InputParameters["Target"]; if (target.LogicalName != "incident") { return; } Entity incident = service.Retrieve("incident", target.Id, new ColumnSet("amxperu_casetype", "ust_osiptelcomplaintid", "ust_notifyoactostopcollectionactions")); string strCode = null; string strComplaintId = null; bool IsCreatedDisput = false; 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 (incident.Attributes.Contains("ust_notifyoactostopcollectionactions") && incident["ust_notifyoactostopcollectionactions"] != null) { IsCreatedDisput = (bool)incident["ust_notifyoactostopcollectionactions"]; } if (incident.Attributes.Contains("ust_osiptelcomplaintid") && incident["ust_osiptelcomplaintid"] != null) { strComplaintId = incident["ust_osiptelcomplaintid"].ToString(); } /* This is the only one case type which send an email: * • Reclamo OSIPTEL */ if (strCode == "004" && IsAmountDisclaimed(service, target.Id) && !IsCreatedDisput) { //CREATE string value = ""; AmxPeruCrearDisputaResponseDTO response = CallPsbServiceAmxPeruCrearDisputa(strComplaintId, value, value, value, value, value, value, value, value, value, value, value, false); target.Attributes["ust_notifyoactostopcollectionactions"] = true; } else if (strCode == "004" && IsAmountDisclaimed(service, target.Id) && IsCreatedDisput) { //UPDATE string value = ""; AmxPeruCrearDisputaResponseDTO response = CallPsbServiceAmxPeruCrearDisputa(strComplaintId, value, value, value, value, value, value, value, value, value, value, value, true); } } } catch (ApplicationException ex) { throw new InvalidPluginExecutionException(ex.Message); } catch (InvalidPluginExecutionException ex) { throw new InvalidPluginExecutionException(ex.Message); } catch (EndpointNotFoundException ex) { throw new EndpointNotFoundException(ex.Message); } catch (FaultException <OrganizationServiceFault> ex) { throw new InvalidPluginExecutionException(ex.Message); } catch (Exception ex) { throw new InvalidPluginExecutionException(ex.Message, ex); } }
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("IncidentResolution") && context.InputParameters["IncidentResolution"] is Entity) { Entity IncidentResolution = (Entity)context.InputParameters["IncidentResolution"]; //foreach (var i in IncidentResolution.KeyAttributes) //{ // myTrace.Trace("key: " + i.Key); // myTrace.Trace("value:" + i.Value); //} //throw new InvalidPluginExecutionException("detener"); EntityReference erIncident = ((EntityReference)IncidentResolution["incidentid"]); String strLogicalName = erIncident.LogicalName.ToLower(); //If this plugIn doesnt trigger in "Close Incident". if (strLogicalName != "incident") { return; } Entity incident = service.Retrieve("incident", erIncident.Id, new ColumnSet("amxperu_casetype", "ust_notifyoactostopcollectionactions", "ust_osiptelcomplaintid")); string strCode = null; string strComplaintId = null; //TO DO: Change this value to FALSE bool isNotified = true; 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 (incident.Attributes.Contains("ust_osiptelcomplaintid") && incident["ust_osiptelcomplaintid"] != null) { strComplaintId = incident["ust_osiptelcomplaintid"].ToString(); } if (incident.Attributes.Contains("ust_notifyoactostopcollectionactions") && incident["ust_notifyoactostopcollectionactions"] != null) { //TO DO: Enable comments when sendEmail works. //isNotified = (Boolean)incident["ust_notifyoactostopcollectionactions"]; } /* This is the only one case type which send an email: * • Reclamo OSIPTEL */ if (strCode == "004" && isNotified) { string value = ""; AmxPeruCrearDisputaResponseDTO response = CallPsbServiceAmxPeruCrearDisputa(strComplaintId, value, value, value, value, value, value, value, value, value, value, value); //throw new InvalidPluginExecutionException(response.Output.response.DescriptionResponse); } } } catch (ApplicationException ex) { throw new InvalidPluginExecutionException(ex.Message); } catch (InvalidPluginExecutionException ex) { throw new InvalidPluginExecutionException(ex.Message); } catch (EndpointNotFoundException ex) { throw new EndpointNotFoundException(ex.Message); } catch (FaultException <OrganizationServiceFault> ex) { throw new InvalidPluginExecutionException(ex.Message); } catch (Exception ex) { throw new InvalidPluginExecutionException(ex.Message, ex); } }