Exemplo n.º 1
0
        /// <summary>Save the Log while deleting mapping
        /// <CreatedFor>For Insert QRC Type</CreatedFor>
        /// <CreatedBy>Vijay sahu</CreatedBy>
        /// <CreatedOn>march-11-2015</CreatedOn>
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public ServiceDARModel UserLocationMappingDelete(ServiceDARModel obj, string locationname, string userType)
        {
            ObjUserRepository = new UserRepository();
            objDARRepository  = new DARRepository();
            try
            {
                string createdByName = "";
                if (obj.LocationId > 0)
                {
                    using (workorderEMSEntities objContext = new workorderEMSEntities())
                    {
                        obj.UserName = (from o in objContext.UserRegistrations
                                        where o.UserId == obj.UserId && o.IsDeleted == false
                                        select o.FirstName + "" + o.LastName).FirstOrDefault();


                        createdByName = (from o in objContext.UserRegistrations
                                         where o.UserId == obj.CreatedBy && o.IsDeleted == false
                                         select o.FirstName + "" + o.LastName).FirstOrDefault();
                    }



                    obj.ActivityDetails = DarMessage.DeleteLocationMapping(obj.UserName, locationname, userType, createdByName); // this will generate an message
                    var result = objDARRepository.SaveDARDetails(obj);
                    if (result != null || result > 0)
                    {
                        obj.Response        = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture);
                        obj.DARId           = result;
                        obj.ResponseMessage = CommonMessage.SaveSuccessMessage();
                    }
                    else
                    {
                        obj.Response        = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                        obj.DARId           = result;
                        obj.ResponseMessage = CommonMessage.WrongParameterMessage();
                    }
                }
                else
                {
                    obj.Response        = Convert.ToInt32(ServiceResponse.FailedResponse, CultureInfo.CurrentCulture);
                    obj.ResponseMessage = CommonMessage.WrongParameterMessage();
                }
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public ServiceDARModel UserLocationMappingDelete(ServiceDARModel obj, string locationname, string userType)", "Exception While creating location", obj);
                throw ex;
            }
            return(obj);
        }
Exemplo n.º 2
0
        /// <summary>Get eFleetVehicle Details
        /// <CreatedBy>Bhushan Dod</CreatedBY>
        /// <CreatedFor>GeteFleetVehicleDetailsByID</CreatedFor>
        /// <CreatedOn>Sept-06-2017</CreatedOn>
        /// </summary>
        /// <param name="ObjServiceQRCElevatorModel"></param>
        /// <returns></returns>
        public ServiceResponseModel <VehicleScanModel> GeteFleetVehicleDetailsByID(VehicleScanModel ObjServiceVehicleModel)
        {
            var             ObjeFleetVehicleRepository        = new eFleetVehicleRepository();
            var             objeFleetVehicleScanLogRepository = new eFleetVehicleScanLogRepository();
            var             ObjUserRepository = new UserRepository();
            var             objDARRepository  = new DARRepository();
            ServiceDARModel obj = new ServiceDARModel();
            ServiceResponseModel <VehicleScanModel> ObjServiceResponseModel = new ServiceResponseModel <VehicleScanModel>();

            try
            {
                var authuser = ObjUserRepository.GetSingleOrDefault(x => x.ServiceAuthKey == ObjServiceVehicleModel.ServiceAuthKey && x.IsDeleted == false);
                if (authuser != null && authuser.UserId > 0)
                {
                    var result = GeteFleetVehicleById(ObjServiceVehicleModel.QRCodeID, ObjServiceVehicleModel.LocationID);

                    ObjServiceResponseModel.Message  = (result != null && result.VehicleID > 0) ? CommonMessage.Successful() : CommonMessage.DoesNotExistsRecordMessage();
                    ObjServiceResponseModel.Response = (result != null && result.VehicleID > 0) ? Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture) : Convert.ToInt32(ServiceResponse.FailedResponse, CultureInfo.CurrentCulture);
                    ObjServiceResponseModel.Data     = result;
                    if (result.VehicleID > 0)
                    {
                        //For Scan log maintian
                        long VehScanLogId = objeFleetVehicleScanLogRepository.SaveeFleetVehicleScanLog(result.VehicleID, Convert.ToInt64(eFleetEnum.VehicleScan), authuser.UserId, Convert.ToInt64(result.LocationID));
                        ObjServiceResponseModel.Data.VehicleScanLogId = VehScanLogId;

                        //For DAR log maintian
                        obj.CreatedBy       = authuser.UserId;
                        obj.ActivityDetails = DarMessage.VehicleScanMessage((authuser.FirstName + " " + authuser.LastName), result.VehicleNumber, result.QRCodeID);
                        obj.LocationId      = Convert.ToInt64(result.LocationID);
                        obj.UserId          = authuser.UserId;
                        obj.TaskType        = (long)eFleetEnum.VehicleScan;
                        long DarId = objDARRepository.SaveDARDetails(obj);
                        ObjServiceResponseModel.Data.DarID = DarId;
                    }
                }
                else
                {
                    ObjServiceResponseModel.Response = Convert.ToInt32(ServiceResponse.InvalidSessionResponse, CultureInfo.CurrentCulture);
                    ObjServiceResponseModel.Message  = CommonMessage.InvalidUser();
                }
            }
            catch (Exception ex)
            {
                WorkOrderEMS.BusinessLogic.Exception_B.Exception_B.exceptionHandel_Runtime(ex, "ServiceResponseModel<VehicleScanModel> GeteFleetVehicleDetailsByID(VehicleScanModel ObjServiceVehicleModel)", "while fetching GeteFleetVehicleDetailsByID", ObjServiceVehicleModel);
                ObjServiceResponseModel.Message  = ex.Message;
                ObjServiceResponseModel.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                ObjServiceResponseModel.Data     = null;
            }
            return(ObjServiceResponseModel);
        }
Exemplo n.º 3
0
        /// <summary>Save DAR for QRC Type
        /// <CreatedFor>For Insert QRC Type</CreatedFor>
        /// <CreatedBy>Bhusha n Dod</CreatedBy>
        /// <CreatedOn>Feb-13-2015</CreatedOn>
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public ServiceDARModel SaveDARDetails(ServiceDARModel obj)
        {
            ObjUserRepository = new UserRepository();
            objDARRepository  = new DARRepository();
            workorderEMSEntities _workorderEMSEntities = new workorderEMSEntities();
            bool   IsContinuesWOExist        = false;
            string startTimeDAR              = "";
            string endTimeDAR                = "";
            string activityString            = string.Empty;
            string activityStringForWONumber = string.Empty;

            try
            {
                if (obj.LocationId > 0 && obj.ServiceAuthKey != null)
                {
                    var authuser = ObjUserRepository.GetSingleOrDefault(x => x.ServiceAuthKey == obj.ServiceAuthKey && x.IsDeleted == false);
                    if (obj.ActivityDetails != null)
                    {
                        activityString            = obj.ActivityDetails.Substring(obj.ActivityDetails.LastIndexOf(',') + 1);
                        activityStringForWONumber = activityString.Substring(activityString.LastIndexOf('r') + 1);
                    }
                    //322 and 323 is used for continues pause  and resume
                    var IsPauseResume = obj.TaskType == Convert.ToInt64(ContinuesPauseResume.Pause) ? true : obj.TaskType == Convert.ToInt64(ContinuesPauseResume.Resume) ? true : false;
                    if (authuser != null && authuser.UserId > 0 && obj.TaskType != 280)
                    {
                        //TO find Any continues WO complete before Notification Arrival
                        var clientdt = DateTime.UtcNow.GetClientDateTimeNow();
                        //flag status for if user filter record in time span so to date is till midnight.
                        bool     isUTCDay        = true;
                        DateTime _fromDate       = clientdt.Date;
                        DateTime _toDate         = clientdt.AddDays(1).Date;
                        var      todayDARDetails = _workorderEMSEntities.DARDetails.Where(x => x.UserId == authuser.UserId &&
                                                                                          x.LocationId == obj.LocationId &&
                                                                                          x.IsDeleted == false &&
                                                                                          x.CreatedOn >= _fromDate &&
                                                                                          (x.TaskType == 320 ||
                                                                                           x.TaskType == 321) &&
                                                                                          x.CreatedOn <= _toDate).ToList();
                        foreach (var item in todayDARDetails)
                        {
                            var darActivity = item.ActivityDetails;
                            var stringCon   = darActivity.Substring(darActivity.LastIndexOf(',') + 1);
                            var stringCon1  = stringCon.Substring(stringCon.LastIndexOf('r') + 1);
                            if (activityStringForWONumber == stringCon1)
                            {
                                IsContinuesWOExist = true;
                                startTimeDAR       = item.StartTime.ToString();
                                endTimeDAR         = item.EndTime.ToString();
                            }
                        }
                        if (IsContinuesWOExist == true && IsPauseResume == false)
                        {
                            if (startTimeDAR != "" && endTimeDAR == "")
                            {
                                obj.Response        = Convert.ToInt32(ServiceResponse.NoRecord, CultureInfo.CurrentCulture);
                                obj.ResponseMessage = CommonMessage.AlreadyContinuesWOStart(activityStringForWONumber);
                            }
                            else if (startTimeDAR == "" && endTimeDAR != "")
                            {
                                obj.Response        = Convert.ToInt32(ServiceResponse.NoRecord, CultureInfo.CurrentCulture);
                                obj.ResponseMessage = CommonMessage.AlreadyContinuesWOComplete(activityStringForWONumber);
                            }
                        }
                        else
                        {
                            //obj.ActivityDetails = DarMessage.QrcVehicleCleaning(obj.UserName);
                            var result = objDARRepository.SaveDARDetails(obj);
                            if (result != null && result > 0)
                            {
                                obj.Response        = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture);
                                obj.DARId           = result;
                                obj.ResponseMessage = CommonMessage.SaveSuccessMessage();
                            }
                            else
                            {
                                obj.Response        = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                                obj.DARId           = result;
                                obj.ResponseMessage = CommonMessage.WrongParameterMessage();
                            }
                        }
                    }
                    else if (authuser != null && authuser.UserId > 0 && obj.TaskType == 280)
                    {
                        var objLoginLogRepository = new LoginLogRepository();
                        obj.ActivityDetails = DarMessage.ShiftEnd(obj.UserName);
                        var result = objDARRepository.SaveDARDetails(obj);
                        if (result != null && result > 0)
                        {
                            var loginlog = objLoginLogRepository.GetSingleOrDefault(x => x.UserID == authuser.UserId && x.LogId == obj.LogId && x.IsDeleted == false && x.IsActive == true);
                            if (loginlog.LogId != 0)
                            {
                                loginlog.IsActive = false;
                                loginlog.ShiftEnd = DateTime.Now;
                                objLoginLogRepository.Update(loginlog);
                                objLoginLogRepository.SaveChanges();
                            }
                            var data = ObjUserRepository.GetSingleOrDefault(v => v.UserId == obj.UserId && v.IsDeleted == false);
                            if (data != null)
                            {
                                data.ModifiedBy    = obj.UserId;
                                data.ModifiedDate  = DateTime.UtcNow;
                                data.IdleTimeLimit = Convert.ToDateTime("00:30");
                                ObjUserRepository.Update(data);

                                obj.Response        = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture);
                                obj.DARId           = result;
                                obj.ResponseMessage = CommonMessage.SaveSuccessMessage();
                            }
                        }
                        else
                        {
                            obj.Response        = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                            obj.DARId           = result;
                            obj.ResponseMessage = CommonMessage.WrongParameterMessage();
                        }
                    }
                    else
                    {
                        obj.Response        = Convert.ToInt32(ServiceResponse.InvalidSessionResponse, CultureInfo.CurrentCulture);
                        obj.ResponseMessage = CommonMessage.InvalidUser();
                    }
                }
                else
                {
                    obj.Response        = Convert.ToInt32(ServiceResponse.FailedResponse, CultureInfo.CurrentCulture);
                    obj.ResponseMessage = CommonMessage.WrongParameterMessage();
                }
            }
            catch (Exception)
            { throw; }
            return(obj);
        }
Exemplo n.º 4
0
        /// <summary>Save DAR for QRC Type
        /// <CreatedFor>For Insert QRC Type</CreatedFor>
        /// <CreatedBy>Bhushan Dod</CreatedBy>
        /// <CreatedOn>Feb-13-2015</CreatedOn>
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public ServiceDARModel SaveDARDetails(ServiceDARModel obj)
        {
            ObjUserRepository = new UserRepository();
            objDARRepository  = new DARRepository();
            try
            {
                if (obj.LocationId > 0 && obj.ServiceAuthKey != null)
                {
                    var authuser = ObjUserRepository.GetSingleOrDefault(x => x.ServiceAuthKey == obj.ServiceAuthKey && x.IsDeleted == false);

                    if (authuser != null && authuser.UserId > 0 && obj.TaskType != 280)
                    {
                        //obj.ActivityDetails = DarMessage.QrcVehicleCleaning(obj.UserName);
                        var result = objDARRepository.SaveDARDetails(obj);
                        if (result != null && result > 0)
                        {
                            obj.Response        = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture);
                            obj.DARId           = result;
                            obj.ResponseMessage = CommonMessage.SaveSuccessMessage();
                        }
                        else
                        {
                            obj.Response        = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                            obj.DARId           = result;
                            obj.ResponseMessage = CommonMessage.WrongParameterMessage();
                        }
                    }
                    else if (authuser != null && authuser.UserId > 0 && obj.TaskType == 280)
                    {
                        obj.ActivityDetails = DarMessage.ShiftEnd(obj.UserName);
                        var result = objDARRepository.SaveDARDetails(obj);

                        if (result != null && result > 0)
                        {
                            var data = ObjUserRepository.GetSingleOrDefault(v => v.UserId == obj.UserId && v.IsDeleted == false);
                            if (data != null)
                            {
                                data.ModifiedBy    = obj.UserId;
                                data.ModifiedDate  = DateTime.UtcNow;
                                data.IdleTimeLimit = Convert.ToDateTime("00:30");
                                ObjUserRepository.Update(data);

                                obj.Response        = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture);
                                obj.DARId           = result;
                                obj.ResponseMessage = CommonMessage.SaveSuccessMessage();
                            }
                        }
                        else
                        {
                            obj.Response        = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                            obj.DARId           = result;
                            obj.ResponseMessage = CommonMessage.WrongParameterMessage();
                        }
                    }
                    else
                    {
                        obj.Response        = Convert.ToInt32(ServiceResponse.InvalidSessionResponse, CultureInfo.CurrentCulture);
                        obj.ResponseMessage = CommonMessage.InvalidUser();
                    }
                }
                else
                {
                    obj.Response        = Convert.ToInt32(ServiceResponse.FailedResponse, CultureInfo.CurrentCulture);
                    obj.ResponseMessage = CommonMessage.WrongParameterMessage();
                }
            }
            catch (Exception)
            { throw; }
            return(obj);
        }