示例#1
0
 /// <summary>
 /// Sync the data from EMS file with data into database, if file was imported before.
 /// </summary>
 /// <param name="objInProcessUser"></param>
 /// <param name="objImportData"></param>
 private void updateEMSData(InProcessUsersBL objInProcessUser, ImportData objImportData)
 {
     try
     {
         if (objInProcessUser.iUserId.HasValue && updateUserData(objInProcessUser.iUserId.Value, objImportData))
         {
             if (objInProcessUser.iVehicleId.HasValue)
             {
                 updateVehicleStatus(objInProcessUser.iVehicleId.Value, objInProcessUser.iShopId.Value, objImportData);
                 updateVehicleData(objInProcessUser.iVehicleId.Value, objImportData);
             }
             updateInsuranceData(objInProcessUser.iUserId.Value, objImportData);
         }
     }
     catch (Exception ex)
     {
         Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, SummitShopApp.Utility.Constants.ExceptionPolicy);
     }
 }
示例#2
0
        public VehicleInfoBL SaveVehicleinfo(VehicleInfoBL objVehicleInfo, ImportData objImportData, UserBL objUser)
        {
            objVehicleInfo.iUserId          = objUser.ID;
            objVehicleInfo.strYear          = objImportData.Year;
            objVehicleInfo.strMake          = objImportData.Make;
            objVehicleInfo.strModel         = objImportData.Model;
            objVehicleInfo.strStyle         = objImportData.Style;
            objVehicleInfo.strColor         = objImportData.Color;
            objVehicleInfo.strPaintCode     = objImportData.Paint_Code;
            objVehicleInfo.strVIN           = objImportData.VIN;
            objVehicleInfo.strEstimatorName = objImportData.EstimatorName.Trim();
            objVehicleInfo.strLicense       = objImportData.License;
            DateTime dtProductionDate;

            objVehicleInfo.dtProductionDate = DateTime.TryParse("", out dtProductionDate) ? dtProductionDate : (Nullable <DateTime>)null;
            objVehicleInfo.bIsUsing         = true;
            objVehicleInfo.Save();
            return(objVehicleInfo);
        }
示例#3
0
        private Boolean updateVehicleStatus(Int32 iVehicleId, Int32 iShopId, ImportData objImportData)
        {
            try
            {
                UserVehicleStatusBL objCustomerVehicleStatus = UserVehicleStatusBL.getDataByVehicleId(iVehicleId);
                if (objCustomerVehicleStatus != null)
                {
                    DateTime dtOut;
                    objCustomerVehicleStatus.dtDateIn  = DateTime.TryParse(objImportData.Scheduled_In_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtDateOut = DateTime.TryParse(objImportData.Target_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtActual_Delivery_Date = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtFile_Import_Date     = DateTime.TryParse(objImportData.File_Import_date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtFile_Import_Time     = DateTime.TryParse(objImportData.File_Import_Time, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtRepair_Start_Date    = DateTime.TryParse(objImportData.Repair_Start_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.dtDeliveryDate         = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
                    objCustomerVehicleStatus.iETA_Hours             = Convert.ToInt32(objImportData.ETA_Hours);
                    objCustomerVehicleStatus.iRO_Hours      = Convert.ToInt32(objImportData.RO_Hours);
                    objCustomerVehicleStatus.strFile_Status = objImportData.File_Status;
                    objCustomerVehicleStatus.Save();


                    //Set Show InProcess true for current vehicle
                    //MarketingUsers objMarUser = MarketingUsers.getDataByShopUserAndVehicleId(iShopId, Convert.ToInt32(objCustomerVehicleStatus.iUserId), iVehicleId);
                    //objMarUser.bisShowInProcess = true;
                    //return objMarUser.Save();
                }
                else
                {
                    //SaveVehicleStatus(VehicleInfoBL objVehicleInfo, ImportData objImportData, UserBL objUser, String strShopId)
                    //Insert new record in UserVehicleStatus table
                    AddnewRecordInVehicleStatus(iVehicleId, iShopId, objImportData);
                }
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, SummitShopApp.Utility.Constants.ExceptionPolicy);
            }
            return(false);
        }
示例#4
0
        /// <summary>
        /// Validate Data before Import
        /// </summary>
        /// <param name="objImportData"></param>
        /// <returns></returns>
        public String ValidateData(ImportData objImportData)
        {
            String strError = String.Empty;

            if (String.IsNullOrEmpty(objImportData.First_Name) || objImportData.First_Name.Length > 50)
            {
                strError = strError + Constants.ERROR_FIRSTNAME + Constants.BR;
            }
            if (String.IsNullOrEmpty(objImportData.Last_Name) || objImportData.Last_Name.Length > 50)
            {
                strError = strError + Constants.ERROR_LASTNAME + Constants.BR;
            }
            if (String.IsNullOrEmpty(objImportData.Year) || (!String.IsNullOrEmpty(objImportData.Year) && !StringProcessing.StringFunctions.IsNumeric(objImportData.Year.Trim())))
            {
                strError = strError + Constants.ERROR_YEAR + Constants.BR;
            }
            if (String.IsNullOrEmpty(objImportData.Make) || objImportData.Make.Length > 50)
            {
                strError = strError + Constants.ERROR_MAKE + Constants.BR;
            }
            if (String.IsNullOrEmpty(objImportData.Model) || objImportData.Model.Length > 50)
            {
                strError = strError + Constants.ERROR_MODEL + Constants.BR;
            }
            if (String.IsNullOrEmpty(objImportData.Mobile) || (!String.IsNullOrEmpty(objImportData.Mobile) && !(StringProcessing.StringFunctions.IsNumeric(objImportData.Mobile.Trim()) && objImportData.Mobile.Trim().Length == 10)))
            {
                strError = strError + Constants.ERROR_PHONE + Constants.BR;
            }
            if ((!String.IsNullOrEmpty(objImportData.Email) && !StringProcessing.StringFunctions.IsEmailAddress(objImportData.Email)))
            {
                strError = strError + Constants.ERROR_EMAIL + Constants.BR;
            }

            strError = ValidateDates(objImportData, strError);
            strError = ValidateNonRequiredFields(objImportData, strError);

            return(strError);
        }
示例#5
0
        /// <summary>
        /// Update Insurance Information
        /// </summary>
        /// <param name="iUserId"></param>
        /// <param name="objImportData"></param>
        /// <returns></returns>
        private Boolean updateInsuranceData(Int32 iUserId, ImportData objImportData)
        {
            try
            {
                //Get InsuranceInfo object from database using user_id
                InsuranceInformationBL objInsurance = InsuranceInformationBL.getDataByUserId(iUserId);
                if (objInsurance == null)
                {
                    //Create new object for Insurance if information is not addedpreviously.
                    objInsurance         = new InsuranceInformationBL();
                    objInsurance.iUserId = iUserId;
                }
                if (!String.IsNullOrEmpty(objImportData.Insurance_Company))
                {
                    objInsurance.strCompanyName = objImportData.Insurance_Company;
                }
                if (!String.IsNullOrEmpty(objImportData.Insurance_Company_Address))
                {
                    objInsurance.strCompanyAddress = objImportData.Insurance_Company_Address;
                }

                if (!String.IsNullOrEmpty(objImportData.Insurance_Company_City))
                {
                    objInsurance.strCompanyCity = objImportData.Insurance_Company_City;
                }

                if (!String.IsNullOrEmpty(objImportData.Insurance_Company_State))
                {
                    objInsurance.strCompanyState = objImportData.Insurance_Company_State;
                }

                if (!String.IsNullOrEmpty(objImportData.Insurance_Company_Zip))
                {
                    objInsurance.strCompanyZip = objImportData.Insurance_Company_Zip;
                }

                if (!String.IsNullOrEmpty(objImportData.Insurance_Company_Email))
                {
                    objInsurance.strCompanyEmail = objImportData.Insurance_Company_Email;
                }

                if (!String.IsNullOrEmpty(objImportData.Insurance_Company_Contact))
                {
                    objInsurance.strCompanyCellPhone = objImportData.Insurance_Company_Contact;
                }

                if (!String.IsNullOrEmpty(objImportData.Insurance_Company_Fax))
                {
                    objInsurance.strCompanyFax = objImportData.Insurance_Company_Fax;
                }

                if (!String.IsNullOrEmpty(objImportData.Agent))
                {
                    objInsurance.strAgentName = objImportData.Agent;
                }

                if (!String.IsNullOrEmpty(objImportData.Claim_Number))
                {
                    objInsurance.strClaimNumber = objImportData.Claim_Number;
                }

                if (!String.IsNullOrEmpty(objImportData.RO_Number))
                {
                    objInsurance.strROIdentifier = objImportData.RO_Number;
                }

                if (!String.IsNullOrEmpty(objImportData.Total_Amount))
                {
                    objInsurance.strNetTotalAmount = objImportData.Total_Amount;
                }


                if (!String.IsNullOrEmpty(objImportData.Total_RO_Amount))
                {
                    objInsurance.strTotalROAmount = objImportData.Total_RO_Amount;
                }

                if (!String.IsNullOrEmpty(objImportData.Date_Of_Loss))
                {
                    DateTime dtDateofLoss;
                    objInsurance.dtDateOfLoss = DateTime.TryParse(objImportData.Date_Of_Loss, out dtDateofLoss) ? dtDateofLoss : (Nullable <DateTime>)null;
                }
                if (!String.IsNullOrEmpty(objImportData.Deductible))
                {
                    Decimal dDeductible;
                    objInsurance.dDeductible = Decimal.TryParse(objImportData.Deductible, out dDeductible) ? dDeductible : (Nullable <Decimal>)null;
                }
                return(objInsurance.Save());
            }
            catch (Exception ex)
            {
                Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, SummitShopApp.Utility.Constants.ExceptionPolicy);
            }
            return(false);
        }
示例#6
0
        public String ValidateNonRequiredFields(ImportData objImportData, String strError)
        {
            if (!String.IsNullOrEmpty(objImportData.Claim_Number) && objImportData.Claim_Number.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Claim number " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.RO_Number) && objImportData.RO_Number.Length > 50)
            {
                strError = strError + Constants.ERROR + ":RO number " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Agent_Email) && StringProcessing.StringFunctions.IsEmailAddress(objImportData.Agent_Email.Trim()))
            {
                strError = strError + Constants.INVALID + " Agent Email " + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.City) && objImportData.City.Length > 50)
            {
                strError = strError + Constants.ERROR + ": City " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Color) && objImportData.Color.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Color " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Agent) && objImportData.Agent.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Agent name " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Insurance_Company) && objImportData.Insurance_Company.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Insurance Company name " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Insurance_Company_Address) && objImportData.Insurance_Company_Address.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Insurance Company address must be less than 200 characters " + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Insurance_Company_City) && objImportData.Insurance_Company_City.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Insurance Company City " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Paint_Code) && objImportData.Paint_Code.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Paint_Code " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Style) && objImportData.Style.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Style " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Total_Amount) && objImportData.Total_Amount.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Total Amount " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.Total_RO_Amount) && objImportData.Total_RO_Amount.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Total RO Amount " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.VIN) && objImportData.VIN.Length > 50)
            {
                strError = strError + Constants.ERROR + ": Vehicle Identification Number " + Constants.MUST_BE_INRANGE + Constants.BR;
            }
            if (!String.IsNullOrEmpty(objImportData.EstimatorName) && objImportData.EstimatorName.Length > 100)
            {
                strError = strError + Constants.ERROR + ": Estimator Name must be less than 100 characters " + Constants.BR;
            }

            Decimal dc;

            if (!String.IsNullOrEmpty(objImportData.Deductible) && !(Decimal.TryParse(objImportData.Deductible.Trim(), out dc) && objImportData.Deductible.Trim().Length < 20))
            {
                strError = strError + Constants.ERROR + ": Deductible must be in decimal format and less than 20 characteres " + Constants.BR;
            }
            return(strError);
        }
示例#7
0
        public void SaveVehicleStatus(VehicleInfoBL objVehicleInfo, ImportData objImportData, UserBL objUser, String strShopId)
        {
            String              strStatus                = String.Empty;
            VehicleStatusBL     objTemp                  = null;
            Boolean             bIsStatusChanged         = false;
            int                 iVehicleStatusId         = 0;
            UserVehicleStatusBL objCustomerVehicleStatus = new UserVehicleStatusBL();
            DateTime            dtOut;

            objCustomerVehicleStatus.iUserId                = objUser.ID;
            objCustomerVehicleStatus.iVehicleId             = objVehicleInfo.ID;
            objCustomerVehicleStatus.dtDateIn               = DateTime.TryParse(objImportData.Scheduled_In_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            objCustomerVehicleStatus.dtDateOut              = DateTime.TryParse(objImportData.Target_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            objCustomerVehicleStatus.dtActual_Delivery_Date = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            objCustomerVehicleStatus.dtFile_Import_Date     = DateTime.TryParse(objImportData.File_Import_date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            objCustomerVehicleStatus.dtFile_Import_Time     = DateTime.TryParse(objImportData.File_Import_Time, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            objCustomerVehicleStatus.dtRepair_Start_Date    = DateTime.TryParse(objImportData.Repair_Start_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            objCustomerVehicleStatus.dtDeliveryDate         = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            objCustomerVehicleStatus.iETA_Hours             = Convert.ToInt32(objImportData.ETA_Hours);
            objCustomerVehicleStatus.iRO_Hours              = Convert.ToInt32(objImportData.RO_Hours);
            objCustomerVehicleStatus.strFile_Status         = objImportData.File_Status;

            System.Collections.Generic.List <SummitShopApp.BL.VehicleStatusBL> lstVehicleStatus = new List <SummitShopApp.BL.VehicleStatusBL>();
            lstVehicleStatus = VehicleStatusBL.getDataByShopId(Convert.ToInt32(strShopId));

            DateTime?dtImportDate         = DateTime.TryParse(objImportData.File_Import_date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            DateTime?dtRepairStartDate    = DateTime.TryParse(objImportData.Repair_Start_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            DateTime?dtActualDeliveryDate = DateTime.TryParse(objImportData.Actual_Delivery_Date, out dtOut) ? dtOut : (Nullable <DateTime>)null;
            DateTime dtToday = DateTime.Today;

            //Update Vehicle Status depending Matching Date

            if (dtToday.Date.Equals(dtImportDate))
            {
                strStatus        = Constants.IMPORTED_ESTIMATE;
                bIsStatusChanged = true;
            }
            if (dtToday.Date.Equals(dtRepairStartDate))
            {
                strStatus        = Constants.INPROCESS_REPAIR;
                bIsStatusChanged = true;
            }
            if (dtToday.Date.Equals(dtActualDeliveryDate))
            {
                strStatus        = Constants.DELIVERED;
                bIsStatusChanged = true;
            }

            if (!bIsStatusChanged)
            {
                strStatus = Constants.UNSOLD_ESTIMATE;
            }

            if (lstVehicleStatus.Count > 0)
            {
                objTemp = lstVehicleStatus.Find(vs => vs.strVehicleStatus == strStatus);
            }
            if (objTemp != null)
            {
                objTemp          = lstVehicleStatus.Find(vs => vs.strVehicleStatus == strStatus);
                iVehicleStatusId = objTemp.ID;
                objCustomerVehicleStatus.iVehicleStatusId        = iVehicleStatusId;
                objCustomerVehicleStatus.dtLastUpdatedStatusDate = DateTime.Now;
                if (String.Equals(strStatus, Constants.DELIVERED))
                {
                    objCustomerVehicleStatus.dtDeliveryDate = DateTime.Now;
                }
                if (strStatus == Constants.UNSOLD_ESTIMATE || strStatus == Constants.DELIVERED)
                {
                    objUser.bIsShowEmailMarketing = true;
                    objUser.bIsShowTextMarketing  = true;
                    objUser.Save();
                    MarketingUsers objMarUser = MarketingUsers.getDataByShopAndUserId(Convert.ToInt32(strShopId), Convert.ToInt32(objUser.ID));
                    if (objMarUser != null)
                    {
                        objMarUser.bisShowInProcess = false;
                        objMarUser.Save();
                    }
                }
            }
            else
            {
                VehicleStatusBL _objVehicleStatus = new VehicleStatusBL();
                _objVehicleStatus.strVehicleStatus = strStatus;
                _objVehicleStatus.strMessage       = String.Empty;
                _objVehicleStatus.iShopId          = Convert.ToInt32(strShopId);
                _objVehicleStatus.bSMS             = false;
                _objVehicleStatus.bIsActive        = false;
                _objVehicleStatus.bEmail           = false;
                if (_objVehicleStatus.Save())
                {
                    objCustomerVehicleStatus.iVehicleStatusId        = _objVehicleStatus.ID;
                    objCustomerVehicleStatus.dtLastUpdatedStatusDate = DateTime.Now;
                }
            }
            objCustomerVehicleStatus.Save();
        }
示例#8
0
        private InProcessUsersBL getInprocessObject(List <InProcessUsersBL> lstInProcessUsers, ImportData objImportData, out Boolean bUpdateData)
        {
            Boolean bIsDuplicate = false;

            foreach (InProcessUsersBL objInProcessObject in lstInProcessUsers)
            {
                //for older file that has been imported and don't have unique file identifier then check for name,year,make,model and mobile #
                if (String.IsNullOrEmpty(objInProcessObject.strEstimateFileIdentifier))
                {
                    bIsDuplicate = (!string.IsNullOrEmpty(objInProcessObject.strUserName) && !string.IsNullOrEmpty(objImportData.strUserName) && objInProcessObject.strUserName.ToLower().Trim() == objImportData.strUserName.ToLower().Trim() && objInProcessObject.strYear != null && objImportData.Year != null && objImportData.Year.ToLower().Trim() == objInProcessObject.strYear.ToLower().Trim() && objInProcessObject.strMake != null && objImportData.Make != null && objInProcessObject.strMake.ToLower().Trim() == objImportData.Make.ToLower().Trim() && objInProcessObject.strModel != null && objImportData.Model != null && objInProcessObject.strModel.ToLower().Trim() == objImportData.Model.ToLower().Trim() && objInProcessObject.strPhone != null && objImportData.Mobile != null && objInProcessObject.strPhone.ToLower().Trim() == objImportData.Mobile.ToLower().Trim());
                }
                if (bIsDuplicate)
                {
                    bUpdateData = true;
                    return(objInProcessObject);
                }
            }
            bUpdateData = false;
            return(null);
        }