コード例 #1
0
ファイル: Service.cs プロジェクト: hari316/Projects
    public ts_UpdateOutputEntity updateTimesheetEntry([XmlElement("TS_Input")] ts_UpdateInputEntity[] TS_Entry)
    {
        logger.Debug("Service:updateTimesheetEntry() called");
        logger.Debug(string.Format("Transaction ID received as {0} for update  ", TS_Entry[0].TransactionID.ToString()));

        ts_UpdateOutputEntity result = new ts_UpdateOutputEntity();;

        try
        {
            timesheetInterface updateTS_IS = new timesheetInterface();
            result = updateTS_IS.updateTimesheetEntry_SI(TS_Entry);
            return result;
        }
        catch (OracleException ex)
        {
            webServiceExHandling.ExceptionLog(ex);
            string mailBody = string.Format(timesheet_Constants.mail_BodyFormat, System.DateTime.Now.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US")), TS_Entry[0].TransactionID.ToString(), ex.TargetSite.ToString(), ex.ToString());
            webServiceExHandling.Send_Email(timesheet_Constants.Email_Dic, mailBody);

            result.StatusFlag = 1;
            string expCode = ExpType(ex);
            result.Message = timesheet_Constants.cnfgErrMessages[expCode];

            logger.Error(string.Format(" ErrorCode : {0}", result.StatusFlag.ToString()));
            logger.Error(string.Format(" ErrorMessage : {0}", result.Message));
            logger.Error(string.Format(" ErrorStack : {0}", ex.StackTrace));
            logger.Error("Service:updateTimesheetEntry() returning error");

            return result;

        }
        catch (Exception ex)
        {
            webServiceExHandling.ExceptionLog(ex);
            string mailBody = string.Format(timesheet_Constants.mail_BodyFormat, System.DateTime.Now.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US")), getTransID(TS_Entry), ex.TargetSite.ToString(), ex.ToString());
            webServiceExHandling.Send_Email(timesheet_Constants.Email_Dic, mailBody);

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

            logger.Error(string.Format(" ErrorCode : {0}", result.StatusFlag.ToString()));
            logger.Error(string.Format(" ErrorMessage : {0}", result.Message));
            logger.Error(string.Format(" ErrorStack : {0}", ex.StackTrace));
            logger.Error("Service:updateTimesheetEntry() returning error");

            return result;
        }
    }
コード例 #2
0
ファイル: timesheet_DAL.cs プロジェクト: hari316/Projects
        /// <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();
            }
        }
コード例 #3
0
ファイル: timesheet_BAL.cs プロジェクト: hari316/Projects
        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;
            }
        }