示例#1
0
        /// <summary>
        /// This function fetch Timesheet status from the Database based on TransactionID 
        /// </summary>
        /// <param name="TransactionID"></param>
        /// <returns>
        /// <paramref name="status"/>
        /// </returns>
        /// <history>
        ///     Hari haran      02/05/2012      created
        /// </history>
        public ts_Status getTimesheetStatus(string TransactionID)
        {
            try
            {

                logger.Debug("timesheet_DAL:getTimesheetStatus() called");

                ts_Status statusEntity = new ts_Status();
                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");

                if (conn.State == System.Data.ConnectionState.Closed)
                {
                    conn.Open();
                    logger.Debug("Connection Status opened ");
                }

                string validateQuery = "SELECT NAME ,TTM_STATUS as Status ,TTM_WEEK as Week from T_TS_EMPLOYEE T ,t_ts_mas_sub M where T.EMPNO = M.TTM_EMPNO  and TTM_ID = :TransID";
                OracleCommand validate_cmd = new OracleCommand(validateQuery, conn);
                validate_cmd.Parameters.AddWithValue("TransID", TransactionID);
                QueryLog.CmdInfo(validate_cmd);
                OracleDataReader reader = validate_cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    statusEntity.EmpName = reader["NAME"].ToString();
                    statusEntity.Status = reader["Status"].ToString();
                    statusEntity.TimesheetWeek = Convert.ToDateTime(reader["Week"]);
                }
                else
                {
                    statusEntity.Status = timesheet_Constants.Unknown;
                }

                logger.DebugFormat("Timesheet Status : {0}", statusEntity.Status);
                logger.Debug("Method : getTimesheetStatus Stop");

                return statusEntity;
            }
            catch (OracleException dbEx)
            {
                logger.Error("Exception Occured At timesheet_DAL - getTimesheetStatus  : " + dbEx.Message.ToString());
                logger.Error("timesheet_DAL:getTimesheetStatus() returning error");

                throw dbEx;
            }
            catch (Exception Ex)
            {
                logger.Error("Exception Occured At timesheet_DAL - getTimesheetStatus  : " + Ex.Message.ToString());
                logger.Error("timesheet_DAL:getTimesheetStatus() returning error");
                throw Ex;
            }
        }
示例#2
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;
            }
        }