コード例 #1
0
ファイル: iSmartInterface.cs プロジェクト: hari316/Projects
        /// <summary>
        /// This Method is a interface to updatePurchaseRequest fuction
        /// </summary>
        /// <param name="entry_SI"></param>
        /// <returns></returns>
        /// /// <history>
        ///     Hari haran      08/05/2012      created
        /// </history>
        public iSmart_UpdateOutputEntity updatePurchaseRequest_SI(iSmart_UpdateInputEntity[] entry_SI)
        {
            try
            {
                logger.Debug("iSmartInterface: updatePurchaseRequest_SI() called");
                logger.Debug("Method : updatePurchaseRequest_SI PReqNo value : " + entry_SI[0].PReqNo.ToString());

                iSmart_BAL updateTS_BAL = new iSmart_BAL();

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

                return (updateTS_BAL.updatePurchaseRequest_BAL(entry_SI));
            }
            catch (SqlException dbEx)
            {
                logger.Error("Database Exception  At iSmartInterface - updatePurchaseRequest_SI  : " + dbEx.Message.ToString());
                logger.Error("iSmartInterface: updatePurchaseRequest_SI() returning error");

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

                throw ex;
            }
        }
コード例 #2
0
ファイル: iSmart_BAL.cs プロジェクト: hari316/Projects
        /// <summary>
        /// This Method validates the input parameters for the updatePurchaseRequest function
        /// </summary>
        /// <param name="entry_BAL"></param>
        /// <returns></returns>
        /// <history>
        ///     Hari haran      08/05/2012      created
        /// </history>
        public iSmart_UpdateOutputEntity updatePurchaseRequest_BAL(iSmart_UpdateInputEntity[] entry_BAL)
        {
            try
            {
                logger.Debug("iSmart_BAL: updatePurchaseRequest_BAL() called");
                logger.Debug("updatePurchaseRequest_BAL PReqNo value : " + entry_BAL[0].PReqNo.ToString());

                iSmart_UpdateOutputEntity errRes = new iSmart_UpdateOutputEntity();
                errRes.StatusFlag = 1;
                errRes.Message = iSmart_Constants.Error;
                int validate_tsParamFlag = 0;

                validate_tsParamFlag = validate_isParam(entry_BAL);

                logger.Debug("iSmart Input parameter validation flag value(success = 0/failure = 1)  : " + 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);
                    logger.Error("Method : getiSmartDetails_BAL validation failed");

                    return errRes;
                }
                else
                {
                    string iSmartStatus = string.Empty;
                    iSmart_DAL updateIS_DAL = new iSmart_DAL();
                    iSmartStatus = updateIS_DAL.getISmartStatus(entry_BAL[count].PReqNo);

                    logger.Debug("iSmartStatus value : " + iSmartStatus.ToString());
                    logger.Debug("EmpId value (To be same as iSmartStatus for Updation) : " + entry_BAL[count].EmpID.ToString());

                    if (string.IsNullOrEmpty(iSmartStatus))
                    {
                        errRes.StatusFlag = 1;
                        //errRes.Message = iSmart_Constants.PReqNoInvalid;
                        errRes.Message = string.Format(iSmart_Constants.preqErrFormat, entry_BAL[count].PReqNo);

                        logger.Debug("ErrorCode = " + errRes.StatusFlag.ToString());
                        logger.Debug("ErrorMessage = " + errRes.Message);
                        logger.Error("Method : getiSmartDetails_BAL validation failed");

                        return errRes;
                    }

                    else if (iSmartStatus.Equals(entry_BAL[count].EmpID))
                    {
                        return (updateIS_DAL.updatePurchaseRequest_DAL(entry_BAL));
                    }

                    else
                    {
                        errRes.StatusFlag = 1;
                        //errRes.Message = "EmpId Miss Match";
                        errRes.Message = string.Format(iSmart_Constants.preqErrFormat,entry_BAL[count].PReqNo);

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

                        return errRes;
                    }
                }
            }
            catch (SqlException dbEx)
            {

                logger.Error("Exception  At BAL - updatePurchaseRequest_BAL  : " + dbEx.Message.ToString());
                logger.Error("iSmart_BAL:updatePurchaseRequest_BAL() returning error");

                throw dbEx;
            }
            catch (Exception ex)
            {
                logger.Fatal("Exception  At BAL - updatePurchaseRequest_BAL  : " + ex.Message.ToString());
                logger.Error("iSmart_BAL:updatePurchaseRequest_BAL() returning error");

                throw ex;
            }
        }
コード例 #3
0
ファイル: iSmart_BAL.cs プロジェクト: hari316/Projects
        int validate_isParam(iSmart_UpdateInputEntity[] entry_BAL)
        {
            logger.Debug("iSmart_BAL: validate_isParam() called");

            string PreqNo = string.Empty;
            string EmpId = string.Empty;

            PreqNo = entry_BAL[count].PReqNo;
            EmpId = entry_BAL[count].EmpID;

            logger.DebugFormat("Input Parameter entry_BAL[0] : PreqNo value = {0} and EmpId value = {1}", PreqNo.ToString(), EmpId.ToString());

            foreach (iSmart_UpdateInputEntity isEntry_value in entry_BAL)
            {
                if ( string.IsNullOrEmpty(isEntry_value.PReqNo) )
                {
                    logger.Error("PReqNo has NULL reference");

                    return 1;
                }

                if (!isEntry_value.PReqNo.Equals(PreqNo))
                {
                    logger.Error("PReqNo is Not same as Previous Entry");

                    return 1;
                }

                if (isEntry_value.Status == 0)
                {
                    logger.Error("Status value is Invalid");

                    return 1;
                }

                if (string.IsNullOrEmpty(isEntry_value.EmpID))
                {
                    logger.Error("EmpID has NULL reference");

                    return 1;
                }

                if (!isEntry_value.EmpID.Equals(EmpId))
                {
                    logger.Error("EmpID is Not same as Previous Entry");

                    return 1;
                }

                //if (string.IsNullOrEmpty(isEntry_value.PurGrpMember))
                //{
                //    logger.Error("PurGrpMember has NULL reference");
                //    logger.Info("Method : validate_isParam Stop");
                //    return 1;
                //}

                if (string.IsNullOrEmpty(isEntry_value.ItemTransactionId))
                {
                    logger.Error("ItemTransactionId has NULL reference");

                    return 1;
                }

                //if (string.IsNullOrEmpty(isEntry_value.AucNo))
                //{
                //    logger.Error("AucNo has NULL reference");
                //    logger.Info("Method : validate_isParam Stop");
                //    return 1;
                //}

                //if (string.IsNullOrEmpty(isEntry_value.CustomerPONum))
                //{
                //    logger.Error("CustomerPONum has NULL reference");
                //    logger.Info("Method : validate_isParam Stop");
                //    return 1;
                //}

                //if (string.IsNullOrEmpty(isEntry_value.PReqRemarks))
                //{
                //    logger.Error("PReqRemarks has NULL reference");
                //    logger.Info("Method : validate_isParam Stop");
                //    return 1;
                //}

                //if (string.IsNullOrEmpty(isEntry_value.RejectedTo))
                //{
                //    logger.Error("PReqRemarks has NULL reference");
                //    logger.Info("Method : validate_isParam Stop");
                //    return 1;
                //}

                //else
                //{
                //    if (isEntry_value.RejectedTo.IndexOf(',') != -1)
                //    {
                //        string[] getRoleCode = isEntry_value.RejectedTo.Split(',');
                //        isEntry_value.RejectedTo = getRoleCode[1].ToString();
                //    }
                //}

                //if (string.IsNullOrEmpty(isEntry_value.AssignTo))
                //{
                //    logger.Error("AssignTo has NULL reference");
                //    logger.Info("Method : validate_isParam Stop");
                //    return 1;
                //}

                if (string.IsNullOrEmpty(isEntry_value.ActionByRole))
                {
                    logger.Error("ActionByRole has NULL reference");

                    return 1;
                }

            }

            logger.Debug("iSmart_BAL: validate_isParam()  Stop");
            return 0;
        }
コード例 #4
0
ファイル: iSmart_DAL.cs プロジェクト: hari316/Projects
        /// <summary>
        /// This function Updates iSmart Details into the Database 
        /// </summary>
        /// <param name="is_entry_DAL"></param>
        /// <returns>
        /// <paramref name="result"/>
        /// </returns>
        /// <history>
        ///     Hari haran      08/05/2012      created
        /// </history>
        public iSmart_UpdateOutputEntity updatePurchaseRequest_DAL(iSmart_UpdateInputEntity[] is_entry_DAL)
        {
            logger.Debug("iSmart_DAL: updatePurchaseRequest_DAL() called");

            iSmart_UpdateOutputEntity result = new iSmart_UpdateOutputEntity();

            databaseLayer dbConStr = new databaseLayer();
            string connStr = dbConStr.connectionInfo;

            //logger.Debug("Connection string : " + connStr);

            SqlConnection conn = new SqlConnection(connStr);
            SqlTransaction Trans = null;
            int updateOpflag = 0;

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

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

            int objCount = 0;
            SqlCommand update_cmd = new SqlCommand();
            update_cmd.Connection = conn;
            update_cmd.CommandType = CommandType.StoredProcedure;
            Trans = conn.BeginTransaction("UpdateTransaction");
            update_cmd.Transaction = Trans;
            SqlDataReader dr;

            string updateQuery = "ITRMSMobileUpdateData";

            update_cmd.Parameters.Add("@PREQNo", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@Status", SqlDbType.Int);
            update_cmd.Parameters.Add("@EmpID", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@PurGrpMember", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@ItemTransactionid", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@AucNo", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@CustomerPONum", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@Remarks", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@RejectedTo", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@AdditionalApprover", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@Flag", SqlDbType.VarChar);
            update_cmd.Parameters.Add("@Mobilerole", SqlDbType.VarChar);

            try
            {

                foreach (iSmart_UpdateInputEntity isEntry_value in is_entry_DAL)
                {
                    logger.DebugFormat("Object Count in Input array is_entry_DAL : {0}",objCount.ToString());

                    update_cmd.CommandText = updateQuery;
                    update_cmd.Parameters["@PREQNo"].Value = isEntry_value.PReqNo;
                    update_cmd.Parameters["@Status"].Value = isEntry_value.Status;
                    update_cmd.Parameters["@EmpID"].Value = isEntry_value.EmpID;
                    update_cmd.Parameters["@PurGrpMember"].Value = isEntry_value.PurGrpMember;
                    update_cmd.Parameters["@ItemTransactionid"].Value = isEntry_value.ItemTransactionId;
                    update_cmd.Parameters["@AucNo"].Value = isEntry_value.AucNo;
                    update_cmd.Parameters["@CustomerPONum"].Value = isEntry_value.CustomerPONum;
                    update_cmd.Parameters["@Remarks"].Value = isEntry_value.PReqRemarks;
                    update_cmd.Parameters["@RejectedTo"].Value = isEntry_value.RejectedTo;
                    update_cmd.Parameters["@AdditionalApprover"].Value = isEntry_value.AssignTo;
                    update_cmd.Parameters["@Flag"].Value = "Details";
                    update_cmd.Parameters["@Mobilerole"].Value = isEntry_value.ActionByRole;

                    QueryLog.CmdInfo(update_cmd);

                    dr = update_cmd.ExecuteReader();

                    dr.NextResult();

                    if (dr.HasRows)
                    {
                        dr.Read();
                        if (dr["StatusFlag"].Equals(0))
                        {
                            dr.Close();
                            updateOpflag = 0;
                            objCount++;
                        }
                        else
                        {
                            dr.Close();
                            updateOpflag = 1;
                            break;
                        }
                    }
                    else
                    {
                        dr.Close();
                        updateOpflag = 1;
                        break;
                    }
                }

                if (updateOpflag == 0)
                {
                    update_cmd.CommandText = updateQuery;
                    update_cmd.Parameters["@PREQNo"].Value = is_entry_DAL[0].PReqNo;
                    update_cmd.Parameters["@Status"].Value = is_entry_DAL[0].Status;
                    update_cmd.Parameters["@EmpID"].Value = is_entry_DAL[0].EmpID;
                    update_cmd.Parameters["@PurGrpMember"].Value = is_entry_DAL[0].PurGrpMember;
                    update_cmd.Parameters["@ItemTransactionid"].Value = is_entry_DAL[0].ItemTransactionId;
                    update_cmd.Parameters["@AucNo"].Value = is_entry_DAL[0].AucNo;
                    update_cmd.Parameters["@CustomerPONum"].Value = is_entry_DAL[0].CustomerPONum;
                    update_cmd.Parameters["@Remarks"].Value = is_entry_DAL[0].PReqRemarks;
                    update_cmd.Parameters["@RejectedTo"].Value = is_entry_DAL[0].RejectedTo;
                    update_cmd.Parameters["@AdditionalApprover"].Value = is_entry_DAL[0].AssignTo;
                    update_cmd.Parameters["@Mobilerole"].Value = is_entry_DAL[0].ActionByRole;
                    update_cmd.Parameters["@Flag"].Value = "Header";

                    logger.Debug("Updating the Header Details of iSmart UpdateInput Entity");

                    QueryLog.CmdInfo(update_cmd);

                    dr = update_cmd.ExecuteReader();

                    dr.NextResult();

                    if (dr.HasRows)
                    {

                        dr.Read();
                        if (dr["StatusFlag"].Equals(0))
                        {
                            dr.Close();
                            Trans.Commit();
                            result.StatusFlag = 0;
                            result.Message = iSmart_Constants.Success;

                            logger.Info("Operation : Update operation executed successfully");
                        }
                        else
                        {
                            dr.Close();
                            Trans.Rollback("UpdateTransaction");

                            logger.Error("Transaction Rollback Executed");

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

                            logger.Error("Operation : Update operation Failed");
                        }
                    }
                    else
                    {
                        dr.Close();
                        Trans.Rollback("UpdateTransaction");

                        logger.Error("Transaction Rollback Executed");

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

                        logger.Error("Operation : Update operation Failed");
                    }

                }
                else
                {
                    Trans.Rollback("UpdateTransaction");

                    logger.Error("Transaction Rollback Executed");

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

                    logger.Error("Operation : Update Error - Invalid parameter values");
                }

                logger.Info("iSmart_DAL: updatePurchaseRequest_DAL() Stop");

                return result;
            }
            catch (SqlException dbEx)
            {
                logger.Error("SQL Exception Occured At iSmart_DAL - updatePurchaseRequest_DAL  : ");
                logger.Error("Exception Code : " + dbEx.Number.ToString());
                logger.Error("Exception Description : " + dbEx.Message.ToString());
                logger.Error("iSmart_DAL: updatePurchaseRequest_DAL() returning error");
                try
                {
                    logger.Error("Transaction Rollback Executed");
                    Trans.Rollback("UpdateTransaction");
                }
                catch (Exception ex2)
                {
                    logger.Error("Tranasction Rollback Failed : " + ex2.Message.ToString());
                    //throw ex2;
                }
                throw dbEx;
            }
            catch (Exception ex)
            {
                logger.Error("Exception Occured At iSmart_DAL - updatePurchaseRequest_DAL  : " + ex.Message.ToString());
                logger.Error("iSmart_DAL: updatePurchaseRequest_DAL() returning error");

                try
                {
                    logger.Error("Transaction Rollback Executed");
                    Trans.Rollback("UpdateTransaction");
                }
                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();
            }
        }
コード例 #5
0
ファイル: Service.cs プロジェクト: hari316/Projects
 /// <summary>
 /// This Method returns PreqNo
 /// </summary>
 /// <param name="Ex"> TS_Entry </param>
 /// <returns>Preq No</returns>
 /// 
 private string getPreqNo(iSmart_UpdateInputEntity[] IS_Entry)
 {
     if (IS_Entry != null)
         return IS_Entry[0].PReqNo.ToString();
     else
         return string.Empty;
 }