Exemplo n.º 1
0
        private bool CallWorkFlow(string TokenCode, string approveFlag, string From)
        {
            //1.1 If cannot SignIn , we not need to call workflow

            IWorkFlowResponseTokenQuery WorkFlowResponseTokenQuery = (IWorkFlowResponseTokenQuery)ContextRegistry.GetContext().GetObject("WorkFlowResponseTokenQuery");

            string docNo = "";

            if (UserAccount != null && UserAccount.Authentication)
            {
                try
                {
                    IList <WorkFlowResponseToken> responseTokens = WorkFlowResponseTokenQuery.FindByTokenCode(TokenCode);

                    int?eventID = null;

                    foreach (WorkFlowResponseToken responseToken in responseTokens)
                    {
                        if (responseToken.WorkFlowStateEvent.Name.ToLower() == approveFlag.ToLower())
                        {
                            eventID = responseToken.WorkFlowStateEvent.WorkFlowStateEventID;
                            break;
                        }
                        else if (responseToken.WorkFlowStateEvent.Name.ToLower() == approveFlag.ToLower())
                        {
                            eventID = responseToken.WorkFlowStateEvent.WorkFlowStateEventID;
                            break;
                        }
                    }


                    WorkFlowResponseToken token = WorkFlowResponseTokenQuery.GetByTokenCode_WorkFlowStateEventID(TokenCode, eventID.Value);

                    if (token == null)
                    {
                        Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
                        string error = new Spring.Validation.ErrorMessage("InvalidTokenID").ToString();
                        //send sms notify error
                        SCGSMSService.SendSMS09(error, TokenCode, From, true);
                    }
                    else
                    {
                        docNo = token.WorkFlow.Document.DocumentNo;

                        WorkFlowService = (IWorkFlowService)ContextRegistry.GetContext().GetObject("WorkFlowService");

                        WorkFlowService.NotifyEventFromSMSToken(TokenCode, UserAccount.UserID, eventID.Value, TokenType.SMS);


                        //send sms notify approve comleted user
                        SCGSMSService.SendSMS05(TokenCode, UserAccount.UserID, true, approveFlag);
                    }
                }
                catch (ServiceValidationException ex)
                {
                    string error = ex.ValidationErrors.ToString();
                    //send sms notify error
                    SCGSMSService.SendSMS09(error, TokenCode, From, true);
                }
                catch (Exception exm)
                {
                    string error = exm.Message.ToString();
                    //send sms notify error
                    SCGSMSService.SendSMS09(error, TokenCode, From, true);
                }
                finally
                {
                    UserEngine.SignOut(UserAccount.UserID);
                }
            }
            else
            {
                //send sms notify approve comleted user
                SCGSMSService.SendSMS06(TokenCode, UserAccount.UserID, true);
            }
            return(true);
        }
Exemplo n.º 2
0
        private bool CallWorkFlow(string TokenCode, string approveFlag, string From)
        {
            //1.1 If cannot SignIn , we not need to call workflow



            string docNo = "";

            if (UserAccount != null && UserAccount.Authentication)
            {
                try
                {
                    IList <WorkFlowResponseToken> responseTokens = WorkFlowQueryProvider.WorkFlowResponseTokenQuery.FindByTokenCode(TokenCode);

                    int?eventID = null;

                    foreach (WorkFlowResponseToken responseToken in responseTokens)
                    {
                        if (responseToken.WorkFlowStateEvent.Name.ToLower() == approveFlag.ToLower())
                        {
                            eventID = responseToken.WorkFlowStateEvent.WorkFlowStateEventID;
                            break;
                        }
                        else if (responseToken.WorkFlowStateEvent.Name.ToLower() == approveFlag.ToLower())
                        {
                            eventID = responseToken.WorkFlowStateEvent.WorkFlowStateEventID;
                            break;
                        }
                    }


                    WorkFlowResponseToken token = WorkFlowResponseTokenQuery.GetByTokenCode_WorkFlowStateEventID(TokenCode, eventID.Value);

                    if (token == null)
                    {
                        Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
                        string error = new Spring.Validation.ErrorMessage("InvalidTokenID").ToString();
                        //errors.AddError("General.Error", new Spring.Validation.ErrorMessage("InvalidTokenID"));

                        //send sms notify error
                        SCGSMSService.SendSMS09(error, TokenCode, From, true);

                        //throw new ServiceValidationException(errors);
                    }
                    else
                    {
                        docNo = token.WorkFlow.Document.DocumentNo;
                        string successText = GetMessage("ApproveRejectResultMessage",
                                                        token.WorkFlow.Document.DocumentNo,
                                                        WorkFlowStateEventQuery.GetTranslatedEventName(
                                                            token.WorkFlowStateEvent.WorkFlowStateEventID,
                                                            UserAccount.CurrentLanguageID));

                        WorkFlowService.NotifyEventFromSMSToken(TokenCode, UserAccount.UserID, eventID.Value, TokenType.SMS);


                        //send sms notify approve comleted user
                        SCGSMSService.SendSMS05(TokenCode, UserAccount.UserID, true, approveFlag);
                    }
                }
                catch (ServiceValidationException ex)
                {
                    this.ValidationErrors.MergeErrors(ex.ValidationErrors);

                    string error = ex.ValidationErrors.ToString();
                    //send sms notify approve comleted user
                    //SCGSMSService.SendSMS04(TokenCode + " " + approveFlag + " ", UserAccount.UserID, true);
                    //send sms notify error
                    SCGSMSService.SendSMS09(error, TokenCode, From, true);
                }
                catch (Exception exm)
                {
                    string error = exm.Message.ToString();
                    //send sms notify approve comleted user
                    //SCGSMSService.SendSMS04(TokenCode + " " + approveFlag + " ", UserAccount.UserID, true);
                    //send sms notify error
                    SCGSMSService.SendSMS09(error, TokenCode, From, true);
                }
                finally
                {
                    UserEngine.SignOut(UserAccount.UserID);
                }
            }
            else
            {
                this.ValidationErrors.AddError("General.Error",
                                               new Spring.Validation.ErrorMessage("ApproveRejectResultLoginFail"));

                //send sms notify approve comleted user
                SCGSMSService.SendSMS06(TokenCode, UserAccount.UserID, true);
            }
            return(true);
        }