Example #1
0
        public void WriteLog_Load(
            string USERNAME, string SESSION_ID, string REQUEST_ID, string MERCHANT_ID
            , string IPADDRESS, string STATUS, string TRANS_ID, string MESSAGE_TYPE_ID
            , string MSISDN, double TRANSACTION_AMOUNT, string CLIENT_ID, string SYSTEM_TRACE_AUDIT_NUMBER
            , string REQUEST_TRANSMISSION_TIME, string RESPONSE_TRANSMISSION_TIME, string RESPONSE_CODE, string NOTE
            , string SERVICE_PROVIDER_CODE
            )
        {
            #region log into text file

            if (strTransactionLogType == "1" || strTransactionLogType == "3")
            {
                string strLogPath        = HttpContext.Current.Server.MapPath("") + "\\Log";
                string strYear           = DateTime.Now.Year.ToString();
                string strMonth          = DateTime.Now.Month.ToString();
                string strDay            = DateTime.Now.Day.ToString();
                string strFileName       = "Log_Load_" + DateTime.Now.ToString("hh") + "h.log";
                string strLogDescription = string.Empty;

                System.IO.DirectoryInfo d1 = new System.IO.DirectoryInfo(strLogPath);
                if (!d1.Exists)
                {
                    d1.Create();
                }
                strLogPath += "\\" + strYear;

                System.IO.DirectoryInfo d2 = new System.IO.DirectoryInfo(strLogPath);
                if (!d2.Exists)
                {
                    d2.Create();
                }
                strLogPath += "\\" + strMonth;

                System.IO.DirectoryInfo d3 = new System.IO.DirectoryInfo(strLogPath);
                if (!d3.Exists)
                {
                    d3.Create();
                }
                strLogPath += "\\" + strDay;

                System.IO.DirectoryInfo d4 = new System.IO.DirectoryInfo(strLogPath);
                if (!d4.Exists)
                {
                    d4.Create();
                }

                strLogPath         = strLogPath + "\\" + strFileName;
                strLogDescription  = USERNAME + "\t" + SESSION_ID + "\t" + REQUEST_ID + "\t" + MERCHANT_ID + "\t";
                strLogDescription += IPADDRESS + "\t" + STATUS + "\t" + TRANS_ID + "\t" + MESSAGE_TYPE_ID + "\t";
                strLogDescription += SERVICE_PROVIDER_CODE + "\t" + MSISDN + "\t" + TRANSACTION_AMOUNT + "\t" + CLIENT_ID + "\t";
                strLogDescription += SYSTEM_TRACE_AUDIT_NUMBER + "\t" + REQUEST_TRANSMISSION_TIME + "\t" + RESPONSE_TRANSMISSION_TIME + "\t" + RESPONSE_CODE + "\t";
                strLogDescription += NOTE + "\t";

                System.IO.FileStream   fs             = new System.IO.FileStream(strLogPath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                System.IO.StreamWriter m_streamWriter = new System.IO.StreamWriter(fs);
                m_streamWriter.BaseStream.Seek(0, System.IO.SeekOrigin.End);
                m_streamWriter.WriteLine(strLogDescription);
                m_streamWriter.Flush();
                m_streamWriter.Close();
            }

            #endregion

            #region log into DB

            if (strTransactionLogType == "2" || strTransactionLogType == "3")
            {
                App_Lib DbObj  = new App_Lib();
                string  strSql = "";
                strSql  = "insert into Transactions(";
                strSql += "  USERNAME, SESSION_ID, REQUEST_ID, MERCHANT_ID";
                strSql += ", IPADDRESS, STATUS, TRANS_ID, MESSAGE_TYPE_ID";
                strSql += ", MSISDN, TRANSACTION_AMOUNT, CLIENT_ID, SYSTEM_TRACE_AUDIT_NUMBER";
                strSql += ", REQUEST_TRANSMISSION_TIME, RESPONSE_TRANSMISSION_TIME, RESPONSE_CODE, NOTE";
                strSql += ", SERVICE_PROVIDER_CODE, CDR_STATUS";
                strSql += " ) ";
                //, Status, ActionDate)";
                strSql += "values(";
                strSql += "'" + USERNAME + "', '" + SESSION_ID + "', '" + REQUEST_ID + "', '" + MERCHANT_ID + "'";
                strSql += " ,'" + IPADDRESS + "', '" + STATUS + "', '" + TRANS_ID + "', '" + MESSAGE_TYPE_ID + "'";
                strSql += " ,'" + MSISDN + "', '" + TRANSACTION_AMOUNT + "', '" + CLIENT_ID + "', '" + SYSTEM_TRACE_AUDIT_NUMBER + "'";
                strSql += " ,TO_DATE('" + REQUEST_TRANSMISSION_TIME + "','mm/dd/yyyy hh:mi:ss PM'), TO_DATE('" + RESPONSE_TRANSMISSION_TIME + "','mm/dd/yyyy hh:mi:ss PM'), '" + RESPONSE_CODE + "', '" + NOTE + "'";
                strSql += " ,'" + SERVICE_PROVIDER_CODE + "', '0'";
                strSql += ")";

                try
                {
                    DbObj.ExecuteQuery(strSql, null, CommandType.Text);
                }
                catch (Exception ex)
                {
                    //throw ex;
                    //HttpContext.Current.Response.Write(strSql);
                    //HttpContext.Current.Response.End();
                    WriteLog("Insert DB failure, ex=" + ex.ToString());
                }
            }

            #endregion
        }
Example #2
0
        public void WriteLog_Load1(string UserName, string Session_ID, string Request_ID, string Trans_ID, string MerchantID, string targetMsIsdn, double Amount, string IPAddress, string Status, bool UpdateType, string Note)
        {
            #region log into text file

            if (strTransactionLogType == "1" || strTransactionLogType == "3")
            {
                string strLogPath        = HttpContext.Current.Server.MapPath("") + "\\Log";
                string strYear           = DateTime.Now.Year.ToString();
                string strMonth          = DateTime.Now.Month.ToString();
                string strDay            = DateTime.Now.Day.ToString();
                string strFileName       = "Log_Load_" + DateTime.Now.ToString("hh") + "h.log";
                string strLogDescription = string.Empty;

                System.IO.DirectoryInfo d1 = new System.IO.DirectoryInfo(strLogPath);
                if (!d1.Exists)
                {
                    d1.Create();
                }
                strLogPath += "\\" + strYear;

                System.IO.DirectoryInfo d2 = new System.IO.DirectoryInfo(strLogPath);
                if (!d2.Exists)
                {
                    d2.Create();
                }
                strLogPath += "\\" + strMonth;

                System.IO.DirectoryInfo d3 = new System.IO.DirectoryInfo(strLogPath);
                if (!d3.Exists)
                {
                    d3.Create();
                }
                strLogPath += "\\" + strDay;

                System.IO.DirectoryInfo d4 = new System.IO.DirectoryInfo(strLogPath);
                if (!d4.Exists)
                {
                    d4.Create();
                }

                strLogPath         = strLogPath + "\\" + strFileName;
                strLogDescription  = UserName + "\t";
                strLogDescription += Session_ID + "\t";
                strLogDescription += Request_ID + "\t";
                strLogDescription += Trans_ID + "\t";
                strLogDescription += MerchantID + "\t";
                strLogDescription += targetMsIsdn + "\t";
                strLogDescription += Amount.ToString() + "\t";
                strLogDescription += IPAddress + "\t";
                strLogDescription += Status.ToString() + "\t";
                strLogDescription += DateTime.Now.ToString("hh:mm:ss:ms:tt") + "\t";
                strLogDescription += Note + "\t";

                System.IO.FileStream   fs             = new System.IO.FileStream(strLogPath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
                System.IO.StreamWriter m_streamWriter = new System.IO.StreamWriter(fs);
                m_streamWriter.BaseStream.Seek(0, System.IO.SeekOrigin.End);
                m_streamWriter.WriteLine(strLogDescription);
                m_streamWriter.Flush();
                m_streamWriter.Close();
            }

            #endregion

            #region log into DB

            if (strTransactionLogType == "2" || strTransactionLogType == "3")
            {
                App_Lib DbObj  = new App_Lib();
                string  strSql = "";
                //If update
                if (UpdateType)
                {
                    strSql = "update Transactions set ConfirmStatus = '" + Status + "', ConfirmDate=sysdate where Trans_ID='" + Trans_ID + "'";
                }
                //Insert
                else
                {
                    strSql  = "insert into Transactions(UserName, Session_ID, Request_ID, Trans_ID, Merchant_ID, targetMsIsdn, Amount, IPAddress, Status, ActionDate)";
                    strSql += "values('" + UserName + "', '" + Session_ID + "', '" + Request_ID + "', '" + Trans_ID + "', '" + MerchantID + "', '" + targetMsIsdn + "', '" + Amount.ToString() + "', '" + IPAddress + "', " + Status.ToString() + ", sysdate)";
                }
                try
                {
                    DbObj.ExecuteQuery(strSql, null, CommandType.Text);
                }
                catch (Exception ex)
                {
                    //throw ex;
                    //HttpContext.Current.Response.Write(strSql);
                    //HttpContext.Current.Response.End();
                    WriteLog("Insert DB failure, ex=" + ex.ToString());
                }
            }

            #endregion
        }