private async void SaveCases() { try { if (CaseTypeCode == "0") { _commonFun.AlertLongText("请选择案例类型"); return; } else if (string.IsNullOrEmpty(CaseTitle.Trim())) { _commonFun.AlertLongText("请填写案例标题"); return; } else if (string.IsNullOrEmpty(CasePoint.Trim())) { _commonFun.AlertLongText("请填写案例要点"); return; } else if (string.IsNullOrEmpty(LossRemark.Trim())) { _commonFun.AlertLongText("请填写失分说明"); return; } else if (string.IsNullOrEmpty(ImproveRemark.Trim())) { _commonFun.AlertLongText("请填写改善措施"); return; } CasesParamDto caseDto = new CasesParamDto() { Id = Id, CaseType = CaseTypeCode, CasePoint = CasePoint, LossRemark = LossRemark, ImproveRemark = ImproveRemark, InUserId = int.Parse(CommonContext.Account.UserId), CaseTitle = CaseTitle, AttachList = CaseAttachList, }; _commonFun.ShowLoading("保存中..."); var result = await _caseService.InsertOrUpdateCasesInfo(caseDto); if (result != null) { if (result.ResultCode == ResultType.Success) { //跳转或刷新CaseIndexViewModel await Navigation.PopAsync(); MessagingCenter.Send <string>("", MessageConst.CASESAVESUCCESS); _commonFun.AlertLongText("保存成功"); } else { _commonFun.AlertLongText("保存失败,请重试"); } } else { _commonFun.AlertLongText("保存时服务出现错误,,请重试"); } } catch (OperationCanceledException) { _commonFun.HideLoading(); _commonFun.AlertLongText("请求超时,请重试"); } catch (Exception) { _commonFun.HideLoading(); _commonFun.AlertLongText("保存失败,请重试"); } finally { _commonFun.HideLoading(); } }
// Si la actividad devuelve un valor, se debe derivar de CodeActivity<TResult> // y devolver el valor desde el método Execute. protected override void Execute(CodeActivityContext executionContext) { //Create the tracing service ITracingService tracingService = executionContext.GetExtension <ITracingService>(); //Create the context IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); Guid idWorkFlowInstance = executionContext.WorkflowInstanceId; Boolean isError = false; try { // GUID of target record (case) Guid gCaseId = context.PrimaryEntityId; Guid gNewCaseId = Guid.Empty; //Obtenemos los valores de los parámetros del caso. //string strCaseTypeCode = CaseTypeCode.Get<string>(executionContext); EntityReference erCaseType = CaseType.Get <EntityReference>(executionContext); EntityReference erCategory1 = Category1.Get <EntityReference>(executionContext); EntityReference erCategory2 = Category2.Get <EntityReference>(executionContext); EntityReference erOriginUser = OriginUser.Get <EntityReference>(executionContext); EntityReference erOriginPDV = OriginPDV.Get <EntityReference>(executionContext); EntityReference erOriginRegion = OriginRegion.Get <EntityReference>(executionContext); OptionSetValue oOriginChannel = OriginChannel.Get <OptionSetValue>(executionContext); OptionSetValue oStatusCode = StatusCode.Get <OptionSetValue>(executionContext); EntityReference erCustomer = Customer.Get <EntityReference>(executionContext); string strTitle = CaseTitle.Get <string>(executionContext); EntityReference erContract = Contract.Get <EntityReference>(executionContext); Boolean? isReincidentCase = ReincidentCase.Get <Boolean>(executionContext); EntityReference erAssociatedCase = AssociatedCase.Get <EntityReference>(executionContext); OptionSetValue oTransactionType = TransactionType.Get <OptionSetValue>(executionContext); Entity eCase = new Entity("incident"); if (erCaseType != null) { eCase.Attributes["amxperu_casetype"] = erCaseType; } if (erCategory1 != null) { eCase.Attributes["ust_category1"] = erCategory1; } if (erCategory2 != null) { eCase.Attributes["ust_category2"] = erCategory2; } //if (erOriginUser != null) // eCase.Attributes["ownerid"] = erOriginUser; if (erOriginPDV != null) { eCase.Attributes["amxperu_originpdv"] = erOriginPDV; } if (erOriginRegion != null) { eCase.Attributes["amxperu_originregion"] = erOriginRegion; } if (oOriginChannel != null) { eCase.Attributes["amxperu_originchannel"] = oOriginChannel; } if (oStatusCode != null) { eCase.Attributes["statuscode"] = oStatusCode; } if (erCustomer != null) { eCase.Attributes["customerid"] = erCustomer; } if (!string.IsNullOrEmpty(strTitle)) { eCase.Attributes["title"] = strTitle; } if (erContract != null) { eCase.Attributes["contractid"] = erContract; } //if (isReincidentCase != null) // eCase.Attributes["amxperu_reincidentcase"] = isReincidentCase; if (erAssociatedCase != null) { eCase.Attributes["ust_associatedcase1"] = erAssociatedCase; } if (oTransactionType != null) { eCase.Attributes["ust_transactiontype"] = oTransactionType; } if (eCase.Attributes.Count > 0) { gNewCaseId = service.Create(eCase); //if (gNewCaseId != Guid.Empty) //{ // //Entity incident = new Entity("incident"); // //incident.Id = gCaseId; // //incident["ust_isretentioncreated"] = true; // //service.Update //} } } catch (FaultException <IOrganizationService> ex) { isError = true; throw new FaultException("IOrganizationServiceExcepcion: " + ex.Message); } catch (FaultException ex) { isError = true; throw new FaultException("FaultException: " + ex.Message); } catch (InvalidWorkflowException ex) { isError = true; throw new InvalidWorkflowException("InvalidWorkflowException: " + ex.Message); } catch (Exception ex) { isError = true; throw new Exception(ex.Message); } finally { if (isError) { //Entity workflowToCancel = new Entity("asyncoperation"); //workflowToCancel.Id = idWorkFlowInstance; //workflowToCancel["statecode"] = new OptionSetValue(3); //workflowToCancel["statuscode"] = new OptionSetValue(32); //service.Update(workflowToCancel); } } }