/// <summary>
        ///
        /// </summary>
        /// <param name="CODE"></param>
        /// <param name="SYSAP"></param>
        /// <param name="SESSION_KEY"></param>
        /// <param name="COMMENTS"></param>
        public void DBLog(SysCode CODE, string SYSAP, string SESSION_KEY, string COMMENTS)
        {
            string strSql = string.Empty;

            List <IDataParameter> para = null;

            DBLib.DBConn dbConn = null;
            try
            {
                if (this.XDocSetting == null || String.IsNullOrEmpty(this.XDocSetting.Root.Element("ConnectionString").Value))
                {
                    this.WriteLog(Mode.LogMode.ERROR, string.Format("設定檔有錯")); return;
                }
                dbConn = new DBLib.DBConn(new DBLibUtility.Mode.FreeMode()
                {
                    APMode           = DBLibUtility.Mode.APMode.Window,
                    DBMode           = DBLibUtility.Mode.DBMode.MSSQL,
                    ConnectionString = this.XDocSetting.Root.Element("ConnectionString").Value.DecryptDES()
                });
                strSql = this.Insert.SYSLOG(CODE, SYSAP, SESSION_KEY, this.GetHostIPAddress(), System.Environment.MachineName, COMMENTS, ref para);

                #region SQL Debug

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

                this.WriteLog(Mode.LogMode.DEBUG, para.ToLog());

                #endregion

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

                this.WriteLog(Mode.LogMode.INFO, string.Format("Result:{0}", result));
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                para = null;

                if (dbConn != null)
                {
                    dbConn.Dispose();
                }

                dbConn = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        public void DBLog(HttpContext Context, SysCode CODE, string SYSAP, string SESSION_KEY, string USERID, string COMMENTS)
        {
            string strSql = string.Empty;

            List <IDataParameter> para = null;

            DBLib.DBConn dbConn = null;
            try
            {
                dbConn = new DBLib.DBConn(new DBLibUtility.Mode.FreeMode()
                {
                    APMode           = DBLibUtility.Mode.APMode.Web,
                    DBMode           = DBLibUtility.Mode.DBMode.MSSQL,
                    ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString().DecryptDES()
                });
                strSql = this.Insert.SYSLOG(CODE, SYSAP, SESSION_KEY, this.GetClientIPv4(), USERID, COMMENTS, ref para);

                #region SQL Debug

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

                this.WriteLog(Log.Mode.LogMode.DEBUG, Context, para.ToLog());

                #endregion

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

                this.WriteLog(Mode.LogMode.INFO, Context, string.Format("Result:{0}", result));
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                para = null;

                if (dbConn != null)
                {
                    dbConn.Dispose();
                }

                dbConn = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Context"></param>
        /// <param name="Code"></param>
        public void CheckAndCreateTable(HttpContext Context, string YearAndMonth, ref SysCode Code)
        {
            int t = -1;

            SysCode code = SysCode.A000;

            if (String.IsNullOrEmpty(YearAndMonth) || !YearAndMonth.Length.Equals(6) || !int.TryParse(YearAndMonth, out t))
            {
                throw new Utility.ProcessException(string.Format("YM Error"), ref code, SysCode.E004);
            }

            string strSql = string.Empty;

            bool check = false;

            List <IDataParameter> para = null;

            DBLib.DBConn dbConn = null;
            try
            {
                dbConn = new DBLib.DBConn(new DBLibUtility.Mode.FreeMode()
                {
                    APMode           = DBLibUtility.Mode.APMode.Web,
                    DBMode           = DBLibUtility.Mode.DBMode.MSSQL,
                    ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString().DecryptDES()
                });

                #region CHECK_CASETABLE

                strSql = this.Select.CHECK_CASETABLE(YearAndMonth, ref para);

                #region SQL Debug

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

                this.WriteLog(Log.Mode.LogMode.DEBUG, Context, para.ToLog());

                #endregion

                check = dbConn.GeneralSqlCmd.ExecuteScalar(strSql, para);

                this.WriteLog(Context, string.Format("Result:{0}", check));

                if (!check)
                {
                    strSql = string.Format("Execute createCaseTable '{0}'", YearAndMonth);

                    #region SQL Debug

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

                    this.WriteLog(Log.Mode.LogMode.DEBUG, Context, para.ToLog());

                    #endregion

                    dbConn.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    strSql = this.Select.CHECK_CASETABLE(YearAndMonth, ref para);

                    #region SQL Debug

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

                    this.WriteLog(Log.Mode.LogMode.DEBUG, Context, para.ToLog());

                    #endregion

                    check = dbConn.GeneralSqlCmd.ExecuteScalar(strSql, para);

                    this.WriteLog(Context, string.Format("Result:{0}", check));

                    if (!check)
                    {
                        throw new Exception(string.Format("新增CASE_TABLE_{0}失敗", check));
                    }
                }
                #endregion

                #region CHECK_FILETABLE

                strSql = this.Select.CHECK_FILETABLE(YearAndMonth, ref para);

                #region SQL Debug

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

                this.WriteLog(Log.Mode.LogMode.DEBUG, Context, para.ToLog());

                #endregion

                check = dbConn.GeneralSqlCmd.ExecuteScalar(strSql, para);

                this.WriteLog(Context, string.Format("Result:{0}", check));

                if (!check)
                {
                    strSql = string.Format("Execute createFileTable '{0}'", YearAndMonth);

                    #region SQL Debug

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

                    this.WriteLog(Log.Mode.LogMode.DEBUG, Context, para.ToLog());

                    #endregion

                    dbConn.GeneralSqlCmd.ExecuteNonQuery(strSql, para);

                    strSql = this.Select.CHECK_FILETABLE(YearAndMonth, ref para);

                    #region SQL Debug

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

                    this.WriteLog(Log.Mode.LogMode.DEBUG, Context, para.ToLog());

                    #endregion

                    check = dbConn.GeneralSqlCmd.ExecuteScalar(strSql, para);

                    this.WriteLog(Context, string.Format("Result:{0}", check));

                    if (!check)
                    {
                        throw new Exception(string.Format("新增FILE_TABLE_{0}失敗", check));
                    }
                }
                #endregion
            }
            catch (System.Exception ex)
            {
                throw new Utility.ProcessException(ex.ToString(), ref Code, SysCode.E002);
            }
            finally
            {
                para = null;

                if (dbConn != null)
                {
                    dbConn.Dispose();
                }

                dbConn = null;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Context"></param>
        /// <param name="APIName"></param>
        /// <param name="SessionKey"></param>
        /// <param name="Code"></param>
        public void SendEMail(HttpContext Context, string APIName, string SessionKey, SysCode Code)
        {
            this.InitMailLog("SendEMail");

            this.WriteMailLog(Mode.LogMode.INFO, Context, string.Format("Code::{0}", Code));

            if (Code != SysCode.E002 && Code != SysCode.E003 && Code != SysCode.E005 && Code != SysCode.E999)
            {
                return;
            }

            MailInfo info = new MailInfo();

            DBLib.DBConn dbConn = null;

            DataTable dt = null;

            string strSql = string.Empty;

            try
            {
                dbConn = new DBLib.DBConn(new DBLibUtility.Mode.FreeMode()
                {
                    APMode           = DBLibUtility.Mode.APMode.Web,
                    DBMode           = DBLibUtility.Mode.DBMode.MSSQL,
                    ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString().DecryptDES()
                });
                strSql = this.Select.SMTP();

                #region SQL Debug

                this.WriteMailLog(Context, strSql);

                #endregion

                dt = dbConn.GeneralSqlCmd.ExecuteToDataTable(strSql);

                this.WriteMailLog(Mode.LogMode.INFO, Context, string.Format("SMTP::{0}", dt.Rows.Count));

                if (dt.Rows.Count.Equals(0))
                {
                    return;
                }

                info = new MailInfo()
                {
                    SMTPServer = dt.Select(string.Format("FUNCTION_CODE='{0}'", "SMTP_IP"))[0]["PARAMETER"].ToString(),
                    Port       = Convert.ToInt32(dt.Select(string.Format("FUNCTION_CODE='{0}'", "SMTP_POST"))[0]["PARAMETER"].ToString()),
                    Account    = dt.Select(string.Format("FUNCTION_CODE='{0}'", "SMTP_USER"))[0]["PARAMETER"].ToString(),
                    Password   = dt.Select(string.Format("FUNCTION_CODE='{0}'", "SMTP_PWD"))[0]["PARAMETER"].ToString(),
                    From       = dt.Select(string.Format("FUNCTION_CODE='{0}'", "SMTP_FROM"))[0]["PARAMETER"].ToString(),
                    Address    = dt.Select(string.Format("FUNCTION_CODE='{0}'", "SMTP_ERROR_TO_ADDRESS"))[0]["PARAMETER"].ToString(),
                    Subject    = "eFiling 系統發生錯誤"
                };
                string message = string.Format("案件代碼:{0}<br/>API名稱:{1}<br/>IP:{2}<br/>錯誤代碼:{3}<br/>", SessionKey, APIName, this.GetClientIPv4(), Code.ToString());

                this.SendEMail(Context, info, message, dt.Select(string.Format("FUNCTION_CODE='{0}'", "SMTP_SSL"))[0]["PARAMETER"].ToString().Trim().ToLower().Equals("true"));
            }
            catch (System.Exception ex) { this.WriteMailLog(Mode.LogMode.ERROR, Context, string.Format("SendEMail.Exception::{0}", ex.Message)); throw ex; }
            finally
            {
                dt = null;

                if (dbConn != null)
                {
                    dbConn.Dispose();
                }

                dbConn = null;
            }
        }