コード例 #1
0
        /// <summary>
        /// Inserts a new Alarm into the alarms table
        /// </summary>
        /// <param name="iSrcId">Source Unit Id</param>
        /// <param name="iDstId">Destine Unit Id</param>
        /// <param name="sType">Message Type Name (m1, m2, ...)</param>
        /// <param name="sIn">Input message body</param>
        /// <param name="sOut">Answer message body</param>
        public void InsertMsg(int iSrcId, int iDstId, string sType, string sIn, string sOut)
        {
            Database          d           = DatabaseFactory.GetDatabase();
            long              id          = GetNewMsgsLogPk();
            AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
            double            nDifHour    = 0;

            try
            {
                nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
            }
            catch
            {
                nDifHour = 0;
            }

            string ssql = "INSERT INTO MSGS_LOG (LMSG_ID, LMSG_SRC_UNI_ID, LMSG_DST_UNI_ID, LMSG_DATE, " +
                          "LMSG_TYPE, LMSG_XML_IN, LMSG_XML_OUT) VALUES (";

            ssql = ssql + "@MSGS_LOG.LMSG_ID@, @MSGS_LOG.LMSG_SRC_UNI_ID@, @MSGS_LOG.LMSG_DST_UNI_ID@, " +
                   "@MSGS_LOG.LMSG_DATE@, @MSGS_LOG.LMSG_TYPE@, @MSGS_LOG.LMSG_XML_IN@, @MSGS_LOG.LMSG_XML_OUT@)";
            d.ExecuteNonQuery(ssql, id, iSrcId, iDstId, DateTime.Now.AddHours(nDifHour), sType, sIn, sOut);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name=""></param>
        /// <returns></returns>
        public int Insert(int iUserID, int iUniID, DateTime dtDate)
        {
            Database       d           = null;                          // Database
            ILogger        localLogger = null;                          // Logger to trace
            IDbTransaction tran        = null;                          // Transacition
            IDbConnection  con         = null;                          // Connection
            int            res         = -1;

            try
            {
                // Getting Database
                d = DatabaseFactory.GetDatabase();
                if (d == null)
                {
                    return(-1);
                }

                // Getting Logger
                localLogger = DatabaseFactory.Logger;
                if (localLogger != null)
                {
                    localLogger.AddLog("[CmpClockInDB  ]: Getting Connection...", LoggerSeverities.Debug);
                }

                // Getting connection
                con = d.GetNewConnection();

                if (con == null)
                {
                    return(-2);
                }
                if (localLogger != null)
                {
                    localLogger.AddLog("[CmpClockInDB  ]: Opening...", LoggerSeverities.Debug);
                }

                //  Open connection
                con.Open();

                tran = con.BeginTransaction(IsolationLevel.Serializable);

                if (tran == null)
                {
                    return(-3);
                }

                int iNumRegs = Convert.ToInt32(d.ExecuteScalar(string.Format("select count(*) from clock_in where ci_usr_id={0} and ci_date=to_date('{1}','hh24missddmmyy')", iUserID, OPS.Comm.Dtx.DtxToString(dtDate)), con, tran));

                if (iNumRegs == 0)
                {
                    string ssql = " INSERT INTO CLOCK_IN (CI_USR_ID, CI_UNI_ID, CI_DATE) " +
                                  " VALUES (@CLOCK_IN.CI_USR_ID@,@CLOCK_IN.CI_UNI_ID@,@CLOCK_IN.CI_DATE@) ";


                    if (localLogger != null)
                    {
                        localLogger.AddLog("[CmpClockInDB  ]: Executing...", LoggerSeverities.Debug);
                        localLogger.AddLog("[CmpClockInDB  ]" + ssql, LoggerSeverities.Debug);
                    }

                    res = d.ExecuteNonQuery(ssql, con, tran, iUserID, iUniID, dtDate);
                    if (res == 1)
                    {
                        if (localLogger != null)
                        {
                            localLogger.AddLog("[CmpClockInDB  ]: Commit", LoggerSeverities.Debug);
                        }
                        tran.Commit();
                    }
                    else
                    {
                        if (localLogger != null)
                        {
                            localLogger.AddLog("[CmpClockInDB  ]: RollBack", LoggerSeverities.Debug);
                        }
                        tran.Rollback();
                    }
                }
                else
                {
                    res = 1;
                }
            }
            catch (Exception e)
            {
                res = -1;
                if (localLogger != null)
                {
                    localLogger.AddLog("[CmpClockInDB  ]: RollBack" + e.Message, LoggerSeverities.Debug);
                }
                if (tran != null)
                {
                    tran.Rollback();
                }
                throw e;                                        // Propagate the error back!
            }
            finally
            {
                // Close connection... and release the mutex!
                try
                {
                    if (localLogger != null)
                    {
                        localLogger.AddLog("[CmpClockInDB  ]: Closing...", LoggerSeverities.Debug);
                    }
                    if (con != null)
                    {
                        con.Close();
                    }
                }
                catch (Exception e)
                {
                    res = -1;
                    if (localLogger != null)
                    {
                        localLogger.AddLog("[CmpClockInDB  ]: RollBack" + e.Message, LoggerSeverities.Debug);
                    }
                }
            }
            return(res);
        }
コード例 #3
0
        public int UpdateError(int nTransId, int iErrorCode, string strErrorMsg, int iRetries)
        {
            Database       d           = null;                          // Database
            ILogger        localLogger = null;                          // Logger to trace
            IDbTransaction tran        = null;                          // Transacition
            IDbConnection  con         = null;                          // Connection
            int            res         = -1;

            try
            {
                // Getting Database
                d = DatabaseFactory.GetDatabase();
                if (d == null)
                {
                    return(-1);
                }

                // Getting Logger
                localLogger = DatabaseFactory.Logger;
                if (localLogger != null)
                {
                    localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: Getting Connection...", LoggerSeverities.Debug);
                }

                // Getting connection
                con = d.GetNewConnection();

                if (con == null)
                {
                    return(-2);
                }
                if (localLogger != null)
                {
                    localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: Opening...", LoggerSeverities.Debug);
                }

                //  Open connection
                con.Open();

                tran = con.BeginTransaction(IsolationLevel.Serializable);

                if (tran == null)
                {
                    return(-3);
                }

                int iNumRegs = Convert.ToInt32(d.ExecuteScalar(string.Format("select count(*) from CREDIT_CARDS_TRANSACTIONS where CCT_ID={0}", nTransId), con, tran));

                if (iNumRegs == 1)
                {
                    AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
                    double            nDifHour    = 0;
                    try
                    {
                        nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
                    }
                    catch
                    {
                        nDifHour = 0;
                    }

                    string ssql = string.Format("update CREDIT_CARDS_TRANSACTIONS set " +
                                                ((iErrorCode == -1) ? "" : "CCT_ERRORCODE=" + iErrorCode.ToString() + ",") +
                                                ((strErrorMsg == "") ? "" : "CCT_ERRORMSG='" + strErrorMsg + "',") +
                                                "CCT_CURRRETRIES={0}," +
                                                "CCT_STATE_DATE=to_date('{1}','hh24missddmmyy') " +
                                                "where CCT_ID={2}",
                                                iRetries, OPS.Comm.Dtx.DtxToString(DateTime.Now.AddHours(nDifHour)), nTransId);



                    if (localLogger != null)
                    {
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: Executing...", LoggerSeverities.Debug);
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]" + ssql, LoggerSeverities.Debug);
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ] TransId: " + nTransId.ToString(), LoggerSeverities.Debug);
                    }



                    //DateTime dtNow = new DateTime();
                    res = d.ExecuteNonQuery(ssql, con, tran);


                    if (res == 1)
                    {
                        if (localLogger != null)
                        {
                            localLogger.AddLog("[CmpCreditCardDB  ]: Commit", LoggerSeverities.Debug);
                        }
                        tran.Commit();
                    }
                    else
                    {
                        if (localLogger != null)
                        {
                            localLogger.AddLog("[CmpCreditCardDB  ]: RollBack", LoggerSeverities.Debug);
                        }
                        tran.Rollback();
                    }
                }
                else
                {
                    res = 0;
                }
            }
            catch (Exception e)
            {
                res = -1;
                if (localLogger != null)
                {
                    localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: RollBack" + e.Message, LoggerSeverities.Debug);
                }
                if (tran != null)
                {
                    tran.Rollback();
                }
                throw e;                                        // Propagate the error back!
            }
            finally
            {
                // Close connection... and release the mutex!
                try
                {
                    if (localLogger != null)
                    {
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: Closing...", LoggerSeverities.Debug);
                    }
                    if (con != null)
                    {
                        con.Close();
                    }
                }
                catch (Exception e)
                {
                    res = -1;
                    if (localLogger != null)
                    {
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: RollBack" + e.Message, LoggerSeverities.Debug);
                    }
                }
            }
            return(res);
        }
コード例 #4
0
        private int Insert(IDbTransaction tran, string strTransId, DateTime dtDate, string sCCNumber, string sCCName, DateTime dtExprtnDate,
                           string strCCCodServ, string strCCDiscData, int nState, int nQuantity, int nOpeId, int nUniId, string strOperInfo, out int nTransId)
        {
            Database      d           = null;                           // Database
            ILogger       localLogger = null;                           // Logger to trace
            IDbConnection con         = null;                           // Connection
            int           res         = -1;

            nTransId = -1;

            try
            {
                // Getting Database
                d = DatabaseFactory.GetDatabase();
                if (d == null)
                {
                    return(-1);
                }

                if (tran == null)
                {
                    return(-3);
                }

                // Getting Logger
                localLogger = DatabaseFactory.Logger;
                if (localLogger != null)
                {
                    localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: Getting Connection...", LoggerSeverities.Debug);
                }

                // Getting connection
                con = tran.Connection;

                if (con == null)
                {
                    return(-2);
                }

                if (localLogger != null)
                {
                    localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: Opening...", LoggerSeverities.Debug);
                }

                int iNumRegs = Convert.ToInt32(d.ExecuteScalar(string.Format("select count(*) from CREDIT_CARDS_TRANSACTIONS where CCT_UNI_ID={0} and CCT_INS_DATE=to_date('{1}','hh24missddmmyy')", nUniId, OPS.Comm.Dtx.DtxToString(dtDate)), con, tran));

                if (iNumRegs == 0)
                {
                    nTransId = Convert.ToInt32(d.ExecuteScalar("select SEQ_CC_TRANSACTIONS.NEXTVAL FROM DUAL"));

                    string ssql = " INSERT INTO CREDIT_CARDS_TRANSACTIONS (" +
                                  "CCT_ID," +
                                  "CCT_TRANS_ID," +
                                  "CCT_INS_DATE," +
                                  "CCT_OPE_ID," +
                                  "CCT_QUANTITY," +
                                  "CCT_NUMBER," +
                                  "CCT_NAME," +
                                  "CCT_EXPRTN_DATE," +
                                  "CCT_STATE," +
                                  "CCT_STATE_DATE," +
                                  "CCT_CODSERV," +
                                  "CCT_DISC_DATA," +
                                  "CCT_UNI_ID," +
                                  "CCT_OPER_INFO) VALUES (" +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_ID@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_TRANS_ID@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_INS_DATE@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_OPE_ID@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_QUANTITY@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_NUMBER@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_NAME@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_EXPRTN_DATE@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_STATE@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_STATE_DATE@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_CODSERV@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_DISC_DATA@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_UNI_ID@," +
                                  "@CREDIT_CARDS_TRANSACTIONS.CCT_OPER_INFO@) ";



                    if (localLogger != null)
                    {
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: Executing...", LoggerSeverities.Debug);
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]" + ssql, LoggerSeverities.Debug);
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ] TransId: " + strTransId, LoggerSeverities.Debug);
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ] OperInfo: " + strOperInfo, LoggerSeverities.Debug);
                        try
                        {
                            if (sCCNumber.Length >= 8)
                            {
                                string strCCBegin = sCCNumber.Substring(0, 4);
                                string strCCEnd   = sCCNumber.Substring(sCCNumber.Length - 4, 4);
                                localLogger.AddLog("[CmpCreditCardsTransactionsDB  ] PAN: " + strCCBegin + strCCEnd.PadLeft(sCCNumber.Length - 4, '*'), LoggerSeverities.Debug);
                            }
                        }
                        catch
                        {
                        }
                    }

                    AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
                    double            nDifHour    = 0;
                    try
                    {
                        nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
                    }
                    catch
                    {
                        nDifHour = 0;
                    }

                    int iCodServ;

                    if (strCCCodServ == "")
                    {
                        iCodServ = 999;
                    }
                    else
                    {
                        try
                        {
                            iCodServ = Convert.ToInt32(strCCCodServ);
                        }
                        catch
                        {
                            iCodServ = 999;
                        }
                    }

                    //DateTime dtNow = new DateTime();
                    res = d.ExecuteNonQuery(ssql, con, tran,
                                            nTransId,
                                            strTransId,
                                            dtDate,
                                            (nOpeId == -1 ? DBNull.Value : (object)nOpeId),
                                            nQuantity,
                                            (sCCNumber == "" ? DBNull.Value : (object)sCCNumber),
                                            (sCCName == "" ? DBNull.Value : (object)sCCName),
                                            (dtExprtnDate.Year == 1900 ? DBNull.Value : (object)dtExprtnDate),
                                            nState,
                                            DateTime.Now.AddHours(nDifHour),
                                            (iCodServ == -1 ? DBNull.Value : (object)iCodServ),
                                            (strCCDiscData == "" ? DBNull.Value : (object)strCCDiscData),
                                            nUniId,
                                            (((strOperInfo == null) || (strOperInfo == "")) ? DBNull.Value : (object)strOperInfo));



                    if (res == 1)
                    {
                        if (localLogger != null)
                        {
                            localLogger.AddLog("[CmpCreditCardDB  ]: Commit", LoggerSeverities.Debug);
                        }
                    }
                    else
                    {
                        if (localLogger != null)
                        {
                            localLogger.AddLog("[CmpCreditCardDB  ]: RollBack", LoggerSeverities.Debug);
                        }
                    }
                }
                else
                {
                    res = 1;
                }
            }
            catch (Exception e)
            {
                res = -1;
                if (localLogger != null)
                {
                    localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: RollBack" + e.Message, LoggerSeverities.Debug);
                }
                throw e;                                        // Propagate the error back!
            }
            finally
            {
                // Close connection... and release the mutex!
                try
                {
                    if (localLogger != null)
                    {
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: Closing...", LoggerSeverities.Debug);
                    }
                }
                catch (Exception e)
                {
                    res = -1;
                    if (localLogger != null)
                    {
                        localLogger.AddLog("[CmpCreditCardsTransactionsDB  ]: RollBack" + e.Message, LoggerSeverities.Debug);
                    }
                }
            }
            return(res);
        }