示例#1
0
        /// <summary>
        /// This method returns the pdf details of car from stored procedure based on requestID
        /// </summary>
        /// <param name="requestID"></param>
        /// <returns></returns>
        public CarApprovalModel GetPDFDetailsFromCAR(string requestID, string backendID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                CarApprovalModel ObjSA = null;
                // Create an array list for storing parameters
                ArrayList parameterArray = new ArrayList();
                // Initialize a new sql parameter list
                List <SqlParameter> sqlParameters = new List <SqlParameter>();
                // Initialize a new sql parameters
                SqlParameter pRequestID = new SqlParameter("@RequestID", requestID);
                pRequestID.Direction = ParameterDirection.Input;
                // Adding all sql parameters to sql parameter array
                sqlParameters.Add(pRequestID);
                // Open a new SQL Connection
                sqldataProvider.OpenConnection(ConfigurationManager.ConnectionStrings["BakendAgentCarConnectionString"].ConnectionString);
                // Execute stored procedure for fetching PDf details from CAR Backend.
                DataSet dsPdfDetails = (DataSet)sqldataProvider.ExecuteDataSet(CommandType.StoredProcedure, ConfigurationManager.AppSettings["GetCarPDFDetailsSPName"], sqlParameters.ToArray());
                // CarSummary objCarbasicInfo = null;
                Dictionary <string, object> objReqDetails = null;
                //stored procedure returns two result sets
                if (dsPdfDetails != null && dsPdfDetails.Tables.Count > 0)
                {
                    FieldsMapping objFieldsMap = new FieldsMapping();
                    //call FieldsMapping.GetFiledsMappingJsonString() method which will return  RequestFieldsMappingJson,ApproverFieldsMappingJson
                    MappingTypes ObjMaps = objFieldsMap.GetFiledsMappingJsonString(backendID);
                    //getting CARApprovalBasicInfo details from dataset table 1
                    if (dsPdfDetails.Tables[0] != null && dsPdfDetails.Tables[0].Rows.Count > 0)
                    {
                        DataRow row = dsPdfDetails.Tables[0].Rows[0];
                        //Call FieldsMapping.MapDtFieldstoBackendRequest() method, which returns Mapping request details to RequestDetailsMapping class object
                        //CarSummary objReqDetails = objFieldsMap.MapDtFieldstoBackendRequest<CarSummary>(row, ObjMaps.RequestFieldsMappingJson);
                        //objCarbasicInfo = new CarSummary()
                        //{
                        //    Name = (!string.IsNullOrEmpty(objReqDetails.Name)) ? objReqDetails.Name : string.Empty,
                        //    Description = (!string.IsNullOrEmpty(objReqDetails.Description)) ? objReqDetails.Description : string.Empty,
                        //    Controller = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.Controller))) ? Convert.ToInt32(objReqDetails.Controller) : 0,
                        //    Requestor = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.Requestor))) ? Convert.ToInt32(objReqDetails.Requestor) : 0,
                        //    DateofRequest= (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.DateofRequest))) ? Convert.ToDateTime(objReqDetails.DateofRequest) : (DateTime?)null,
                        //    BrandDescription = (!string.IsNullOrEmpty(objReqDetails.BrandDescription)) ? objReqDetails.BrandDescription : string.Empty,
                        //    CountryDescription = (!string.IsNullOrEmpty(objReqDetails.CountryDescription)) ? objReqDetails.CountryDescription : string.Empty,
                        //    MarketDescription = (!string.IsNullOrEmpty(objReqDetails.MarketDescription)) ? objReqDetails.MarketDescription : string.Empty,
                        //    InvestmentTypeDescription = (!string.IsNullOrEmpty(objReqDetails.InvestmentTypeDescription)) ? objReqDetails.InvestmentTypeDescription : string.Empty,
                        //    EstimatedStartDate = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.EstimatedStartDate))) ? Convert.ToDateTime(objReqDetails.EstimatedStartDate) : (DateTime?)null,
                        //    EstimatedCompletionDate = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.EstimatedCompletionDate))) ? Convert.ToDateTime(objReqDetails.EstimatedCompletionDate) : (DateTime?)null,
                        //    Budgeted= (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.Budgeted))) ? Convert.ToBoolean(Convert.ToInt32(objReqDetails.Budgeted)) : false,
                        //    Capex = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.Capex))) ? Convert.ToDecimal(objReqDetails.Capex) : 0,
                        //    CapexLocal = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.CapexLocal))) ? Convert.ToDecimal(objReqDetails.CapexLocal) : 0,
                        //    SpenttodateEUR = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.SpenttodateEUR))) ? Convert.ToDecimal(objReqDetails.SpenttodateEUR) : 0,
                        //    CAPEXThisRequest = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.CAPEXThisRequest))) ? Convert.ToDecimal(objReqDetails.CAPEXThisRequest) : 0,
                        //    LocalCurency = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.LocalCurency))) ? Convert.ToInt32(objReqDetails.LocalCurency) : 0,
                        //    AssetNo = (!string.IsNullOrEmpty(objReqDetails.AssetNo)) ? Convert.ToString(objReqDetails.AssetNo) : string.Empty,
                        //    CostCenterInternalOrder = (!string.IsNullOrEmpty(objReqDetails.CostCenterInternalOrder)) ? Convert.ToString(objReqDetails.CostCenterInternalOrder) : string.Empty,
                        //    IMSNumber = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.IMSNumber))) ? Convert.ToInt32(objReqDetails.IMSNumber) : 0,
                        //    CAPEXCodeGrape = (!string.IsNullOrEmpty(objReqDetails.CAPEXCodeGrape))?objReqDetails.CAPEXCodeGrape : string.Empty,
                        //    FinanceLease = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.FinanceLease))) ? Convert.ToBoolean(Convert.ToInt32(objReqDetails.FinanceLease)) : false,
                        //    ContractualObligation = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.ContractualObligation))) ? Convert.ToBoolean(Convert.ToInt32(objReqDetails.ContractualObligation)) : false,
                        //    PurchaseOption = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.PurchaseOption))) ? Convert.ToBoolean(Convert.ToInt32(objReqDetails.PurchaseOption)) : false,
                        //    GlobalRealEstate = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.GlobalRealEstate))) ? Convert.ToBoolean(Convert.ToInt32(objReqDetails.GlobalRealEstate)) : false,
                        //    NoOfYears = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.NoOfYears))) ? Convert.ToInt32(objReqDetails.NoOfYears) : 0,


                        //};
                        objReqDetails = objFieldsMap.MapDBFieldstoBackendRequest(row, ObjMaps.RequestFieldsMappingJson);
                    }
                    //getting CarCapexMatrix details from dataset table 2
                    //writing it into CarCapexMatrixlist
                    List <CarCapexMatrix> lstCarCapexmatrix = null;
                    if (dsPdfDetails.Tables[1] != null && dsPdfDetails.Tables[1].Rows.Count > 0)
                    {
                        //call FieldsMapping.MapApproverFieldstoBackendRequest() method, which returns list of approver details after Mapping into ApproverFeildsMapping class object
                        lstCarCapexmatrix = objFieldsMap.MapApproverFieldstoBackendRequest <CarCapexMatrix>(dsPdfDetails.Tables[1], ObjMaps.MatrixFieldsMappingJson);

                        //lstCarCapexmatrix = dsPdfDetails.Tables[1].AsEnumerable().Select(row =>
                        //                                    new CarCapexMatrix
                        //                                    {
                        //                                        CapexMatricDescription = row.Field<string>("Description"),
                        //                                        Y1 = row.Field<decimal>("Y1"),
                        //                                        Y2 = row.Field<decimal>("Y2"),
                        //                                        Y3 = row.Field<decimal>("Y3"),
                        //                                        TotalSum = row.Field<decimal>("TotalSum")
                        //                                    }).ToList();
                    }
                    //clone CAR pdf details into CarApprovalModel class
                    ObjSA = new CarApprovalModel()
                    {
                        CarBasicInformation   = objReqDetails,
                        CarCapexMatrixDetails = lstCarCapexmatrix
                    };
                }
                return(ObjSA);
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                throw new DataAccessException(exception.Message, exception.InnerException);
            }
        }
        /// <summary>
        /// This method returns the pdf details of store from stored procedure based on requestID
        /// </summary>
        /// <param name="requestID"></param>
        /// <returns></returns>
        public StoreApprovalModel GetPDFDetailsFromStore(string requestID, string backendID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                StoreApprovalModel ObjSA = null;
                // Create an array list for storing parameters
                ArrayList parameterArray = new ArrayList();
                // Initialize a new sql parameter list
                List <SqlParameter> sqlParameters = new List <SqlParameter>();
                // Initialize a new sql parameters
                SqlParameter pRequestID = new SqlParameter("@BPMID", requestID);
                pRequestID.Direction = ParameterDirection.Input;
                // Adding all sql parameters to sql parameter array
                sqlParameters.Add(pRequestID);
                // Open a new SQL Connection
                sqldataProvider.OpenConnection(ConfigurationManager.ConnectionStrings["BakendAgentStoreConnectionString"].ConnectionString);
                // Execute stored procedure for fetching PDf details from STORE Backend.
                DataSet dsPdfDetails = (DataSet)sqldataProvider.ExecuteDataSet(CommandType.StoredProcedure, ConfigurationManager.AppSettings["GetStorePDFDetailsSPName"], sqlParameters.ToArray());
                //StoreApprovalBasicInfo objSAbasicInfo = null;
                Dictionary <string, object> objReqDetails = null;
                //stored procedure returns two result sets
                if (dsPdfDetails != null && dsPdfDetails.Tables.Count > 0)
                {
                    FieldsMapping objFieldsMap = new FieldsMapping();
                    //call FieldsMapping.GetFiledsMappingJsonString() method which will return  RequestFieldsMappingJson,ApproverFieldsMappingJson
                    MappingTypes ObjMaps = objFieldsMap.GetFiledsMappingJsonString(backendID);
                    //getting StoreApprovalBasicInfo details from dataset table 1
                    if (dsPdfDetails.Tables[0] != null && dsPdfDetails.Tables[0].Rows.Count > 0)
                    {
                        DataRow row = dsPdfDetails.Tables[0].Rows[0];

                        //Call FieldsMapping.MapDtFieldstoBackendRequest() method, which returns Mapping request details to RequestDetailsMapping class object
                        //StoreApprovalBasicInfo objReqDetails = objFieldsMap.MapDtFieldstoBackendRequest<StoreApprovalBasicInfo>(row, ObjMaps.RequestFieldsMappingJson);
                        //objSAbasicInfo = new StoreApprovalBasicInfo()
                        //{
                        //    DisplayBPMID = (!string.IsNullOrEmpty(objReqDetails.DisplayBPMID)) ? objReqDetails.DisplayBPMID : string.Empty,
                        //    RequestName = (!string.IsNullOrEmpty(objReqDetails.RequestName)) ? objReqDetails.RequestName : string.Empty,
                        //    MarketName = (!string.IsNullOrEmpty(objReqDetails.MarketName)) ? objReqDetails.MarketName : string.Empty,
                        //    ProjectName = (!string.IsNullOrEmpty(objReqDetails.ProjectName)) ? objReqDetails.ProjectName : string.Empty,
                        //    BrandName = (!string.IsNullOrEmpty(objReqDetails.BrandName)) ? objReqDetails.BrandName : string.Empty,
                        //    SecurityDeposit = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.SecurityDeposit))) ? objReqDetails.SecurityDeposit : 0,
                        //    TotalInvestment = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.TotalInvestment))) ? objReqDetails.TotalInvestment : 0,
                        //    KeyMoney = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.KeyMoney))) ? objReqDetails.KeyMoney : 0,
                        //    Brand = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.Brand))) ? Convert.ToDecimal(objReqDetails.Brand) : 0,
                        //    CaseID = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.CaseID))) ? Convert.ToInt32(objReqDetails.CaseID) : 0,
                        //    StoreTypeName = (!string.IsNullOrEmpty(objReqDetails.StoreTypeName)) ? objReqDetails.StoreTypeName : string.Empty,
                        //    NetSellingSpace = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.NetSellingSpace))) ? Convert.ToInt32(objReqDetails.NetSellingSpace) : 0,
                        //    OpeningDate = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.OpeningDate))) ? Convert.ToDateTime(objReqDetails.OpeningDate) : (DateTime?)null,
                        //    LeaseEndDate = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.LeaseEndDate))) ? Convert.ToDateTime(objReqDetails.LeaseEndDate) : (DateTime?)null,
                        //    LeasingPeriodDec = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.LeasingPeriodDec))) ? Convert.ToDecimal(objReqDetails.LeasingPeriodDec) : 0,
                        //    CancelPeriod = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.CancelPeriod))) ? Convert.ToInt32(objReqDetails.CancelPeriod) : 0,
                        //    LeaseBreakOption = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.LeaseBreakOption))) ? Convert.ToInt32(objReqDetails.LeaseBreakOption) : 0,
                        //    CapexSpendYear = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.CapexSpendYear))) ? Convert.ToInt32(objReqDetails.CapexSpendYear) : 0,
                        //    GrossLeasedArea = (!string.IsNullOrEmpty(Convert.ToString(objReqDetails.GrossLeasedArea))) ? Convert.ToInt32(objReqDetails.GrossLeasedArea) : 0
                        //};
                        objReqDetails = objFieldsMap.MapDBFieldstoBackendRequest(row, ObjMaps.RequestFieldsMappingJson);
                    }
                    //getting StoreExecutiveSummary details from dataset table 2

                    List <StoreExecutiveSummary> lstSASummary = null;
                    if (dsPdfDetails.Tables[1] != null && dsPdfDetails.Tables[1].Rows.Count > 0)
                    {
                        //call FieldsMapping.MapApproverFieldstoBackendRequest() method, which returns list of approver details after Mapping into ApproverFeildsMapping class object
                        lstSASummary = objFieldsMap.MapApproverFieldstoBackendRequest <StoreExecutiveSummary>(dsPdfDetails.Tables[1], ObjMaps.MatrixFieldsMappingJson);


                        //lstSASummary = dsPdfDetails.Tables[1].AsEnumerable().Select(row =>
                        //                                    new StoreExecutiveSummary
                        //                                    {
                        //                                        LineID = row.Field<string>("LineID"),
                        //                                        Description = row.Field<string>("Description"),
                        //                                        Y0 = row.Field<string>("Y0"),
                        //                                        Y0Val = row.Field<string>("Y0Val"),
                        //                                        Y1 = row.Field<string>("Y1"),
                        //                                        Y1Val = row.Field<string>("Y1Val"),
                        //                                        Y2 = row.Field<string>("Y2"),
                        //                                        Y2Val = row.Field<string>("Y2Val"),
                        //                                        Y3 = row.Field<string>("Y3"),
                        //                                        Y3Val = row.Field<string>("Y3Val"),
                        //                                        Y4 = row.Field<string>("Y4"),
                        //                                        Y4Val = row.Field<string>("Y4Val"),
                        //                                        Y5 = row.Field<string>("Y5"),
                        //                                        Y5Val = row.Field<string>("Y5Val"),
                        //                                        GRSVal = row.Field<string>("GRSVal"),
                        //                                    }).ToList();
                    }
                    //getting store pdf details into StoreApprovalModel class
                    ObjSA = new StoreApprovalModel()
                    {
                        StoreBasicInformation = objReqDetails,
                        StoreSummaryDetails   = lstSASummary
                    };
                }
                return(ObjSA);
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                throw new DataAccessException(exception.Message, exception.InnerException);
            }
        }