Beispiel #1
0
        private bool SendNotifyLetterMethod(HrUnitOfWork _hrUnitOfWork, string UserName, int EmpID, string ID, out string ErrorMessage)
        {
            ErrorMessage = "";

            int          CompanyID      = User.Identity.GetDefaultCompany();
            string       CurrentURL     = HttpContext.Request.Url.Authority;
            string       DownloadAPKUrl = System.Configuration.ConfigurationManager.AppSettings["DownloadAPKUrl"];
            DateTime     Today          = DateTime.Now.Date;
            string       Language       = HttpContext.User.Identity.GetLanguage();
            NotifyLetter NL             = new NotifyLetter()
            {
                CompanyId    = CompanyID,
                EmpId        = EmpID,
                NotifyDate   = Today,
                NotifySource = MsgUtils.Instance.Trls(Db.Persistence.Constants.Sources.UserProfile, Language),
                SourceId     = ID,
                Sent         = true,
                EventDate    = Today,
                Description  = MsgUtils.Instance.Trls("User Name", Language) + " : " + UserName + " " + MsgUtils.Instance.Trls("Website", Language) + " : " + CurrentURL + " " + MsgUtils.Instance.Trls("Download APK", Language) + " : " + DownloadAPKUrl
            };


            AddNotifyLetters AddNotifyLetters = new AddNotifyLetters(_hrUnitOfWork, NL, Language);
            bool             Result           = AddNotifyLetters.Run(out ErrorMessage);

            return(Result);
        }
Beispiel #2
0
        private TryAsync <NotifyAcknowledgement> SendNotifyEmail(NotifyLetter letter)
        => async() =>
        {
            var emialSender = _client.GetGrain <IEmailSender>(0);
            await emialSender.SendEmailAsync(letter.Letter);

            return(new NotifyAcknowledgement(Guid.NewGuid().ToString()));
        };
 public void Remove(NotifyLetter notify)
 {
     if (Context.Entry(notify).State == EntityState.Detached)
     {
         context.NotifyLetters.Attach(notify);
     }
     context.NotifyLetters.Remove(notify);
 }
 public AddNotifyLetters(IHrUnitOfWork _unitofwork, NotifyLetter _Record, string _Language)
 {
     unitofwork = _unitofwork;
     Language   = _Language;
     if (_Record != null)
     {
         RecordsList.Add(_Record);
     }
 }
        public static bool ExtendContractMethod(IHrUnitOfWork unitofwork, string Language, out string ErrorMessage)
        {
            bool Result = false;

            ErrorMessage = "";
            try
            {
                // Get All employees The will Send Email to whose contract Finish and before No of days
                var Employments = unitofwork.EmployeeRepository.SendMailEmployees();

                List <NotifyLetter> NotifyLettersList = new List <NotifyLetter>();
                foreach (var item in Employments)
                {
                    string NotifySource = "", Description = "";
                    if (item.Renew)
                    {
                        NotifySource = Constants.Sources.RenewContract;
                        Description  = MsgUtils.Instance.Trls("Contract has been renewed", Language);
                    }
                    else
                    {
                        NotifySource = Constants.Sources.ContractFinish;
                        Description  = MsgUtils.Instance.Trls("Contract has been finished", Language);
                    }

                    bool IsSentBefore = unitofwork.NotifyLetterRepository.IsNotificationSent(item.EmpId, DateTime.Today.Date, NotifySource);

                    if (!IsSentBefore)
                    {
                        NotifyLetter NL = new NotifyLetter()
                        {
                            CompanyId    = item.CompanyId,
                            EmpId        = item.EmpId,
                            NotifyDate   = DateTime.Today,
                            NotifySource = NotifySource,
                            SourceId     = item.Id.ToString(),
                            Sent         = false,
                            EventDate    = item.EndDate,
                            Description  = Description
                        };

                        NotifyLettersList.Add(NL);
                        //unitofwork.NotifyLetterRepository.Add(NL);
                    }
                }
                string           DefaultErrorMessage = MsgUtils.Instance.Trls("NotifyLetterNotSent", Language);
                AddNotifyLetters AddNotifyLetters    = new AddNotifyLetters(unitofwork, NotifyLettersList, Language);
                Result = AddNotifyLetters.Run(out ErrorMessage, DefaultErrorMessage);
            }
            catch
            {
            }
            return(Result);
        }
        public static void RunNotificationsAlgorithm(string ConnectionString, string Language)
        {
            HrUnitOfWork unitofwork = new HrUnitOfWork(new HrContextFactory(ConnectionString));

            try
            {
                DateTime Today = DateTime.Now.Date;
                List <EmploymentPaper_ToNotify> EmpPapers_ToNotify = unitofwork.CompanyDocsViewsRepository.EmploymentPapersForNotifications();

                string EmpIDs = (EmpPapers_ToNotify.Any()) ? EmpPapers_ToNotify.Select(a => a.EmpID.ToString()).Aggregate <string>((x1, x2) => x1 + "," + x2).ToString() : "";
                List <FormDropDown> EmpsLangs = unitofwork.MeetingRepository.GetUsersLang(EmpIDs);

                List <NotifyLetter> NotifyLettersList = new List <NotifyLetter>();
                EmpPapers_ToNotify.ForEach(e =>
                {
                    FormDropDown EmpLang = EmpsLangs.Where(a => a.id == e.EmpID).FirstOrDefault();

                    string Lang = "";
                    if (EmpLang != null)
                    {
                        Lang = EmpLang.name;
                    }

                    NotifyLetter NL = new NotifyLetter()
                    {
                        CompanyId    = e.CompanyId.Value,
                        EmpId        = e.EmpID,
                        NotifyDate   = Today,
                        NotifySource = MsgUtils.Instance.Trls(Lang, e.DocTypeName),
                        SourceId     = e.Stream_Id.ToString(),
                        Sent         = true,
                        EventDate    = e.ExpiryDate.Value,
                        Description  = MsgUtils.Instance.Trls(Lang, "you must renew") + " " + e.PaperFileName + " " + MsgUtils.Instance.Trls(Lang, "Before") + " " + e.ExpiryDate.Value.ToMyDateString(Lang, "yyyy-MM-dd")
                    };
                    //unitofwork.NotifyLetterRepository.Add(NL);
                    NotifyLettersList.Add(NL);
                });

                string           ErrorMessage;
                AddNotifyLetters AddNotifyLetters = new AddNotifyLetters(unitofwork, NotifyLettersList, Language);
                bool             Result           = AddNotifyLetters.Run(out ErrorMessage);
                //unitofwork.SaveChanges();
            }

            catch (Exception ex)
            {
                unitofwork.HandleDbExceptions(ex);
            }
            finally
            {
            }
        }
Beispiel #7
0
        public void RunNotificationsAlgorithm(string ConnectionString, SendFormPageVM model, string Culture)
        {
            HrUnitOfWork unitofwork = new HrUnitOfWork(new HrContextFactory(ConnectionString));

            try
            {
                DateTime            Today = DateTime.Now.Date;
                List <int>          EmployeesToNotificate = GetEmpIdList(ConnectionString, model, Culture);
                string              FormName  = unitofwork.Repository <FlexForm>().Where(a => a.Id == model.FormId).SingleOrDefault().Name;
                List <FormDropDown> EmpsLangs = unitofwork.MeetingRepository.GetUsersLang((EmployeesToNotificate.Any()) ? EmployeesToNotificate.Select(a => a.ToString()).Aggregate <string>((x1, x2) => x1 + "," + x2).ToString() : "");
                foreach (var e in EmployeesToNotificate.Distinct())
                {
                    string Lang;
                    if (EmpsLangs.Select(a => a.id).Contains(e))
                    {
                        Lang = EmpsLangs.Where(a => a.id == e).FirstOrDefault().name;
                    }
                    else
                    {
                        Lang = Culture;
                    }
                    NotifyLetter NL = new NotifyLetter()
                    {
                        CompanyId    = model.CompanyId,
                        EmpId        = e,
                        NotifyDate   = Today,
                        NotifySource = MsgUtils.Instance.Trls(Lang, "Questionnaire") + " " + MsgUtils.Instance.Trls(Lang, FormName),
                        SourceId     = model.FormId.ToString(),
                        Sent         = true,
                        EventDate    = model.ExpiryDate,
                        Description  = MsgUtils.Instance.Trls(Lang, "Please fill") + " " + MsgUtils.Instance.Trls(Lang, FormName) + " " + MsgUtils.Instance.Trls(Lang, "Before") + " " + model.ExpiryDate.ToShortDateString()
                    };
                    unitofwork.NotifyLetterRepository.Add(NL);
                }


                unitofwork.SaveChanges();
            }

            catch (Exception ex)
            {
                unitofwork.HandleDbExceptions(ex);
            }
            finally
            {
            }
        }
 public DbEntityEntry <NotifyLetter> Entry(NotifyLetter notify)
 {
     return(Context.Entry(notify));
 }
 public void Attach(NotifyLetter notify)
 {
     context.NotifyLetters.Attach(notify);
 }
 public void AddNotifyLetter(NotifyLetter notify)
 {
     context.NotifyLetters.Add(notify);
 }