Exemplo n.º 1
0
        private void insertArchLog(OracleConnection oracleConnection, int errorCode, char errorCodeChar)
        {
            //OracleCommand oracleCommand = null;
            string sql = "INSERT INTO CCSOWNER.PWN_DOC_REG_ARCH_STAT(ID,DOC_REG_ID,STORAGE_ID,ARCH_DATE,USER_ID,STATUS,ERROR_ID)" +
                         " VALUES(:ID,:DOC_REG_ID,:STORAGE_ID,:ARCH_DATE,:USER_ID,:STATUS,:ERROR_ID)";

            string str = null;

            using (var oracleCommand = new OracleCommand(null, oracleConnection))
            {
                log.Debug(string.Format("Executing: {0}", sql));
                oracleCommand.CommandText = sql;
                oracleCommand.Parameters.Add(":ID", OracleDbType.Int32);
                oracleCommand.Parameters.Add(":DOC_REG_ID", OracleDbType.Int32);
                oracleCommand.Parameters.Add(":STORAGE_ID", OracleDbType.Varchar2);
                oracleCommand.Parameters.Add(":ARCH_DATE", OracleDbType.TimeStampTZ);
                oracleCommand.Parameters.Add(":USER_ID", OracleDbType.Varchar2);
                oracleCommand.Parameters.Add(":STATUS", OracleDbType.Char);
                oracleCommand.Parameters.Add(":ERROR_ID", OracleDbType.Int32);
                oracleCommand.Prepare();
                oracleCommand.Parameters[0].Value = ConnDAO.getInstance().getUniqueID(ref str, oracleConnection);
                oracleCommand.Parameters[1].Value = 1;
                oracleCommand.Parameters[2].Value = "43434232242";
                oracleCommand.Parameters[3].Value = Utilities.GetTimestampValue(DateTime.Now);
                oracleCommand.Parameters[4].Value = "sssssss";
                oracleCommand.Parameters[5].Value = errorCodeChar;
                oracleCommand.Parameters[6].Value = errorCode;
                oracleCommand.ExecuteNonQuery();
            }
        }
Exemplo n.º 2
0
        private void insertArchLog(OracleConnection oracleConnection, PawnDocRegVO vo, char succCodeChar)
        {
            //OracleCommand oracleCommand = null;
            string sql = "INSERT INTO CCSOWNER.PWN_DOC_REG_ARCH_STAT(ID,DOC_REG_ID,STORAGE_ID,ARCH_DATE,USER_ID,STATUS,TARGET_DOC_DB)" +
                         " VALUES(:ID,:DOC_REG_ID,:STORAGE_ID,:ARCH_DATE,:USER_ID,:STATUS,:TARGET_DOC_DB)";

            string str = null;

            using (var oracleCommand = new OracleCommand(null, oracleConnection))
            {
                log.Debug(string.Format("Executing: {0}", sql));
                oracleCommand.CommandText = sql;
                oracleCommand.Parameters.Add(":ID", OracleDbType.Int32);
                oracleCommand.Parameters.Add(":DOC_REG_ID", OracleDbType.Int32);
                oracleCommand.Parameters.Add(":STORAGE_ID", OracleDbType.Varchar2);
                oracleCommand.Parameters.Add(":ARCH_DATE", OracleDbType.TimeStampTZ);
                oracleCommand.Parameters.Add(":USER_ID", OracleDbType.Varchar2);
                oracleCommand.Parameters.Add(":STATUS", OracleDbType.Char);
                oracleCommand.Parameters.Add(":TARGET_DOC_DB", OracleDbType.Varchar2);
                oracleCommand.Prepare();
                oracleCommand.Parameters[0].Value = ConnDAO.getInstance().getUniqueID(ref str, oracleConnection);
                oracleCommand.Parameters[1].Value = vo.DocID;
                oracleCommand.Parameters[2].Value = vo.StorageID;
                oracleCommand.Parameters[3].Value = Utilities.GetTimestampValue(DateTime.Now);
                oracleCommand.Parameters[4].Value = vo.UserID;
                oracleCommand.Parameters[5].Value = succCodeChar;
                oracleCommand.Parameters[6].Value = vo.TargetCouchDBName;
                oracleCommand.ExecuteNonQuery();
            }
        }
Exemplo n.º 3
0
        public int CreateArchLog(int totalDocs, string srcDB, string tarDB, string userID, out bool isSuccess, out string errorMSG)
        {
            //OracleConnection connection = null;
            //OracleCommand oracleCommand = null;
            isSuccess = false;
            errorMSG  = "";
            int logID = 0;

            if (DBConnector.getInstance().getStatus() != DBConnector.Status.INITIALIZED)
            {
                log.Error(" from CreateArchLog :DB Connection not established: create aborted");
                return(0);
            }
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            try
            {
                using (var connection = new OracleConnection())
                {
                    connection.ConnectionString = DBConnector.getInstance().databaseServiceName();
                    connection.Open();
                    string sql = "INSERT INTO PWN_DOC_REG_ARCH_LOG(ID,ARCH_DATE,TOTAL_DOCS,SOURCE_DOC_DB,TARGET_DOC_DB," +
                                 "STARTTIME,USER_ID) VALUES (:ID,:ARCH_DATE,:TOTAL_DOCS,:SOURCE_DOC_DB,:TARGET_DOC_DB,:STARTTIME,:USER_ID)";
                    string str = null;
                    using (var oracleCommand = new OracleCommand(null, connection))
                    {
                        log.Debug(string.Format("Executing: {0}", sql));
                        oracleCommand.CommandText = sql;
                        oracleCommand.Parameters.Add(":ID", OracleDbType.Int32);
                        oracleCommand.Parameters.Add(":ARCH_DATE", OracleDbType.Date);
                        oracleCommand.Parameters.Add(":TOTAL_DOCS", OracleDbType.Int32);
                        oracleCommand.Parameters.Add(":SOURCE_DOC_DB", OracleDbType.Varchar2);
                        oracleCommand.Parameters.Add(":TARGET_DOC_DB", OracleDbType.Varchar2);
                        oracleCommand.Parameters.Add(":STARTTIME", OracleDbType.TimeStampTZ);
                        oracleCommand.Parameters.Add(":USER_ID", OracleDbType.Varchar2);
                        oracleCommand.Prepare();
                        logID = ConnDAO.getInstance().getUniqueID(ref str, connection);
                        oracleCommand.Parameters[0].Value = logID;
                        oracleCommand.Parameters[1].Value = DateTime.Today;
                        oracleCommand.Parameters[2].Value = totalDocs;
                        oracleCommand.Parameters[3].Value = srcDB;
                        oracleCommand.Parameters[4].Value = tarDB;
                        oracleCommand.Parameters[5].Value = Utilities.GetTimestampValue(DateTime.Now);
                        oracleCommand.Parameters[6].Value = userID;
                        oracleCommand.ExecuteNonQuery();
                        isSuccess = true;
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("CreateArchLog Failed:", e);
                errorMSG = "CreateArchLog Failed:" + e.Message;
                log.Debug(e.StackTrace.ToString());
                isSuccess = false;
            }
            finally
            {
                stopwatch.Stop();
                log.Info(string.Format("Time Taken for CreateArchLog  : {0} Msec", stopwatch.ElapsedMilliseconds));
                // oracleCommand = null;
            }
            return(logID);
        }
Exemplo n.º 4
0
        /*public bool CreateArchLogWithError(PawnDocRegVO vo, int errorCode, string msg, Char errorCodeChar, bool isRecovery,out string oraError)
         * {
         *  bool ret = false;
         *  string retVal = "";
         *  oraError = "";
         *  //OracleDataReader reader = null;
         *  //OracleConnection connection = null;
         *  //OracleCommand oracleCommand = null;
         *  int errorID = 0;
         *  if (DBConnector.getInstance().getStatus() != DBConnector.Status.INITIALIZED)
         *  {
         *      log.Error(" from GetDocumentSets :DB Connection not established: Search aborted");
         *      return false;
         *  }
         *  var stopwatch = new Stopwatch();
         *  stopwatch.Start();
         *  var stopwatch1 = new Stopwatch();
         *  OracleTransaction myTrans = null;
         *  long t0 = 0;
         *  long t1 = 0;
         *  long t2 = 0;
         *  long t3 = 0;
         *  long t4 = 0;
         *
         *  using (var connection = new OracleConnection())
         *  {
         *      try
         *      {
         *          connection.ConnectionString = DBConnector.getInstance().databaseServiceName();
         *          stopwatch1.Start();
         *          if (!getConnectionWithRetry(connection))
         *          {
         *              log.Error("AddErrorsToDB Failed: due to connection error");
         *              string str =
         *               string.Format("---DB Archive Log Failure Doc ID{0} Storage ID {1} Status {2} Target DB ID{3} Target DB Name{4}  Error Code{5} ErrorMSG {6}---",
         *                             vo.DocID, vo.StorageID, errorCodeChar, vo.TargetCouchDBID, vo.TargetCouchDBName, errorCode, msg);
         *              log.Error(str);
         *              return false;
         *          }
         *          t0 = stopwatch1.ElapsedMilliseconds;
         *          stopwatch1.Restart();
         *          //connection.Open();
         *          if (errorCode == -1)
         *          {
         *              errorID = getErrorCodeSeq(connection);
         *          }
         *          else
         *          {
         *              errorID = errorCode;
         *          }
         *
         *
         *          myTrans = connection.BeginTransaction(IsolationLevel.ReadCommitted);
         *          if (errorCode == -1)
         *              insertErrorMSG(connection, msg, errorID);
         *
         *          t1 = stopwatch1.ElapsedMilliseconds;
         *          stopwatch1.Restart();
         *
         *          //log.Debug("Time for Insert Error " + stopwatch.ElapsedMilliseconds);
         *          //stopwatch.Restart();
         *          if (isRecovery)
         *              updateArchLog(connection, vo, errorID, errorCodeChar);
         *          else
         *              insertArchLog(connection, vo, errorID, errorCodeChar);
         *
         *          t2 = stopwatch1.ElapsedMilliseconds;
         *          stopwatch1.Restart();
         *          //log.Debug("Time for insertArchLog " + stopwatch.ElapsedMilliseconds);
         *          // stopwatch.Restart();
         *          updatePwnDocReg(connection, vo, errorCodeChar);
         *          t3 = stopwatch1.ElapsedMilliseconds;
         *          stopwatch1.Restart();
         *          //log.Debug("Time for updatePwnDocReg " + stopwatch.ElapsedMilliseconds);
         *          myTrans.Commit();
         *
         *          t4 = stopwatch1.ElapsedMilliseconds;
         *          stopwatch1.Stop();
         *          ret = true;
         *      }
         *      catch (Exception e)
         *      {
         *          log.Error("AddErrorsToDB Failed:", e);
         *          oraError = e.Message;
         *          string str =
         *                 string.Format("---DB Archive Log Failure Doc ID{0} Storage ID {1} Status {2} Target DB ID{3} Target DB Name{4}  Error Code{5} ErrorMSG {6}---",
         *                               vo.DocID, vo.StorageID, errorCodeChar, vo.TargetCouchDBID, vo.TargetCouchDBName, errorCode, msg);
         *          log.Error(str);
         *          log.Debug(e.StackTrace.ToString());
         *          if (myTrans != null && connection.State != ConnectionState.Closed)
         *          {
         *              try
         *              {
         *                  myTrans.Rollback();
         *              }
         *              catch (OracleException oracleException)
         *              {
         *                  log.Error("Oracle Exception" + oracleException.Message);
         *                  return false;
         *              }
         *
         *          }
         *          ret = false;
         *      }
         *      finally
         *      {
         *          stopwatch.Stop();
         *          log.Info(string.Format("Time Taken for AddErrorsToDB  : {0} Msec", stopwatch.ElapsedMilliseconds));
         *          log.Info(string.Format(" conn {0} error insert {1} arch log insert {2} update reg{3} final commit {4}", t0, t1, t2, t3, t4));
         *          //oracleCommand = null;
         *      }
         *  }
         *
         *  return ret;
         * }*/

        public bool CreateBatchArchLogWithError(List <ArchiveJob3> jobList, bool isRecovery)
        {
            bool   ret    = false;
            string retVal = "";
            //OracleDataReader reader = null;
            //OracleConnection connection = null;
            //OracleCommand oracleCommand = null;
            int errorID = 0;

            if (DBConnector.getInstance().getStatus() != DBConnector.Status.INITIALIZED)
            {
                log.Error(" from GetDocumentSets :DB Connection not established: Search aborted");
                return(false);
            }
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            OracleTransaction myTrans = null;

            using (var connection = new OracleConnection())
            {
                try
                {
                    connection.ConnectionString = DBConnector.getInstance().databaseServiceName();
                    connection.Open();
                    foreach (var archiveJob3 in jobList)
                    {
                        if (archiveJob3.getErrorCode() == -1)
                        {
                            errorID = getErrorCodeSeq(connection);
                        }
                        else
                        {
                            errorID = archiveJob3.getErrorCode();
                        }
                        int uqID = 0;
                        if (!isRecovery)
                        {
                            uqID = ConnDAO.getInstance().getUniqueIDNew(ref retVal, connection);
                            //insertArchLogNew
                        }

                        myTrans = connection.BeginTransaction(IsolationLevel.ReadCommitted);
                        if (archiveJob3.getErrorCode() == -1)
                        {
                            insertErrorMSG(connection, archiveJob3.getErrorMessageForDB(), errorID);
                        }

                        if (isRecovery)
                        {
                            updateArchLog(connection, archiveJob3.getDocObject(), errorID, archiveJob3.getErrorCodeChar());
                        }
                        else
                        {
                            insertArchLog(connection, archiveJob3.getDocObject(), errorID, archiveJob3.getErrorCodeChar(), uqID);
                        }
                        //log.Debug("Time for insertArchLog " + stopwatch.ElapsedMilliseconds);
                        // stopwatch.Restart();
                        updatePwnDocReg(connection, archiveJob3.getDocObject(), archiveJob3.getErrorCodeChar());
                        //log.Debug("Time for updatePwnDocReg " + stopwatch.ElapsedMilliseconds);
                        myTrans.Commit();
                        ret = true;
                    }
                }
                catch (Exception e)
                {
                    log.Error("AddErrorsToDB Failed:", e);
                    log.Debug(e.StackTrace.ToString());
                    if (myTrans != null && connection.State != ConnectionState.Closed)
                    {
                        try
                        {
                            myTrans.Rollback();
                        }
                        catch (OracleException oracleException)
                        {
                            log.Error("Oracle Exception" + oracleException.Message);
                            return(false);
                        }
                    }
                    ret = false;
                    throw e;
                }
                finally
                {
                    stopwatch.Stop();
                    log.Debug(string.Format("Time Taken for AddErrorsToDB  : {0} Msec", stopwatch.ElapsedMilliseconds));
                    //oracleCommand = null;
                }
            }

            return(ret);
        }
Exemplo n.º 5
0
        public bool CreateArchLogWithError(PawnDocRegVO vo, int errorCode, string msg, Char errorCodeChar, bool isRecovery)
        {
            bool   ret    = false;
            string retVal = "";
            //OracleDataReader reader = null;
            //OracleConnection connection = null;
            //OracleCommand oracleCommand = null;
            int errorID = 0;
            int uqID    = 0;

            if (DBConnector.getInstance().getStatus() != DBConnector.Status.INITIALIZED)
            {
                log.Error(" from GetDocumentSets :DB Connection not established: Search aborted");
                return(false);
            }
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            //var stopwatch1 = new Stopwatch();
            OracleTransaction myTrans = null;

            /* long t0 = 0;
             * long t1 = 0;
             * long t2 = 0;
             * long t3 = 0;
             * long t4 = 0;*/

            using (var connection = new OracleConnection())
            {
                try
                {
                    connection.ConnectionString = DBConnector.getInstance().databaseServiceName();
                    // stopwatch1.Start();
                    connection.Open();

                    /*if(!getConnectionWithRetry(connection))
                     * {
                     *  log.Error("AddErrorsToDB Failed: due to connection error");
                     *  string str =
                     *   string.Format("---DB Archive Log Failure Doc ID{0} Storage ID {1} Status {2} Target DB ID{3} Target DB Name{4}  Error Code{5} ErrorMSG {6}---",
                     *                 vo.DocID, vo.StorageID, errorCodeChar, vo.TargetCouchDBID, vo.TargetCouchDBName, errorCode, msg);
                     *  log.Error(str);
                     *  return false;
                     * }*/
                    if (!isRecovery)
                    {
                        uqID = ConnDAO.getInstance().getUniqueIDNew(ref retVal, connection);
                        //insertArchLogNew
                    }
                    //  t0 = stopwatch1.ElapsedMilliseconds;
                    //  stopwatch1.Restart();
                    //connection.Open();
                    if (errorCode == -1)
                    {
                        errorID = getErrorCodeSeq(connection);
                    }
                    else
                    {
                        errorID = errorCode;
                    }


                    myTrans = connection.BeginTransaction(IsolationLevel.ReadCommitted);
                    if (errorCode == -1)
                    {
                        insertErrorMSG(connection, msg, errorID);
                    }

                    //   t1 = stopwatch1.ElapsedMilliseconds;
                    //  stopwatch1.Restart();

                    //log.Debug("Time for Insert Error " + stopwatch.ElapsedMilliseconds);
                    //stopwatch.Restart();
                    if (isRecovery)
                    {
                        updateArchLog(connection, vo, errorID, errorCodeChar);
                    }
                    else
                    {
                        insertArchLog(connection, vo, errorID, errorCodeChar, uqID);
                    }

                    //   t2 = stopwatch1.ElapsedMilliseconds;
                    //   stopwatch1.Restart();
                    //log.Debug("Time for insertArchLog " + stopwatch.ElapsedMilliseconds);
                    // stopwatch.Restart();
                    updatePwnDocReg(connection, vo, errorCodeChar);
                    //   t3 = stopwatch1.ElapsedMilliseconds;
                    //    stopwatch1.Restart();
                    //log.Debug("Time for updatePwnDocReg " + stopwatch.ElapsedMilliseconds);
                    myTrans.Commit();

                    //     t4 = stopwatch1.ElapsedMilliseconds;
                    //   stopwatch1.Stop();
                    ret = true;
                }
                catch (Exception e)
                {
                    log.Error("AddErrorsToDB Failed:", e);
                    string str =
                        string.Format("---DB Archive Log Failure Doc ID{0} Storage ID {1} Status {2} Target DB ID{3} Target DB Name{4}  Error Code{5} ErrorMSG {6}---",
                                      vo.DocID, vo.StorageID, errorCodeChar, vo.TargetCouchDBID, vo.TargetCouchDBName, errorCode, msg);
                    log.Error(str);
                    log.Debug(e.StackTrace.ToString());
                    if (myTrans != null && connection.State != ConnectionState.Closed)
                    {
                        try
                        {
                            myTrans.Rollback();
                        }
                        catch (OracleException oracleException)
                        {
                            log.Error("Oracle Exception" + oracleException.Message);
                            return(false);
                        }
                    }
                    ret = false;
                }
                finally
                {
                    stopwatch.Stop();
                    log.Info(string.Format("Time Taken for Error ArchLog  : {0} Msec", stopwatch.ElapsedMilliseconds));
                    //log.Info(string.Format(" conn {0} error insert {1} arch log insert {2} update reg{3} final commit {4}", t0, t1, t2, t3, t4));
                    //oracleCommand = null;
                }
            }

            return(ret);
        }
Exemplo n.º 6
0
        public bool CreateArchLog(PawnDocRegVO vo, char succCodeChar, bool isRecovery)
        {
            bool   ret    = false;
            string retVal = "";

            //OracleDataReader reader = null;
            //OracleConnection connection = null;
            if (DBConnector.getInstance().getStatus() != DBConnector.Status.INITIALIZED)
            {
                log.Error(" from GetDocumentSets :DB Connection not established: Search aborted");
                return(false);
            }
            int uqID      = 0;
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            OracleTransaction myTrans = null;

            using (var connection = new OracleConnection())
            {
                try
                {
                    connection.ConnectionString = DBConnector.getInstance().databaseServiceName();
                    connection.Open();
                    if (!isRecovery)
                    {
                        uqID = ConnDAO.getInstance().getUniqueIDNew(ref retVal, connection);
                        //insertArchLogNew
                    }

                    myTrans = connection.BeginTransaction(IsolationLevel.ReadCommitted);
                    if (isRecovery)
                    {
                        updateArchLog(connection, vo, succCodeChar);
                    }
                    else
                    {
                        insertArchLogNew(connection, vo, succCodeChar, uqID);
                    }
                    //log.Debug("Time for insertArchLog " + stopwatch.ElapsedMilliseconds);
                    //stopwatch.Restart();
                    updatePwnDocReg(connection, vo, succCodeChar);
                    //log.Debug("Time for updatePwnDocReg " + stopwatch.ElapsedMilliseconds);
                    myTrans.Commit();
                    ret = true;
                }
                catch (Exception e)
                {
                    log.Error("CreateArchLog Failed:", e);
                    string str =
                        string.Format("---DB Archive Log Failure Doc ID{0} Storage ID {1} Status {2} Target DB ID{3} Target DB Name{4} ---",
                                      vo.DocID, vo.StorageID, succCodeChar, vo.TargetCouchDBID, vo.TargetCouchDBName);
                    log.Error(str);
                    log.Debug(e.StackTrace.ToString());
                    if (myTrans != null && connection.State != ConnectionState.Closed)
                    {
                        try
                        {
                            myTrans.Rollback();
                        }
                        catch (OracleException oracleException)
                        {
                            log.Error("Oracle Exception" + oracleException.Message);
                            return(false);
                        }
                    }
                    ret = false;
                }
                finally
                {
                    stopwatch.Stop();
                    log.Info(string.Format("Time Taken for Success CreateArchLog  : {0} Msec", stopwatch.ElapsedMilliseconds));
                    //oracleCommand = null;
                }
                return(ret);
            }
        }
Exemplo n.º 7
0
        /* public bool CreateArchLog(PawnDocRegVO vo, char succCodeChar, bool isRecovery,out string errorMessage)
         * {
         *   bool ret = false;
         *   string retVal = "";
         *   errorMessage = "";
         *   //OracleDataReader reader = null;
         *   //OracleConnection connection = null;
         *   if (DBConnector.getInstance().getStatus() != DBConnector.Status.INITIALIZED)
         *   {
         *       log.Error(" from GetDocumentSets :DB Connection not established: Search aborted");
         *       return false;
         *   }
         *   int uqID = 0;
         *   var stopwatch = new Stopwatch();
         *   stopwatch.Start();
         *
         *   var stopwatch1 = new Stopwatch();
         *
         *   long t0 = 0;
         *   long t1 = 0;
         *   long t2 = 0;
         *   long t3 = 0;
         *   long t4 = 0;
         *
         *   OracleTransaction myTrans = null;
         *
         *   using (var connection = new OracleConnection())
         *   {
         *       try
         *       {
         *           connection.ConnectionString = DBConnector.getInstance().databaseServiceName();
         *
         *           connection.Open();
         *           t0 = stopwatch1.ElapsedMilliseconds;
         *           stopwatch1.Restart();
         *
         *           if (!isRecovery)
         *           {
         *               uqID = ConnDAO.getInstance().getUniqueIDNew(ref retVal, connection);
         *               //insertArchLogNew
         *           }
         *           t1 = stopwatch1.ElapsedMilliseconds;
         *           stopwatch1.Restart();
         *           myTrans = connection.BeginTransaction(IsolationLevel.ReadCommitted);
         *           if (isRecovery)
         *           {
         *               updateArchLog(connection, vo, succCodeChar);
         *           }
         *           else
         *           {
         *               insertArchLogNew(connection, vo, succCodeChar, uqID);
         *           }
         *           t2 = stopwatch1.ElapsedMilliseconds;
         *           stopwatch1.Restart();
         *
         *           //log.Debug("Time for insertArchLog " + stopwatch.ElapsedMilliseconds);
         *           //stopwatch.Restart();
         *           updatePwnDocReg(connection, vo, succCodeChar);
         *           t3 = stopwatch1.ElapsedMilliseconds;
         *           stopwatch1.Restart();
         *           //log.Debug("Time for updatePwnDocReg " + stopwatch.ElapsedMilliseconds);
         *           myTrans.Commit();
         *           t4 = stopwatch1.ElapsedMilliseconds;
         *           stopwatch1.Restart();
         *           ret = true;
         *
         *       }
         *       catch (Exception e)
         *       {
         *           errorMessage = e.Message;
         *           log.Error("CreateArchLog Failed:", e);
         *           string str =
         *                   string.Format("---DB Archive Log Failure Doc ID{0} Storage ID {1} Status {2} Target DB ID{3} Target DB Name{4} ---",
         *                                 vo.DocID, vo.StorageID, succCodeChar, vo.TargetCouchDBID, vo.TargetCouchDBName);
         *           log.Error(str);
         *           log.Debug(e.StackTrace.ToString());
         *           if (myTrans != null && connection.State != ConnectionState.Closed)
         *           {
         *               try
         *               {
         *                   myTrans.Rollback();
         *               }
         *               catch (OracleException oracleException)
         *               {
         *                   log.Error("Oracle Exception" + oracleException.Message);
         *                   return false;
         *               }
         *           }
         *           ret = false;
         *       }
         *       finally
         *       {
         *           stopwatch.Stop();
         *           log.Debug(string.Format("Time Taken for CreateArchLog  : {0} Msec", stopwatch.ElapsedMilliseconds));
         *           //oracleCommand = null;
         *           log.Info(string.Format(" conn {0} success UQ ID {1} arch log insert {2} update reg{3} final commit {4}", t0, t1, t2, t3, t4));
         *       }
         *       return ret;
         *   }
         * }*/

        public bool CreateArchLogForBatch(List <PawnDocRegVO> voList, char succCodeChar, bool isRecovery)
        {
            bool   ret    = false;
            string retVal = "";

            if (DBConnector.getInstance().getStatus() != DBConnector.Status.INITIALIZED)
            {
                log.Error(" from GetDocumentSets :DB Connection not established: Search aborted");
                return(false);
            }
            int uqID      = 0;
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            OracleTransaction myTrans = null;

            using (var connection = new OracleConnection())
            {
                try
                {
                    connection.ConnectionString = DBConnector.getInstance().databaseServiceName();
                    connection.Open();
                    foreach (var pawnDocRegVO in voList)
                    {
                        if (!isRecovery)
                        {
                            uqID = ConnDAO.getInstance().getUniqueIDNew(ref retVal, connection);
                            //insertArchLogNew
                        }

                        myTrans = connection.BeginTransaction(IsolationLevel.ReadCommitted);
                        if (isRecovery)
                        {
                            updateArchLog(connection, pawnDocRegVO, succCodeChar);
                        }
                        else
                        {
                            insertArchLogNew(connection, pawnDocRegVO, succCodeChar, uqID);
                        }
                        updatePwnDocReg(connection, pawnDocRegVO, succCodeChar);
                        myTrans.Commit();
                    }
                    ret = true;
                }
                catch (Exception e)
                {
                    log.Error("CreateArchLog Failed:", e);
                    log.Debug(e.StackTrace.ToString());
                    if (myTrans != null && connection.State != ConnectionState.Closed)
                    {
                        try
                        {
                            myTrans.Rollback();
                        }
                        catch (OracleException oracleException)
                        {
                            log.Error("Oracle Exception" + oracleException.Message);
                            return(false);
                        }
                    }
                    ret = false;
                    throw e;
                }
                finally
                {
                    stopwatch.Stop();
                    log.Debug(string.Format("Time Taken for CreateArchLog  : {0} Msec", stopwatch.ElapsedMilliseconds));
                    //oracleCommand = null;
                }
                return(ret);
            }
        }
Exemplo n.º 8
0
        public bool AddCouchDbToRepos(List <CouchConsoleApp.vo.PwnDocArchDBRepVO> dbList, out int dbid)
        {
            bool   ret    = false;
            string retVal = "";

            dbid = 0;
            if (DBConnector.getInstance().getStatus() != DBConnector.Status.INITIALIZED)
            {
                log.Error(" from GetDocumentSets :DB Connection not established: Search aborted");
                return(false);
            }
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            try
            {
                using (var connection = new OracleConnection())
                {
                    connection.ConnectionString = DBConnector.getInstance().databaseServiceName();
                    connection.Open();
                    string sql = "INSERT INTO PWN_DOC_ARCH_DB_REP(ID,DBNAME,DBINFO,CREATIONDATE) VALUES " +
                                 "(:ID,:DBNAME,:DBINFO,:CREATIONDATE)";
                    string str = null;
                    using (var oracleCommand = new OracleCommand(null, connection))
                    {
                        log.Debug(string.Format("Executing: {0}", sql));
                        oracleCommand.CommandText = sql;
                        oracleCommand.Parameters.Add(":ID", OracleDbType.Int32);
                        oracleCommand.Parameters.Add(":DBNAME", OracleDbType.Varchar2);
                        oracleCommand.Parameters.Add(":DBINFO", OracleDbType.Varchar2);
                        oracleCommand.Parameters.Add(":CREATIONDATE", OracleDbType.TimeStampTZ);
                        oracleCommand.Prepare();  // Calling Prepare after having set the Commandtext and parameters.
                        //oracleCommand.ExecuteNonQuery();

                        foreach (var vo in dbList)
                        {
                            dbid = ConnDAO.getInstance().getUniqueID(ref str, connection);
                            oracleCommand.Parameters[0].Value = dbid;
                            oracleCommand.Parameters[1].Value = vo.DBName;
                            oracleCommand.Parameters[2].Value = vo.DBInfo;
                            oracleCommand.Parameters[3].Value = Utilities.GetTimestampValue(DateTime.Now);
                            oracleCommand.ExecuteNonQuery();
                        }

                        ret = true;
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("AddCouchDbToRepos Failed:", e);
                log.Debug(e.StackTrace.ToString());
                ret = false;
            }
            finally
            {
                stopwatch.Stop();
                log.Debug(string.Format("Time Taken for AddCouchDbToRepos  : {0} Msec", stopwatch.ElapsedMilliseconds));
                //oracleCommand = null;
            }
            return(ret);
        }