Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string TokenCode = Request.QueryString["TokenCode"] == null ? string.Empty : Request.QueryString["TokenCode"].Trim();
            string From      = Request.QueryString["From"] == null ? string.Empty : Request.QueryString["From"].Trim();
            string Type      = Request.QueryString["Type"] == null ? string.Empty : Request.QueryString["Type"].Trim();
            int    eventID   = Request.QueryString["EventID"] == null ? -1 : Int32.Parse(Request.QueryString["EventID"].Trim());

            //1. SignIn by UserName (From)
            string userName = SS.SU.Query.QueryProvider.SuUserQuery.FindByIdentity(UIHelper.ParseLong(From)).UserName;

            UserEngine.SignIn(userName);

            this.Title       = "Approval via Email By :" + userName;
            this.ProgramCode = "ApprovalViaEmail";
            UserAccount.CurrentProgramCode = this.ProgramCode;

            //1.1 If cannot SignIn , we not need to call workflow
            if (UserAccount.Authentication)
            {
                try
                {
                    WorkFlowResponseToken token = WorkFlowResponseTokenQuery.GetByTokenCode_WorkFlowStateEventID(TokenCode, eventID);


                    if (token == null)
                    {
                        Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors();
                        errors.AddError("General.Error", new Spring.Validation.ErrorMessage(
                                            GetMessage("InvalidTokenID")
                                            ));
                        throw new ServiceValidationException(errors);
                    }
                    else
                    {
                        string successText = GetMessage("ApproveRejectResultMessage",
                                                        token.WorkFlow.Document.DocumentNo,
                                                        WorkFlowStateEventQuery.GetTranslatedEventName(
                                                            token.WorkFlowStateEvent.WorkFlowStateEventID,
                                                            UserAccount.CurrentLanguageID));

                        WorkFlowService.NotifyEventFromToken(TokenCode, UserAccount.UserID, eventID, TokenType.Email);

                        ctlResult.Text = successText;
                    }
                }
                catch (ServiceValidationException ex)
                {
                    this.ValidationErrors.MergeErrors(ex.ValidationErrors);
                }
                finally
                {
                    UserEngine.SignOut(UserAccount.UserID);
                }
            }
            else
            {
                this.ValidationErrors.AddError("General.Error",
                                               new Spring.Validation.ErrorMessage("ApproveRejectResultLoginFail"));
            }
        }