コード例 #1
0
ファイル: Schedular.cs プロジェクト: aMishra57/eTrac
        public Task Execute(IJobExecutionContext context)
        {
            #region Email
            var objEmailLogRepository = new EmailLogRepository();
            var objEmailReturn        = new List <EmailToManagerModel>();
            var objListEmailog        = new List <EmailLog>();
            var objTemplateModel      = new TemplateModel();
            var userData = _workorderems.UserRegistrations.Where(x => x.UserId == 10073 &&
                                                                 x.IsDeleted == false).FirstOrDefault();


            var  locationData   = _workorderems.LocationMasters.Where(x => x.LocationId == 7 && x.IsDeleted == false).FirstOrDefault();
            bool IsSent         = false;
            var  objEmailHelper = new EmailHelper();
            objEmailHelper.emailid       = userData.SubscriptionEmail;
            objEmailHelper.ManagerName   = userData.FirstName + " " + userData.LastName;
            objEmailHelper.LocationName  = locationData.LocationName;
            objEmailHelper.UserName      = userData.FirstName + " " + userData.LastName;
            objEmailHelper.MailType      = "EMAILDEMOSEND";
            objEmailHelper.SentBy        = userData.UserId;
            objEmailHelper.LocationID    = locationData.LocationId;
            objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString();
            IsSent = objEmailHelper.SendEmailWithTemplate();

            //Push Notification
            /// string message = PushNotificationMessages.eFleetIncidentForServiceReported(objeFleetVehicleIncidentModel.LocationName, objeFleetVehicleIncidentModel.QRCodeID, objeFleetVehicleIncidentModel.VehicleNumber);
            //PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper);
            if (IsSent == true)
            {
                var objEmailog = new EmailLog();
                try
                {
                    objEmailog.CreatedBy   = userData.UserId;
                    objEmailog.CreatedDate = DateTime.UtcNow;
                    objEmailog.DeletedBy   = null;
                    objEmailog.DeletedOn   = null;
                    objEmailog.LocationId  = locationData.LocationId;
                    objEmailog.ModifiedBy  = null;
                    objEmailog.ModifiedOn  = null;
                    objEmailog.SentBy      = userData.UserId;
                    objEmailog.SentEmail   = userData.SubscriptionEmail;
                    objEmailog.Subject     = objEmailHelper.Subject;
                    objEmailog.SentTo      = userData.UserId;
                    objListEmailog.Add(objEmailog);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            using (var tt = new workorderEMSEntities())
            {
                tt.EmailLogs.AddRange(objListEmailog);
                tt.SaveChanges();
            }
            return(null);
        }
コード例 #2
0
 public List <EmailLogModel> GetAllEmailList(long?emailId, long?locationId, int?pageIndex, int?numberOfRows, string sortColumnName, string sortOrderBy, string textSearch, ObjectParameter totalRecords)
 {
     try
     {
         objEmailLogRepository = new EmailLogRepository();
         return(objEmailLogRepository.GetAllEmailList(emailId, locationId, pageIndex, numberOfRows, sortColumnName, sortOrderBy, textSearch, totalRecords));
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
        /// <summary>
        /// Delete the Rule.
        /// CreatedBy   :   Roshan Rahood
        /// CreatedOn   :   Feb 25 2015
        /// </summary>
        /// <param name="emailLogId"></param>
        /// <param name="loggedInUserId"></param>
        /// <returns></returns>
        public Result DeleteEmail(long emailLogId, long loggedInUserId)
        {
            Result result;

            try
            {
                if (emailLogId > 0)
                {
                    if (true)
                    {
                        objEmailLogRepository  = new EmailLogRepository();
                        objCommonMethodManager = new CommonMethodManager();

                        var data = objEmailLogRepository.GetSingleOrDefault(v => v.EmailLogId == emailLogId && v.IsDeleted == false);
                        data.IsDeleted = true;
                        data.DeletedBy = loggedInUserId;
                        data.DeletedOn = DateTime.UtcNow;
                        objEmailLogRepository.Update(data);

                        return(Result.Delete);
                    }
                    else
                    {
                        return(Result.Failed);
                    }
                }
                else
                {
                    return(Result.DoesNotExist);
                }
                return(Result.Delete);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
        /// <summary>
        /// Created By : Ashwajit Bansod
        /// Created Date : 18-OCT-2018
        /// Created for : To approve miscellaneous data.
        /// </summary>
        /// <param name="Obj"></param>
        /// <returns></returns>
        public bool ApproveMiscellaneous(List <MiscellaneousListModel> Obj, string UserName, long UserId, long LocationId, long MiscQbkId, long VendorDetailsId)
        {
            bool     IsApproved     = false;
            long     MISNumber      = 0;
            decimal? calculatedAmt  = 0;
            string   MISID          = "";
            var      objDAR         = new DARModel();
            var      CommonManager  = new CommonMethodManager();
            DateTime date           = new DateTime();
            long     CreatedBy      = 0;
            long     Location       = 0;
            bool     GetOnceData    = false;
            var      UserDetail     = new UserModel();
            var      LocationDetail = new LocationMaster();
            string   Status         = "Approved";

            try
            {
                if (Obj.Count > 0)
                {
                    foreach (var item in Obj)
                    {
                        MISID = item.MISId;
                        string id = item.MISId.Split('S')[1];
                        MISNumber       = Convert.ToInt64(id);
                        calculatedAmt  += item.InvoiceAmount;
                        Location        = item.LocationId;
                        date            = Convert.ToDateTime(item.MISDate);
                        CreatedBy       = item.Vendor;
                        objDAR.TaskType = (long)TaskTypeCategory.MiscellaneousReject;
                        if (item.Status == "N")
                        {
                            Status          = "Reject";
                            calculatedAmt  -= item.InvoiceAmount;
                            objDAR.TaskType = (long)TaskTypeCategory.MiscellaneousReject;
                        }
                        var saveApprove = _workorderems.spSetApprovalForMiscellaneous(item.MId, item.Comment, item.Status, UserId);
                        if (GetOnceData == false)
                        {
                            GetOnceData = true;
                            UserDetail  = _workorderems.UserRegistrations.Join(_workorderems.LogMiscellaneous, u => u.UserId, m => m.LMIS_ModifiedBy, (u, m) => new { u, m }).
                                          Where(x => x.m.LMIS_MIS_Id == MISNumber).
                                          Select(x => new UserModel()
                            {
                                UserName = x.u.FirstName + " " + x.u.LastName,
                                Email    = x.u.UserEmail,
                                Location = x.m.LMIS_LocationId
                            }).FirstOrDefault();
                            LocationDetail = _workorderems.LocationMasters.Where(x => x.LocationId == UserDetail.Location &&
                                                                                 x.IsDeleted == false).FirstOrDefault();
                        }

                        #region Save DAR
                        objDAR.ActivityDetails = DarMessage.MiscellaneousApproveReject(LocationDetail.LocationName, MISID, Status);
                        objDAR.UserId          = UserId;
                        objDAR.CreatedBy       = UserId;
                        objDAR.LocationId      = UserDetail.Location;
                        objDAR.CreatedOn       = DateTime.UtcNow;
                        CommonManager.SaveDAR(objDAR);
                        #endregion DAR
                    }
                    string Action   = "I";
                    var    saveBill = _workorderems.spSetBill(Action, MiscQbkId, null, MISNumber, null, VendorDetailsId, Location, "MIS", calculatedAmt,
                                                              calculatedAmt, date, null, CreatedBy, null, "Y");
                    IsApproved = true;
                }
                else
                {
                    IsApproved = true;
                }
                if (IsApproved == true)
                {
                    #region Email
                    var objEmailLogRepository = new EmailLogRepository();
                    var objEmailReturn        = new List <EmailToManagerModel>();
                    var objListEmailog        = new List <EmailLog>();
                    var objTemplateModel      = new TemplateModel();
                    if (IsApproved == true)
                    {
                        var userData = _workorderems.UserRegistrations.Join(_workorderems.LogMiscellaneous, u => u.UserId, m => m.LMIS_ModifiedBy, (u, m) => new { u, m }).
                                       Where(x => x.m.LMIS_MIS_Id == MISNumber).FirstOrDefault();
                        //Select(x => new UserModel()
                        //{
                        //    UserName = x.u.FirstName + " " + x.u.LastName,
                        //    Email = x.u.UserEmail,
                        //    Location = x.m.LMIS_LocationId,

                        //}).FirstOrDefault();
                        var locationName = _workorderems.LocationMasters.Where(x => x.LocationId == userData.m.LMIS_LocationId &&
                                                                               x.IsDeleted == false).FirstOrDefault();
                        if (userData != null)
                        {
                            bool IsSent         = false;
                            var  objEmailHelper = new EmailHelper();
                            objEmailHelper.emailid       = userData.u.SubscriptionEmail;
                            objEmailHelper.LocationName  = locationName.LocationName;
                            objEmailHelper.UserName      = userData.u.FirstName + " " + userData.u.LastName;
                            objEmailHelper.MISId         = MISID;
                            objEmailHelper.MailType      = "APPROVEMISCELLANEOUS";
                            objEmailHelper.SentBy        = UserId;
                            objEmailHelper.LocationID    = userData.m.LMIS_LocationId;
                            objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString();
                            IsSent = objEmailHelper.SendEmailWithTemplate();

                            //Push Notification
                            if (userData.u.DeviceId != null)
                            {
                                string message = PushNotificationMessages.MiscellaneousApprovedReject(objEmailHelper.LocationName, MISID, Status, objEmailHelper.UserName);
                                PushNotification.GCMAndroid(message, userData.u.DeviceId, objEmailHelper);
                            }
                            if (IsSent == true)
                            {
                                var objEmailog = new EmailLog();
                                try
                                {
                                    objEmailog.CreatedBy   = UserId;
                                    objEmailog.CreatedDate = DateTime.UtcNow;
                                    objEmailog.DeletedBy   = null;
                                    objEmailog.DeletedOn   = null;
                                    objEmailog.LocationId  = userData.m.LMIS_LocationId;
                                    objEmailog.ModifiedBy  = null;
                                    objEmailog.ModifiedOn  = null;
                                    objEmailog.SentBy      = UserId;
                                    objEmailog.SentEmail   = userData.u.SubscriptionEmail;
                                    objEmailog.Subject     = objEmailHelper.Subject;
                                    objEmailog.SentTo      = userData.u.UserId;
                                    objListEmailog.Add(objEmailog);
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                            using (var context = new workorderEMSEntities())
                            {
                                context.EmailLogs.AddRange(objListEmailog);
                                context.SaveChanges();
                            }
                            #endregion Email
                        }
                    }
                    else
                    {
                        IsApproved = true;
                    }
                }
                return(IsApproved);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public MiscellaneousListDetails GetListMiscellaneous(long? UserId,long? Location, int? pageIndex, int? numberOfRows, string sortColumnName, string sortOrderBy, long? locationId, string textSearch, string statusType)", "Exception While Getting List of Miscellaneous details.", null);
                throw;
            }
        }
コード例 #5
0
ファイル: InspectionPDFCreator.cs プロジェクト: radtek/eTrac
        public static string PDFCreationDAREMailforInspection(T obj1, ServiceResponseModel <UpdateEfleetInspectionTypeXML> result)
        {
            try
            {
                string  returnPath            = string.Empty;
                dynamic obj                   = obj1;
                var     objEmailLogRepository = new EmailLogRepository();
                var     objEmailReturn        = new List <EmailToManagerModel>();
                var     objListEmailog        = new List <EmailLog>();
                if (result.Data.Response == 1)
                {
                    objEmailReturn = objEmailLogRepository.SendEmailToManagerForeFleetInspection(obj.LocationId, obj.UserId).Result;
                }
                if (result.Data.DamageTireStatus == true && result.Data.EmergencyAccessoriesStatus == true &&
                    result.Data.EngineExteriorStatus == true && result.Data.InteriorMileageDriverStatus == true &&
                    obj.Status == eFleetCheckInOut.PreTrip || obj.Status == eFleetCheckInOut.PostTrip)
                {
                    var objTemplateModel = new TemplateModel();
                    //Added By Bhushan Dod on 06/09/2017 for Damage in mobile app
                    if (result.Data.DamageTireDetails != null)
                    {
                        var ObjReturnDamageTire = new eFleetDamageTireModel();
                        ObjReturnDamageTire = GenericDataContractSerializer <eFleetDamageTireModel> .DeserializeXml(result.Data.DamageTireDetails);

                        objTemplateModel.DamageTire = ObjReturnDamageTire;
                    }
                    //Added By Bhushan Dod on 06/09/2017 for Damage in mobile app
                    if (result.Data.InteriorMileageDriverDetails != null)
                    {
                        var objInteriorMileageDriverDetails = new eFleetInteriorMileageDriverModel();
                        objInteriorMileageDriverDetails = GenericDataContractSerializer <eFleetInteriorMileageDriverModel> .DeserializeXml(result.Data.InteriorMileageDriverDetails);

                        objTemplateModel.InteriorMileageDriver = objInteriorMileageDriverDetails;
                    }
                    //Added By Bhushan Dod on 06/09/2017 for Damage in mobile app
                    if (result.Data.EngineExteriorDetails != null)
                    {
                        var objEngineExteriorDetails = new eFleetEngineExteriorModel();
                        objEngineExteriorDetails = GenericDataContractSerializer <eFleetEngineExteriorModel> .DeserializeXml(result.Data.EngineExteriorDetails);

                        objTemplateModel.EngineExterior = objEngineExteriorDetails;
                    }
                    //Added By Bhushan Dod on 06/09/2017 for Damage in mobile app
                    if (result.Data.EmergencyAccessoriesDetails != null)
                    {
                        var objEmergencyAccessoriesDetails = new eFleetEmergencyAccessoriesModel();
                        objEmergencyAccessoriesDetails = GenericDataContractSerializer <eFleetEmergencyAccessoriesModel> .DeserializeXml(result.Data.EmergencyAccessoriesDetails);

                        objTemplateModel.EmergencyAccessories = objEmergencyAccessoriesDetails;
                    }
                    objTemplateModel.Status               = obj.Status;
                    objTemplateModel.UserName             = obj.UserName;
                    objTemplateModel.VehicleNumber        = result.Data.VehicleNumber;
                    objTemplateModel.QRCodeID             = result.Data.QRCodeID;
                    objTemplateModel.TimeZoneName         = obj.TimeZoneName;
                    objTemplateModel.TimeZoneOffset       = obj.TimeZoneOffset;
                    objTemplateModel.IsTimeZoneinDaylight = obj.IsTimeZoneinDaylight;

                    string htmlData = TemplateDesigner.eFleetTemplate(objTemplateModel);

                    returnPath = VehicleManager.SaveInspectionPDF(obj.QrcodeId, htmlData);

                    if (objEmailReturn.Count > 0 && result.Data.Response == 1)
                    {
                        foreach (var item in objEmailReturn)
                        {
                            bool IsSent         = false;
                            var  objEmailHelper = new EmailHelper();
                            objEmailHelper.emailid      = item.ManagerEmail;
                            objEmailHelper.ManagerName  = item.ManagerName;
                            objEmailHelper.VehicleMake  = result.Data.Make;
                            objEmailHelper.VehicleModel = result.Data.Model;
                            objEmailHelper.VehicleIdentificationNumber = result.Data.VehicleNumber;
                            objEmailHelper.LocationName     = result.Data.LocationName;
                            objEmailHelper.UserName         = item.UserName;
                            objEmailHelper.QrCodeId         = obj.QrcodeId;
                            objEmailHelper.InfractionStatus = obj.Status;
                            objEmailHelper.MailType         = "EFLEETINSPECTIONREPORT";
                            objEmailHelper.SentBy           = item.RequestBy;
                            objEmailHelper.LocationID       = item.LocationID;
                            objEmailHelper.TimeAttempted    = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString();

                            string[] attachFiles = new string[1];
                            for (var i = 0; i < attachFiles.Count(); i++)
                            {
                                attachFiles[i] = HttpContext.Current.Server.MapPath("~/Content/eFleetDocs/Inspection/" + returnPath);
                            }
                            IsSent = objEmailHelper.SendEmailWithTemplate(attachFiles);

                            //Push Notification
                            string message = PushNotificationMessages.eFleetInspectionReported(result.Data.LocationName, result.Data.QRCodeID, result.Data.VehicleNumber);
                            PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper);
                            if (IsSent == true)
                            {
                                var objEmailog = new EmailLog();
                                try
                                {
                                    objEmailog.CreatedBy   = item.RequestBy;
                                    objEmailog.CreatedDate = DateTime.UtcNow;
                                    objEmailog.DeletedBy   = null;
                                    objEmailog.DeletedOn   = null;
                                    objEmailog.LocationId  = item.LocationID;
                                    objEmailog.ModifiedBy  = null;
                                    objEmailog.ModifiedOn  = null;
                                    objEmailog.SentBy      = item.RequestBy;
                                    objEmailog.SentEmail   = item.ManagerEmail;
                                    objEmailog.Subject     = objEmailHelper.Subject;
                                    objEmailog.SentTo      = item.ManagerUserId;
                                    objListEmailog.Add(objEmailog);
                                }
                                catch (Exception ex)
                                {
                                    return(returnPath);
                                }
                            }
                        }
                        using (var context = new workorderEMSEntities())
                        {
                            context.EmailLogs.AddRange(objListEmailog);
                            context.SaveChanges();;
                        }
                        //var x = EmailLogRepository.InsertEntitiesNew("EmailLog", objListEmailog);
                        //Task<bool> x = null;
                        //foreach (var i in objListEmailog)
                        //{
                        //    x = objEmailLogRepository.SaveEmailLogAsync(i);
                        //}
                    }
                }

                return(returnPath);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "static bool PDFCreationDAREMailforInspection(T obj1, ServiceResponseModel<UpdateEfleetInspectionTypeXML> result)", "while creating PDF", result.Data.VehicleID);

                return(null);
            }
        }
コード例 #6
0
ファイル: ManageManager.cs プロジェクト: aMishra57/eTrac
        /// <summary>
        /// Created By : Bhushan Dod
        /// Created Date : 07/22/2015
        /// Description : Send Email to manager if Qrc Expiration is today(DateTime.Now)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool EmailToMangerForQrcExpiration(long LocId, long userId, long userType)
        {
            LoginManager objLoginManager = new LoginManager();
            List <EmailToManagerModel> objEmailReturn = new List <EmailToManagerModel>();

            objEmailLogRepository = new EmailLogRepository();

            bool result = false;

            try
            {
                using (workorderEMSEntities Context = new workorderEMSEntities())
                {
                    List <long> objL = new List <long>();

                    if (userType == 2)//Manager
                    {
                        var list = objLoginManager.GetManageAdminUserLocationList(userId);
                        foreach (var t in list)
                        {
                            objL.Add(t.LocationId);
                        }
                    }
                    if (userType == 5 || userType == 6 || userType == 1)//IT Administrator//Administrator
                    {
                        var list = objLoginManager.GetAdminUserLocationList(userId);
                        foreach (var t in list)
                        {
                            objL.Add(t.LocationId);
                        }
                    }

                    EmailHelper objEmailHelper = new EmailHelper();
                    DateTime    time           = DateTime.UtcNow;

                    var QrcDetails = Context.QRCMasters.Where(x => x.InsuranceExpDate != null && objL.Contains(x.LocationId.Value) &&
                                                              (x.ExpirationStatus == null || x.ExpirationStatus == false)).ToList();

                    var QrcDetailsMinified = QrcDetails.Where(y => y.InsuranceExpDate.Value.Date == time.Date);

                    if (QrcDetailsMinified.Count() > 0)
                    {
                        objEmailReturn = objEmailLogRepository.SendEmailToManagerForItemMissingQRC(LocId, userId);
                        if (objEmailReturn.Count() > 0)
                        {
                            foreach (var d in QrcDetailsMinified)
                            {
                                foreach (var item in objEmailReturn)
                                {
                                    objEmailHelper.MailType     = "QRCEXPIRATIONMAIL";
                                    objEmailHelper.QrCodeId     = d.QRCodeID;
                                    objEmailHelper.ManagerName  = item.ManagerName;
                                    objEmailHelper.UserName     = item.UserName;
                                    objEmailHelper.emailid      = item.ManagerEmail;
                                    objEmailHelper.LocationName = item.LocationName;
                                    objEmailHelper.SentBy       = item.RequestBy;
                                    objEmailHelper.LocationID   = item.LocationID;
                                    objEmailHelper.ItemName     = d.QRCName;
                                    objEmailHelper.QrcType      = _ICommonMethod.GetGlobalCodeDetailById(d.QRCTYPE);

                                    bool IsSent = objEmailHelper.SendEmailWithTemplate();
                                    if (IsSent == true)
                                    {
                                        objEmailog = new EmailLog();
                                        try
                                        {
                                            objEmailog.CreatedBy   = item.RequestBy;
                                            objEmailog.CreatedDate = DateTime.UtcNow;
                                            objEmailog.DeletedBy   = null;
                                            objEmailog.DeletedOn   = null;
                                            objEmailog.LocationId  = item.LocationID;
                                            objEmailog.ModifiedBy  = null;
                                            objEmailog.ModifiedOn  = null;
                                            objEmailog.SentBy      = item.RequestBy;
                                            objEmailog.SentEmail   = item.ManagerEmail;
                                            objEmailog.Subject     = objEmailHelper.Subject;
                                            objEmailog.SentTo      = item.ManagerUserId;

                                            objEmailLogRepository.SaveEmailLog(objEmailog);
                                        }
                                        catch (Exception)
                                        {
                                            throw;
                                        }
                                    }
                                    if (item.DeviceId != null)
                                    {
                                        PushNotification.GCMAndroid("Today is the last day of QRC " + d.QRCodeID + ".It will get expire by tommorrow at location " + item.LocationName, item.DeviceId, objEmailHelper);
                                    }
                                    result = true;
                                }
                                if (result == true)
                                {
                                    objQRCMasterRepository = new QRCMasterRepository();
                                    var qrcDetails = objQRCMasterRepository.GetSingleOrDefault(t => t.QRCID == d.QRCID && t.IsDeleted == false);
                                    if (qrcDetails != null)
                                    {
                                        qrcDetails.ExpirationStatus = true;
                                        objQRCMasterRepository.SaveChanges();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "bool EmailToMangerForQrcExpiration(long LocId, long userId, long userType)", "Exception while EmailToMangerForQrcExpiration ", LocId);
            }
            return(result);
        }
コード例 #7
0
        /// <summary>Save eFleet Preventative Maintenance
        /// <CreatedBy>Bhushan Dod</CreatedBy>
        /// <CreatedFor>SaveeFleetPreventativeMaintenance</CreatedFor>
        /// <CreatedOn>August-29-2017</CreatedOn>
        /// </summary>
        /// <param name="eFleetDamageTireModel"></param>
        /// <returns></returns>
        public ServiceResponseModel <string> InsertPreventativeMaintenance(eFleetPreventaticeMaintenanceModel objModel)
        {
            var objReturnModel = new ServiceResponseModel <string>();

            try
            {
                var objeFleetPreventativeMaintenanceRepository = new eFleetPreventativeMaintenanceRepository();
                eFleetPreventativeMaintenance Obj = new eFleetPreventativeMaintenance();
                AutoMapper.Mapper.CreateMap <eFleetPreventaticeMaintenanceModel, eFleetPreventativeMaintenance>();
                Obj             = AutoMapper.Mapper.Map(objModel, Obj);
                Obj.CreatedBy   = objModel.UserId;
                Obj.CreatedDate = DateTime.UtcNow;
                objeFleetPreventativeMaintenanceRepository.Add(Obj);
                if (Obj.ID > 0)
                {
                    #region Save DAR
                    DARModel objDAR = new DARModel();
                    objDAR.ActivityDetails = DarMessage.NeweFleetPMCreated(objModel.LocationName);
                    objDAR.LocationId      = objModel.LocationID;
                    objDAR.UserId          = objModel.UserId;
                    objDAR.CreatedBy       = objModel.UserId;
                    objDAR.CreatedOn       = DateTime.UtcNow;
                    objDAR.TaskType        = (long)TaskTypeCategory.PreventativeMaintenanceSubmission;
                    Result result = _ICommonMethod.SaveDAR(objDAR);
                    #endregion Save DAR

                    #region Email
                    var objEmailLogRepository = new EmailLogRepository();
                    var objEmailReturn        = new List <EmailToManagerModel>();
                    var objListEmailog        = new List <EmailLog>();
                    var objTemplateModel      = new TemplateModel();
                    if (result == Result.Completed)
                    {
                        objEmailReturn = objEmailLogRepository.SendEmailToManagerForeFleetInspection(objModel.LocationID, objModel.UserId).Result;
                    }

                    if (objEmailReturn.Count > 0 && result == Result.Completed)
                    {
                        foreach (var item in objEmailReturn)
                        {
                            bool IsSent         = false;
                            var  objEmailHelper = new EmailHelper();
                            objEmailHelper.emailid        = item.ManagerEmail;
                            objEmailHelper.ManagerName    = item.ManagerName;
                            objEmailHelper.RemiderMetric  = Convert.ToString(objModel.ReminderMetric);
                            objEmailHelper.Meter          = Convert.ToString(objModel.Meter);
                            objEmailHelper.VehicleNumber  = objModel.VehicleNumber;
                            objEmailHelper.LocationName   = objModel.LocationName;
                            objEmailHelper.UserName       = item.UserName;
                            objEmailHelper.QrCodeId       = objModel.QrCodeId;
                            objEmailHelper.ServiceDueDate = objModel.ServiceDueDate.ToString();
                            //objEmailHelper.InfractionStatus = obj.Status;
                            objEmailHelper.MailType      = "PreventativeMaintenance";
                            objEmailHelper.SentBy        = item.RequestBy;
                            objEmailHelper.LocationID    = item.LocationID;
                            objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString();

                            IsSent = objEmailHelper.SendEmailWithTemplate();

                            //Push Notification
                            string message = PushNotificationMessages.eFleetPreventativeMaintenanceReported(objModel.LocationName, objModel.QrCodeId, objModel.VehicleNumber);
                            PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper);
                            if (IsSent == true)
                            {
                                var objEmailog = new EmailLog();
                                try
                                {
                                    objEmailog.CreatedBy   = item.RequestBy;
                                    objEmailog.CreatedDate = DateTime.UtcNow;
                                    objEmailog.DeletedBy   = null;
                                    objEmailog.DeletedOn   = null;
                                    objEmailog.LocationId  = item.LocationID;
                                    objEmailog.ModifiedBy  = null;
                                    objEmailog.ModifiedOn  = null;
                                    objEmailog.SentBy      = item.RequestBy;
                                    objEmailog.SentEmail   = item.ManagerEmail;
                                    objEmailog.Subject     = objEmailHelper.Subject;
                                    objEmailog.SentTo      = item.ManagerUserId;
                                    objListEmailog.Add(objEmailog);
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                        using (var context = new workorderEMSEntities())
                        {
                            context.EmailLogs.AddRange(objListEmailog);
                            context.SaveChanges();;
                        }
                        //    //var x = EmailLogRepository.InsertEntitiesNew("EmailLog", objListEmailog);
                        //    //Task<bool> x = null;
                        //    //foreach (var i in objListEmailog)
                        //    //{
                        //    //    x = objEmailLogRepository.SaveEmailLogAsync(i);
                        //    //}
                        //}


                        #endregion Email
                        objReturnModel.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.InvariantCulture);
                        objReturnModel.Message  = CommonMessage.Successful();
                    }
                }
            }


            catch (Exception ex)
            {
                WorkOrderEMS.BusinessLogic.Exception_B.Exception_B.exceptionHandel_Runtime(ex, "ServiceResponseModel<string> InsertPreventativeMaintenance(eFleetPreventaticeMaintenanceModel objModel)", "while insert preventative maintenance", objModel);
                objReturnModel.Message  = ex.Message;
                objReturnModel.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                objReturnModel.Data     = null;
            }
            return(objReturnModel);
        }
コード例 #8
0
        /// <summary>
        /// Created By Ashwajit Bansod Dated 08/29/2017
        /// Save and edit Preventative maintenance Data
        /// </summary>
        /// <param name="objeFleetPMModel"></param>
        /// <returns></returns>
        public eFleetPMModel SaveEfleetPreventativeMaintenance(eFleetPMModel objeFleetPMModel)
        {
            try
            {
                workorderEMSEntities db = new workorderEMSEntities();
                var objLocationMaster   = new LocationMaster();
                var objeFleetPreventativeMaintenance = new eFleetPreventativeMaintenance();
                var objeFleetVehicleModel            = new eFleetVehicleModel();
                var meterval = Convert.ToInt64(eFleetEnum.Hours);
                var objeFleetPreventativeMaintenanceRepository = new eFleetPreventativeMaintenanceRepository();
                var objeTracLoginModel = new eTracLoginModel();
                if (objeFleetPMModel.ID == 0)
                {
                    AutoMapper.Mapper.CreateMap <eFleetPMModel, eFleetPreventativeMaintenance>();
                    if (objeFleetPMModel.Meter == meterval)
                    {
                        objeFleetPMModel.ReminderMetric = objeFleetPMModel.HoursValue;
                    }
                    var objfleetPMMapper = AutoMapper.Mapper.Map(objeFleetPMModel, objeFleetPreventativeMaintenance);
                    objeFleetPreventativeMaintenanceRepository.Add(objfleetPMMapper);
                    objeFleetPreventativeMaintenanceRepository.SaveChanges();
                    objeFleetPMModel.Result = Result.Completed;
                    if (objeFleetPMModel.Result == Result.Completed)
                    {
                        #region Save DAR
                        DARModel objDAR = new DARModel();
                        objDAR.ActivityDetails = DarMessage.NeweFleetPMCreated(objeFleetPMModel.LocationName);
                        objDAR.LocationId      = objeFleetPMModel.LocationID;
                        objDAR.UserId          = objeFleetPMModel.UserId;
                        objDAR.CreatedBy       = objeFleetPMModel.UserId;
                        objDAR.CreatedOn       = DateTime.UtcNow;
                        objDAR.TaskType        = (long)TaskTypeCategory.PreventativeMaintenanceSubmission;
                        Result result = _ICommonMethod.SaveDAR(objDAR);
                        #endregion Save DAR

                        //Created By Ashwajit Bansod Date: Oct-04-2017 for sending a mail regarding Prevenatative maintenance to the manager
                        #region Email
                        var objEmailLogRepository = new EmailLogRepository();
                        var objEmailReturn        = new List <EmailToManagerModel>();
                        var objListEmailog        = new List <EmailLog>();
                        var objTemplateModel      = new TemplateModel();
                        if (result == Result.Completed)
                        {
                            objEmailReturn = objEmailLogRepository.SendEmailToManagerForeFleetInspection(objeFleetPMModel.LocationID, objeFleetPMModel.UserId).Result;
                        }

                        if (objEmailReturn.Count > 0 && result == Result.Completed)
                        {
                            foreach (var item in objEmailReturn)
                            {
                                bool IsSent         = false;
                                var  objEmailHelper = new EmailHelper();
                                objEmailHelper.emailid     = item.ManagerEmail;
                                objEmailHelper.ManagerName = item.ManagerName;
                                if (objeFleetPMModel.ReminderMetric == null)
                                {
                                    objEmailHelper.RemiderMetric = "N/A";
                                }
                                else
                                {
                                    objEmailHelper.RemiderMetric = (from em in db.eFleetMeters where em.ID == objeFleetPMModel.ReminderMetric select em.MeterValue).FirstOrDefault();
                                }
                                objEmailHelper.Meter          = (from gc in db.GlobalCodes where gc.GlobalCodeId == objeFleetPMModel.Meter select gc.CodeName).FirstOrDefault();
                                objEmailHelper.Category       = (from gc in db.GlobalCodes where gc.GlobalCodeId == objeFleetPMModel.Category select gc.CodeName).FirstOrDefault();;
                                objEmailHelper.VehicleNumber  = objeFleetPMModel.VehicleNumber;
                                objEmailHelper.LocationName   = objeFleetPMModel.LocationName;
                                objEmailHelper.UserName       = item.UserName;
                                objEmailHelper.QrCodeId       = objeFleetPMModel.QRCodeID;
                                objEmailHelper.ServiceDueDate = objeFleetPMModel.ServiceDueDate.ToString();
                                objEmailHelper.PMMetric       = objeFleetPMModel.ReminderMetricDesc;
                                //objEmailHelper.InfractionStatus = obj.Status;
                                objEmailHelper.MailType      = "PreventativeMaintenance";
                                objEmailHelper.SentBy        = item.RequestBy;
                                objEmailHelper.LocationID    = item.LocationID;
                                objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString();
                                IsSent = objEmailHelper.SendEmailWithTemplate();
                                //Push Notification
                                string message = PushNotificationMessages.eFleetPreventativeMaintenanceReported(objeFleetPMModel.LocationName, objeFleetPMModel.QRCodeID, objeFleetPMModel.VehicleNumber);
                                PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper);
                                if (IsSent == true)
                                {
                                    var objEmailog = new EmailLog();
                                    try
                                    {
                                        objEmailog.CreatedBy   = item.RequestBy;
                                        objEmailog.CreatedDate = DateTime.UtcNow;
                                        objEmailog.DeletedBy   = null;
                                        objEmailog.DeletedOn   = null;
                                        objEmailog.LocationId  = item.LocationID;
                                        objEmailog.ModifiedBy  = null;
                                        objEmailog.ModifiedOn  = null;
                                        objEmailog.SentBy      = item.RequestBy;
                                        objEmailog.SentEmail   = item.ManagerEmail;
                                        objEmailog.Subject     = objEmailHelper.Subject;
                                        objEmailog.SentTo      = item.ManagerUserId;
                                        objListEmailog.Add(objEmailog);
                                    }
                                    catch (Exception)
                                    {
                                        throw;
                                    }
                                }
                            }
                            using (var context = new workorderEMSEntities())
                            {
                                context.EmailLogs.AddRange(objListEmailog);
                                context.SaveChanges();;
                            }
                            //    //var x = EmailLogRepository.InsertEntitiesNew("EmailLog", objListEmailog);
                            //    //Task<bool> x = null;
                            //    //foreach (var i in objListEmailog)
                            //    //{
                            //    //    x = objEmailLogRepository.SaveEmailLogAsync(i);
                            //    //}
                            //}
                            #endregion Email
                        }
                    }
                }
                //edit Data
                else
                {
                    var PreventativeData = objeFleetPreventativeMaintenanceRepository.GetAll(v => v.IsDeleted == false && v.ID == objeFleetPMModel.PmID).SingleOrDefault(); //PmID = ID PmID in Ashwajit Table
                                                                                                                                                                            //objeFleetPMModel.DriverImage = DriverData.DriverImage;//== null ? "" : HostingPrefix + ProfilePicPath.Replace("~", "") + DriverData.DriverImage;
                    AutoMapper.Mapper.CreateMap <eFleetPMModel, eFleetPreventativeMaintenance>();
                    if (objeFleetPMModel.Meter == meterval)
                    {
                        objeFleetPMModel.ReminderMetric = objeFleetPMModel.HoursValue;
                    }
                    var objfleetDriverMapper = AutoMapper.Mapper.Map(objeFleetPMModel, PreventativeData);
                    objeFleetPreventativeMaintenanceRepository.SaveChanges();
                    objeFleetPMModel.Result = Result.UpdatedSuccessfully;
                    if (objeFleetPMModel.Result == Result.UpdatedSuccessfully)
                    {
                        #region Save DAR
                        DARModel objDAR = new DARModel();
                        objDAR.ActivityDetails = DarMessage.NeweFleetPMUpdated(objeFleetPMModel.LocationName);
                        objDAR.LocationId      = objeFleetPMModel.LocationID;
                        objDAR.UserId          = objeFleetPMModel.UserId;
                        objDAR.ModifiedBy      = objeFleetPMModel.UserId;
                        objDAR.ModifiedOn      = DateTime.UtcNow;
                        objDAR.TaskType        = (long)TaskTypeCategory.UpdatePreventativeMaintenance;
                        Result result = _ICommonMethod.SaveDAR(objDAR);
                        #endregion Save DAR
                    }
                }

                return(objeFleetPMModel);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public eFleetPMModel SaveEfleetPreventativeMaintenance(eFleetPMModel objeFleetPMModel)", "Exception While saving Preventative Maintenence request.", objeFleetPMModel);
                throw;
            }
        }
コード例 #9
0
        /// <summary>Save eFleet Incident
        /// <CreatedBy>Bhushan Dod</CreatedBy>
        /// <CreatedFor>InsertVehicleIncident</CreatedFor>
        /// <CreatedOn>September-15-2017</CreatedOn>
        /// </summary>
        /// <param name="eFleetIncidentModel"></param>
        /// <returns></returns>
        public ServiceResponseModel <string> InsertVehicleIncident(eFleetIncidentModel objModel)
        {
            var objReturnModel = new ServiceResponseModel <string>();

            try
            {
                var objeFleetVehicleIncidentRepository = new eFleetVehicleIncidentRepository();
                var Obj    = new eFleetVehicleIncident();
                var objDAR = new DARModel();
                AutoMapper.Mapper.CreateMap <eFleetIncidentModel, eFleetVehicleIncident>();
                Obj             = AutoMapper.Mapper.Map(objModel, Obj);
                Obj.CreatedBy   = objModel.UserId;
                Obj.CreatedDate = DateTime.UtcNow;
                Obj.IsDeleted   = false;
                objeFleetVehicleIncidentRepository.Add(Obj);
                if (Obj.IncidentID > 0)
                {
                    // objDAR.ActivityDetails = objModel.ActivityDetails;
                    objDAR.ActivityDetails = DarMessage.RegisterNeweFleetIncidentVehicle(objModel.LocationName);
                    objDAR.LocationId      = objModel.LocationID;
                    // objDAR.TaskType = objModel.TaskType;
                    objDAR.TaskType   = (long)TaskTypeCategory.EfleetIncidentSubmission;
                    objDAR.CreatedBy  = objModel.UserId;
                    objDAR.CreatedOn  = DateTime.UtcNow;
                    objDAR.DeletedBy  = null;
                    objDAR.DeletedOn  = null;
                    objDAR.IsDeleted  = false;
                    objDAR.IsManual   = false;
                    objDAR.ModifiedBy = null;
                    objDAR.ModifiedOn = null;
                    objDAR.UserId     = objModel.UserId;
                    objDAR.StartTime  = objModel.AccidentDate.ToString();
                    objDAR.EndTime    = DateTime.UtcNow.ToString();
                    // objDARRepository.Add(objDAR);
                    Result result = _ICommonMethod.SaveDAR(objDAR);

                    #region Email
                    var objEmailLogRepository = new EmailLogRepository();
                    var objEmailReturn        = new List <EmailToManagerModel>();
                    var objListEmailog        = new List <EmailLog>();
                    var objTemplateModel      = new TemplateModel();
                    workorderEMSEntities db   = new workorderEMSEntities();
                    if (result == Result.Completed)
                    {
                        objEmailReturn = objEmailLogRepository.SendEmailToManagerForeFleetInspection(objModel.LocationID, objModel.UserId).Result;
                        //Code added by Bhu on 14 Dec 2017 for sending email to [email protected]. This is common MRA for risk manager.
                        var objEmailToManagerModel = new EmailToManagerModel();
                        objEmailToManagerModel.LocationID    = objModel.LocationID;
                        objEmailToManagerModel.LocationName  = objModel.LocationName;
                        objEmailToManagerModel.ManagerEmail  = "*****@*****.**";
                        objEmailToManagerModel.ManagerName   = "Team";
                        objEmailToManagerModel.ManagerUserId = 3; //admin user id for need to track email log
                        objEmailToManagerModel.RequestBy     = 3; //admin user id for need to track email log
                        objEmailToManagerModel.UserName      = "******";
                        objEmailReturn.Add(objEmailToManagerModel);
                    }

                    if (objEmailReturn.Count > 0 && result == Result.Completed)
                    {
                        foreach (var item in objEmailReturn)
                        {
                            bool IsSent         = false;
                            var  objEmailHelper = new EmailHelper();
                            objEmailHelper.emailid     = item.ManagerEmail;
                            objEmailHelper.ManagerName = item.ManagerName;
                            //objEmailHelper.DriverNameforFueling = objModel.DriverName;
                            /// objEmailHelper.FuelType = (from gc in db.GlobalCodes where gc.GlobalCodeId == objModel.FuelType select gc.CodeName).FirstOrDefault();
                            objEmailHelper.IncidentDescription = objModel.Description;
                            if (objModel.Preventability == true)
                            {
                                objEmailHelper.Prevenatability = "Yes";
                            }
                            else
                            {
                                objEmailHelper.Prevenatability = "No";
                            }
                            objEmailHelper.NumberOfInjuries = objModel.NumberOfInjuries;
                            objEmailHelper.City             = objModel.City;
                            objEmailHelper.VehicleNumber    = objModel.VehicleNumber;
                            objEmailHelper.LocationName     = objModel.LocationName;
                            objEmailHelper.UserName         = item.UserName;
                            objEmailHelper.QrCodeId         = objModel.QRCodeID;
                            objEmailHelper.AccidentDate     = objModel.AccidentDate.ToString();
                            //objEmailHelper.InfractionStatus = obj.Status;
                            objEmailHelper.MailType      = "EfleetIncidentForService";
                            objEmailHelper.SentBy        = item.RequestBy;
                            objEmailHelper.LocationID    = item.LocationID;
                            objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString();

                            IsSent = objEmailHelper.SendEmailWithTemplate();

                            if (item.DeviceId != null && item.DeviceId != "")
                            {
                                //Push Notification
                                string message = PushNotificationMessages.eFleetIncidentForServiceReported(objModel.LocationName, objModel.QRCodeID, objModel.VehicleNumber);
                                PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper);
                            }
                            if (IsSent == true)
                            {
                                var objEmailog = new EmailLog();
                                try
                                {
                                    objEmailog.CreatedBy   = item.RequestBy;
                                    objEmailog.CreatedDate = DateTime.UtcNow;
                                    objEmailog.DeletedBy   = null;
                                    objEmailog.DeletedOn   = null;
                                    objEmailog.LocationId  = item.LocationID;
                                    objEmailog.ModifiedBy  = null;
                                    objEmailog.ModifiedOn  = null;
                                    objEmailog.SentBy      = item.RequestBy;
                                    objEmailog.SentEmail   = item.ManagerEmail;
                                    objEmailog.Subject     = objEmailHelper.Subject;
                                    objEmailog.SentTo      = item.ManagerUserId;
                                    objListEmailog.Add(objEmailog);
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                    }
                    using (var context = new workorderEMSEntities())
                    {
                        context.EmailLogs.AddRange(objListEmailog);
                        context.SaveChanges();;
                    }
                    //    //var x = EmailLogRepository.InsertEntitiesNew("EmailLog", objListEmailog);
                    //    //Task<bool> x = null;
                    //    //foreach (var i in objListEmailog)
                    //    //{
                    //    //    x = objEmailLogRepository.SaveEmailLogAsync(i);
                    //    //}
                    //}


                    #endregion Email
                    if (Obj.IncidentID > 0)
                    {
                        objReturnModel.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.InvariantCulture);
                        objReturnModel.Message  = CommonMessage.Successful();
                    }
                }
            }
            catch (Exception ex)
            {
                WorkOrderEMS.BusinessLogic.Exception_B.Exception_B.exceptionHandel_Runtime(ex, "ServiceResponseModel<string> InsertVehicleIncident(eFleetIncidentModel objModel)", "while insert eFleet vehicle incident", objModel);
                objReturnModel.Message  = ex.Message;
                objReturnModel.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                objReturnModel.Data     = null;
            }
            return(objReturnModel);
        }
コード例 #10
0
        public eFleetVehicleIncidentModel SaveEfleetVehicleIncident(eFleetVehicleIncidentModel objeFleetVehicleIncidentModel)
        {
            try
            {
                LocationMaster objLocationMaster                  = new LocationMaster();
                var            objeFleetVehicleIncident           = new eFleetVehicleIncident();
                var            objeFleetVehicleIncidentRepository = new eFleetVehicleIncidentRepository();
                var            objeTracLoginModel                 = new eTracLoginModel();

                if (objeFleetVehicleIncidentModel.IncidentID == 0)
                {
                    objeFleetVehicleIncidentModel.IsDeleted = false;
                    AutoMapper.Mapper.CreateMap <eFleetVehicleIncidentModel, eFleetVehicleIncident>();
                    var objfleetVehicleIncidentMapper = AutoMapper.Mapper.Map(objeFleetVehicleIncidentModel, objeFleetVehicleIncident);
                    objeFleetVehicleIncidentRepository.Add(objfleetVehicleIncidentMapper);
                    // objeFleetVehicle.QRCodeID = objeFleetVehicleModel.QRCodeID + "EFV" + (objeFleetVehicle.VehicleID + 100).ToString();
                    objeFleetVehicleIncidentRepository.SaveChanges();
                    objeFleetVehicleIncidentModel.Result = Result.Completed;
                    if (objeFleetVehicleIncidentModel.Result == Result.Completed)
                    {
                        #region Save DAR
                        DARModel objDAR = new DARModel();
                        objDAR.ActivityDetails = DarMessage.RegisterNeweFleetIncidentVehicle(objeFleetVehicleIncidentModel.LocationName);
                        objDAR.LocationId      = objeFleetVehicleIncidentModel.LocationID;
                        objDAR.UserId          = objeFleetVehicleIncidentModel.UserID;
                        objDAR.CreatedBy       = objeFleetVehicleIncidentModel.UserID;
                        objDAR.CreatedOn       = DateTime.UtcNow;
                        objDAR.TaskType        = (long)TaskTypeCategory.eFleetVehicleIncidentSubmission;
                        Result result = _ICommonMethod.SaveDAR(objDAR);
                        #endregion Save DAR

                        //Created By Ashwajit Bansod for Sending the Mail of Vehicle Incident to the Manager
                        #region Email
                        var objEmailLogRepository = new EmailLogRepository();
                        var objEmailReturn        = new List <EmailToManagerModel>();
                        var objListEmailog        = new List <EmailLog>();
                        var objTemplateModel      = new TemplateModel();
                        if (result == Result.Completed)
                        {
                            objEmailReturn = objEmailLogRepository.SendEmailToManagerForeFleetInspection(objeFleetVehicleIncidentModel.LocationID, objeFleetVehicleIncidentModel.UserID).Result;
                            //Code added by Bhu on 14 Dec 2017 for sending email to [email protected]. This is common MRA for risk manager.
                            var objEmailToManagerModel = new EmailToManagerModel();
                            objEmailToManagerModel.LocationID    = objeFleetVehicleIncidentModel.LocationID;
                            objEmailToManagerModel.LocationName  = objeFleetVehicleIncidentModel.LocationName;
                            objEmailToManagerModel.ManagerEmail  = "*****@*****.**";
                            objEmailToManagerModel.ManagerName   = "Team";
                            objEmailToManagerModel.ManagerUserId = 3; //admin user id for need to track email log
                            objEmailToManagerModel.RequestBy     = 3; //admin user id for need to track email log
                            objEmailToManagerModel.UserName      = "******";
                            objEmailReturn.Add(objEmailToManagerModel);
                        }

                        if (objEmailReturn.Count > 0 && result == Result.Completed)
                        {
                            foreach (var item in objEmailReturn)
                            {
                                bool IsSent         = false;
                                var  objEmailHelper = new EmailHelper();
                                objEmailHelper.emailid                      = item.ManagerEmail;
                                objEmailHelper.ManagerName                  = item.ManagerName;
                                objEmailHelper.VehicleNumber                = objeFleetVehicleIncidentModel.VehicleNumber;
                                objEmailHelper.LocationName                 = objeFleetVehicleIncidentModel.LocationName;
                                objEmailHelper.UserName                     = item.UserName;
                                objEmailHelper.QrCodeId                     = objeFleetVehicleIncidentModel.QRCodeID;
                                objEmailHelper.AccidentDate                 = objeFleetVehicleIncidentModel.AccidentDate.ToString();
                                objEmailHelper.City                         = objeFleetVehicleIncidentModel.City;
                                objEmailHelper.NumberOfInjuries             = objeFleetVehicleIncidentModel.NumberOfInjuries;
                                objEmailHelper.DriverNameForVehicleIncident = objeFleetVehicleIncidentModel.DriverName;
                                objEmailHelper.IncidentDescription          = objeFleetVehicleIncidentModel.Description;
                                if (objeFleetVehicleIncidentModel.Preventability == true)
                                {
                                    objEmailHelper.Prevenatability = "Yes";
                                }
                                else
                                {
                                    objEmailHelper.Prevenatability = "No";
                                }
                                //objEmailHelper.InfractionStatus = obj.Status;
                                objEmailHelper.MailType      = "VehicleIncident";
                                objEmailHelper.SentBy        = item.RequestBy;
                                objEmailHelper.LocationID    = item.LocationID;
                                objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString();

                                IsSent = objEmailHelper.SendEmailWithTemplate();

                                //Push Notification
                                string message = PushNotificationMessages.eFleetIncidentForServiceReported(objeFleetVehicleIncidentModel.LocationName, objeFleetVehicleIncidentModel.QRCodeID, objeFleetVehicleIncidentModel.VehicleNumber);
                                PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper);
                                if (IsSent == true)
                                {
                                    var objEmailog = new EmailLog();
                                    try
                                    {
                                        objEmailog.CreatedBy   = item.RequestBy;
                                        objEmailog.CreatedDate = DateTime.UtcNow;
                                        objEmailog.DeletedBy   = null;
                                        objEmailog.DeletedOn   = null;
                                        objEmailog.LocationId  = item.LocationID;
                                        objEmailog.ModifiedBy  = null;
                                        objEmailog.ModifiedOn  = null;
                                        objEmailog.SentBy      = item.RequestBy;
                                        objEmailog.SentEmail   = item.ManagerEmail;
                                        objEmailog.Subject     = objEmailHelper.Subject;
                                        objEmailog.SentTo      = item.ManagerUserId;
                                        objListEmailog.Add(objEmailog);
                                    }
                                    catch (Exception)
                                    {
                                        throw;
                                    }
                                }
                            }
                            using (var context = new workorderEMSEntities())
                            {
                                context.EmailLogs.AddRange(objListEmailog);
                                context.SaveChanges();;
                            }
                            //    //var x = EmailLogRepository.InsertEntitiesNew("EmailLog", objListEmailog);
                            //    //Task<bool> x = null;
                            //    //foreach (var i in objListEmailog)
                            //    //{
                            //    //    x = objEmailLogRepository.SaveEmailLogAsync(i);
                            //    //}
                            //}
                            #endregion Email
                        }
                    }
                }
                else
                {
                    var vehicleIncidentData = objeFleetVehicleIncidentRepository.GetAll(v => v.IsDeleted == false && v.LocationID == objeFleetVehicleIncidentModel.LocationID && v.IncidentID == objeFleetVehicleIncidentModel.IncidentID).SingleOrDefault();
                    objeFleetVehicleIncidentModel.IncidentImage = vehicleIncidentData.IncidentImage;
                    AutoMapper.Mapper.CreateMap <eFleetVehicleIncidentModel, eFleetVehicleIncident>();
                    // objeFleetVehicleIncident.FuelType = Convert.ToInt32(objeFleetVehicleIncidentModel.FuelType);
                    var objfleetVehicleMapper = AutoMapper.Mapper.Map(objeFleetVehicleIncidentModel, vehicleIncidentData);
                    objeFleetVehicleIncidentRepository.SaveChanges();
                    objeFleetVehicleIncidentModel.Result = Result.UpdatedSuccessfully;
                    if (objeFleetVehicleIncidentModel.Result == Result.UpdatedSuccessfully)
                    {
                        #region Save DAR
                        DARModel objDAR = new DARModel();
                        objDAR.ActivityDetails = DarMessage.UpdateeFleetVehicleIncident(objeFleetVehicleIncidentModel.LocationName);
                        objDAR.LocationId      = objeFleetVehicleIncidentModel.LocationID;
                        objDAR.UserId          = objeFleetVehicleIncidentModel.UserID;
                        objDAR.ModifiedBy      = objeFleetVehicleIncidentModel.UserID;
                        objDAR.ModifiedOn      = DateTime.UtcNow;
                        objDAR.TaskType        = (long)TaskTypeCategory.UpdateeFleetIncidentVehicle;
                        Result result = _ICommonMethod.SaveDAR(objDAR);
                        #endregion Save DAR
                    }
                }
                return(objeFleetVehicleIncidentModel);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public eFleetVehicleIncidentModel SaveEfleetVehicleIncident(eFleetVehicleIncidentModel objeFleetVehicleIncidentModel)", "Exception While saving vehicle Incident request.", objeFleetVehicleIncidentModel);
                throw;
            }
        }
コード例 #11
0
        /// <summary>
        /// Created By : Ashwajit Bansod
        /// Created Date : 20-OCT-2018
        /// Created For : To approve and reject bill
        /// </summary>
        /// <param name="Obj"></param>
        /// <param name="UserName"></param>
        /// <param name="UserId"></param>
        /// <param name="LocationId"></param>
        /// <returns></returns>
        public string ApproveBill(BillListApproveModel Obj, string UserName, long UserId, long LocationId)
        {
            bool   IsApproved    = false;
            string result        = "";
            var    objDAR        = new DARModel();
            var    CommonManager = new CommonMethodManager();
            string ApproveStatus = "";

            try
            {
                var userDataItem = _workorderems.UserRegistrations.Where(x => x.UserId == UserId &&
                                                                         x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault();
                if (Obj != null)
                {
                    string Action = "I";
                    if (Obj.Comment == null)
                    {
                        Obj.Status    = "Y";
                        ApproveStatus = "Approved";
                    }
                    else
                    {
                        Obj.Status    = "N";
                        ApproveStatus = "Rejected";
                    }
                    var saveBillApprove = _workorderems.spSetApprovalForPreBill(Obj.LBLL_Id, Obj.Comment, Obj.Status, UserId);
                    //var saveApprove = _workorderems.spSetApprovalForBill(Obj.LBLL_Id, Obj.Comment,Obj.Status,UserId);
                    Obj.InvoiceDate = Convert.ToDateTime(Obj.BillDate);
                    var saveSetBill = _workorderems.spSetBill(Action, Obj.QuickBookBillId, null, null, Obj.BillId, Obj.VendorId, LocationId,
                                                              "Manual Bill", null, Obj.BillAmount, Obj.InvoiceDate,
                                                              Obj.BillImage, UserId, UserId, "Y");

                    IsApproved = true;
                    if (Obj.Comment == null)
                    {
                        result = CommonMessage.BillApprove();
                    }
                    else
                    {
                        result = CommonMessage.BillReject();
                    }
                    #region Save DAR

                    var locationData = _workorderems.LocationMasters.Where(x => x.LocationId == LocationId &&
                                                                           x.IsDeleted == false).FirstOrDefault();
                    objDAR.ActivityDetails = DarMessage.BillApprovedReject(userDataItem.FirstName + "" + userDataItem.LastName, locationData.LocationName, ApproveStatus);
                    objDAR.TaskType        = (long)TaskTypeCategory.BillApprovedReject;
                    objDAR.UserId          = UserId;
                    objDAR.CreatedBy       = UserId;
                    objDAR.LocationId      = LocationId;
                    objDAR.CreatedOn       = DateTime.UtcNow;
                    CommonManager.SaveDAR(objDAR);
                    #endregion DAR
                }
                else
                {
                    IsApproved = true;
                }
                if (IsApproved == true)
                {
                    #region Email
                    var objEmailLogRepository = new EmailLogRepository();
                    var objEmailReturn        = new List <EmailToManagerModel>();
                    var objListEmailog        = new List <EmailLog>();
                    var objTemplateModel      = new TemplateModel();
                    if (IsApproved == true)
                    {
                        var userData = _workorderems.spGetVendorAllDetail(Obj.VendorId).
                                       Select(x => new BillListApproveModel()
                        {
                            Email = x.COD_Email,
                        }).FirstOrDefault();
                        if (userData != null)
                        {
                            bool IsSent         = false;
                            var  objEmailHelper = new EmailHelper();
                            objEmailHelper.emailid       = userData.Email;
                            objEmailHelper.LocationName  = Obj.LocationName;
                            objEmailHelper.VendorName    = Obj.VendorName;
                            objEmailHelper.UserName      = userDataItem.FirstName + " " + userDataItem.LastName;
                            objEmailHelper.MailType      = "APPROVEBILL";
                            objEmailHelper.SentBy        = UserId;
                            objEmailHelper.LocationID    = LocationId;
                            objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString();
                            IsSent = objEmailHelper.SendEmailWithTemplate();
                            var userDataApprove = _workorderems.LogBills.Join(_workorderems.UserRegistrations, q => q.LBLL_ModifiedBy, u => u.UserId, (q, u) => new { q, u }).
                                                  Where(x => x.q.LBLL_Id == Obj.LBLL_Id).FirstOrDefault();
                            //Push Notification
                            if (userDataApprove != null)
                            {
                                if (userDataApprove.u.DeviceId != null)
                                {
                                    string message = PushNotificationMessages.BillApprovedReject(objEmailHelper.LocationName, Obj.LBLL_Id, ApproveStatus, objEmailHelper.UserName);
                                    PushNotification.GCMAndroid(message, userDataApprove.u.DeviceId, objEmailHelper);
                                }
                            }
                            if (IsSent == true)
                            {
                                var objEmailog = new EmailLog();
                                try
                                {
                                    objEmailog.CreatedBy   = UserId;
                                    objEmailog.CreatedDate = DateTime.UtcNow;
                                    objEmailog.DeletedBy   = null;
                                    objEmailog.DeletedOn   = null;
                                    objEmailog.LocationId  = LocationId;
                                    objEmailog.ModifiedBy  = null;
                                    objEmailog.ModifiedOn  = null;
                                    objEmailog.SentBy      = UserId;
                                    objEmailog.SentEmail   = userData.Email;
                                    objEmailog.Subject     = objEmailHelper.Subject;
                                    objEmailog.SentTo      = Obj.VendorId;
                                    objListEmailog.Add(objEmailog);
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                            using (var context = new workorderEMSEntities())
                            {
                                context.EmailLogs.AddRange(objListEmailog);
                                context.SaveChanges();
                            }
                            #endregion Email
                        }
                    }
                    else
                    {
                        result = "Somethinsg goes wrong.";
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public MiscellaneousListDetails GetListMiscellaneous(long? UserId,long? Location, int? pageIndex, int? numberOfRows, string sortColumnName, string sortOrderBy, long? locationId, string textSearch, string statusType)", "Exception While Getting List of Miscellaneous details.", null);
                throw;
            }
        }
コード例 #12
0
        public ServiceResponseModel <string> InserteFleetFueling(eFleetFuelingModelForService objModel)
        {
            var objReturnModel = new ServiceResponseModel <string>();

            try
            {
                var objFuelingRepository = new FuelingRepository();
                var objDARRepository     = new DARRepository();
                var objDARDetail         = new DARDetail();
                var objDAR = new DARModel();
                var Obj    = new eFleetFueling();
                AutoMapper.Mapper.CreateMap <eFleetFuelingModelForService, eFleetFueling>();
                Obj             = AutoMapper.Mapper.Map(objModel, Obj);
                Obj.CreatedBy   = objModel.UserId;
                Obj.CreatedDate = DateTime.UtcNow;
                objFuelingRepository.Add(Obj);
                if (Obj.FuelID > 0)
                {
                    objDARDetail.ActivityDetails = DarMessage.RegisterNeweFleetFueling(objModel.LocationName);
                    //objDAR.ActivityDetails = objModel.ActivityDetails;
                    objDARDetail.LocationId = objModel.LocationID;
                    objDARDetail.TaskType   = (long)TaskTypeCategory.EfleetFuelingSubmission;
                    objDARDetail.CreatedBy  = objModel.UserId;
                    objDARDetail.CreatedOn  = DateTime.UtcNow;
                    objDARDetail.DeletedBy  = null;
                    objDARDetail.DeletedOn  = null;
                    objDARDetail.IsDeleted  = false;
                    objDARDetail.IsManual   = false;
                    objDARDetail.ModifiedBy = null;
                    objDARDetail.ModifiedOn = null;

                    objDARDetail.UserId    = objModel.UserId;
                    objDARDetail.StartTime = objModel.FuelingDate;
                    objDARDetail.EndTime   = DateTime.UtcNow;
                    objDARRepository.Add(objDARDetail);
                    //Result result = _ICommonMethod.SaveDAR(objDARDetail);

                    #region Email
                    var    objEmailLogRepository = new EmailLogRepository();
                    var    objEmailReturn        = new List <EmailToManagerModel>();
                    var    objListEmailog        = new List <EmailLog>();
                    var    objTemplateModel      = new TemplateModel();
                    Result result;
                    workorderEMSEntities db = new workorderEMSEntities();
                    if (objDARDetail.DARId > 0)
                    {
                        objEmailReturn = objEmailLogRepository.SendEmailToManagerForeFleetInspection(objModel.LocationID, objModel.UserId).Result;
                    }

                    if (objEmailReturn.Count > 0 && objDARDetail.DARId > 0)
                    {
                        foreach (var item in objEmailReturn)
                        {
                            bool IsSent         = false;
                            var  objEmailHelper = new EmailHelper();
                            objEmailHelper.emailid              = item.ManagerEmail;
                            objEmailHelper.ManagerName          = item.ManagerName;
                            objEmailHelper.DriverNameforFueling = objModel.DriverName;
                            objEmailHelper.FuelType             = (from gc in db.GlobalCodes where gc.GlobalCodeId == objModel.FuelType select gc.CodeName).FirstOrDefault();
                            objEmailHelper.GasStatioName        = objModel.GasStatioName;
                            objEmailHelper.Mileage              = objModel.Mileage;
                            objEmailHelper.CurrentFuel          = objModel.CurrentFuel;
                            objEmailHelper.Total         = objModel.Total.ToString();
                            objEmailHelper.VehicleNumber = objModel.VehicleNumber;
                            objEmailHelper.LocationName  = objModel.LocationName;
                            objEmailHelper.UserName      = item.UserName;
                            objEmailHelper.QrCodeId      = objModel.QRCodeID;
                            objEmailHelper.FuelingDate   = objModel.FuelingDate.ToString();
                            //objEmailHelper.InfractionStatus = obj.Status;
                            objEmailHelper.MailType      = "EfleetFueling";
                            objEmailHelper.SentBy        = item.RequestBy;
                            objEmailHelper.LocationID    = item.LocationID;
                            objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString();

                            IsSent = objEmailHelper.SendEmailWithTemplate();

                            //Push Notification
                            string message = PushNotificationMessages.eFleetFuelingReported(objModel.LocationName, objModel.QRCodeID, objModel.VehicleNumber);
                            PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper);
                            if (IsSent == true)
                            {
                                var objEmailog = new EmailLog();
                                try
                                {
                                    objEmailog.CreatedBy   = item.RequestBy;
                                    objEmailog.CreatedDate = DateTime.UtcNow;
                                    objEmailog.DeletedBy   = null;
                                    objEmailog.DeletedOn   = null;
                                    objEmailog.LocationId  = item.LocationID;
                                    objEmailog.ModifiedBy  = null;
                                    objEmailog.ModifiedOn  = null;
                                    objEmailog.SentBy      = item.RequestBy;
                                    objEmailog.SentEmail   = item.ManagerEmail;
                                    objEmailog.Subject     = objEmailHelper.Subject;
                                    objEmailog.SentTo      = item.ManagerUserId;
                                    objListEmailog.Add(objEmailog);
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }

                        using (var context = new workorderEMSEntities())
                        {
                            context.EmailLogs.AddRange(objListEmailog);
                            context.SaveChanges();
                        }
                        //    //var x = EmailLogRepository.InsertEntitiesNew("EmailLog", objListEmailog);
                        //    //Task<bool> x = null;
                        //    //foreach (var i in objListEmailog)
                        //    //{
                        //    //    x = objEmailLogRepository.SaveEmailLogAsync(i);
                        //    //}
                        //}


                        #endregion Email

                        if (objDARDetail.DARId > 0)
                        {
                            objReturnModel.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.InvariantCulture);
                            objReturnModel.Message  = CommonMessage.Successful();
                        }
                        else
                        {
                            objReturnModel.Response = Convert.ToInt32(ServiceResponse.FailedResponse, CultureInfo.CurrentCulture);
                            objReturnModel.Message  = CommonMessage.FailureMessage();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WorkOrderEMS.BusinessLogic.Exception_B.Exception_B.exceptionHandel_Runtime(ex, "ServiceResponseModel<string> InsertPreventativeMaintenance(eFleetPreventaticeMaintenanceModel objModel)", "while insert preventative maintenance", objModel);
                objReturnModel.Message  = ex.Message;
                objReturnModel.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                objReturnModel.Data     = null;
            }
            return(objReturnModel);
        }