/// <summary>
        ///
        /// </summary>
        /// <param name="GroupID"></param>
        /// <param name="AcctID"></param>
        /// <returns></returns>
        private string CheckVerify(string GroupID, string AcctID)
        {
            string status = string.Empty;

            DataTable dt = null;

            List <IDataParameter> para = null;

            try
            {
                string strSql = this.Select.Verify(null, GroupID, "1", null, null, null, true, ref para);

                #region SQL Debug

                this.WriteLog(Mode.LogMode.DEBUG, strSql);

                this.WriteLog(para.ToLog());

                #endregion

                dt = this.DBConnTransac.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                if (dt.Rows.Count == 0)
                {
                    return(string.Empty);
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    VerifyInfo verifyInfo = JsonConvert.DeserializeObject <VerifyInfo>(dt.Rows[i]["action_req_detail"].ToString().Trim().DecryptBase64());

                    if (verifyInfo.AcctID.Equals(AcctID))
                    {
                        return(dt.Rows[i]["action_req_status"].ToString().Trim());
                    }
                }
            }
            catch (System.Exception ex) { throw ex; }
            finally
            {
                dt = null;
            }
            return(string.Empty);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            e.RowPermissions(sender, this.SessionMgr.WebTypePrivilege, this.WebTypePrivilege);

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                VerifyInfo verifyInfo = JsonConvert.DeserializeObject <VerifyInfo>(e.Row.Cells[9].Text.HtmlDecode().DecryptBase64());

                int verify_status = verifyInfo.VerifyStatus;

                e.Row.Cells[1].Text = verify_status.ToString().GetVerifyStatusCH().HtmlEncode();

                verify_status = Convert.ToInt32(e.Row.Cells[2].Text.Trim());

                e.Row.Cells[2].ForeColor = verify_status == 8 ? Color.Blue : verify_status == 9 ? Color.Red : Color.Green;

                Button btnVerify = (Button)e.Row.FindControl("btnVerify");

                if (verify_status > 3)
                {
                    btnVerify.Text = "檢視覆核";

                    btnVerify.CssClass = "btn btn-info btn-sm";

                    e.Row.Cells[2].Text = verify_status.ToString().GetVerifyStatusCH().HtmlEncode();
                }
                else
                {
                    e.Row.Cells[2].Text = string.Format("待審");

                    e.Row.Cells[4].Text = string.Empty;

                    btnVerify.Visible = !this.SessionMgr.UserInfos.UserID.Equals(e.Row.Cells[10].Text.Trim());
                }
                e.Row.Cells[3].Text = verifyInfo.SubmittalDate.ToString("yyyy/MM/dd HH:mm:ss").HtmlEncode();

                e.Row.Cells[5].Text = verifyInfo.AcctName.DecryptBase64().HtmlEncode();

                e.Row.Cells[6].Text = verifyInfo.RoleName.DecryptBase64().HtmlEncode();

                this.WriteLog(string.Format("{0},{1},{2},{3},{4}", e.Row.Cells[3].Text, e.Row.Cells[1].Text, e.Row.Cells[2].Text, this.SessionMgr.UserInfos.UserID, e.Row.Cells[10].Text.Trim()));
            }
        }
        /// <summary>
        ///
        /// </summary>
        private void LoadUserInfo()
        {
            List <IDataParameter> para = null;

            string strSql = string.Empty;

            DataTable dt = null;

            try
            {
                strSql = this.Select.Verify(this.UID, null, null, null, null, null, false, ref para);

                #region SQL Debug

                this.WriteLog(Mode.LogMode.DEBUG, strSql);

                this.WriteLog(para.ToLog());

                #endregion

                dt = this.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                if (dt == null || !dt.Rows.Count.Equals(1))
                {
                    this.MessageBox(Mode.LogMode.ERROR, string.Format("發生資料取得錯誤"));

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Query, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.VerifyLoadFail), this.PageName, string.Empty);

                    return;
                }
                string action_req_time = dt.Rows[0]["action_req_time"].ToString();

                this.ViewState["Detail"] = dt.Rows[0]["action_req_detail"].ToString().Trim().DecryptBase64();

                this.ViewState["VerifyStatus"] = Convert.ToInt32(dt.Rows[0]["action_req_status"].ToString().Trim());

                VerifyInfo verifyInfo = JsonConvert.DeserializeObject <VerifyInfo>(this.ViewState["Detail"].ToString().Trim());

                strSql = this.Select.US(verifyInfo.AcctID, null, null, ref para);

                #region SQL Debug

                this.WriteLog(Mode.LogMode.DEBUG, strSql);

                this.WriteLog(para.ToLog());

                #endregion

                dt = this.DBConn.GeneralSqlCmd.ExecuteToDataTable(strSql, para);

                if (dt == null || !dt.Rows.Count.Equals(1))
                {
                    this.MessageBox(Mode.LogMode.ERROR, string.Format("發生資料取得錯誤"));

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Query, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.VerifyLoadFail), this.PageName, string.Empty);

                    return;
                }
                this.ViewState["UserID"]    = verifyInfo.AcctID;
                this.ViewState["Account"]   = dt.Rows[0]["acct_account"].ToString().Trim();
                this.ViewState["RoleID"]    = verifyInfo.RoleID;
                this.ViewState["GroupID"]   = dt.Rows[0]["group_id"].ToString().Trim();
                this.ViewState["GroupCode"] = dt.Rows[0]["group_code"].ToString().Trim();

                int verify_status = (int)this.ViewState["VerifyStatus"];

                this.btnOverrule.Visible = this.btnVerify.Visible = verify_status <= 3;

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Query, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.VerifyLoad), this.PageName, string.Format("審核編號:{0},單位編號:{1},角色編號:{2},被覆核人員:{3}", this.UID, this.ViewState["GroupID"].ToString(), this.ViewState["RoleID"].ToString(), this.ViewState["UserID"].ToString()));

                this.LiteralUserInfo.Text = string.Format("<table id=\"tb_UserInfo\" class=\"table table-striped table-bordered table-hover dataTable no-footer\" cellspacing=\"0\" rules=\"all\" Count=\"1\" border=\"1\" id=\"GridView1\" style=\"border-collapse:collapse;\">\n"
                                                          + "	<tr>\n"
                                                          + "		<th colspan=\"4\" class=\"title\">覆核</th>\n"
                                                          + "	</tr>\n"
                                                          + "	<tr>\n"
                                                          + "		<th>被覆核人員</th>\n"
                                                          + "		<td>{0}</td>\n"
                                                          + "		<th>送核日期</th>\n"
                                                          + "		<td>{1}</td>\n"
                                                          + "	</tr>\n"
                                                          + "	<tr>\n"
                                                          + "		<th>覆核日期</th>\n"
                                                          + "		<td>{6}</td>\n"
                                                          + "		<th>覆核人員</th>\n"
                                                          + "		<td>{7}</td>\n"
                                                          + "	</tr>\n"
                                                          + "	<tr>\n"
                                                          + "		<th>單位</th>\n"
                                                          + "		<td colspan=\"3\">{2}</td>\n"
                                                          + "	</tr>\n"
                                                          + "	<tr>\n"
                                                          + "		<th>覆核項目</th>\n"
                                                          + "		<td colspan=\"3\">{3}</td>\n"
                                                          + "	</tr>\n"
                                                          + "	<tr>\n"
                                                          + "		<th>覆核狀態</th>\n"
                                                          + "		<td colspan=\"3\">{4}</td>\n"
                                                          + "	</tr>\n"
                                                          + "	<tr>\n"
                                                          + "		<th>指派角色</th>\n"
                                                          + "		<td colspan=\"3\">{5}</td>\n"
                                                          + "	</tr>\n"
                                                          + "</table>\n",
                                                          verifyInfo.AcctName.DecryptBase64().HtmlEncode(),
                                                          verifyInfo.SubmittalDate.ToString("yyyy/MM/dd HH:mm:ss").HtmlEncode(),
                                                          string.Format("{0} ({1})", dt.Rows[0]["group_name"].ToString().HtmlEncode(), dt.Rows[0]["group_code"].ToString()).HtmlEncode(),
                                                          verifyInfo.VerifyStatus.ToString().GetVerifyStatusCH().HtmlEncode(),
                                                          verify_status > 3 ? verify_status.ToString().GetVerifyStatusCH().HtmlEncode() : "待審",
                                                          verifyInfo.RoleName.DecryptBase64().HtmlEncode(),
                                                          verify_status > 3 ? action_req_time.HtmlEncode() : string.Empty,
                                                          verify_status > 3 ? verifyInfo.ApprovedName.HtmlEncode() : string.Empty
                                                          );
            }
            catch (System.Exception ex)
            {
                this.MessageBox(ex);

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Load, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.SystemError), this.PageName, ex.Message);
            }
            finally
            {
                para = null;

                this.CloseConn();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnVerify_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

            string strSql = string.Empty, message = string.Empty;

            try
            {
                this.WriteLog(string.Format("覆核開始"));

                string role_id = this.ViewState["RoleID"].ToString();

                string group_id = this.ViewState["GroupID"].ToString();

                string user_id = this.ViewState["UserID"].ToString();

                int verify_status = (int)this.ViewState["VerifyStatus"];

                message = string.Format("審核編號:{0},單位編號:{1},角色編號:{2},被覆核人員:{3}", this.UID, group_id, role_id, user_id);

                if (String.IsNullOrEmpty(role_id) || String.IsNullOrEmpty(group_id) || String.IsNullOrEmpty(this.UID))
                {
                    this.MessageBox(Mode.LogMode.ERROR, string.Format("發生資訊參數取得錯誤"));

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.VerifyFail), this.PageName, message);

                    return;
                }
                VerifyInfo verifyInfo = JsonConvert.DeserializeObject <VerifyInfo>(this.ViewState["Detail"].ToString());

                verifyInfo.ApprovedID = this.SessionMgr.UserInfos.UserID;

                verifyInfo.ApprovedName = this.SessionMgr.UserInfos.RealName;

                string detail = JsonConvert.SerializeObject(verifyInfo);

                strSql = this.Update.UserRolesVerifyStatus(this.UID, "8", detail.EncryptBase64(), ref para);

                #region SQL Debug

                this.WriteLog(Mode.LogMode.DEBUG, strSql);

                this.WriteLog(para.ToLog());

                #endregion

                int result = this.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                if (!result.Equals(1))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, "覆核失敗");

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.VerifyFail), this.PageName, message);

                    return;
                }
                strSql = this.Select.UserRoles(user_id, null, group_id, ref para);

                #region SQL Debug

                this.WriteLog(Mode.LogMode.DEBUG, strSql);

                this.WriteLog(para.ToLog());

                #endregion

                string acct_role_id = this.DBConnTransac.GeneralSqlCmd.ExecuteByColumnName(strSql, para, "acct_role_id");

                string status = verify_status == 1 || verify_status == 2 ? "0" : "99";

                if (String.IsNullOrEmpty(acct_role_id))
                {
                    strSql = this.Insert.UserRoles(role_id, user_id, status, ref para);
                }
                else
                {
                    strSql = this.Update.UserRoles(acct_role_id, role_id, status, ref para);
                }

                #region SQL Debug

                this.WriteLog(Mode.LogMode.DEBUG, strSql);

                this.WriteLog(para.ToLog());

                #endregion

                result = this.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                if (!result.Equals(1))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, "覆核失敗");

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.VerifyFail), this.PageName, message);

                    return;
                }
                if (Utility.WebConfig.LoginMode.Equals(1))
                {
                    SoapResult soapDepartmentResult = null;

                    string adws_url = this.GetSystemSetting("ADWS");

                    string adws_group_name = this.GetSystemSetting("AdwsGroupName");

                    string group_code = this.ViewState["GroupCode"].ToString();

                    this.WriteLog(string.Format("AggregateInquiry:{0},{1},{2}", adws_url, group_code, adws_group_name));

                    soapDepartmentResult = this.AggregateInquiry(adws_url, group_code, adws_group_name);

                    this.WriteLog(string.Format("AggregateInquiry.Result:{0}", soapDepartmentResult.Info != null ? soapDepartmentResult.Info.Count.ToString() : "Null"));

                    if (soapDepartmentResult.Info != null && soapDepartmentResult.Info.Count > 0)
                    {
                        bool add_member = true;

                        for (int i = 0; i < soapDepartmentResult.Info.Count; i++)
                        {
                            XmlNode xmlNodeUserInfo = soapDepartmentResult.Info[i];

                            string acct_account = xmlNodeUserInfo.SelectSingleNode("./cg:Id", soapDepartmentResult.Mgr).InnerText.Trim();
                            string acct_name    = xmlNodeUserInfo.SelectSingleNode("./cg:DisplayName", soapDepartmentResult.Mgr).InnerText.Trim();
                            string acct_type    = xmlNodeUserInfo.SelectSingleNode("./cg:Title", soapDepartmentResult.Mgr).InnerText.Trim();

                            if (this.ViewState["Account"].ToString().Equals(acct_account))
                            {
                                add_member = false; break;
                            }
                        }
                        if (status.Equals("0"))
                        {
                            this.WriteLog(string.Format("AddMember::{0},{1},{2}", this.ViewState["Account"].ToString(), add_member, status));
                        }
                        else
                        {
                            this.WriteLog(string.Format("RemoveMember::{0},{1},{2}", this.ViewState["Account"].ToString(), add_member, status));
                        }

                        if (add_member && status.Equals("0") && !this.AddMember(adws_url, this.ViewState["Account"].ToString(), adws_group_name))
                        {
                            this.Rollback();

                            this.MessageBox(Mode.LogMode.ERROR, "覆核失敗,AddMember 發生錯誤");

                            this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.VerifyFail), this.PageName, message);

                            return;
                        }
                        else if (!add_member && status.Equals("99") && !this.RemoveMember(adws_url, this.ViewState["Account"].ToString(), adws_group_name))
                        {
                            this.Rollback();

                            this.MessageBox(Mode.LogMode.ERROR, "覆核失敗,RemoveMember 發生錯誤");

                            this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.VerifyFail), this.PageName, message);

                            return;
                        }
                    }
                }

                strSql = this.Select.US(user_id, string.Empty, string.Empty, ref para);

                #region SQL Debug

                this.WriteLog(Mode.LogMode.DEBUG, strSql);

                this.WriteLog(para.ToLog());

                #endregion

                string acct_desc = this.DBConnTransac.GeneralSqlCmd.ExecuteByColumnName(strSql, para, "acct_desc");

                if (String.IsNullOrEmpty(acct_desc) || Convert.ToInt32(acct_desc) < 1)
                {
                    #region Login Count

                    strSql = this.Update.LoginCount(user_id, ref para);

                    #region SQL Debug

                    this.WriteLog(Mode.LogMode.DEBUG, strSql);

                    this.WriteLog(para.ToLog());

                    #endregion

                    this.DBConnTransac.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    #endregion
                }
                this.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MessageBox(Mode.LogMode.INFO, "覆核成功");

                this.LoadUserInfo();

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.Verify), this.PageName, message);
            }
            catch (System.Exception ex)
            {
                this.Rollback();

                this.MessageBox(ex);

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.SystemError), this.PageName, ex.Message);
            }
            finally
            {
                para = null;

                this.CloseConnTransac();

                this.WriteLog(string.Format("覆核結束"));
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOverrule_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

            string strSql = string.Empty, message = string.Empty;

            try
            {
                this.WriteLog(string.Format("駁回開始"));

                string role_id = this.ViewState["RoleID"].ToString();

                string group_id = this.ViewState["GroupID"].ToString();

                string user_id = this.ViewState["UserID"].ToString();

                int verify_status = (int)this.ViewState["VerifyStatus"];

                message = string.Format("審核編號:{0},單位編號:{1},角色編號:{2},被覆核人員:{3}", this.UID, group_id, role_id, user_id);

                if (String.IsNullOrEmpty(role_id) || String.IsNullOrEmpty(group_id) || String.IsNullOrEmpty(this.UID))
                {
                    this.MessageBox(Mode.LogMode.ERROR, string.Format("發生資訊參數取得錯誤"));

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.OverruleFail), this.PageName, message);

                    return;
                }
                VerifyInfo verifyInfo = JsonConvert.DeserializeObject <VerifyInfo>(this.ViewState["Detail"].ToString());

                verifyInfo.ApprovedID = this.SessionMgr.UserInfos.UserID;

                verifyInfo.ApprovedName = this.SessionMgr.UserInfos.RealName;

                string detail = JsonConvert.SerializeObject(verifyInfo);

                strSql = this.Update.UserRolesVerifyStatus(this.UID, "9", detail.EncryptBase64(), ref para);

                #region SQL Debug

                this.WriteLog(Mode.LogMode.DEBUG, strSql);

                this.WriteLog(para.ToLog());

                #endregion

                int result = this.DBConn.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                if (!result.Equals(1))
                {
                    this.MessageBox(Mode.LogMode.ERROR, "駁回失敗");

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.OverruleFail), this.PageName, message);

                    return;
                }
                this.MessageBox(Mode.LogMode.INFO, "駁回成功");

                this.LoadUserInfo();

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.Overrule), this.PageName, message);
            }
            catch (System.Exception ex)
            {
                this.MessageBox(ex);

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Overrule, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.SystemError), this.PageName, ex.Message);
            }
            finally
            {
                para = null;

                this.CloseConn();

                this.WriteLog(string.Format("駁回結束"));
            }
        }