Пример #1
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);
        }
Пример #2
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();
        }