示例#1
0
        public void DrawBodies(CaptionMode CaptionMode, double Zoom)
        {
            foreach (var ttr in starsToRender)
            {
                renderBody(ttr, CaptionMode, Zoom);
            }

            foreach (var ttr in orbitersToRender.OrderByDescending(ttr => ttr.DistanceFromCamera)) // draw further things first
            {
                renderBody(ttr, CaptionMode, Zoom);
            }
        }
示例#2
0
        private void renderBody(CelestialBody Body, CaptionMode CaptionMode, double Zoom)
        {
            if (projector.PositionNearlyLocked && projector.BodyWithCamera.Equals(Body) && projector.ViewMode != ViewMode.TopDown)
            {
                return;
            }

            float radiusInPixels;

            double subtendedAngle = Body.AngleSubtendedFromDistance(Body.DistanceFromCamera) / 2.0;

            radiusInPixels = (float)Math.Abs(projector.Zoom * subtendedAngle);

            if (Body.RenderPoint.X < -radiusInPixels || Body.RenderPoint.Y < -radiusInPixels || Body.RenderPoint.X > this.ScreenSize.Width + radiusInPixels || Body.RenderPoint.Y > this.ScreenSize.Height + radiusInPixels)
            {
                return;
            }

#if DEBUG
            if (Body.RenderPoint.IsZero)
            {
                throw new Exception();
            }
#endif

            bool caption;

            switch (CaptionMode)
            {
            case SolarMax.CaptionMode.Auto:
                caption = projector.BodyBeingViewed.Equals(Body) || radiusInPixels > AUTO_CAPTION_THRESHOLD || Zoom > Body.CaptionZoomThreshold;
                break;

            case SolarMax.CaptionMode.DynamicOnly:
                caption = projector.BodyBeingViewed.Equals(Body) || (Body.BodyType == CelestialBodyType.Dynamic && (radiusInPixels > AUTO_CAPTION_THRESHOLD || Zoom > Body.CaptionZoomThreshold));
                break;

            default:
                caption = false;
                break;
            }
            if (caption)
            {
                DrawString(Body.DisplayName, new QPoint(Body.RenderPoint.X + radiusInPixels, Body.RenderPoint.Y + radiusInPixels), Body == projector.BodyBeingViewed ? QPen.White : Body.CaptionPen, this.SmallFont);
            }

            if (this.WireFrameBodyRender &&
                radiusInPixels > 7 &&
                Body.HasShape)
            {
                var shape = (radiusInPixels > 80) ? Body.ShapeBig :
                            (radiusInPixels > 30) ? Body.ShapeMedium :
                            Body.ShapeSmall;

                shape.Reset();
                if (Body.HasDynamicShape)
                {
                    shape.RotateAbout(Body.Axis, Body.AngleSnapshot);
                }
                shape.Move(Body.PositionSnapshot);

                QPoint p1, p2;

                double distSqr = projector.Position.DistanceToSquared(Body.PositionSnapshot);

                bool highlightSun = HighlightSunlitAreas && Body is Orbiter;

                double distSqrSun = highlightSun ? CelestialBody.Sun.PositionSnapshot.DistanceToSquared(Body.PositionSnapshot) : double.MaxValue;

                // Draw back of object
                foreach (var l in shape.Lines)
                {
                    l.IsInFront = l.P1.DistanceToSquared(projector.Position) < distSqr || l.P2.DistanceToSquared(projector.Position) < distSqr;
                    if (!l.IsInFront)
                    {
                        if (projector.Project2DLine(l.P1, l.P2, out p1, out p2))
                        {
                            DrawingTarget.DrawLine(l.LineType == LineType.Special ? primeMeridianDarkPen : Body.BackPen, p1, p2);
                        }
                    }
                }
                // Draw axis
                if (radiusInPixels > DRAW_AXIS_THRESHOLD)
                {
                    if (projector.Project2DLine(Body.PositionSnapshot + Body.Axis * Body.Radius * AXIS_SCALE, Body.PositionSnapshot - Body.Axis * Body.Radius * AXIS_SCALE, out p1, out p2))
                    {
                        DrawingTarget.DrawLine(planetAxisPen, p1, p2);
                    }
                }
                //Draw front of object
                foreach (var l in shape.Lines)
                {
                    if (l.IsInFront)
                    {
                        if (projector.Project2DLine(l.P1, l.P2, out p1, out p2))
                        {
                            if (highlightSun && l.LineType != LineType.Special && (l.P1.DistanceToSquared(CelestialBody.Sun.PositionSnapshot) < distSqrSun || l.P2.DistanceToSquared(CelestialBody.Sun.PositionSnapshot) < distSqrSun))
                            {
                                DrawingTarget.DrawLine(sunlitArea, p1, p2);
                            }
                            else
                            {
                                DrawingTarget.DrawLine(l.LineType == LineType.Special ? primeMeridianPen : Body.FrontPen, p1, p2);
                            }
                        }
                    }
                }
            }
            else
            {
                radiusInPixels += Body.RadiusEnhancement;
                if (radiusInPixels > 1f)
                {
                    DrawingTarget.FillCircle(Body.Pen, Body.RenderPoint.X, Body.RenderPoint.Y, radiusInPixels);
                }
                else
                {
                    DrawingTarget.SetPixel(Body.Pen, Body.RenderPoint.X, Body.RenderPoint.Y);
                }
            }
            RenderLocations[NumRenderLocations++] = Body;
        }
        /// <summary>
        ///
        /// </summary>
        private void LoadData()
        {
            this.btnSave.Visible = this.btnOK.Visible = false;

            bool verifty = true;

            List <IDataParameter> para = null;

            DataTable dt = null;

            string strSql = string.Empty;

            try
            {
                string uid = this.RequestQueryString("uid").DecryptDES();

                strSql = this.Select.PushMessage(uid, null, null, null, null, null, null, this.SessionMgr.UserInfos.UserID, 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.Rows.Count == 0)
                {
                    throw new Exception(string.Format("資料取得失敗"));
                }

                this.ViewState["IDF"] = dt.Rows[0]["msg_identifier"].ToString().Trim();

                string msg_apply_maker = dt.Rows[0]["msg_apply_maker"].ToString().Trim();

                verifty = !msg_apply_maker.Equals(this.SessionMgr.UserInfos.UserID);

                int status = Convert.ToInt16(dt.Rows[0]["msg_status"].ToString().Trim());

                this.btnSave.Visible = this.btnOK.Visible = status.Equals(1) || status.Equals(2) || status.Equals(4);

                string color = string.Empty;

                switch (status)
                {
                case 1: color = "Chocolate"; break;

                case 2: color = "Green"; break;

                case 3: color = "Blue"; break;

                case 4: color = "Red"; break;

                case 5: color = "Gray"; break;
                }
                this.lblStatus.InnerHtml = string.Format("<font color=\"{1}\">{0}</font>", status.ToString().GetPushMessageCH().HtmlEncode(), color);

                this.txtID.Text            = dt.Rows[0]["msg_identifier"].ToString().Trim();
                this.txtPushTitle.Text     = dt.Rows[0]["msg_push_title"].ToString().Trim().HtmlEncode();
                this.txtPushBody.Text      = dt.Rows[0]["msg_push_content"].ToString().Trim().HtmlEncode();
                this.txtPushHyperlink.Text = dt.Rows[0]["msg_push_hyperlink"].ToString().Trim();

                this.ViewState["PushImageName"] = this.HiddenPushImageName.Value = dt.Rows[0]["msg_push_image"].ToString().Trim().EncryptBase64();

                this.ddlOS.SelectedValue = dt.Rows[0]["msg_push_os_type"].ToString().Trim();

                this.HiddenAppName.Value = dt.Rows[0]["msg_push_app_identifier"].ToString().Trim();

                string msg_push_recp_list = dt.Rows[0]["msg_push_recp_list"].ToString().Trim();

                string[] msg_push_recp_list_date = msg_push_recp_list.Split('|');

                this.HiddenPushListName.Value = msg_push_recp_list_date.Length > 0 && !String.IsNullOrEmpty(msg_push_recp_list_date[0]) ? msg_push_recp_list_date[0].DecryptBase64() : string.Empty;

                this.HiddenPushListBody.Value = msg_push_recp_list_date.Length > 1 && !String.IsNullOrEmpty(msg_push_recp_list_date[1]) ? msg_push_recp_list_date[1] : string.Empty;

                this.chBoxCustList.Checked = !String.IsNullOrEmpty(this.HiddenPushListName.Value);

                bool msg_is_send_now = dt.Rows[0]["msg_is_send_now"].ToString().Trim().Equals("1");

                this.sendMode1.Checked = msg_is_send_now;

                this.sendMode2.Checked = !this.sendMode1.Checked;

                DateTime send_date = DateTime.MinValue;

                if (!msg_is_send_now)
                {
                    send_date = DateTime.Parse(dt.Rows[0]["msg_reserv_send_time"].ToString().Trim());
                }

                if (!send_date.Equals(DateTime.MinValue))
                {
                    this.txtSendDate.Text = send_date.ToString("yyyy/MM/dd");

                    this.ddlHour.SelectedValue = send_date.Hour.ToString();

                    this.ddlMinute.SelectedValue = send_date.Minute.ToString();
                }
                this.btnSave.Visible = !status.Equals(4);
            }
            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();

                this.VeriftyTokenFromPreviousPage(WebTypeMode.btnUpdate, verifty);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="Anew"></param>
        /// <param name="LockPageNum"></param>
        public void DataBind(bool Anew, bool LockPageNum)
        {
            if (!this.QueryPermissions)
            {
                return;
            }

            if (String.IsNullOrEmpty(this.txtStartDate.Text) || String.IsNullOrEmpty(this.txtEndDate.Text))
            {
                this.txtStartDate.Text = DateTime.Now.AddDays(-14).ToString("yyyy/MM/dd");

                this.txtEndDate.Text = DateTime.Now.ToString("yyyy/MM/dd");
            }
            string where = this.QueryConditions(new List <string[]>
            {
                new string[] { this.lblStartDate.InnerText, this.txtStartDate.Text.Trim() },
                new string[] { this.lblEndDate.InnerText, this.txtEndDate.Text.Trim() },
                new string[] { this.lblWebName.InnerText, this.ddlWebName.SelectedValue },
                new string[] { this.lblCaption.InnerText, this.ddlCaption.SelectedValue },
                new string[] { this.lblActionMode.InnerText, this.ddlActionMode.SelectedValue, },
                new string[] { this.lblUserAccount.InnerText, this.txtUserAccount.Text.Trim() },
                new string[] { this.lblUserIP.InnerText, this.txtUserIP.Text.Trim() }
            });

            string caption = CaptionMode.Get(CaptionLib.Mode.Query);

            try
            {
                this.WriteLog(string.Format("準備查詢"));

                List <LinkButton> pageLinkButton = new List <LinkButton>();
                pageLinkButton.Add(this.btnFirst_GridView1);
                pageLinkButton.Add(this.btnPrev_GridView1);
                pageLinkButton.Add(this.btnNext_GridView1);
                pageLinkButton.Add(this.btnLast_GridView1);

                if (Anew)
                {
                    string strSql = string.Empty;

                    DataTable dt = null;

                    List <IDataParameter> para = null;

                    strSql = this.Select.Logs(
                        DateTime.Parse(this.txtStartDate.Text).ToString("yyyy/MM/dd 00:00:00"),
                        DateTime.Parse(this.txtEndDate.Text).ToString("yyyy/MM/dd 23:59:59"),
                        this.ddlWebName.SelectedValue,
                        this.ddlCaption.SelectedValue,
                        this.ddlActionMode.SelectedValue,
                        this.txtUserAccount.Text.Trim(),
                        this.txtUserIP.Text.Trim(),
                        ref para);

                    #region SQL Debug

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

                    this.WriteLog(para.ToLog());

                    #endregion

                    this.DBConn.GeneralSqlCmd.Command.CommandTimeout = 90;

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

                    para = null;

                    bool check = this.divPageLayer_GridView1.Visible = dt.Rows.Count > 0;

                    if (!check)
                    {
                        this.GridView1.DataBind(); return;
                    }
                    else
                    {
                        ViewState[this.GridView1.ClientID] = dt;

                        dt.Dispose(); dt = null;
                    }
                }
                this.GridView1.DataBind((DataTable)ViewState[this.GridView1.ClientID], Anew, LockPageNum, this.lblTotalPage_GridView1, this.lblPage_GridView1, pageLinkButton);
            }
            catch (System.Exception ex) { this.WriteLog(Log.Mode.LogMode.ERROR, ex.ToString()); this.MessageBox("發生錯誤", string.Format("系統發生錯誤\r\n{0}", ex.Message)); caption = CaptionMode.Get(CaptionLib.Mode.QueryFail); }
            finally
            {
                this.CloseConn();

                this.WriteLog(string.Format("查詢結束"));

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Query, this.SessionMgr.UserInfos.UserID, caption, this.PageName, string.Format("{0}\r\n查詢結果共{1}筆\r\n當前為第{2}頁", where, ViewState[this.GridView1.ClientID] != null ? ((DataTable)ViewState[this.GridView1.ClientID]).Rows.Count : 0, (this.GridView1.PageIndex + 1).ToString()));
            }
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            try
            {
                string uid = this.UID;

                if (String.IsNullOrEmpty(uid))
                {
                    return;
                }
                this.WriteLog(string.Format("修改單位"));

                strSql = this.Select.CheckDepts(uid, this.txtGroupCode.Text.Trim(), ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

                if (this.DBConnTransac.GeneralSqlCmd.ExecuteScalar(strSql, para))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("單位代碼重覆了 ({0})", this.txtGroupCode.Text.Trim()));

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

                    return;
                }
                this.WriteLog(string.Format("準備修改單位編號:{0}", uid));

                strSql = this.Update.Group(uid, this.txtGroupCode.Text.Trim(), this.txtGroupName.Text.Trim(), this.ViewState["group_status"].ToString(), this.SessionMgr.UserInfos.UserID, 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.INFO, string.Format("修改失敗"));

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Update, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.UpdateFail), this.PageName, string.Format("單位編號:{0}", uid.ToString()));

                    return;
                }
                this.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MessageBox(Mode.LogMode.INFO, string.Format("修改成功"));

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Update, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.Update), this.PageName, string.Format("單位編號:{0}", uid.ToString()));
            }
            catch (System.Exception ex)
            {
                this.Rollback();

                this.MessageBox(ex);

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Update, 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 btnOK_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            try
            {
                this.WriteLog(string.Format("修改分組"));

                strSql = this.Update.Types(this.UID, this.txtlblIdentifier.Text.Trim(), this.txtTypeName.Text.Trim(), 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(0))
                {
                    this.MessageBox(Mode.LogMode.ERROR, string.Format("修改角色失敗"));

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Update, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.UpdateFail), this.PageName, string.Format("分組識別碼:{0}", this.txtlblIdentifier.Text.Trim()));

                    return;
                }


                this.MessageBox(Mode.LogMode.INFO, string.Format("修改成功"));

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

                this.MessageBox(ex);

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

                this.CloseConn();

                this.WriteLog(string.Format("修改角色權限結束"));
            }
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        private void LoadRoleWeb()
        {
            List <IDataParameter> para = null;

            string strSql = string.Empty;

            StringBuilder sb = new StringBuilder();

            DataTable dt = null, dt_RolePermission = null;

            DataRow[] dr_web_type = null;
            try
            {
                strSql = this.Select.RolesWebPermission(this.UID, null, ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

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

                strSql = this.Select.RolesWebList();

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

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

                sb.Append(string.Format("<table id=\"tb_RolesWeb\" 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;\">"));

                DataRow[] drs = dt.Select(string.Format("web_perm_is_visible = '1'"));

                List <string> group_name_list = new List <string>();

                if (drs.Length > 0)
                {
                    DataRow dr = drs[0];

                    var dr_sort = drs.OrderByDescending(d => dr["web_perm_seq"]);

                    foreach (var dr1 in dr_sort)
                    {
                        string page_group_name = dr1["web_perm_group_name"].ToString().HtmlEncode();

                        int web_type = Convert.ToInt32(dr1["web_perm_pri"].ToString().Trim().HtmlEncode());

                        dr_web_type = dt_RolePermission.Select(string.Format("role_perm_perm_id = '{0}'", dr1["web_perm_id"].ToString().Trim().HtmlEncode()));

                        int check_web_type = dr_web_type.Length > 0 ? Convert.ToInt32(dr_web_type[0]["role_perm_value"].ToString().HtmlEncode()) : 0;

                        if (String.IsNullOrEmpty(page_group_name))
                        {
                            sb.Append(string.Format("<tr>"));
                            sb.Append(string.Format("   <th></th>"));
                            sb.Append(string.Format("   <td>{0}</td>", dr1["web_perm_page_name"].ToString().HtmlEncode()));
                            sb.Append(string.Format("   <td>{0}</td>", this.GenerateRoleWebCheckBox(dr1["web_perm_id"].ToString().HtmlEncode(), Convert.ToInt32(dr1["web_perm_pri"].ToString().HtmlEncode()), check_web_type, dr1["web_perm_is_manage"].ToString().HtmlEncode() == "1")));
                            sb.Append(string.Format("</tr>"));

                            continue;
                        }
                        if (!String.IsNullOrEmpty(group_name_list.Find(x => x == page_group_name)))
                        {
                            continue;
                        }

                        string id = Guid.NewGuid().ToString();

                        DataRow[] dr_item = dt.Select(string.Format("web_perm_is_visible = '1' And web_perm_group_name = '{0}'", page_group_name));

                        var dr_item_sort = dr_item.OrderByDescending(d => dr1["web_perm_seq"]);

                        int count = 0;

                        foreach (var dr2 in dr_item_sort)
                        {
                            dr_web_type = dt_RolePermission.Select(string.Format("role_perm_perm_id = '{0}'", dr2["web_perm_id"].ToString().Trim().HtmlEncode()));

                            check_web_type = dr_web_type.Length > 0 ? Convert.ToInt32(dr_web_type[0]["role_perm_value"].ToString().HtmlEncode()) : 0;

                            sb.Append(string.Format("<tr>"));
                            if (count == 0)
                            {
                                sb.Append(string.Format("   <th rowspan=\"{0}\">{1}</th>", dr_item_sort.Count(), page_group_name.HtmlEncode()));
                            }
                            sb.Append(string.Format("   <td>{0}</td>", dr2["web_perm_page_name"].ToString().HtmlEncode()));
                            sb.Append(string.Format("   <td>{0}</td>", this.GenerateRoleWebCheckBox(dr2["web_perm_id"].ToString().HtmlEncode(), Convert.ToInt32(dr2["web_perm_pri"].ToString().HtmlEncode()), check_web_type, dr2["web_perm_is_manage"].ToString().HtmlEncode() == "1")));
                            sb.Append(string.Format("</tr>"));
                            count++;
                        }
                        group_name_list.Add(page_group_name);
                    }
                }
                sb.AppendLine(string.Format("</table>"));
            }
            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
            {
                dt = dt_RolePermission = null;

                para = null;

                this.CloseConn();
            }
            string html = sb.ToString().HtmlEncode();

            this.LiteralRoleWeb.Text = html.HtmlDecode();
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        private void LoadGroup()
        {
            List <IDataParameter> para = null;

            string strSql = string.Empty;

            StringBuilder sb = new StringBuilder();

            DataTable dt = null, dt_RoleGroup = null;

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

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

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

                strSql = this.Select.Group(null, null, 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);

                int max_count = 3;

                sb.Append(string.Format("<table id=\"tb_Depts\" 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;\">"));

                sb.Append(string.Format("<tr>"));
                sb.Append(string.Format("   <th colspan=\"{0}\" style=\"text-align: left!important;\">{1}</th>", max_count.ToString(), "<input type=\"checkbox\" onclick=\"return deptSelectAll(this);\">&nbsp;<span>全選</span>"));
                sb.Append(string.Format("</tr>"));

                for (int i = 0; i < dt.Rows.Count; i += max_count)
                {
                    sb.Append(string.Format("<tr>"));

                    for (int i2 = 0; i2 < max_count; i2++)
                    {
                        int index = i + i2;

                        if (index < dt.Rows.Count)
                        {
                            DataRow[] dr = dt_RoleGroup.Select(string.Format("role_group_group_id = '{0}'", dt.Rows[index]["group_id"].ToString().Trim()));

                            bool check_group = dr.Length > 0;

                            sb.Append(string.Format("<td><input type=\"checkbox\" key=\"role-dept-item\" value=\"{0}\"{2}>&nbsp;<span>{1}</span></td>",
                                                    dt.Rows[index]["group_id"].ToString().Trim().HtmlEncode(),
                                                    dt.Rows[index]["group_name"].ToString().Trim().HtmlEncode(),
                                                    check_group ? " checked" : string.Empty
                                                    ));
                        }
                        else
                        {
                            sb.Append(string.Format("<td></td>"));
                        }
                    }
                    sb.Append(string.Format("</tr>"));
                }
                sb.AppendLine(string.Format("</table>"));
            }
            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();
            }
            this.LiteralDepts.Text = sb.ToString();
        }
        /// <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("駁回結束"));
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            Hashtable ht = new Hashtable();

            try
            {
                this.WriteLog(string.Format("新增系統存取管理名單"));

                strSql = this.Select.CheckPushWhitelist(null, this.txtAccount.Text.Trim(), ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

                bool check = this.DBConnTransac.GeneralSqlCmd.ExecuteScalar(strSql, para);

                if (check)
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("帳號重覆了 ({0})", this.txtAccount.Text.Trim().HtmlEncode()));

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

                    return;
                }
                ht.Add("agent_account", this.txtAccount.Text.Trim());
                ht.Add("agent_pwd", this.txtPassword1.Text.Trim().SHA256());
                ht.Add("agent_secret", this.lblShareSecret.Text.Trim());
                ht.Add("agent_name", this.txtAgentName.Text.Trim());
                ht.Add("agent_status", this.ddlStatus.SelectedValue);
                ht.Add("agent_desc", this.txtComment.Text.Trim());
                ht.Add("agent_address", this.txtIPAddres.Text.Trim());
                ht.Add("agent_creator", this.SessionMgr.UserInfos.UserID);

                strSql = this.Insert.PushWhitelist(ht, ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

                object agent_id_temp = this.DBConnTransac.GeneralSqlCmd.ExecuteItentity(strSql, para);

                if (agent_id_temp == null)
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("新增失敗 ({0})", this.txtAgentName.Text.Trim().HtmlEncode()));

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

                    return;
                }
                string[] app_id_list = this.HiddenAppList.Value.Split('|');

                for (int i = 0; i < app_id_list.Length; i++)
                {
                    strSql = this.Insert.AgentApp(agent_id_temp.ToString(), app_id_list[i], 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(0))
                    {
                        this.Rollback();

                        this.MessageBox(Mode.LogMode.ERROR, message = string.Format("新增APP失敗 ({0})", this.txtAgentName.Text.Trim().HtmlEncode()));

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

                        return;
                    }
                }

                string[] type_id_list = this.HiddenTypeList.Value.Split('|');

                for (int i = 0; i < type_id_list.Length; i++)
                {
                    strSql = this.Insert.AgentType(agent_id_temp.ToString(), type_id_list[i], 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(0))
                    {
                        this.Rollback();

                        this.MessageBox(Mode.LogMode.ERROR, message = string.Format("新增分組失敗 ({0})", this.txtAgentName.Text.Trim().HtmlEncode()));

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

                        return;
                    }
                }
                this.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MessageBox(Mode.LogMode.INFO, message = string.Format("新增成功"));

                message += string.Format(",APP數量{0}個", app_id_list.Length.ToString());
                message += string.Format(",分組數量{0}個", type_id_list.Length.ToString());

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

                this.MessageBox(ex);

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Add, 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 btnOK_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            try
            {
                strSql = this.Insert.Type(this.txtlblIdentifier.Text.Trim(), this.txtTypeName.Text.Trim(), ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

                object type_id = this.DBConn.GeneralSqlCmd.ExecuteItentity(strSql, para);

                if (type_id == null)
                {
                    this.MessageBox(Mode.LogMode.ERROR, string.Format("新增分組失敗"));

                    this.MyMonitor.LogMonitor(this, MonitorActionMode.Add, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.AddFail), this.PageName, string.Format("分組識別碼名稱:{0}", this.txtlblIdentifier.Text.Trim()));

                    return;
                }

                this.MessageBox(Mode.LogMode.INFO, string.Format("新增成功"));

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

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

                this.CloseConn();

                this.WriteLog(string.Format("新增分組結束"));
            }
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Anew"></param>
        /// <param name="LockPageNum"></param>
        public void DataBind(bool Anew, bool LockPageNum)
        {
            if (!this.QueryPermissions)
            {
                return;
            }

            string where = this.QueryConditions(new List <string[]>
            {
                new string[] { this.lblDept.InnerText, !String.IsNullOrEmpty(this.ddlDept.SelectedItem.Value) ? string.Format("{0} ({1})", this.ddlDept.SelectedItem.Value, this.ddlDept.SelectedItem.Text) : string.Empty }
            });
            string caption = CaptionMode.Get(CaptionLib.Mode.Query);

            try
            {
                string group_id = this.ddlDept.SelectedValue;

                if (!this.SessionMgr.UserInfos.IsSuperUser && String.IsNullOrEmpty(group_id))
                {
                    return;
                }

                this.WriteLog(string.Format("準備查詢"));

                List <LinkButton> pageLinkButton = new List <LinkButton>();
                pageLinkButton.Add(this.btnFirst_GridView1);
                pageLinkButton.Add(this.btnPrev_GridView1);
                pageLinkButton.Add(this.btnNext_GridView1);
                pageLinkButton.Add(this.btnLast_GridView1);

                if (Anew)
                {
                    string strSql = string.Empty;

                    DataTable dt = null;

                    List <IDataParameter> para = null;

                    strSql = this.Select.Verify(null, group_id, "1", null, this.txtUserAccount.Text.Trim(), this.ddlVerifyStatus.SelectedValue, false, ref para);

                    #region SQL Debug

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

                    this.WriteLog(para.ToLog());

                    #endregion

                    this.DBConn.GeneralSqlCmd.Command.CommandTimeout = 90;

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

                    para = null;

                    bool check = this.divPageLayer_GridView1.Visible = dt.Rows.Count > 0;

                    if (!check)
                    {
                        this.GridView1.DataBind(); return;
                    }
                    else
                    {
                        ViewState[this.GridView1.ClientID] = dt;

                        dt.Dispose(); dt = null;
                    }
                }
                this.GridView1.DataBind((DataTable)ViewState[this.GridView1.ClientID], Anew, LockPageNum, this.lblTotalPage_GridView1, this.lblPage_GridView1, pageLinkButton);
            }
            catch (System.Exception ex) { this.WriteLog(Log.Mode.LogMode.ERROR, ex.ToString()); this.MessageBox("發生錯誤", string.Format("系統發生錯誤\r\n{0}", ex.Message)); caption = CaptionMode.Get(CaptionLib.Mode.QueryFail); }
            finally
            {
                this.CloseConn();

                this.WriteLog(string.Format("查詢結束"));

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Query, this.SessionMgr.UserInfos.UserID, caption, this.PageName, string.Format("{0}\r\n查詢結果共{1}筆\r\n當前為第{2}頁", where, ViewState[this.GridView1.ClientID] != null ? ((DataTable)ViewState[this.GridView1.ClientID]).Rows.Count : 0, (this.GridView1.PageIndex + 1).ToString()));
            }
        }
        /// <summary>
        ///
        /// </summary>
        private void LoadData()
        {
            List <IDataParameter> para = null;

            DataTable dt = null;

            string strSql = string.Empty;

            try
            {
                strSql = this.Select.PushWhitelist(this.UID, null, 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.Rows.Count == 0)
                {
                    throw new Exception(string.Format("資料取得失敗"));
                }

                this.lblInfo.InnerText = string.Format("{0}", dt.Rows[0]["agent_name"].ToString().Trim());

                this.txtAgentName.Text = dt.Rows[0]["agent_name"].ToString().Trim();

                this.HiddenAgentName.Value = this.txtAgentName.Text.EncryptDES();

                this.txtAccount.Text = dt.Rows[0]["agent_account"].ToString().Trim();

                this.HiddenAccount.Value = this.txtAccount.Text.EncryptDES();

                this.ddlStatus.SelectedValue = dt.Rows[0]["agent_status"].ToString().Trim();

                this.txtIPAddres.Text = dt.Rows[0]["agent_address"].ToString().Trim();

                this.txtComment.Text = dt.Rows[0]["agent_desc"].ToString().Trim();

                this.lblShareSecret.Text = dt.Rows[0]["agent_secret"].ToString().Trim();

                this.ViewState["PWD"] = dt.Rows[0]["agent_pwd"].ToString().Trim();

                strSql = this.Select.AgentAppList(this.UID, ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

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

                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    StringBuilder sb_os_type = new StringBuilder();

                    string os_type = dt.Rows[i]["app_os_type"].ToString().Trim();

                    foreach (OsTypeMode os in Enum.GetValues(typeof(OsTypeMode)))
                    {
                        bool check = (Convert.ToInt32(os_type) & (int)os) > 0;

                        if (!check)
                        {
                            continue;
                        }

                        sb_os_type.Append(string.Format("{0}[br/]", ((int)os).ToString().GetOsTypeCH()));
                    }
                    if (i > 0)
                    {
                        sb.Append(", ");
                    }

                    sb.Append(string.Format("< \"app_id\" : \"{0}\", \"app_identifier\" : \"{1}\", \"app_name\" : \"{2}\", \"app_os_type\" : \"{3}\" >"
                                            , dt.Rows[i]["app_id"].ToString().HtmlEncode().EncryptBase64()
                                            , dt.Rows[i]["app_identifier"].ToString().HtmlEncode().EncryptBase64()
                                            , dt.Rows[i]["app_name"].ToString().HtmlEncode().EncryptBase64()
                                            , sb_os_type.ToString().HtmlEncode().EncryptBase64()
                                            ));
                }
                string json = "{ \"data\": [" + sb.ToString().Replace("<", "{").Replace(">", "}") + "] }";

                ScriptManager.RegisterStartupScript(this, this.GetType(), "appData", string.Format("var appData = {0};\r\n", json), true);

                strSql = this.Select.AgentTypeList(this.UID, ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

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

                StringBuilder sb2 = new StringBuilder();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (i > 0)
                    {
                        sb2.Append(", ");
                    }

                    sb2.Append(string.Format("< \"type_id\" : \"{0}\", \"type_identifier\" : \"{1}\", \"type_name\" : \"{2}\" >"
                                             , dt.Rows[i]["type_id"].ToString().HtmlEncode().EncryptBase64()
                                             , dt.Rows[i]["type_identifier"].ToString().HtmlEncode().EncryptBase64()
                                             , dt.Rows[i]["type_name"].ToString().HtmlEncode().EncryptBase64()
                                             ));
                }
                string json2 = "{ \"data\": [" + sb2.ToString().Replace("<", "{").Replace(">", "}") + "] }";

                ScriptManager.RegisterStartupScript(this, this.GetType(), "typeData", string.Format("var typeData = {0};\r\n", json2), true);
            }
            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 btnExport_Click(object sender, EventArgs e)
        {
            this.WriteLog(string.Format("開始匯出"));

            if (String.IsNullOrEmpty(this.txtStartDate.Text) || String.IsNullOrEmpty(this.txtEndDate.Text))
            {
                this.txtStartDate.Text = DateTime.Now.AddDays(-14).ToString("yyyy/MM/dd");

                this.txtEndDate.Text = DateTime.Now.ToString("yyyy/MM/dd");
            }
            string start_date_time = string.Format("{0} 00:00:00", this.txtStartDate.Text.HtmlEncode());

            string end_date_time = string.Format("{0} 23:59:59", this.txtEndDate.Text.HtmlEncode());

            string where = this.QueryConditions(new List <string[]>
            {
                new string[] { this.lblStartDate.InnerText, start_date_time },
                new string[] { this.lblEndDate.InnerText, end_date_time },
                new string[] { this.lblOs.InnerText, !String.IsNullOrEmpty(this.ddlOS.SelectedValue) ? this.ddlOS.SelectedValue.GetOsTypeCH() : string.Empty },
                new string[] { this.lblApp.InnerText, !String.IsNullOrEmpty(this.ddlApp.SelectedValue) ? this.ddlApp.SelectedValue : string.Empty }
            });

            string caption = CaptionMode.Get(CaptionLib.Mode.Export);

            DataTable dt = null;

            List <IDataParameter> para = null;

            try
            {
                string strSql = this.Select.Report002(start_date_time, end_date_time, !String.IsNullOrEmpty(this.ddlOS.SelectedValue) ? Convert.ToInt16(this.ddlOS.SelectedValue) : -1, this.HiddenAppName.Value, 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.Rows.Count.Equals(0))
                {
                    this.MessageBox(string.Format("所選條件沒有任何資料")); return;
                }
                string[] columnNames = new string[] { "APP ID", "APP 項目", "APP 版本", "作業系統", "數量" };

                if (this.ddlExportMode.SelectedValue.Equals("0"))
                {
                    this.Export2CSV(this, dt, string.Format("{0}.csv", DateTime.Now.ToString("yyyyMMddHHmmss")), columnNames);
                }
                else if (this.ddlExportMode.SelectedValue.Equals("1"))
                {
                    this.Export2TXT(this, dt, string.Format("{0}.txt", DateTime.Now.ToString("yyyyMMddHHmmss")), columnNames);
                }
            }
            catch (System.Exception ex) { this.MessageBox(ex); }
            finally
            {
                para = null;

                this.CloseConn();

                this.WriteLog(string.Format("匯出結束"));

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Export, this.SessionMgr.UserInfos.UserID, caption, this.PageName, string.Format("{0}\r\n匯出結果共{1}筆", where, dt != null ? dt.Rows.Count : 0));
            }
        }
示例#15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            try
            {
                this.WriteLog(string.Format("新增APP"));

                strSql = this.Select.App(null, this.txtAppID.Text.Trim(), null, null, ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

                if (this.DBConn.GeneralSqlCmd.ExecuteScalar(strSql, para))
                {
                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("APP ID重覆了 ({0})", this.txtAppID.Text.Trim().HtmlEncode()));

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

                    return;
                }
                int os_type = this.radioBtnOsType1.Checked ? Convert.ToInt16(this.radioBtnOsType1.Value) : Convert.ToInt16(this.radioBtnOsType2.Value);

                strSql = this.Insert.App(
                    this.txtAppID.Text.Trim(),
                    this.txtAppName.Text.Trim(),
                    os_type,
                    this.radioBtnOsType1.Checked ? this.txtAppKey.Text : string.Empty,
                    this.radioBtnOsType1.Checked ? string.Empty : this.HiddenAppCertBody.Value,
                    this.radioBtnOsType1.Checked ? string.Empty : this.txtAppCertKey.Text,
                    this.radioBtnOsType1.Checked ? string.Empty : this.HiddenAppCertDateTime.Value.DecryptBase64(),
                    this.radioBtnOsType1.Checked ? 0 : this.radioBtnCertType1.Checked ? Convert.ToInt16(this.radioBtnCertType1.Value) : Convert.ToInt16(this.radioBtnCertType2.Value),
                    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, message = string.Format("新增失敗 ({0})", this.txtAppID.Text.Trim().HtmlEncode()));

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

                    return;
                }
                this.MessageBox(Mode.LogMode.INFO, string.Format("新增成功"));

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

                this.MessageBox(ex);

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

                this.CloseConn();

                this.WriteLog(string.Format("新增APP結束"));
            }
        }
示例#16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            DataTable dt = null;

            try
            {
                string body_fromat = "{"
                                     + " \"data_content\":\"[data_content]\""
                                     + " ,\"is_private\": \"[is_private]\""
                                     + " ,\"data_link\": \"[data_link]\""
                                     + " ,\"data_image\": \"[data_image]\""
                                     + " ,\"msg_id\": \"[msg_id]\""
                                     + " }";

                this.WriteLog(string.Format("開始核准推播訊息"));

                strSql = this.Update.PushMessageStatus(this.UID, "3", 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(0))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("核准推播訊息失敗,推播申請單號:{0}", this.lblID.Text.HtmlEncode()));

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

                    return;
                }
                strSql = this.Select.PushMessageApproved(this.UID, null, null, null, ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

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

                string msg_push_image = dt.Rows[0]["msg_push_image"].ToString().Trim();

                if (!String.IsNullOrEmpty(msg_push_image))
                {
                    string publicURIPrefix = this.GetSystemSetting("PublicURIPrefix");

                    if (!publicURIPrefix.EndsWith("/") && !publicURIPrefix.EndsWith(@"\"))
                    {
                        publicURIPrefix += "/";
                    }

                    string connect_test_url = publicURIPrefix + "ConnectTest";

                    string http_result = connect_test_url.WebRequest(UtilityExtensions.RequestMode.GET, null);

                    if (!http_result.Equals("OK"))
                    {
                        throw new Exception(string.Format("File Server 連線失敗::\r\n{0}", http_result));
                    }

                    string upload_file_url = publicURIPrefix + "GetFileLink";

                    string parameter = string.Format("opUser={0}&opPassword={1}&fileHandle={2}"
                                                     , Utility.WebConfig.OP_USER
                                                     , Utility.WebConfig.OP_PASS
                                                     , msg_push_image);

                    http_result = upload_file_url.WebRequest(UtilityExtensions.RequestMode.POST, parameter);

                    JSONResonse json_result = JsonConvert.DeserializeObject <JSONResonse>(http_result);

                    if (!json_result.ReturnCode.Equals(0))
                    {
                        throw new Exception(string.Format("取得檔案連結失敗::\r\n{0}", json_result.Message.DecryptBase64()));
                    }

                    msg_push_image = json_result.Result.DecryptBase64();
                }
                string body = body_fromat.Replace("[data_content]", dt.Rows[0]["msg_push_content"].ToString().Trim());
                body = body.Replace("[is_private]", dt.Rows[0]["msg_push_is_private"].ToString().Trim());
                body = body.Replace("[data_link]", dt.Rows[0]["msg_push_hyperlink"].ToString().Trim().Replace("/", "\\/"));
                body = body.Replace("[data_image]", msg_push_image);
                body = body.Replace("[msg_id]", dt.Rows[0]["msg_identifier"].ToString().Trim());

                strSql = this.Update.PushMessagePushBody(this.UID, body, 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(0))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("Push Body 寫入失敗,推播申請單號:{0}", this.lblID.Text.HtmlEncode()));

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

                    return;
                }
                int push_total = 0;

                #region OS & APP

                int msg_push_os_type = Convert.ToInt16(this.ViewState["msg_push_os_type"].ToString().Trim());

                if (msg_push_os_type > 0)
                {
                    string msg_push_app_identifier = this.ViewState["msg_push_app_identifier"].ToString().Trim();

                    strSql = this.Select.UserDeviceToken(msg_push_os_type, msg_push_app_identifier, this.UID, ref para);

                    #region SQL Debug

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

                    this.WriteLog(para.ToLog());

                    #endregion

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

                    DataTable dt_push_send = new DataTable();
                    dt_push_send.Columns.Add("msg_id", typeof(int));
                    dt_push_send.Columns.Add("msg_push_send_time", typeof(DateTime));
                    dt_push_send.Columns.Add("msg_push_send_recp", typeof(string));
                    dt_push_send.Columns.Add("msg_push_send_app_identifier", typeof(string));
                    dt_push_send.Columns.Add("msg_push_send_recp_device", typeof(string));
                    dt_push_send.Columns.Add("msg_push_send_processor", typeof(string));
                    dt_push_send.Columns.Add("msg_push_send_status", typeof(int));
                    dt_push_send.Columns.Add("msg_push_send_user_operation", typeof(int));
                    dt_push_send.Columns.Add("msg_push_send_log", typeof(string));

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string push_device_token_id = dt.Rows[i]["push_device_token_id"].ToString().Trim();

                        string push_device_token_value = dt.Rows[i]["push_device_token_value"].ToString().Trim();

                        string push_device_token_app_identifier = dt.Rows[i]["push_device_token_app_identifier"].ToString().Trim();

                        string msg_push_send_id = dt.Rows[i]["msg_push_send_id"].ToString().Trim();

                        bool check = String.IsNullOrEmpty(msg_push_send_id);

                        if (!check)
                        {
                            this.WriteLog(string.Format("Token ID 有重覆 ({0})", push_device_token_id)); continue;
                        }
                        DataRow dr_push_send = dt_push_send.NewRow();
                        dr_push_send["msg_id"]                       = Convert.ToInt32(this.UID);
                        dr_push_send["msg_push_send_time"]           = DateTime.Now;
                        dr_push_send["msg_push_send_recp"]           = push_device_token_id;
                        dr_push_send["msg_push_send_app_identifier"] = push_device_token_app_identifier;
                        dr_push_send["msg_push_send_recp_device"]    = push_device_token_value;
                        dr_push_send["msg_push_send_processor"]      = DBNull.Value;
                        dr_push_send["msg_push_send_status"]         = 1;
                        dr_push_send["msg_push_send_user_operation"] = 0;
                        dr_push_send["msg_push_send_log"]            = DBNull.Value;
                        dt_push_send.Rows.Add(dr_push_send);
                    }
                    push_total = dt_push_send.Rows.Count;

                    bool bulk_copy_result = ((DBLibDAO.SqlTransac) this.DBConnTransac.GeneralSqlCmd).InsertBulkCopy("cg_message_push_send", dt_push_send);

                    if (!bulk_copy_result)
                    {
                        this.Rollback();

                        this.MessageBox(Mode.LogMode.ERROR, message = string.Format("1.新增推播名單失敗,推播申請單號:{0},OS Type:{1}", this.UID, msg_push_os_type));

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

                        return;
                    }
                }
                #endregion

                #region Push List

                if (!String.IsNullOrEmpty(this.HiddenPushListName.Value))
                {
                    string[] push_list = this.HiddenPushListName.Value.Split('|');

                    strSql = this.Select.UserDeviceToken(push_list, msg_push_os_type, this.UID, ref para);

                    #region SQL Debug

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

                    this.WriteLog(para.ToLog());

                    #endregion

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

                    DataTable dt_push_send = new DataTable();
                    dt_push_send.Columns.Add("msg_id", typeof(int));
                    dt_push_send.Columns.Add("msg_push_send_time", typeof(DateTime));
                    dt_push_send.Columns.Add("msg_push_send_recp", typeof(string));
                    dt_push_send.Columns.Add("msg_push_send_app_identifier", typeof(string));
                    dt_push_send.Columns.Add("msg_push_send_recp_device", typeof(string));
                    dt_push_send.Columns.Add("msg_push_send_processor", typeof(string));
                    dt_push_send.Columns.Add("msg_push_send_status", typeof(int));
                    dt_push_send.Columns.Add("msg_push_send_user_operation", typeof(int));
                    dt_push_send.Columns.Add("msg_push_send_log", typeof(string));

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string push_device_token_id = dt.Rows[i]["push_device_token_id"].ToString().Trim();

                        string push_device_token_value = dt.Rows[i]["push_device_token_value"].ToString().Trim();

                        string push_device_token_app_identifier = dt.Rows[i]["push_device_token_app_identifier"].ToString().Trim();

                        string msg_push_send_id = dt.Rows[i]["msg_push_send_id"].ToString().Trim();

                        DataRow dr_push_send = dt_push_send.NewRow();
                        dr_push_send["msg_id"]                       = Convert.ToInt32(this.UID);
                        dr_push_send["msg_push_send_time"]           = DateTime.Now;
                        dr_push_send["msg_push_send_recp"]           = push_device_token_id;
                        dr_push_send["msg_push_send_app_identifier"] = push_device_token_app_identifier;
                        dr_push_send["msg_push_send_recp_device"]    = push_device_token_value;
                        dr_push_send["msg_push_send_processor"]      = DBNull.Value;
                        dr_push_send["msg_push_send_status"]         = 1;
                        dr_push_send["msg_push_send_user_operation"] = 0;
                        dr_push_send["msg_push_send_log"]            = DBNull.Value;
                        dt_push_send.Rows.Add(dr_push_send);
                    }
                    push_total += dt_push_send.Rows.Count;

                    bool bulk_copy_result = ((DBLibDAO.SqlTransac) this.DBConnTransac.GeneralSqlCmd).InsertBulkCopy("cg_message_push_send", dt_push_send);

                    if (!bulk_copy_result)
                    {
                        this.Rollback();

                        this.MessageBox(Mode.LogMode.ERROR, message = string.Format("2.新增推播名單失敗,推播申請單號:{0},OS Type:{1}", this.UID, msg_push_os_type));

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

                        return;
                    }
                }
                #endregion

                this.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MessageBox(Mode.LogMode.INFO, message = string.Format("推播申請單號 {0},核准推播完成\r\n共排入{1}個裝置待發送", this.lblID.Text.HtmlEncode(), push_total.ToString()));

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

                this.LoadData();
            }
            catch (System.Exception ex)
            {
                this.Rollback();

                this.MessageBox(ex);

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

                para = null;

                this.CloseConnTransac();

                this.WriteLog(string.Format("退回推播訊息結束"));
            }
        }
示例#17
0
        /// <summary>
        ///
        /// </summary>
        private void LoadData()
        {
            List <IDataParameter> para = null;

            DataTable dt = null;

            string strSql = string.Empty;

            try
            {
                strSql = this.Select.PushMessageApproved(this.UID, null, 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.Rows.Count == 0)
                {
                    throw new Exception(string.Format("資料取得失敗"));
                }

                int status = Convert.ToInt16(dt.Rows[0]["msg_status"].ToString().Trim());

                this.btnOK.Visible = this.btnReject.Visible = status.Equals(2);

                string color = string.Empty;

                switch (status)
                {
                case 1: color = "Chocolate"; break;

                case 2: color = "Green"; break;

                case 3: color = "Blue"; break;

                case 4: color = "Red"; break;

                case 5: color = "Gray"; break;
                }
                this.lblStatus.InnerHtml = string.Format("<font color=\"{1}\">{0}</font>", status.ToString().GetPushMessageCH().HtmlEncode(), color);

                bool msg_is_send_now = dt.Rows[0]["msg_is_send_now"].ToString().Trim().Equals("1");

                this.HiddenPushImageName.Value = dt.Rows[0]["msg_push_image"].ToString().Trim().EncryptBase64();

                string msg_push_recp_list = dt.Rows[0]["msg_push_recp_list"].ToString().Trim();

                string[] msg_push_recp_list_date = msg_push_recp_list.Split('|');

                this.HiddenPushListName.Value = msg_push_recp_list_date.Length > 0 && !String.IsNullOrEmpty(msg_push_recp_list_date[0]) ? msg_push_recp_list_date[0].DecryptBase64() : string.Empty;

                this.HiddenPushListBody.Value = msg_push_recp_list_date.Length > 1 && !String.IsNullOrEmpty(msg_push_recp_list_date[1]) ? msg_push_recp_list_date[1] : string.Empty;

                this.lblID.Text           = dt.Rows[0]["msg_identifier"].ToString().Trim();
                this.lblApplyMaker.Text   = dt.Rows[0]["msg_apply_maker_name"].ToString().Trim().HtmlEncode();
                this.lblApplyTime.Text    = dt.Rows[0]["msg_apply_time"].ToString().Trim().HtmlEncode();
                this.lblGroup.Text        = dt.Rows[0]["group_name"].ToString().Trim().HtmlEncode();
                this.lblPushTitle.Text    = dt.Rows[0]["msg_push_title"].ToString().Trim().HtmlEncode();
                this.lblPushBody.Text     = dt.Rows[0]["msg_push_content"].ToString().Trim().HtmlEncode();
                this.hyperLinkPush.Text   = this.hyperLinkPush.NavigateUrl = dt.Rows[0]["msg_push_hyperlink"].ToString().Trim().HtmlEncode();
                this.lblPushSendTime.Text = msg_is_send_now ? "即時" : DateTime.Parse(dt.Rows[0]["msg_reserv_send_time"].ToString().Trim()).ToString("yyyy/MM/dd HH:mm:ss");

                string msg_push_os_type = dt.Rows[0]["msg_push_os_type"].ToString().Trim();

                this.ViewState["msg_push_os_type"] = msg_push_os_type;

                string msg_push_app_identifier = dt.Rows[0]["msg_push_app_identifier"].ToString().Trim();

                this.ViewState["msg_push_app_identifier"] = msg_push_app_identifier;

                if (!msg_push_os_type.Equals("0"))
                {
                    this.lblOsType.Text = this.ViewState["msg_push_os_type"].ToString().GetOsTypeCH().HtmlEncode();

                    this.lblAppType.Text = this.ViewState["msg_push_app_identifier"].ToString().HtmlEncode();
                }
                else
                {
                    this.lblOsType.Text = this.lblAppType.Text = "無";
                }

                this.divDanger.Visible = !msg_is_send_now && DateTime.Compare(DateTime.Now, DateTime.Parse(dt.Rows[0]["msg_reserv_send_time"].ToString().Trim())) >= 0;

                if (this.divDanger.Visible)
                {
                    this.MessageBox(this.lblDanger.InnerText);

                    this.btnOK.Visible = false;
                }
            }
            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("覆核結束"));
            }
        }
示例#19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            try
            {
                this.WriteLog(string.Format("修改角色權限"));

                int status = Convert.ToInt16(this.ddlStatus.SelectedValue);

                string select_role_web = this.HiddenRoleWeb.Value;

                string select_depts = this.HiddenDepts.Value;

                this.WriteLog(string.Format("HiddenRoleWeb::{0}", this.HiddenRoleWeb.Value));

                this.WriteLog(string.Format("HiddenDepts::{0}", this.HiddenDepts.Value));

                this.WriteLog(message = string.Format("角色名稱:{0},狀態為:{1},權限參數為:{2}", this.txtRoleName.Text.Trim(), status.ToString().GetStatusCH(), select_role_web));

                if (!String.IsNullOrEmpty(select_role_web))
                {
                    string[] depts = select_depts.Split(',');

                    this.WriteLog(string.Format("欲附加的單位有{0}個", depts.Length.ToString()));

                    strSql = this.Update.Roles(this.UID, this.txtRoleName.Text.Trim(), status.ToString(), this.txtComment.Text.Trim(), this.SessionMgr.UserInfos.UserID, 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(0))
                    {
                        this.Rollback();

                        this.MessageBox(Mode.LogMode.ERROR, string.Format("修改角色失敗"));

                        this.MyMonitor.LogMonitor(this, MonitorActionMode.Update, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.UpdateFail), this.PageName, string.Format("角色名稱:{0}", this.txtRoleName.Text.Trim()));

                        return;
                    }
                    strSql = this.Delete.RolesWeb(this.UID, ref para);

                    #region SQL Debug

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

                    this.WriteLog(para.ToLog());

                    #endregion

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

                    string[] web_items = select_role_web.Split('|');

                    for (int i = 0; i < web_items.Length; i++)
                    {
                        string web_id = web_items[i].Split('=')[0];

                        int privilege = 0;

                        string[] privileges = web_items[i].Split('=')[1].Split(',');

                        for (int i2 = 0; i2 < privileges.Length; i2++)
                        {
                            if (!String.IsNullOrEmpty(privileges[i2]))
                            {
                                privilege += Convert.ToInt32(privileges[i2]);
                            }
                        }

                        if (privilege == 0)
                        {
                            continue;
                        }

                        this.WriteLog(message = string.Format("角色編號:{0},角色名稱:{1},權限:{2}", this.UID, this.txtRoleName.Text.Trim(), privilege.ToString()));

                        strSql = this.Insert.RolesWeb(this.UID, web_id, privilege.ToString(), 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, string.Format("修改角色權限失敗"));

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

                            return;
                        }
                        this.MyMonitor.LogMonitor(this, MonitorActionMode.Update, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.Update), this.PageName, message);
                    }
                    strSql = this.Delete.RolesGroup(this.UID, ref para);

                    #region SQL Debug

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

                    this.WriteLog(para.ToLog());

                    #endregion

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

                    for (int i = 0; i < depts.Length; i++)
                    {
                        if (String.IsNullOrEmpty(depts[i]))
                        {
                            continue;
                        }

                        this.WriteLog(message = string.Format("分派單位編號:{0},角色編號:{1},角色名稱:{2}", depts[i], this.UID, this.txtRoleName.Text.Trim()));

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

                        strSql = this.Insert.RolesGroup(this.UID, depts[i], 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, string.Format("分派單位於角色失敗"));

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

                            return;
                        }
                        this.MyMonitor.LogMonitor(this, MonitorActionMode.Update, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.Update), this.PageName, message);
                    }
                    this.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                    this.LoadRoleWeb();

                    this.LoadGroup();

                    this.MessageBox(Mode.LogMode.INFO, string.Format("修改成功"));
                }
                this.MyMonitor.LogMonitor(this, MonitorActionMode.Update, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.Update), this.PageName, message);
            }
            catch (System.Exception ex)
            {
                this.Rollback();

                this.MessageBox(ex);

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Update, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.SystemError), this.PageName, ex.Message);
            }
            finally
            {
                this.HiddenRoleWeb.Value = this.HiddenDepts.Value = string.Empty;

                para = null;

                this.CloseConnTransac();

                this.WriteLog(string.Format("修改角色權限結束"));
            }
        }
        /// <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();
            }
        }
示例#21
0
        /// <summary>
        ///
        /// </summary>
        private void LoadLogs()
        {
            Dictionary <string, string> logs = this.ViewState["Logs"] != null ? (Dictionary <string, string>) this.ViewState["Logs"] : null;

            StringBuilder sb = new StringBuilder();

            try
            {
                this.WriteLog(string.Format("查詢系統記錄"));

                if (logs == null)
                {
                    logs = new Dictionary <string, string>();

                    if (!String.IsNullOrEmpty(this.ddlDate.SelectedValue))
                    {
                        string name = string.Format("push_server_{0}.log", this.ddlDate.SelectedValue);

                        string path = Path.Combine(this.MyLog.DirectoryPath, name);

                        if (File.Exists(path))
                        {
                            logs.Add(name.HtmlEncode(), path.HtmlEncode());
                        }
                    }
                    else
                    {
                        DirectoryInfo dirInfo = new DirectoryInfo(this.MyLog.DirectoryPath);

                        FileInfo[] files = dirInfo.GetFiles(string.Format("push_server_*.log"));

                        if (files.Length > 0)
                        {
                            for (int i = files.Length - 1; i >= 0; i--)
                            {
                                string name = files[i].Name;

                                string path = files[i].FullName;

                                string date = name.Replace(files[i].Extension, "").Replace("push_server_", "");

                                logs.Add(name.HtmlEncode(), path.HtmlEncode());

                                DirectoryInfo dirBackupInfo = new DirectoryInfo(this.MyLog.BackupDirectoryPath);

                                FileInfo[] filesBackup = dirInfo.GetFiles(string.Format("push_server_{0}_*.log", date));

                                for (int i2 = 0; i2 < filesBackup.Length; i2++)
                                {
                                    logs.Add(filesBackup[i2].Name, filesBackup[i2].FullName);
                                }

                                filesBackup = null; dirBackupInfo = null;
                            }
                        }
                        files = null; dirInfo = null;

                        GC.Collect(); GC.WaitForPendingFinalizers();
                    }
                    this.ViewState["Logs"] = logs;
                }
                sb.Append(string.Format("<table id=\"tb_Logs\" 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;\">"));

                sb.Append(string.Format("<tr>"));
                sb.Append(string.Format("   <th>名稱</th>"));
                sb.Append(string.Format("   <th>下載</th>"));
                sb.Append(string.Format("</tr>"));

                foreach (string key in logs.Keys)
                {
                    sb.Append(string.Format("<tr>"));
                    sb.Append(string.Format("   <th>{0}</th>", key.HtmlEncode()));
                    sb.Append(string.Format("   <th><a target=\"_blank\" href=\"DownloadFile.aspx?path={0}\">下載</a></th>", logs[key].ToString().EncryptDES()));
                    sb.Append(string.Format("</tr>"));
                }
                sb.AppendLine(string.Format("</table>"));

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Query, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.SystemError), this.PageName, !String.IsNullOrEmpty(this.ddlDate.SelectedValue) ? string.Format("查詢:{0}", this.ddlDate.SelectedValue) : string.Empty);
            }
            catch (System.Exception ex)
            {
                this.MessageBox(ex);

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Query, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.SystemError), this.PageName, ex.Message);
            }
            finally
            {
                this.WriteLog(string.Format("系統記錄結束"));
            }
            string html = sb.ToString().HtmlEncode();

            this.LiteralLogs.Text = html.HtmlDecode();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            DataTable dt_User = null;

            int result = -1;

            try
            {
                string role_id = this.ddlRole.SelectedValue;

                string group_id = this.ddlDept.SelectedValue;

                if (String.IsNullOrEmpty(role_id) || String.IsNullOrEmpty(group_id))
                {
                    return;
                }

                string role_name = this.ddlRole.SelectedItem.Text;

                this.WriteLog(string.Format("準備新增角色成員 ({0})", this.txtUserAccount.Text.Trim()));

                strSql = this.Select.US(null, this.txtUserAccount.Text.Trim(), null, group_id, "0", ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

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

                string acct_id = dt_User.Rows.Count > 0 ? dt_User.Rows[0]["acct_id"].ToString().Trim() : string.Empty;

                if (String.IsNullOrEmpty(acct_id))
                {
                    if (!String.IsNullOrEmpty(group_id) && Utility.WebConfig.LoginMode.Equals(1))
                    {
                        #region AggregateInquiry
                        try
                        {
                            SoapResult soapDepartmentResult = null;

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

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

                            strSql = this.Select.Group(group_id, null, null, null, ref para);

                            #region SQL Debug

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

                            this.WriteLog(para.ToLog());

                            #endregion

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

                            if (!String.IsNullOrEmpty(group_code))
                            {
                                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)
                                {
                                    for (int i = 0; i < soapDepartmentResult.Info.Count; i++)
                                    {
                                        XmlNode xmlNodeUserInfo = soapDepartmentResult.Info[i];

                                        string acct_account2 = xmlNodeUserInfo.SelectSingleNode("./cg:Id", soapDepartmentResult.Mgr).InnerText.Trim();

                                        string acct_name2 = xmlNodeUserInfo.SelectSingleNode("./cg:DisplayName", soapDepartmentResult.Mgr).InnerText.Trim();

                                        string acct_type2 = xmlNodeUserInfo.SelectSingleNode("./cg:Title", soapDepartmentResult.Mgr).InnerText.Trim();

                                        if (!acct_account2.Equals(this.txtUserAccount.Text.Trim()))
                                        {
                                            continue;
                                        }
                                        try
                                        {
                                            strSql = this.Select.AccountType(acct_type2, ref para);

                                            #region SQL Debug

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

                                            this.WriteLog(para.ToLog());

                                            #endregion

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

                                            this.WriteLog(string.Format("Type:{0}={1}", acct_type2, type2));

                                            strSql = this.Insert.LandBack_Account(acct_account2, acct_name2, type2, ref para);

                                            #region SQL Debug

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

                                            this.WriteLog(para.ToLog());

                                            #endregion

                                            object acct_id_temp2 = this.DBConnTransac.GeneralSqlCmd.ExecuteItentity(strSql, para);

                                            this.WriteLog(string.Format("同步單位新增使用者:{0}", acct_id_temp2 == null ? "Fail" : "Pass"));

                                            if (acct_id_temp2 == null)
                                            {
                                                this.Rollback();

                                                this.MessageBox(Mode.LogMode.ERROR, message = string.Format("同步單位新增使用者失敗"));

                                                this.MyMonitor.LogMonitor(this, MonitorActionMode.Add, null, CaptionMode.Get(CaptionLib.Mode.AddFail), this.PageName, string.Format("Account:{1}\r\n{0}", message, acct_account2)); return;
                                            }
                                            string acct_id_2 = acct_id_temp2.ToString();

                                            strSql = this.Insert.LandBack_AccountExt(acct_id_2, ref para);

                                            #region SQL Debug

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

                                            this.WriteLog(para.ToLog());

                                            #endregion

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

                                            this.WriteLog(string.Format("同步單位新增使用者失敗(Ext):{0}", result.Equals(0) ? "Fail" : "Pass"));

                                            if (result.Equals(0))
                                            {
                                                this.Rollback();

                                                this.MessageBox(Mode.LogMode.ERROR, message = string.Format("同步單位新增使用者失敗(Ext)"));

                                                this.MyMonitor.LogMonitor(this, MonitorActionMode.Add, null, CaptionMode.Get(CaptionLib.Mode.AddFail), this.PageName, string.Format("Account:{1}\r\n{0}", message, acct_account2)); return;
                                            }
                                            strSql = this.Insert.LandBack_AccountGroup(acct_id_2, group_id, ref para);

                                            #region SQL Debug

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

                                            this.WriteLog(para.ToLog());

                                            #endregion

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

                                            this.WriteLog(string.Format("同步單位新增使用者失敗(Group):{0}", result.Equals(0) ? "Fail" : "Pass"));

                                            if (result.Equals(0))
                                            {
                                                this.Rollback();

                                                this.MessageBox(Mode.LogMode.ERROR, message = string.Format("同步單位新增使用者失敗(Group)"));

                                                this.MyMonitor.LogMonitor(this, MonitorActionMode.Add, null, CaptionMode.Get(CaptionLib.Mode.AddFail), this.PageName, string.Format("Account:{1}\r\n{0}", message, acct_account2)); return;
                                            }
                                            this.WriteLog(message = string.Format("Account:{0}\r\n同步帳號至資料庫完成", acct_account2));
                                        }
                                        catch (System.Exception ex)
                                        {
                                            this.WriteLog(Log.Mode.LogMode.ERROR, string.Format("btnAdd_Click.AggregateInquiry.Exception::\r\n{0}", ex.ToString()));
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            this.WriteLog(Log.Mode.LogMode.ERROR, string.Format("btnAdd_Click.AggregateInquiry.Exception::\r\n{0}", ex.ToString()));
                        }
                        #endregion

                        strSql = this.Select.US(null, this.txtUserAccount.Text.Trim(), null, group_id, "0", ref para);

                        #region SQL Debug

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

                        this.WriteLog(para.ToLog());

                        #endregion

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

                        acct_id = dt_User.Rows.Count > 0 ? dt_User.Rows[0]["acct_id"].ToString().Trim() : string.Empty;
                    }

                    if (String.IsNullOrEmpty(acct_id))
                    {
                        this.Rollback();

                        this.MessageBox(Mode.LogMode.ERROR, message = string.Format("查無該使用者編號 ({0})", this.txtUserAccount.Text.Trim().HtmlEncode()));

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

                        return;
                    }
                }
                string acct_name = dt_User.Rows[0]["acct_name"].ToString().Trim();

                string acct_status = dt_User.Rows[0]["acct_status"].ToString().Trim();

                if (!acct_status.Equals("0"))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("使用者非啟用狀態 ({0} ({1}))", acct_name.HtmlEncode(), this.txtUserAccount.Text.Trim().HtmlEncode()));

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

                    return;
                }
                if (role_id.Equals("-1"))
                {
                    strSql = this.Select.DefaultRole(this.txtUserAccount.Text.Trim(), ref para);

                    #region SQL Debug

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

                    this.WriteLog(para.ToLog());

                    #endregion

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

                    if (String.IsNullOrEmpty(role_id))
                    {
                        this.Rollback();

                        this.MessageBox(Mode.LogMode.ERROR, message = string.Format("該使用者沒有預設的角色 ({0})", this.txtUserAccount.Text.Trim().HtmlEncode()));

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

                        return;
                    }
                }
                int verify_status = 1;

                string detail = JsonConvert.SerializeObject(new VerifyInfo()
                {
                    RoleID = role_id, RoleName = role_name.EncryptBase64(), AcctID = acct_id, AcctName = acct_name.EncryptBase64(), CreaterID = this.SessionMgr.UserInfos.UserID, CreaterName = this.SessionMgr.UserInfos.RealName, VerifyStatus = verify_status
                });

                this.WriteLog(detail);

                string status = this.CheckVerify(group_id, acct_id);

                if (!String.IsNullOrEmpty(status))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("該使用者目前已在審核階段【{0}】", status.GetVerifyStatusCH()));

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

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

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

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

                if (dt_User.Rows.Count > 0)
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("該使用者已有指派角色 ({0})", dt_User.Rows[0]["acct_role_role_name"].ToString().HtmlEncode()));

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

                    return;
                }
                strSql = this.Insert.Verify("1", detail.EncryptBase64(), verify_status.ToString(), this.SessionMgr.UserInfos.UserID, 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, message = string.Format("新增送審失敗 {0}", detail.HtmlEncode()));

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

                    return;
                }
                this.WriteLog(message = string.Format("新增送審角色成員 {0}", detail.HtmlEncode()));

                this.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MessageBox(Mode.LogMode.INFO, string.Format("新增送審成功"));

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

                this.MessageBox(ex);

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

                para = null;

                this.CloseConnTransac();

                this.WriteLog(string.Format("新增角色成員結束"));
            }
        }
示例#23
0
        /// <summary>
        ///
        /// </summary>
        private void LoadData()
        {
            List <IDataParameter> para = null;

            DataTable dt = null;

            string strSql = string.Empty;

            try
            {
                strSql = this.Select.Group(this.UID, null, 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.Rows.Count == 0)
                {
                    throw new Exception(string.Format("資料取得失敗"));
                }

                this.lblInfo.InnerText = string.Format("{0}-{1}", dt.Rows[0]["group_code"].ToString().Trim(), dt.Rows[0]["group_name"].ToString().Trim());

                this.txtGroupCode.Text = dt.Rows[0]["group_code"].ToString().Trim();

                this.txtGroupName.Text = dt.Rows[0]["group_name"].ToString().Trim();

                this.ViewState["group_status"] = dt.Rows[0]["group_status"].ToString().Trim();
            }
            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 btnDelete_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            DataTable dt_User = null;

            try
            {
                string role_id = this.ddlRole.SelectedValue;

                string group_id = this.ddlDept.SelectedValue;

                if (String.IsNullOrEmpty(role_id) || String.IsNullOrEmpty(group_id))
                {
                    return;
                }

                string role_name = this.ddlRole.SelectedItem.Text;

                this.WriteLog(string.Format("刪除角色成員"));

                strSql = this.Select.US(null, this.txtUserAccount.Text.Trim(), null, group_id, "0", ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

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

                string acct_id = dt_User.Rows.Count > 0 ? dt_User.Rows[0]["acct_id"].ToString().Trim() : string.Empty;

                if (String.IsNullOrEmpty(acct_id))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("查無該使用者編號 ({0})", this.txtUserAccount.Text.Trim().HtmlEncode()));

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

                    return;
                }
                int verify_status = 3;

                string acct_name = dt_User.Rows[0]["acct_name"].ToString().Trim();

                string detail = JsonConvert.SerializeObject(new VerifyInfo()
                {
                    RoleID = role_id, RoleName = role_name.EncryptBase64(), AcctID = acct_id, AcctName = acct_name.EncryptBase64(), CreaterID = this.SessionMgr.UserInfos.UserID, CreaterName = this.SessionMgr.UserInfos.RealName, VerifyStatus = verify_status
                });

                this.WriteLog(detail);

                string status = this.CheckVerify(group_id, acct_id);

                if (!String.IsNullOrEmpty(status))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("該使用者目前已在審核階段【{0}】", status.GetVerifyStatusCH()));

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

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

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

                if (!this.DBConnTransac.GeneralSqlCmd.ExecuteScalar(strSql, para))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("該使用者目前沒有任何角色,無法進行刪除"));

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

                    return;
                }
                strSql = this.Insert.Verify("1", detail.EncryptBase64(), verify_status.ToString(), this.SessionMgr.UserInfos.UserID, 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, message = string.Format("刪除送審失敗 {0}", detail.HtmlEncode()));

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

                    return;
                }
                this.WriteLog(message = string.Format("刪除送審角色成員 {0}", detail.HtmlEncode()));

                this.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MessageBox(Mode.LogMode.INFO, string.Format("刪除送審成功"));

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

                this.MessageBox(ex);

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Delete, 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 btnExport_Click(object sender, EventArgs e)
        {
            string where = this.QueryConditions(new List <string[]>
            {
                new string[] { this.lblStartDate.InnerText, this.txtStartDate.Text.Trim() },
                new string[] { this.lblEndDate.InnerText, this.txtEndDate.Text.Trim() },
                new string[] { this.lblWebName.InnerText, this.ddlWebName.SelectedValue },
                new string[] { this.lblCaption.InnerText, this.ddlCaption.SelectedValue },
                new string[] { this.lblActionMode.InnerText, this.ddlActionMode.SelectedValue, },
                new string[] { this.lblUserAccount.InnerText, this.txtUserAccount.Text.Trim() },
                new string[] { this.lblUserIP.InnerText, this.txtUserIP.Text.Trim() }
            });
            string caption = CaptionMode.Get(CaptionLib.Mode.Export);

            DataTable dt = null;

            List <IDataParameter> para = null;

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

            try
            {
                this.WriteLog(string.Format("準備匯出"));

                strSql = this.Select.LogsForExcel(
                    DateTime.Parse(this.txtStartDate.Text).ToString("yyyy/MM/dd 00:00:00"),
                    DateTime.Parse(this.txtEndDate.Text).ToString("yyyy/MM/dd 23:59:59"),
                    this.ddlWebName.SelectedValue,
                    this.ddlCaption.SelectedValue,
                    this.ddlActionMode.SelectedValue,
                    this.txtUserAccount.Text.Trim(),
                    this.txtUserIP.Text.Trim(),
                    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.Rows.Count > 65535)
                {
                    this.MessageBox("發生錯誤", message = string.Format("匯出的資料大於65535筆,請改變條件縮小資料量")); return;
                }
                message = string.Format("{0}\r\n匯出結果共{1}筆", where, dt != null ? dt.Rows.Count : 0);

                dt.ToExcal(this, string.Format("SystemLogs_{0}", DateTime.Now.ToString("yyyyMMdd")));
            }
            catch (System.Exception ex) { this.WriteLog(Log.Mode.LogMode.ERROR, ex.ToString()); this.MessageBox("發生錯誤", string.Format("系統發生錯誤\r\n{0}", ex.Message)); caption = CaptionMode.Get(CaptionLib.Mode.ExportFail); }
            finally
            {
                dt = null;

                this.CloseConn();

                this.WriteLog(string.Format("匯出結束"));

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Export, this.SessionMgr.UserInfos.UserID, caption, this.PageName, message);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlDept_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

            string strSql = string.Empty;

            DataTable dt = null;

            try
            {
                this.ddlRole.Items.Clear();

                this.WriteLog(string.Format("載入角色清單:{0}", this.ddlDept.SelectedValue));

                if (String.IsNullOrEmpty(this.ddlDept.SelectedValue))
                {
                    return;
                }

                strSql = this.Select.GroupRoles(this.ddlDept.SelectedValue, ref para);

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

                this.ddlRole.Items.Add(new ListItem()
                {
                    Text = "系統預設", Value = "-1"
                });

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    this.ddlRole.Items.Add(new ListItem()
                    {
                        Text = Server.HtmlEncode(dt.Rows[i]["role_name"].ToString().Trim()), Value = Server.HtmlEncode(dt.Rows[i]["role_group_role_id"].ToString().Trim())
                    });
                }
            }
            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();

                this.WriteLog(string.Format("載入角色清單結束"));
            }
        }
        /// <summary>
        ///
        /// </summary>
        private void LoadData()
        {
            try
            {
                bool check = false;

                string url = this.GetSystemSetting("PublicURIPrefix");

                if (!url.EndsWith("/") && !url.EndsWith(@"\"))
                {
                    url += "/";
                }

                string connect_test_url = url + "ConnectTest";

                string http_result = connect_test_url.WebRequest(UtilityExtensions.RequestMode.GET, null);

                check = http_result.StartsWith("OK");

                imgFileServerStatus.Src = check ? "images/sys_pass.png" : "images/sys_fail.png";

                this.lblFileServerStatus.InnerText = check ? "已連線" : "斷線";

                this.lblFileServerStatus.Attributes.Add("style", string.Format("color:#{0}", check ? "0000FF" : "FF0000"));

                url = this.GetSystemSetting("PushGatewayURL");

                if (!url.EndsWith("/") && !url.EndsWith(@"\"))
                {
                    url += "/";
                }

                connect_test_url = url + "ConnectTest";

                http_result = connect_test_url.WebRequest(UtilityExtensions.RequestMode.GET, null);

                check = http_result.StartsWith("OK");

                imgPushGatewayStatus.Src = check ? "images/sys_pass.png" : "images/sys_fail.png";

                this.lblPushGatewayStatus.InnerText = check ? "已連線" : "斷線";

                this.lblPushGatewayStatus.Attributes.Add("style", string.Format("color:#{0}", check ? "0000FF" : "FF0000"));
            }
            catch (System.Exception ex) { this.WriteLog(Log.Mode.LogMode.ERROR, ex.ToString()); this.MessageBox("發生錯誤", string.Format("系統發生錯誤\r\n{0}", ex.Message)); }
            finally
            {
                this.MyMonitor.LogMonitor(this, MonitorActionMode.Load, this.SessionMgr.UserInfos.UserID, CaptionMode.Get(CaptionLib.Mode.Load), this.PageName, string.Empty, true);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="Anew"></param>
        public void DataBind2(bool Anew)
        {
            if (!this.QueryPermissions)
            {
                return;
            }

            if (String.IsNullOrEmpty(this.txtStartDate.Text) || String.IsNullOrEmpty(this.txtEndDate.Text))
            {
                this.txtStartDate.Text = DateTime.Now.AddDays(-14).ToString("yyyy/MM/dd");

                this.txtEndDate.Text = DateTime.Now.ToString("yyyy/MM/dd");
            }
            string start_date_time = string.Format("{0} {1}:{2}:00", this.txtStartDate.Text.HtmlEncode(), this.ddlStartDateHour.SelectedValue, this.ddlStartDateMinute.SelectedValue);

            string end_date_time = string.Format("{0} {1}:{2}:00", this.txtEndDate.Text.HtmlEncode(), this.ddlEndDateHour.SelectedValue, this.ddlEndDateMinute.SelectedValue);

            string where = this.QueryConditions(new List <string[]>
            {
                new string[] { this.lblStartDate.InnerText, start_date_time },
                new string[] { this.lblEndDate.InnerText, end_date_time },
            });

            int data_mode = Convert.ToInt16(this.ddlData.SelectedValue);

            List <int> status_list = new List <int>();

            if (this.chBoxSendStatus1.Checked)
            {
                status_list.Add(Convert.ToInt16(this.chBoxSendStatus1.Value));
            }
            if (this.chBoxSendStatus2.Checked)
            {
                status_list.Add(Convert.ToInt16(this.chBoxSendStatus2.Value));
            }
            if (this.chBoxSendStatus3.Checked)
            {
                status_list.Add(Convert.ToInt16(this.chBoxSendStatus3.Value));
            }
            if (this.chBoxSendStatus4.Checked)
            {
                status_list.Add(Convert.ToInt16(this.chBoxSendStatus4.Value));
            }

            string caption = CaptionMode.Get(CaptionLib.Mode.Query);

            try
            {
                this.WriteLog(string.Format("準備查詢"));

                List <LinkButton> pageLinkButton = new List <LinkButton>();
                pageLinkButton.Add(this.btnFirst_GridView1);
                pageLinkButton.Add(this.btnPrev_GridView1);
                pageLinkButton.Add(this.btnNext_GridView1);
                pageLinkButton.Add(this.btnLast_GridView1);

                string strSql = string.Empty;

                DataTable dt = null;

                List <IDataParameter> para = null;

                if (Anew)
                {
                    strSql = data_mode.Equals(0) ? this.Select.Report005_Total(start_date_time, end_date_time, this.txtAppID.Text, this.txtContent.Text, this.txtMsgID.Text, status_list, ref para) : this.Select.Report005_Arc_Total(start_date_time, end_date_time, this.txtAppID.Text, this.txtContent.Text, this.txtMsgID.Text, status_list, ref para);

                    #region SQL Debug

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

                    this.WriteLog(para.ToLog());

                    #endregion

                    ViewState["Total"] = Convert.ToInt32(this.DBConn.GeneralSqlCmd.ExecuteByColumnName(strSql, para, "Total"));

                    ViewState["PageIndex"] = 1;

                    ViewState["StartIndex"] = 1;

                    ViewState["EndIndex"] = Convert.ToInt32(ViewState["PageIndex"]) * this.GridView1.PageSize;
                }
                strSql = data_mode.Equals(0) ? this.Select.Report005(start_date_time, end_date_time, this.txtAppID.Text, this.txtContent.Text, this.txtMsgID.Text, status_list, Convert.ToInt32(ViewState["StartIndex"]), Convert.ToInt32(ViewState["EndIndex"]), this.GridView1.Attributes[GridViewExtensions.SortBy], ref para) : this.Select.Report005_Arc(start_date_time, end_date_time, this.txtAppID.Text, this.txtContent.Text, this.txtMsgID.Text, status_list, Convert.ToInt32(ViewState["StartIndex"]), Convert.ToInt32(ViewState["EndIndex"]), this.GridView1.Attributes[GridViewExtensions.SortBy], ref para);

                #region SQL Debug

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

                this.WriteLog(para.ToLog());

                #endregion

                this.DBConn.GeneralSqlCmd.Command.CommandTimeout = 90;

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

                para = null;

                this.divPageLayer_GridView1.Visible = Convert.ToInt32(ViewState["Total"]) > 0;

                this.GridView1.DataBind(dt, Convert.ToInt32(ViewState["Total"]), Convert.ToInt32(ViewState["StartIndex"]), Convert.ToInt32(ViewState["EndIndex"]), Anew, LockPageNum, this.lblTotalPage_GridView1, this.lblPage_GridView1, pageLinkButton);
            }
            catch (System.Exception ex) { this.WriteLog(Log.Mode.LogMode.ERROR, ex.ToString()); this.MessageBox("發生錯誤", string.Format("系統發生錯誤\r\n{0}", ex.Message)); caption = CaptionMode.Get(CaptionLib.Mode.QueryFail); }
            finally
            {
                this.CloseConn();

                this.WriteLog(string.Format("查詢結束"));

                this.MyMonitor.LogMonitor(this, MonitorActionMode.Query, this.SessionMgr.UserInfos.UserID, caption, this.PageName, string.Format("{0}\r\n查詢結果共{1}筆\r\n當前為第{2}頁", where, ViewState[this.GridView1.ClientID] != null ? ((DataTable)ViewState[this.GridView1.ClientID]).Rows.Count : 0, (this.GridView1.PageIndex + 1).ToString()));
            }
        }
        /// <summary>
        ///
        /// </summary>
        private void UpdatePushMessage(PushMessageMode Status)
        {
            string uid = this.RequestQueryString("uid").DecryptDES();

            List <IDataParameter> para = null;

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

            Hashtable ht = new Hashtable();

            DataTable dt = null;

            try
            {
                this.WriteLog(string.Format("修改推播訊息({0})", Status.GetPushMessageCH()));

                bool send_now = this.sendMode1.Checked;

                DateTime send_time = DateTime.Parse(string.Format("{0} {1}:{2}:00", this.txtSendDate.Text, this.ddlHour.SelectedValue, this.ddlMinute.SelectedValue));

                strSql = this.Update.PushMessage(this.UID, "3", "0", send_now, send_now ? string.Empty : send_time.ToString("yyyy/MM/dd HH:mm:ss"), (int)Status, this.SessionMgr.UserInfos.UserID, 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(0))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("修改{0}失敗", Status.GetPushMessageCH()));

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

                    return;
                }
                string[] push_list = this.chBoxCustList.Checked && !String.IsNullOrEmpty(this.HiddenPushListName.Value) ? this.HiddenPushListName.Value.Split('|') : null;

                string json = string.Empty;

                if (push_list != null)
                {
                    strSql = this.Select.UserDeviceToken(push_list, 0, string.Empty, ref para);

                    #region SQL Debug

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

                    this.WriteLog(para.ToLog());

                    #endregion

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

                    StringBuilder sb = new StringBuilder();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        StringBuilder sb_item = new StringBuilder();

                        sb_item.Append(string.Format("{0}<", i == 0 ? " " : " ,"));

                        for (int i2 = 0; i2 < dt.Columns.Count; i2++)
                        {
                            string column_name = dt.Columns[i2].ColumnName;

                            sb_item.Append(string.Format("{0}\"{1}\" : \"{2}\""
                                                         , i2 == 0 ? " " : " ,"
                                                         , column_name.ToLower()
                                                         , dt.Rows[i][column_name].ToString().EncryptBase64()
                                                         ));
                        }
                        sb_item.Append(">");

                        sb.AppendLine(sb_item.ToString().Replace("<", "{").Replace(">", "}"));
                    }
                    json = "{ \"Changingtec\": { \"sendList\": [" + sb.ToString() + "] }}";
                }
                string old_file_name = this.ViewState["PushImageName"].ToString();

                bool upload_image = !String.IsNullOrEmpty(this.HiddenPushImageName.Value) && !this.HiddenPushImageName.Value.Equals(old_file_name);

                if (upload_image && !String.IsNullOrEmpty(this.HiddenPushImageBody.Value))
                {
                    string file_body = this.HiddenPushImageBody.Value;

                    string publicURIPrefix = this.HiddenPublicURIPrefix.Value;

                    if (!publicURIPrefix.EndsWith("/") && !publicURIPrefix.EndsWith(@"\"))
                    {
                        publicURIPrefix += "/";
                    }

                    string connect_test_url = publicURIPrefix + "ConnectTest";

                    string http_result = connect_test_url.WebRequest(UtilityExtensions.RequestMode.GET, null);

                    if (!http_result.Equals("OK"))
                    {
                        throw new Exception(string.Format("File Server 連線失敗::\r\n{0}", http_result));
                    }

                    string upload_file_url = publicURIPrefix + "UploadFile";

                    string parameter = string.Format("opUser={0}&opPassword={1}&b64FileContent={2}"
                                                     , Utility.WebConfig.OP_USER
                                                     , Utility.WebConfig.OP_PASS
                                                     , file_body);

                    http_result = upload_file_url.WebRequest(UtilityExtensions.RequestMode.POST, parameter);

                    JSONResonse json_result = JsonConvert.DeserializeObject <JSONResonse>(http_result);

                    if (!json_result.ReturnCode.Equals(0))
                    {
                        throw new Exception(string.Format("檔案上傳失敗::\r\n{0}", json_result.Message.DecryptBase64()));
                    }

                    this.ViewState["PushImageName"] = this.HiddenPushImageName.Value = json_result.Result;

                    if (!String.IsNullOrEmpty(old_file_name))
                    {
                        string delete_file_url = publicURIPrefix + string.Format("{0}?opUser={1}&opPassword={2}&fileHandle={3}"
                                                                                 , "DeleteFile"
                                                                                 , Utility.WebConfig.OP_USER
                                                                                 , Utility.WebConfig.OP_PASS
                                                                                 , old_file_name.DecryptBase64());

                        http_result = delete_file_url.WebRequest(UtilityExtensions.RequestMode.GET, null);

                        this.WriteLog(string.Format("DeleteFile:{0}", http_result));
                    }
                }
                ht.Add("msg_id", this.UID);
                ht.Add("msg_push_title", this.txtPushTitle.Text.Trim());
                ht.Add("msg_push_content", this.txtPushBody.Text.Trim());
                ht.Add("msg_push_hyperlink", this.txtPushHyperlink.Text.Trim());
                ht.Add("msg_push_image", this.HiddenPushImageName.Value.DecryptBase64());
                ht.Add("msg_push_is_private", "0");
                ht.Add("msg_push_os_type", String.IsNullOrEmpty(this.ddlOS.SelectedValue) ? "0" : this.ddlOS.SelectedValue);
                ht.Add("msg_push_app_identifier", this.HiddenAppName.Value.Trim());
                ht.Add("msg_push_recp_list", this.chBoxCustList.Checked ? string.Format("{0}|{1}", this.HiddenPushListName.Value.EncryptBase64(), this.HiddenPushListBody.Value) : string.Empty);
                ht.Add("msg_push_recp_bind_info", json);
                ht.Add("msg_push_type_identifier", String.IsNullOrEmpty(this.ddlType.SelectedValue) ? "0" : this.ddlType.SelectedItem.Text.Split('-')[0]);

                strSql = this.Update.PushMessageDetail(ht, 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(0))
                {
                    this.Rollback();

                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("修改{0}細節資料失敗", Status.GetPushMessageCH()));

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

                    return;
                }
                this.DBConnTransac.GeneralSqlCmd.Transaction.Commit();

                this.MessageBox(Mode.LogMode.INFO, message = string.Format("修改{0}成功", Status.GetPushMessageCH()));

                message += string.Format(",訊息編號:{0}", this.ViewState["IDF"].ToString());

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

                this.LoadData();
            }
            catch (System.Exception ex)
            {
                this.Rollback();

                this.MessageBox(ex);

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

                ht = null;

                para = null;

                this.CloseConnTransac();

                this.WriteLog(string.Format("修改推播訊息結束({0})", Status.GetPushMessageCH()));
            }
        }
示例#30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnReject_Click(object sender, EventArgs e)
        {
            List <IDataParameter> para = null;

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

            try
            {
                this.WriteLog(string.Format("開始退回推播訊息"));

                strSql = this.Update.PushMessageStatus(this.UID, "4", ref para);

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

                if (result.Equals(0))
                {
                    this.MessageBox(Mode.LogMode.ERROR, message = string.Format("退回推播訊息失敗,推播申請單號:{0}", this.lblID.Text.HtmlEncode()));

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

                    return;
                }
                this.MessageBox(Mode.LogMode.INFO, message = string.Format("退回完成,推播申請單號:{0}", this.lblID.Text.HtmlEncode()));

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

                this.LoadData();
            }
            catch (System.Exception ex)
            {
                this.MessageBox(ex);

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

                this.CloseConn();

                this.WriteLog(string.Format("退回推播訊息結束"));
            }
        }