Beispiel #1
0
        /// <summary>
        /// This Method is a interface to updateTimesheetEntry fuction
        /// </summary>
        /// <param name="entry_SI"></param>
        /// <returns></returns>
        /// /// <history>
        ///     Hari haran      02/05/2012      created
        /// </history>
        public ts_UpdateOutputEntity updateTimesheetEntry_SI(ts_UpdateInputEntity[] entry_SI)
        {
            try
            {
                logger.Debug("timesheetInterface:updateTimesheetEntry_SI() called");
                logger.Debug("Method : updateTimesheetEntry Transaction ID value : " + entry_SI[0].TransactionID.ToString());

                timesheet_BAL updateTS_BAL = new timesheet_BAL();

                logger.Debug("Control Flow : Method - updateTimesheetEntry_SI Stop");

                return (updateTS_BAL.updateTimesheetEntry_BAL(entry_SI));
            }
            catch (OracleException dbEx)
            {
                logger.Error("Database Exception  At timesheetInterface - updateTimesheetEntry_SI  : " + dbEx.Message.ToString());
                logger.Error("timesheetInterface:updateTimesheetEntry_SI() returning error");

                throw dbEx;
            }
            catch (Exception ex)
            {
                logger.Error("Exception  At timesheetInterface - updateTimesheetEntry_SI  : " + ex.Message.ToString());
                logger.Error("timesheetInterface:updateTimesheetEntry_SI() returning error");

                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// This Function will Update Timesheet details into the Database
        /// </summary>
        /// <param name="ts_entry_DAL"></param>
        /// <returns>
        /// <paramref name="result"/>
        /// </returns>
        /// /// <history>
        ///     Hari haran      02/05/2012      created
        /// </history>
        public ts_UpdateOutputEntity updateTimesheetEntry_DAL(ts_UpdateInputEntity[] ts_entry_DAL)
        {
            logger.Debug("timesheet_DAL:updateTimesheetEntry_DAL() called");
            ts_UpdateOutputEntity result = new ts_UpdateOutputEntity();

            databaseLayer dbConStr = new databaseLayer();
            string connStr = dbConStr.connectionInfo;
            //logger.Debug("Connection string : " + connStr);
            OracleConnection conn = new OracleConnection(connStr);

            logger.Debug("Connetion to the database established");

            OracleTransaction Trans = null;
            int header_flag = 0;
            int child_flag = 0;
            if (conn.State == System.Data.ConnectionState.Closed)
            {
                conn.Open();
                logger.Debug("Connection Status opened ");
            }
            Trans = conn.BeginTransaction();

            try
            {
                //Approve=A,S, AcceptRejectRule=R,U

                string strPRFlag = string.Empty;

                switch (ts_entry_DAL[0].UpdateFlag)
                {
                    case timesheet_Constants.ApproveChar:
                        strPRFlag = timesheet_Constants.A_PRFlagChar;
                        break;
                    case timesheet_Constants.RejectChar:
                        strPRFlag = timesheet_Constants.R_PRFlagChar;
                        break;
                    default:
                        logger.Error("Invalid Update Flag value Expected : (A/R)");
                        logger.Debug("Method : updateTimesheetEntry_DAL Stop");

                        result.StatusFlag = 1;
                        result.Message = timesheet_Constants.Error;
                        return result;
                }

                string HeaderQuery = "UPDATE t_ts_mas_sub SET TTM_STATUS = :Status, TTM_PR_FLAG = :PRFlag, TTM_APP_DATE = :ApprDate, TTM_AP_REM = :Mcomments  WHERE TTM_ID = :TransID";
                OracleCommand header_cmd = new OracleCommand(HeaderQuery, conn);
                header_cmd.Transaction = Trans;
                header_cmd.Parameters.AddWithValue("TransID", ts_entry_DAL[0].TransactionID);
                header_cmd.Parameters.AddWithValue("Status", ts_entry_DAL[0].UpdateFlag);
                //header_cmd.Parameters.AddWithValue("PRFlag", ts_entry_DAL[0].PRFlag);
                header_cmd.Parameters.AddWithValue("PRFlag", strPRFlag);
                header_cmd.Parameters.AddWithValue("ApprDate", System.DateTime.Now);
                header_cmd.Parameters.AddWithValue("Mcomments", ts_entry_DAL[0].MComments);

                QueryLog.CmdInfo(header_cmd);

                header_flag = header_cmd.ExecuteNonQuery();

                int objCount = 0;
                OracleCommand child_cmd = new OracleCommand();
                child_cmd.Connection = conn;
                child_cmd.Transaction = Trans;

                //string ChildQuery = " INSERT into TS_MAS_BILL_PER (TMBP_TTMID,TMBP_BILLPER,TMBP_DATE,TMBP_CHGCODE)" +
                //                    " VALUES (:TransID,:Billable,TO_DATE('04/26/2012 12:00:00','MM/DD/YYYY HH24:MI:SS'),:ChargeCode)";
                string ChildQuery = " INSERT into TS_MAS_BILL_PER (TMBP_TTMID,TMBP_BILLPER,TMBP_DATE,TMBP_CHGCODE)" +
                                        " VALUES (:TransID,:Billable,:BDate,:ChargeCode)";

                child_cmd.Parameters.Add("TransID",OracleType.VarChar);
                child_cmd.Parameters.Add("Billable",OracleType.Int32);
                child_cmd.Parameters.Add("BDate",OracleType.DateTime);
                child_cmd.Parameters.Add("ChargeCode",OracleType.VarChar);

                foreach (ts_UpdateInputEntity tsEntry_value in ts_entry_DAL)
                {

                    child_cmd.CommandText = ChildQuery;
                    logger.Debug("Child_cmd Query parameters initialised");
                    child_cmd.Parameters["TransID"].Value = tsEntry_value.TransactionID ;
                    child_cmd.Parameters["Billable"].Value = tsEntry_value.Billable;
                    child_cmd.Parameters["BDate"].Value = System.DateTime.Now;
                    child_cmd.Parameters["ChargeCode"].Value = tsEntry_value.ChargeCode;

                    QueryLog.CmdInfo(child_cmd);

                    child_flag = child_cmd.ExecuteNonQuery();
                    if (child_flag == 0)
                        break;
                    objCount++;
                }

                logger.Info(string.Format(" Number of records updated : {0}", header_flag));
                logger.Info(string.Format(" Number of records inserted : {0}", objCount.ToString()));

                if (header_flag == 1 && child_flag == 1)
                {
                    Trans.Commit();
                    result.StatusFlag = 0;
                    result.Message = timesheet_Constants.Success;
                    logger.Debug("Transaction Committed");
                    logger.Debug("Operation : Update & insert executed successfully");
                }
                else
                {
                    result.StatusFlag = 1;
                    result.Message = timesheet_Constants.Error;

                    logger.Debug("Tranasction Rollback Executed");

                    if (header_flag == 0)
                    {
                        logger.Error("Operation : Update Error - Invalid parameter values / Invalid Transction ID");
                    }
                    else
                    {
                        logger.Error("Operation : Insert Error - Invalid parameter values");
                    }
                    Trans.Rollback();
                }

                return result;
            }
            catch (OracleException dbEx)
            {
                logger.Error("Exception Occured At timesheet_DAL - updateTimesheetEntry_DAL  : ");
                logger.Error("Exception Code : " + dbEx.ErrorCode.ToString());
                logger.Error("Exception Description : " + dbEx.Message.ToString());
                logger.Error("timesheet_DAL:updateTimesheetEntry_DAL() returning error");
                try
                {
                    logger.Debug("Transaction Rollback Executed");
                    Trans.Rollback();
                }
                catch (Exception ex2)
                {
                    logger.Error("Transaction Rollback Failed : " + ex2.Message.ToString());
                    //throw ex2;
                }

                throw dbEx;
            }
            catch (Exception ex)
            {
                logger.Error("Exception Occured At timesheet_DAL - updateTimesheetEntry_DAL  : " + ex.Message.ToString());
                logger.Error("timesheet_DAL:updateTimesheetEntry_DAL() returning error");

                try
                {
                    logger.Debug("Transaction Rollback Executed");
                    Trans.Rollback();
                }
                catch (Exception ex2)
                {
                    logger.Error("Transaction Rollback Failed : " + ex2.Message.ToString());
                    //throw ex2;
                }

                //throw new myCustomException(32, ex.Message);
                throw ex;
            }
            finally
            {
                logger.Debug("Connection Status Closed ");

                conn.Dispose();
            }
        }
Beispiel #3
0
        public ts_UpdateOutputEntity updateTimesheetEntry_BAL(ts_UpdateInputEntity[] entry_BAL)
        {
            try
            {
                logger.Debug("timesheet_BAL:updateTimesheetEntry_BAL() called");
                logger.Debug(" updateTimesheetEntry Transaction ID value : " + entry_BAL[0].TransactionID.ToString());

                ts_UpdateOutputEntity errRes = new ts_UpdateOutputEntity();
                errRes.StatusFlag = 1;
                errRes.Message = timesheet_Constants.Error;
                int validate_tsParamFlag = 0;

                validate_tsParamFlag = validate_tsParam(entry_BAL);

                logger.Debug("Timesheet Input parameter validation flag value : " + validate_tsParamFlag.ToString());

                if (validate_tsParamFlag == 1)
                {
                    logger.Debug("Error in input parameter values");
                    logger.Debug("ErrorCode = " + errRes.StatusFlag.ToString());
                    logger.Debug("ErrorMessage = " + errRes.Message);
                    return errRes;
                }
                else
                {
                    //ts_Status TimesheetStatus = string.Empty;
                    string validate_tsStatusFlag = string.Empty;

                    timesheet_DAL updateTS_DAL = new timesheet_DAL();
                    StatusRes = updateTS_DAL.getTimesheetStatus(entry_BAL[count].TransactionID);
                    if (StatusRes.Status == timesheet_Constants.Unknown)
                    {
                        errRes.StatusFlag = 1;
                        errRes.Message = timesheet_Constants.TransIdInvalid;

                        logger.Debug("ErrorCode = " + errRes.StatusFlag.ToString());
                        logger.Debug("ErrorMessage = " + errRes.Message);
                        logger.Error("Method : updateTimesheetEntry_BAL Stop");

                        return errRes;
                    }
                    validate_tsStatusFlag = validate_tsStatus(StatusRes.Status);
                    if (validate_tsStatusFlag.Equals(timesheet_Constants.Pending))
                    {
                        return (updateTS_DAL.updateTimesheetEntry_DAL(entry_BAL));
                    }
                    else
                    {
                        errRes.StatusFlag = 1;
                        errRes.Message = validate_tsStatusFlag;

                        logger.Debug("ErrorCode = " + errRes.StatusFlag.ToString());
                        logger.Debug("ErrorMessage = " + errRes.Message);
                        logger.Error("Method : updateTimesheetEntry_BAL validation failed");
                        return errRes;
                    }
                }
            }
            catch (OracleException dbEx)
            {
                logger.Error("Exception  At BAL - updateTimesheetEntry_BAL  : " + dbEx.Message.ToString());
                logger.Error("timesheet_BAL:updateTimesheetEntry_BAL() returning error");
                throw dbEx;
            }
            catch
            {
                logger.Error("timesheet_BAL:updateTimesheetEntry_BAL() returning error");
                throw;
            }
        }
Beispiel #4
0
 /// <summary>
 /// This Method returns Transaction ID
 /// </summary>
 /// <param name="Ex"> TS_Entry </param>
 /// <returns>TransactionID</returns>
 /// 
 private string getTransID(ts_UpdateInputEntity[] TS_Entry)
 {
     if (TS_Entry != null)
         return TS_Entry[0].TransactionID.ToString();
     else
         return string.Empty;
 }
Beispiel #5
0
        int validate_tsParam(ts_UpdateInputEntity[] entry_BAL)
        {
            logger.Debug("timesheet_BAL:validate_tsParam() called");
            switch (entry_BAL[count].UpdateFlag.ToUpper())
            {
                case timesheet_Constants.Approve:
                    entry_BAL[count].UpdateFlag = timesheet_Constants.ApproveChar;
                    //entry_BAL[count].PRFlag = timesheet_Constants.A_PRFlagChar;
                    break;
                case timesheet_Constants.Reject:
                    entry_BAL[count].UpdateFlag = timesheet_Constants.RejectChar;
                    //entry_BAL[count].PRFlag = timesheet_Constants.R_PRFlagChar;
                    break;
                default:
                    logger.Error("Invalid Update Flag value Expected : (Approve/Reject)");
                    return 1;
                //break;
            }

            foreach (ts_UpdateInputEntity tsEntry_value in entry_BAL)
            {
                if ( string.IsNullOrEmpty(tsEntry_value.ChargeCode) ||  string.IsNullOrEmpty(tsEntry_value.TransactionID) )
                {
                    logger.Error("ChargeCode/TransactionID had NULL reference");
                    logger.Debug("Method : validate_tsParam Stop");
                    return 1;
                }
            }

            logger.Debug("Method : validate_tsParam Stop");
            return 0;
        }