public JsonResult RunNotificationsAlgorithm(int Id, int Period, bool Enable, bool OnStopError, bool Invoke)
        {
            string msg = "Enabled";
            if (Enable)
            {

                try
                {
                    int UNHour,   UNMinute;
                    DateTimeServices.GetTimeUniversal(9, 0,User.Identity.GetTimeZone(), out UNHour, out UNMinute);
                    RecurringJob.AddOrUpdate(Id.ToString(), () => EmploymentPapers.RunNotificationsAlgorithm(System.Configuration.ConfigurationManager.ConnectionStrings["HrContext"].ConnectionString,Language), Cron.Daily(UNHour,UNMinute));
                }
                catch
                {
                    if (OnStopError)
                        RecurringJob.RemoveIfExists(Id.ToString());
                }


                if (!Invoke)
                {
                    RecurringJob.Trigger(Id.ToString());
                    EmploymentPapers _EmploymentPapers = new EmploymentPapers(HrUnitOfWork);
                    _EmploymentPapers.UpdateTimeofTask(Id,Language);
                }
            }
            else
                msg = "Disabled";
            return Json(msg, JsonRequestBehavior.AllowGet);

           
        }
        public ActionResult ExtendContract(int Id, int Period, bool Enable, bool OnStopError, bool Invoke)
        {
            string msg = "Enabled";

            if (Enable)
            {
                try
                {
                    int UNHour, UNMinute;
                    DateTimeServices.GetTimeUniversal(9, 0, User.Identity.GetTimeZone(), out UNHour, out UNMinute);
                    RecurringJob.AddOrUpdate(Id.ToString(), () => HangFireJobs.ExtendContract(Language), Cron.Daily(UNHour, UNMinute));
                }
                catch
                {
                    if (OnStopError)
                    {
                        RecurringJob.RemoveIfExists(Id.ToString());
                    }
                }


                if (!Invoke)
                {
                    RecurringJob.Trigger(Id.ToString());
                    var model = _hrUnitOfWork.Repository <SchedualTask>().Where(a => a.EventId == Id).FirstOrDefault();
                    UpdateTimeofTask(model);
                }
            }
            else
            {
                msg = "Disabled";
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
            public static bool IsValid(IHrUnitOfWork _hrUnitOfWork, string EmpIds, string Source, int SourceId, DateTime StartTime, DateTime EndTime, DateTime DateToCheck, string Language, out string ErrorMessage)
            {
                ErrorMessage = string.Empty;
                bool IsValid = true;
                var  Tasks   = _hrUnitOfWork.MeetingRepository.GetEmployeeSchedual(EmpIds, StartTime, EndTime, Source, SourceId, Language).Select(a => a.Tasks).ToList();

                foreach (var item in Tasks)
                {
                    if (item.Select(s => s.EndTime).FirstOrDefault() != null)
                    {
                        if (item.FirstOrDefault().StartTime != null)
                        {
                            if (item.FirstOrDefault().Source.Equals(StringEnum.GetStringValue(Constants.Enumerations.ScheduleSourcesEnum.Leave)))
                            {
                                IsValid = false;
                            }

                            if (item.FirstOrDefault().Source.Equals(StringEnum.GetStringValue(Constants.Enumerations.ScheduleSourcesEnum.AssignOrder)))
                            {
                                IsValid = false;
                            }

                            if (IsValid)
                            {
                                var Task_StartDateTime = item.Select(s => s.StartTime).FirstOrDefault();
                                var Task_EndDateTime   = item.Select(s => s.EndTime).FirstOrDefault();
                                var StartDateTime      = StartTime;
                                var EndDateTime        = EndTime;
                                List <DateTimeGroup> DateTimeGroupList = new List <DateTimeGroup>();
                                DateTimeGroupList.Add(new DateTimeGroup()
                                {
                                    StartDate = StartDateTime, EndDate = EndDateTime
                                });
                                DateTimeGroupList.Add(new DateTimeGroup()
                                {
                                    StartDate = Convert.ToDateTime(Task_StartDateTime), EndDate = Convert.ToDateTime(Task_EndDateTime)
                                });
                                IsValid = DateTimeServices.CheckConflict(DateTimeGroupList);
                            }

                            if (!IsValid)
                            {
                                ErrorMessage = GetErrorMessage(item.FirstOrDefault(), Language);
                                return(IsValid);
                            }
                        }
                    }
                }

                return(true);
            }
Beispiel #4
0
        private List <Tirage> GetTiragesFromSourceCode(string _sourceCode, int _year)
        {
            List <Tirage>   tirages = new List <Tirage>();
            Tirage          tirage;
            List <DateTime> allTuesday = null;
            List <DateTime> allFriday  = DateTimeServices.GetAllDatesForDayOfWeekInYear(DayOfWeek.Friday, _year);

            // Since 2011 we need to look for tuesday dates too.
            if (_year >= this._startingTuesdayYear)
            {
                allTuesday = DateTimeServices.GetAllDatesForDayOfWeekInYear(DayOfWeek.Tuesday, _year);
                // Only since May 2011.
                if (_year == this._startingTuesdayYear)
                {
                    allTuesday.RemoveAll(x => x.Month < 5);
                }
            }

            string resultsTableContent = HtmlParsingServices.GetTableContentFromCode(_sourceCode, this._resultTableIdTag);

            if (allTuesday != null)
            {
                foreach (var d in allTuesday)
                {
                    tirage = this.GetTirageOfDateInTableContent(resultsTableContent, d);
                    if (tirage != null)
                    {
                        tirages.Add(tirage);
                    }
                }
            }

            foreach (var d in allFriday)
            {
                tirage = this.GetTirageOfDateInTableContent(resultsTableContent, d);
                if (tirage != null)
                {
                    tirages.Add(tirage);
                }
            }

            return(tirages);
        }
Beispiel #5
0
        public ServiceManager()
        {
            this.googleServices = new GoogleServices();
            this.googleServices.LatestCalendarEvent += (sender, calendar) => { this.CalendarStatusEvent?.Invoke(this, calendar); };
            this.googleServices.LatestEmailsEvent   += (sender, mail) => { this.LatestEmailsEvent?.Invoke(this, mail); };

            this.googleMapsServices = new GoogleMapsServices();
            this.googleMapsServices.TrafficUpdateEvent += (sender, traffic) => { this.TrafficUpdateEvent?.Invoke(this, traffic); };

            this.newsServices = new NewsServices();
            this.newsServices.LatestNewsEvent += (sender, newsmodel) => { this.LatestNewsEvent?.Invoke(this, newsmodel); };

            this.weatherServices = new WeatherServices(this.lat, this.logt);
            this.weatherServices.WeatherUpdateEvent += (sender, weather) => { this.WeatherUpdateEvent?.Invoke(this, weather); };

            this.quoteServices = new QuoteServices();
            this.quoteServices.QuoteUpdateEvent += (sender, quote) => { this.QuoteUpdateEvent?.Invoke(this, quote); };

            this.dateTimeServices = new DateTimeServices();
            this.dateTimeServices.TimerUpdateEvent += (sender, time) => { this.TimerUpdateEvent?.Invoke(this, time); };
        }