Exemplo n.º 1
0
 public void DisconnectOriginChannel()
 {
     if (HasOriginConnection)
     {
         OriginChannel.Dispose();
     }
 }
Exemplo n.º 2
0
 private void OnProxyInfoPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     try
     {
         if (e.PropertyName == "Enabled")
         {
             if (!ProxyInfo.Enabled)
             {
                 OriginChannel.Dispose();
                 ProxyInfo.PropertyChanged -= OnProxyInfoPropertyChanged;
             }
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 3
0
        public virtual void SendData(EventInfo eventInfo)
        {
            switch (eventInfo.Direction)
            {
            case Messages.DataDirection.Target:
                if (eventInfo.ProxyConnection.HasTargetConnection)
                {
                    TargetChannel.SendData(new Buffer <byte>(eventInfo.Message.RawBytes));
                }
                break;

            case DataDirection.Origin:
                if (eventInfo.ProxyConnection.HasOriginConnection)
                {
                    OriginChannel.SendData(new Buffer <byte>(eventInfo.Message.RawBytes));
                }
                break;
            }
        }
Exemplo n.º 4
0
        // 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);
                }
            }
        }