protected void btnUploadFile_Click(object sender, EventArgs e)
    {
        //check if a file is selected
        if (uploadAttachment.HasFile)
        {
            uploadAttachment.SaveAs(Server.MapPath("/UploadedXml/")
            + uploadAttachment.FileName.Split('.')[0]
            + Path.GetExtension(uploadAttachment.FileName));
            XElement document = XElement.Load(Server.MapPath("/UploadedXml/") + uploadAttachment.FileName);
            ContentTypeManager<Holiday> contentTypeManagerHoliday = new ContentTypeManager<Holiday>();
            foreach (var booking in document.Elements())
            {
                Holiday holiday = new Holiday();
                holiday.FirstName = booking.Element("customer").Element("firstname").Value;
                holiday.LastName = booking.Element("customer").Element("lastname").Value;
                holiday.Email = booking.Element("customer").Element("email").Value;
                holiday.Phone = booking.Element("customer").Element("phone").Value;
                holiday.HolidayType = booking.Element("holiday").Element("type").Value;
                holiday.HolidayCountry = booking.Element("holiday").Element("destination").Value;
                holiday.HolidayDate = booking.Element("holiday").Element("date").Value;
                holiday.Comments = booking.Element("holiday").Element("comments").Value;

                ContentType<Holiday> holidayContent = new ContentType<Holiday>();
                holidayContent.Content = new Ektron.Cms.ContentData();
                holidayContent.Content.FolderId = 102;
                holidayContent.Content.Title = booking.Attribute("name").Value;
                holidayContent.SmartForm = holiday;

                contentTypeManagerHoliday.Add(holidayContent);

            }
            litMessage.Text = "Successfully added " + document.Elements().ToArray().Length + " items to the CMS";
        }
    }
示例#2
0
 public IEnumerable<CalendarEvent> SaveBatchOfWeekends(DateTime activeTime, string country)
 {
     var days = DateTime.DaysInMonth(activeTime.Year, activeTime.Month);
     var calendarEvents = new List<CalendarEvent>();
     for (var i = 1; i <= days; i++)
     {
         var currentDay = new DateTime(activeTime.Year, activeTime.Month, i);
         if (currentDay.DayOfWeek == DayOfWeek.Saturday || currentDay.DayOfWeek == DayOfWeek.Sunday)
         {
             var entity = new Holiday
                                  {
                                      Country = country,
                                      Start = currentDay,
                                      End = currentDay.AddDays(1),
                                      EventName = currentDay.DayOfWeek.ToString()
                                  };
             if (CanSave(entity))
             {
                 _calendarEventRepository.MakePersistent(entity);
                 calendarEvents.Add(entity);
             }
         }
     }
     return calendarEvents;
 }
 public Holiday Delete(Holiday entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         _connection.Delete(entity);
     }
     return entity;
 }
 public Holiday Insert(Holiday entity)
 {
     using (_connection = Utilities.GetProfiledOpenConnection())
     {
         entity.Id = _connection.Insert(entity);
         return entity;
     }
 }
        public HolidayRandomiser()
        {
            holidays = new Holiday[3];
            randGen = new Random();

            holidays[0] = new Holiday("Queens Birthday", new DateTime(2016, 06, 06), "/queens.jpg");
            holidays[1] = new Holiday("Halloween", new DateTime(2016, 10, 31), "/halloween.jpeg");
            holidays[2] = new Holiday("Boxing Day", new DateTime(2016, 12, 26), "/boxingday.jpg");
        }
 public ActionResult Edit(Holiday holiday)
 {
     if (ModelState.IsValid)
     {
         db.Entry(holiday).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(holiday);
 }
        public ActionResult Create(Holiday holiday)
        {
            if (ModelState.IsValid)
            {
                db.Holidays.Add(holiday);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(holiday);
        }
        /// <summary>
        /// Function to save holiday details.
        /// </summary>
        /// <param name="holiday">holiday information.</param>
        public void InsertOrUpdate(Holiday holiday)
        {
            if (holiday == null)
            {
                throw new ArgumentNullException(HolidayConstant);
            }

            if (holiday.HolidayID == default(int))
            {
                this.unitOfWork.Context.Entry(holiday).State = EntityState.Added;
            }
            else
            {
                this.unitOfWork.Context.Entry(holiday).State = EntityState.Modified;
            }
        }
示例#9
0
 public static bool AddHoliday(Holiday aHoliday_)
 {
   lock (m_holidayMap)
   {
     Hashtable hashtable = (Hashtable)m_holidayMap[aHoliday_.ResourceCode];
     if (hashtable == null)
     {
       Hashtable hashtable2 = new Hashtable();
       hashtable2.Add(aHoliday_, null);
       m_holidayMap.Add(aHoliday_.ResourceCode, hashtable2);
     }
     else
     {
       hashtable.Add(aHoliday_, null);
     }
   }
   return true;
 }
示例#10
0
        public void SetShippingTime(DateTime pickupTime, int shippingMinuteConfig, WorkingTime[] logisticsWorkingTimes, Holiday[] logisticsHolidayTimes)
        {
            PickupTime   = pickupTime;
            ShippingTime = PickupTime.Value.AddMinutes(shippingMinuteConfig);
            int i = -1;

            while (true)
            {
                i++;
                if (i > 10)
                {
                    break;
                }
                ShippingTime = ShippingTime.Value.AddDays(i);
                var         dayOfWeek  = ShippingTime.Value.DayOfWeek;
                WorkingTime workingDay = logisticsWorkingTimes.FirstOrDefault(p => p.DayOfWeek == dayOfWeek);
                if (workingDay == null)
                {
                    ShippingTime = ShippingTime.Value.Date;
                    continue;
                }
                // ReSharper disable once AccessToModifiedClosure
                Holiday holidayDay = logisticsHolidayTimes.FirstOrDefault(p => p.Day.Date == ShippingTime.Value.Date);
                if (holidayDay != null)
                {
                    var workingTime =
                        holidayDay.WorkingTimes.FirstOrDefault(p => p.Item2 - p.Item1 > shippingMinuteConfig);
                    if (workingTime == null)
                    {
                        continue;
                    }
                    ShippingTime = ShippingTime.Value.Date.AddMinutes(workingTime.Item1 + shippingMinuteConfig);
                }
                else
                {
                    ShippingTime = ShippingTime.Value.Date.AddMinutes(workingDay.Times[0].Item1 + shippingMinuteConfig);
                }
            }
        }
示例#11
0
        public static async void ShowRRHHvoucherCard(IMessageActivity message, Holiday input)
        {
            Activity reply = ((Activity)message).CreateReply();

            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            List <CardImage> cardImages = new List <CardImage>();

            cardImages.Add(new CardImage(url: "https://cdn0.iconfinder.com/data/icons/office-files-icons/110/Pdf-File-512.png"));
            HeroCard card = new HeroCard()
            {
                Title   = "BOLETA DE PAGO",
                Images  = cardImages,
                Buttons = new List <CardAction>()
                {
                    new CardAction(ActionTypes.DownloadFile, "Descargar", value: "https://www.marquam.com/Documents/Microsoft%20Bot%20Framework%20Documentation.pdf"),
                }
            };

            reply.Attachments.Add(card.ToAttachment());
            ConnectorClient connector = new ConnectorClient(new Uri(reply.ServiceUrl));
            await connector.Conversations.SendToConversationAsync(reply);
        }
示例#12
0
        public Profile()
        {
            for (int i = 3; i < 55; i++)
            {
                Age.Add(i.ToString());
            }
            Age.Add("55+");

            Interest.AddRange(new string[]
                              { String.Empty,
                                "Спорт",
                                "Музыка",
                                "Рукоделие",
                                "Литература",
                                "Рисование",
                                "Танцы",
                                "Рыбалка",
                                "Охота",
                                "Работа",
                                "Языкознание",
                                "Программирование" });

            Holiday.AddRange(new string[]
                             { "День Рождение",
                               "Новый Год",
                               "8 марта",
                               "23 февраля",
                               "14 февраля",
                               "1 сентября",
                               "1 мая",
                               "День Народного Единства",
                               "День Победы",
                               "Рождество",
                               "Крещение",
                               "Свадьба",
                               "День Учителя",
                               "День Семьи",
                               "Любви и Верности" });
        }
示例#13
0
        public List <Holiday> ReadHolidaysByMonthYear(int year, int month)
        {
            List <Holiday> lstHolidays = new List <Holiday>();
            DbCommand      dbcommand   = myDataBase.GetStoredProcCommand(DBConstant.READ_HOLIDAY_BY_YEAR_MONTH);

            myDataBase.AddInParameter(dbcommand, "@inYear", DbType.String, year);
            myDataBase.AddInParameter(dbcommand, "@inMonth", DbType.String, month);
            using (IDataReader reader1 = myDataBase.ExecuteReader(dbcommand))
            {
                while (reader1.Read())
                {
                    Holiday holidayMaster = new Holiday();
                    holidayMaster.Holiday_Detail = GetStringFromDataReader(reader1, "Holiday_Detail");
                    holidayMaster.Holiday_Date   = GetStringFromDataReader(reader1, "HolidayDate");
                    holidayMaster.Holiday_Name   = GetStringFromDataReader(reader1, "Name_of_the_Holiday");
                    holidayMaster.Holiday_Day    = GetStringFromDataReader(reader1, "Day");
                    holidayMaster.Country_Name   = GetStringFromDataReader(reader1, "COUNTRY_ID");
                    lstHolidays.Add(holidayMaster);
                }
            }
            return(lstHolidays);
        }
示例#14
0
        private static int occurrenceOnInPeriodWorkingDay(Holiday holiday, DateTime start, DateTime end, int year)
        {
            var holidayDate      = new DateTime(year, holiday.Month, 1);
            var currentDayOfWeek = (int)holidayDate.DayOfWeek;

            if (currentDayOfWeek != holiday.DayOfWeek)
            {
                // Shift the day to the start of the next week
                if (holiday.DayOfWeek < currentDayOfWeek)
                {
                    holidayDate = holidayDate.AddDays(7 - currentDayOfWeek);
                }

                // shift the date to the desired day of the week
                holidayDate = holidayDate.AddDays(holiday.DayOfWeek ?? 0);
            }

            // Shift the date to the desired day in the month
            holidayDate = holidayDate.AddDays(7 * ((holiday.OccurrenceInMonth ?? 1) - 1));

            return(holidayDate > start && holidayDate < end && OnWeekday(holidayDate) ? 1 : 0);
        }
示例#15
0
        public void EditPost_ValidModelConcurrency_ErrorReturned()
        {
            //Arrange
            HolidayController controller = new HolidayController(mock.Object);
            Holiday           holiday    = new Holiday {
                HolidayDate = new DateTime(2014, 05, 05), IsPostponed = false, CountryID = 1, Title = "TEST"
            };

            mock.Setup(m => m.SaveHoliday(It.IsAny <Holiday>())).Throws(new DbUpdateConcurrencyException());
            string modelError = "The record you attempted to edit "
                                + "was modified by another user after you got the original value. The "
                                + "edit operation was canceled.";

            //Act
            var    result = (JsonResult)controller.Edit(mock.Object.Holidays.FirstOrDefault());
            string data   = (string)(new Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject(result.Data, "error")).Target;

            //Assert
            mock.Verify(d => d.SaveHoliday(It.IsAny <Holiday>()), Times.Once());
            Assert.AreEqual(typeof(JsonResult), result.GetType());
            Assert.AreEqual(modelError, data);
        }
示例#16
0
        public async Task Should_ReturnLeaveTypeList_When_PassValidCompanyId()
        {
            // Arrange
            var holiday = new Holiday()
            {
                HolidayId = 1,
                CompanyId = 1,
                CreatedAt = DateTime.Now,
                CreatedBy = -1,
                Name      = "Holiday Test - 1"
            };

            _fixture.Context.Holidays.Add(holiday);
            holiday = new Holiday()
            {
                HolidayId = 2,
                CompanyId = 1,
                CreatedAt = DateTime.Now,
                CreatedBy = -1,
                Name      = "Holiday Test - 2"
            };
            _fixture.Context.Holidays.Add(holiday);
            _fixture.Context.SaveChanges();

            IRepository <Holiday> repository = new Repository <Holiday>(_fixture.Context);

            var handler = new GetHolidayListHandler(repository, _mapper, _logger);

            var queryRequest = new GetHolidayListQuery(companyId: 1);

            // Act
            var tcs = new CancellationToken();

            var result = await handler.Handle(queryRequest, tcs);

            // Assert
            Assert.NotEmpty(result);
            Assert.Equal(2, result.Count());
        }
示例#17
0
        public object Post(Holiday added)
        {
            object json;
            string messageError = "";

            try
            {
                Holiday posted = repository.Add(added, ref messageError);

                if (posted != null)
                {
                    json = new
                    {
                        total   = 1,
                        data    = posted,
                        success = true
                    };
                }
                else
                {
                    throw new System.InvalidOperationException(messageError);
                }
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                object error = new { message = ex.Message };

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }
示例#18
0
        public static void SaveHolidays(DSModel db, KeyBinder key, List <HolidayModel> model)
        {
            if (db == null)
            {
                throw new ArgumentNullException("db");
            }
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var holidaysToDelete = db.Holidays.ToList();

            foreach (var h in holidaysToDelete.ToList())
            {
                var check = model.Where(hh => hh.HolidayDate == h.HolidayDate).FirstOrDefault();
                if (check == null)
                {
                    db.Delete(h);
                }
                else
                {
                    model.Remove(check);
                }
            }

            foreach (var h in model)
            {
                Holiday poco = new Holiday();
                poco.HolidayDate = h.HolidayDate;
                db.Add(poco);
                key.AddKey(poco, h, h.GetName(p => p.HolidayDate));
            }
        }
        public static Holiday FillObject(IDataReader _dr)
        {
            List <Holiday> list = new List <Holiday>();

            try
            {
                while (_dr.Read())
                {
                    Holiday holiday = new Holiday();
                    holiday.Id        = _dr["Id"].ToString();
                    holiday.Code      = _dr["Code"].ToString();
                    holiday.Name      = _dr["Name"].ToString();
                    holiday.DayOff    = ConvertHelper.ToDateTime(_dr["DayOff"], DateTime.Now);
                    holiday.CreatedBy = _dr["CreatedBy"].ToString();
                    holiday.CreatedAt = ConvertHelper.ToDateTime(_dr["CreatedAt"], DateTime.Now);
                    holiday.UpdatedBy = _dr["UpdatedBy"].ToString();
                    holiday.UpdatedAt = ConvertHelper.ToDateTime(_dr["UpdatedAt"], DateTime.Now);
                    holiday.IsDeleted = ConvertHelper.ToInt32(_dr["IsDeleted"], 0);
                    if (list.IndexOf(holiday) < 0)
                    {
                        list.Add(holiday);
                    }
                    if (list.Count > 0)
                    {
                        Holiday[] holidays = list.ToArray();
                        if (holidays != null && holidays.Length > 0)
                        {
                            return(holidays[0]);
                        }
                    }
                }
            }
            catch (Exception)
            {
                _dr.Close();
            }
            return(null);
        }
示例#20
0
        protected override void ItemShowing()
        {
            Holiday info = UpdatingItem as Holiday;

            this.dtStartDate.Value = info.StartDate.Date;
            this.dtEndDate.Value   = info.EndDate.Date;
            this.txtMemo.Text      = info.Memo;
            if (info.WeekendToWorkDay1 != null)
            {
                checkBox1.Checked = true;
                dtWorkday1.Value  = info.WeekendToWorkDay1.Value;
            }
            if (info.WeekendToWorkDay2 != null)
            {
                checkBox2.Checked = true;
                dtWorkday2.Value  = info.WeekendToWorkDay2.Value;
            }
            if (info.WeekendToWorkDay3 != null)
            {
                checkBox3.Checked = true;
                dtWorkday3.Value  = info.WeekendToWorkDay3.Value;
            }
            if (info.WeekendToWorkDay4 != null)
            {
                checkBox4.Checked = true;
                dtWorkday4.Value  = info.WeekendToWorkDay4.Value;
            }
            if (info.WeekendToWorkDay5 != null)
            {
                checkBox5.Checked = true;
                dtWorkday5.Value  = info.WeekendToWorkDay5.Value;
            }
            if (info.WeekendToWorkDay6 != null)
            {
                checkBox6.Checked = true;
                dtWorkday6.Value  = info.WeekendToWorkDay6.Value;
            }
        }
示例#21
0
        private void Btn_Save_Holiday_Click(object sender, RoutedEventArgs e)
        {
            ManageData _manage = new ManageData();


            if (txtHoliday.Text.Length != 0 && getStartDate.Text.Length != 0 && getEndDate.Text.Length != 0)
            {
                Holiday   _holiday = new Holiday();
                MyContext _context = new MyContext();

                string   name  = txtHoliday.Text;
                DateTime sDate = Convert.ToDateTime(getStartDate.Text);
                DateTime eDate = Convert.ToDateTime(getEndDate.Text);

                _manage.addHoliday(name, sDate, eDate);
                var get = _context.Holidays.Where(u => u.isDeleted != true).ToList();
                DataGridHoliday.ItemsSource = get;
            }
            else
            {
                MessageBox.Show("Please Fill All Data!");
            }
        }
示例#22
0
        private static Holiday CreateHoliday(ExcelWorksheet sheet, ProjectSheet projectSheet, int columns, int i)
        {
            var holiday = new Holiday
            {
                Id             = Guid.NewGuid().ToString(),
                ProjectSheetId = projectSheet.ProjectSheetId,
                ProjectSheet   = projectSheet,
                UserLogin      = projectSheet.UserLogin
            };
            var holidayName = "";

            for (int j = 1; j <= columns; j++)
            {
                var content = sheet.Cells[i, j].Value;
                if (content != null)
                {
                    holidayName += content.ToString() + "; ";
                }
            }
            holiday.Name = holidayName;

            return(holiday);
        }
 public async Task <IActionResult> Edit(EditHolidayViewModel holidayChange)
 {
     if (ModelState.IsValid)
     {
         if (holidayChange.DateOfHoliday != holidayChange.PreviousDate)
         {
             if (holidayChange.PreviousDate.DayOfWeek != DayOfWeek.Saturday && holidayChange.PreviousDate.DayOfWeek != DayOfWeek.Sunday)
             {
                 await deleteHolidayAdjustment(holidayChange.PreviousDate, userManager, requestRepository, emailSender);
             }
             if (holidayChange.DateOfHoliday.DayOfWeek != DayOfWeek.Saturday && holidayChange.DateOfHoliday.DayOfWeek != DayOfWeek.Sunday)
             {
                 await newHolidayAdjustment(holidayChange.DateOfHoliday, userManager, requestRepository, emailSender);
             }
         }
         Holiday holiday = holidayRepository.GetHoliday(holidayChange.HolidayID);
         holiday.DateOfHoliday = holidayChange.DateOfHoliday;
         holiday.NameOfHoliday = holidayChange.NameOfHoliday;
         holidayRepository.Update(holiday);
         return(RedirectToAction("index"));
     }
     return(View(holidayChange));
 }
示例#24
0
 public IActionResult Update(HolidayViewModel updatedHoliday)
 {
     if (ModelState.IsValid)
     {
         var holidayToUpdate = new Holiday()
         {
             FromDate    = updatedHoliday.FromDate,
             ToDate      = updatedHoliday.ToDate,
             HolidayName = updatedHoliday.HolidayName,
             Comments    = updatedHoliday.Comments,
             HolidayId   = updatedHoliday.HolidayId.Value
                           // HolidayId = updatedHoliday.HolidayId.Value
         };
         // _employee.AddNewHoliday(holiday);
         _employee.UpdateHoliday(holidayToUpdate);
         return(RedirectToAction("Index"));
     }
     else
     {
         ViewBag.IsEditing = true;
         return(View("Form", updatedHoliday));
     }
 }
 public IActionResult Index()
 {
     ViewBag.Title = "节假日列表";
     var model = new Holiday[]
     {
         new Holiday
         {
             Day = new DateTime(2019,1,1),
             Name = "元旦"
         },
         new Holiday
         {
             Day = new DateTime(2019,10,1),
             Name = "国庆"
         },
         new Holiday
         {
             Day = new DateTime(2019, 12, 25),
             Name = "圣诞"
         }
     };
     return View(model);
 }
    public void btnBookHoliday_Click(object sender, EventArgs e)
    {
        Page.Validate();
        Holiday holiday = new Holiday();
        holiday.FirstName = txtFirstName.Text;
        holiday.LastName = txtLastName.Text;
        holiday.Email = txtEmail.Text;
        holiday.Phone = txtPhone.Text;
        holiday.HolidayType = RadioHolidayType.SelectedValue;
        holiday.HolidayCountry = ddlCountries.SelectedValue;
        holiday.HolidayDate = clndrHolidayDate.SelectedDate.ToString();
        holiday.Comments = tbComments.Text;

        ContentTypeManager<Holiday> contentTypeManager = new ContentTypeManager<Holiday>();
        ContentType<Holiday> newHoliday = new ContentType<Holiday>();
        newHoliday.Content = new ContentData();
        newHoliday.Content.FolderId = 102;
        newHoliday.Content.Title = holiday.FirstName + "-" + holiday.HolidayCountry + "-" + holiday.HolidayDate;
        newHoliday.SmartForm = holiday;
        // adds content to the CMS
        contentTypeManager.Add(newHoliday);
        Response.Redirect("/Source/Wireframes/Pagination.aspx");
    }
        public JsonResult GetAll(long OrgId)
        {
            Holiday          Holidayobj = new Holiday();
            var              Year       = DateTime.Now.Year;
            webSchoolContext db         = new webSchoolContext();
            var              Holidays   = (from tableHoliday in db.tblHolidayLists
                                           where tableHoliday.Date.Value.Year == Year && tableHoliday.OrgId == OrgId
                                           select new { Date = tableHoliday.Date.ToString(), tableHoliday.Name }).ToList().OrderBy(o => o.Date);

            //Holidayobj.HolidaysList = new List<days>();
            //foreach (var temp in Holidays)
            //{
            //    var HolidayTemp = new days();
            //    Holidayobj.HolidaysList.Add(HolidayTemp);
            //    HolidayTemp.Name = temp.Name;
            //    if (temp.Date != null)
            //    {
            //        HolidayTemp.Date = ConvertToJavascriptDate(new DateTime (temp.Date.Value.Year, temp.Date.Value.Month, temp.Date.Value.Day));
            //    }
            //}

            return(Json(new { Holidays }, JsonRequestBehavior.AllowGet));
        }
示例#28
0
        public static Holiday GetHolidayByID(int HolidayID)
        {
            try
            {
                DataRow HolidayRow = HolidayDataAccess.GetInstance.GetHolidayByID(HolidayID);

                Holiday _Holiday = new Holiday();

                _Holiday.HolidayID         = int.Parse(HolidayRow["HolidayID"].ToString());
                _Holiday.Occasion          = HolidayRow["Occasion"].ToString();
                _Holiday.DateOfOccasion    = System.DateTime.Parse(HolidayRow["DateOfOccasion"].ToString());
                _Holiday.WeekDayOfOccasion = _Holiday.DateOfOccasion.DayOfWeek.ToString();

                _Holiday.IsDateFixed = Boolean.Parse(HolidayRow["IsDateFixed"].ToString());
                _Holiday.IsActive    = Boolean.Parse(HolidayRow["IsActive"].ToString());

                return(_Holiday);
            }
            catch (Exception ex)
            {
                throw (new Exception(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + (new System.Diagnostics.StackFrame()).GetMethod().Name, ex));
            }
        }
        public IActionResult Index()
        {
            var model = new Holiday[]
            {
                new Holiday
                {
                    Day  = new DateTime(2019, 1, 1),
                    Name = "元旦"
                },
                new Holiday
                {
                    Day  = new DateTime(2019, 10, 1),
                    Name = "国庆"
                },
                new Holiday
                {
                    Day  = new DateTime(2019, 12, 25),
                    Name = "圣诞"
                }
            };

            return(View(model));
        }
示例#30
0
        private static Attachment FillHeroCard(Holiday holiday)
        {
            var heroCard = new HeroCard
            {
                Title  = holiday.Title,
                Text   = holiday.Date.ToString("dd/MM/yyyy"),
                Images = new List <CardImage> {
                    new CardImage("https://gothinkbig.co.uk/wp-content/uploads/2015/06/holiday.png")
                },
                Subtitle = holiday.Description,
                Buttons  = new List <CardAction> {
                    new CardAction
                    {
                        Type        = ActionTypes.PostBack,
                        DisplayText = "Congratulations you have opted in for a flexible holiday",
                        Title       = "Opt In",
                        Value       = $"Opt In {holiday.Id}"
                    }
                }
            };

            return(heroCard.ToAttachment());
        }
示例#31
0
        public static Holiday GetHoliday(DateTime date)
        {
            Holiday retur       = null;
            string  queryString = "Select * from Holidays where [From] >= @Date AND too <= @Date";

            using (SqlConnection cnn = new SqlConnection(aspplanconnectionString))
            {
                SqlCommand cmd = new SqlCommand(queryString, cnn);
                cnn.Open();
                cmd.Parameters.AddWithValue("@Date", date);

                using (SqlDataReader oReader = cmd.ExecuteReader())
                {
                    while (oReader.Read())
                    {
                        retur       = new Holiday();
                        retur.Start = DateTime.Parse(oReader["[From]"].ToString());
                        retur.S**t  = DateTime.Parse(oReader["Too"].ToString());
                    }
                }
            }
            return(retur);
        }
示例#32
0
        private void ButtonSaveHoliday_Click(object sender, EventArgs e)
        {
            int     index           = checkedListBoxHolidays.SelectedIndex;
            bool    holidayActive   = checkedListBoxHolidays.GetItemChecked(index);
            Holiday selectedHoliday = checkedListBoxHolidays.SelectedItem as Holiday;

            selectedHoliday.Name = textBoxHolidayName.Text;
            if (dateTimePickerHolidayDate.Checked)
            {
                selectedHoliday.OverrideDate = dateTimePickerHolidayDate.Value;
            }
            else
            {
                selectedHoliday.OverrideDate = null;
            }

            checkedListBoxHolidays.Items.RemoveAt(index);
            checkedListBoxHolidays.Items.Insert(index, selectedHoliday);
            checkedListBoxHolidays.SetItemChecked(index, holidayActive);
            checkedListBoxHolidays.SelectedIndex = index;

            SyncHolidaysToCharts();
        }
示例#33
0
        private async Task ValidateHoliday(Holiday holiday)
        {
            if (holiday.Status == HolidayStatus.AdminConfirmed)
            {
                throw new InvalidOperationException("Holiday already confirmed.");
            }

            var currentTime = _timeService.GetCurrentTime();
            var employee    = await _employeeRepository.GetById(holiday.EmployeeId);

            ValidateDateInterval(holiday, currentTime);
            ValidateOvertime(holiday, employee);

            if (holiday.Type == HolidayType.DayForChildren && !IsEmployeeEligibleForDayForChildren(holiday, employee, currentTime))
            {
                throw new InvalidOperationException("Employee is not eligible for day for children leave.");
            }

            if (IsAnyBoundaryNotAWorkday(holiday))
            {
                throw new InvalidOperationException("Either first or last holiday's day is not a workday anyway.");
            }
        }
        public ActionResult DetermineHolidays(string date)
        {
            Holiday holidays = new Holiday();

            string[] dates = date.Split(',');


            try
            {
                foreach (var item in dates)
                {
                    if (ModelState.IsValid)
                    {
                        DateTime selectedDate = DateTime.Parse(item);
                        var      query        = (from h in db.Holiday
                                                 where h.value == selectedDate
                                                 select h).FirstOrDefault();
                        if (query != null)
                        {
                            ModelState.AddModelError("", "Selected date is already a holiday: " + selectedDate.Date);
                        }
                        holidays.value = selectedDate;
                        db.Holiday.Add(holidays);
                        db.SaveChanges();
                    }
                }

                return(RedirectToAction("DetermineHolidays"));
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Error occured.");
            }


            return(View());
        }
示例#35
0
        /// <summary>
        /// Le constructeur
        /// </summary>
        /// <param name="holiday">Le congé concerné</param>
        /// <param name="nbHolidays">Le nombre de vacances</param>
        /// <param name="alreadyPresent">Le nombre de congé déjà posé</param>
        public NewHolidaysForm(Holiday holiday, int nbHolidays, int alreadyPresent)
        {
            InitializeComponent();

            //On associe tous les contrôles aux données

            this.currentYear    = holiday.StartingDate.Year;
            this.alreadyPresent = alreadyPresent;
            this.CurrentHoliday = holiday;
            this.nbHolidays     = nbHolidays;

            this.nbDay.Text     = nbHolidays.ToString();
            this.amplitude.Text = (CurrentHoliday.numberOfDays() + 1).ToString();

            //Si le congé est pas persisté ça veut dire que l'on est en création
            if (!holiday.Exists)
            {
                this.start.Visible     = false;
                this.end.Visible       = false;
                this.title.Text        = "Nouveau congé";
                this.Name              = "Demande de congé";
                this.startingDate.Text = holiday.StartingDate.ToLongDateString();
                this.endingDate.Text   = holiday.EndingDate.ToLongDateString();
                this.rest.Text         = (30 - nbHolidays - alreadyPresent).ToString();

                return;
            }

            this.startingDate.Visible = false;
            this.endingDate.Visible   = false;
            this.Name        = "Modification de congé";
            this.title.Text  = "Modification de congé";
            this.end.Value   = holiday.EndingDate;
            this.start.Value = holiday.StartingDate;
            this.rest.Text   = (30 - alreadyPresent).ToString();
            init             = false;
        }
示例#36
0
        private Dictionary <string, string> GetReplacementMap(Holiday holiday, Employee employee, FileTypeEnum holidayDocumentType)
        {
            var overtimeOrderString   = "";
            var overtimeRequestString = "";
            var increasedSalaryString = "";

            if (holiday.Type == HolidayType.Annual)
            {
                if (holiday.OvertimeDays > 0)
                {
                    var overtimeHours = _overtimeUtility.ConvertOvertimeDaysToHours(holiday.OvertimeDays);
                    overtimeOrderString = _configuration["DocxGeneration:OvertimeOrder"]
                                          .Replace("{OVERTIME_HOURS}", Math.Round(overtimeHours, 2).ToString());
                    overtimeRequestString = _configuration["DocxGeneration:OvertimeRequest"]
                                            .Replace("{OVERTIME_HOURS}", Math.Round(overtimeHours, 2).ToString());
                }

                increasedSalaryString = _configuration["DocxGeneration:IncreasedSalaryRequest"];
            }

            return(new Dictionary <string, string>
            {
                { "{HOLIDAY_PURPOSE}", GetTitleByHolidayType(holiday.Type, holidayDocumentType) },
                { "{POSITION}", employee.Position },
                { "{FULL_NAME}", $"{employee.Name} {employee.Surname}" },
                { "{CREATION_DATE}", holiday.RequestCreatedDate.ToString("yyyy-MM-dd") },
                { "{CURRENT_DATE}", _timeService.GetCurrentTime().ToString("yyyy-MM-dd") },
                { "{HOLIDAY_ID}", holiday.Id.ToString() },
                { "{HOLIDAY_BEGIN}", holiday.FromInclusive.ToString("yyyy-MM-dd") },
                { "{HOLIDAY_END}", holiday.ToInclusive.ToString("yyyy-MM-dd") },
                { "{WORK_DAY_COUNT}", _timeService.GetWorkDays(holiday.FromInclusive, holiday.ToInclusive).ToString() },
                { "{HOLIDAY_TYPE}", TypeToLithuanian(holiday.Type, holidayDocumentType) },
                { "{OVERTIME_ORDER}", overtimeOrderString },
                { "{OVERTIME_REQUEST}", overtimeRequestString },
                { "{INCREASED_SALARY_REQUEST}", increasedSalaryString }
            });
        }
示例#37
0
        public override async Task <AddHolidaysRsp> AddHolidays(AddHolidaysReq request, ServerCallContext context)
        {
            var result = new AddHolidaysRsp();

            try
            {
                var model = new Holiday()
                {
                    HolidayName = request.HolidayName,
                    StartDate   = DateTime.Parse(request.StartDate),
                    EndDate     = DateTime.Parse(request.EndDate),
                };
                await _context.TbHoliday.AddAsync(model);

                result.Id = model.Id;
            }
            catch (Exception e)
            {
                LogHelper.Error(e, "AddHolidays error");
                result.RetCode = -1;
                result.RetDesc = e.Message;
            }
            return(result);
        }
示例#38
0
        public ActionResult EditHoliday([DataSourceRequest] DataSourceRequest request, HolidayModel holiday, string employeId)
        {
            Guid id;

            if (holiday != null && ModelState.IsValid && Guid.TryParse(employeId, out id))
            {
                Holiday h = db.Holidays.First(o => o.Id == holiday.Id);
                h.DateEnd                    = holiday.DateEnd;
                h.DateStart                  = holiday.DateStart;
                h.PeriodEnd                  = holiday.PeriodEnd;
                h.PeriodStart                = holiday.PeriodStart;
                h.DocumentId                 = DictionaryHelper.GetItemsId(holiday.DocumentId);
                h.DocumentValue              = DictionaryHelper.GetItemsName(holiday.DocumentId);
                h.EmployeeId                 = DictionaryHelper.GetItemsId(holiday.EmployeeId);
                h.EmployeeValue              = DictionaryHelper.GetItemsName(holiday.EmployeeId);
                h.HolidayTypeDictionaryId    = DictionaryHelper.GetItemsId(holiday.HolidayTypeDictionaryId);
                h.HolidayTypeDictionaryValue = DictionaryHelper.GetItemsName(holiday.HolidayTypeDictionaryId);
                h.Note  = holiday.Note;
                h.Count = holiday.Count;
                db.SaveChanges();
            }

            return(Json(new[] { holiday }.ToDataSourceResult(request, ModelState)));
        }
示例#39
0
        private static Holiday FindHoliday(DateTime date, bool includeSubstitudeHoliday, bool includeNationalHoliday)
        {
            Holiday result = null;

            var holidayRule = _holidayRules.FirstOrDefault((rule) =>
            {
                if (!includeSubstitudeHoliday && rule.Type == DateRule.DateType.SubstituteHoliday)
                {
                    return(false);
                }
                if (!includeNationalHoliday && rule.Type == DateRule.DateType.NationalHoliday)
                {
                    return(false);
                }
                return(rule.Eval(date));
            });

            if (holidayRule != null)
            {
                result = new Holiday(holidayRule.Name, date);
            }

            return(result);
        }
示例#40
0
 //Holiday edit
 public JsonResult Edit(int id)
 {
     if (id != null)
     {
         if (db.Holidays.Find(id) != null)
         {
             Holiday hol = db.Holidays.Find(id);
             return(Json(new
             {
                 status = 200,
                 data = new
                 {
                     name = hol.Name,
                     startDate = hol.StartDate.Value.ToShortDateString(),
                     endDate = hol.EndDate.Value.ToShortDateString()
                 }
             }, JsonRequestBehavior.AllowGet));
         }
     }
     return(Json(new
     {
         status = 404
     }, JsonRequestBehavior.AllowGet));
 }
示例#41
0
 public void AddHoliday(Holiday holiday)
 {
     holidayList.Add(holiday);
 }
 // Special substitute holiday rule for Seol(lunisolar new year) and Chuseok(15th of 8th lunisolar month)
 // effective since Oct. 29, 2013.
 private void AddSubstituteHoliday(IDictionary<DateTime, Holiday> holidayMap, DateTime[] dates, Holiday holiday)
 {
     foreach (DateTime date in dates)
     {
         Holiday overlappedHoliday = null;
         if (date.DayOfWeek == DayOfWeek.Sunday ||
             holidayMap.TryGetValue(date, out overlappedHoliday) && overlappedHoliday != holiday)
         {
             DateTime substituteDay = dates.Last().AddDays(1);
             while (substituteDay.DayOfWeek == DayOfWeek.Sunday ||
                     holidayMap.TryGetValue(date, out overlappedHoliday) && overlappedHoliday != holiday)
             {
                 substituteDay = substituteDay.AddDays(1);
             }
             holidayMap.Add(substituteDay, holiday);
         }
     }
 }
 private static bool IsTuesdayised(Holiday holiday, DayOfWeek occurenceDay)
 {
     return
         (holiday.Equals(ChristianHolidays.NewYear) && occurenceDay == DayOfWeek.Sunday) ||
         (holiday.Equals(DayAfterNewYear) && occurenceDay == DayOfWeek.Sunday) ||
         (holiday.Equals(ChristianHolidays.Christmas) && occurenceDay == DayOfWeek.Sunday) ||
         (holiday.Equals(GlobalHolidays.BoxingDay) && occurenceDay == DayOfWeek.Sunday);
 }
示例#44
0
 public static ObservableCollection<Holiday> LoadHoliday()
 {
     ObservableCollection<Holiday> list = new ObservableCollection<Holiday>();
     using (FileStream stream = File.OpenRead(DATA_PATH + "DBC/Holidays.dbc"))
     {
         BinaryReader r = new BinaryReader(stream);
         DBCHeader header = DBC.ReadDBCHeader(r);
         int dataSize = header.GetDataSize();
         for (int i = 0; i != header.Records; ++i)
         {
             Holiday holiday = new Holiday();
             holiday.EventID = r.ReadInt32();
             for (int j = 0; j != 10; ++j)
                 holiday.EventStageDuration[j] = r.ReadInt32();
             for (int j = 0; j != 26; ++j)
                 holiday.EventDate[j] = r.ReadInt32();
             holiday.Region = r.ReadInt32();
             holiday.Looping = r.ReadInt32();
             for (int j = 0; j != 10; ++j)
                 holiday.CalendarFlags[j] = r.ReadInt32();
             holiday.EventCalendarName = r.ReadInt32();
             holiday.EventCalendarDescription = r.ReadInt32();
             holiday.EventCalendarOverlay = DBC.ReadString(r, dataSize);
             holiday.Priority = r.ReadInt32();
             holiday.EventSchedulerType = r.ReadInt32();
             holiday.EventFlags = r.ReadInt32();
             list.Add(holiday);
         }
         r.Close();
     }
     return list;
 }
示例#45
0
        /// <summary>
        /// Perform validation and store the changes
        /// </summary>
        private void HolidayPropertiesDlg_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // Ignore on cancel
            if(this.DialogResult == DialogResult.Cancel)
                return;

            txtDescription.Text = txtDescription.Text.Trim();
            epErrors.Clear();

            // We must have a description
            if(txtDescription.Text.Length == 0)
            {
                epErrors.SetError(txtDescription, LR.GetString("EditHAEBlankDesc"));
                e.Cancel = true;
            }

            // Leap years aren't accepted so always use a non-leap year to check the date
            if(rbFixed.Checked && udcDayOfMonth.Value > DateTime.DaysInMonth(2003, (int)cboMonth.SelectedValue))
            {
                epErrors.SetError(udcDayOfMonth, LR.GetString("EditHAEBadDayOfMonth"));
                e.Cancel = true;
            }

            // If all is good, update the holiday object with the new settings
            if(!e.Cancel)
            {
                if(!rbFixed.Checked)
                {
                    FloatingHoliday fl = new FloatingHoliday();
                    holiday = fl;

                    fl.Occurrence = (DayOccurrence)cboOccurrence.SelectedValue;
                    fl.Weekday = (System.DayOfWeek)cboDayOfWeek.SelectedValue;
                    fl.Offset = (int)udcOffset.Value;
                }
                else
                {
                    FixedHoliday fx = new FixedHoliday();
                    holiday = fx;

                    fx.AdjustFixedDate = chkAdjustDate.Checked;
                    fx.Day = (int)udcDayOfMonth.Value;
                }

                holiday.Month = (int)cboMonth.SelectedValue;
                holiday.Description = txtDescription.Text;
            }
        }
示例#46
0
 //List<>
 // Use this for initialization
 void Start()
 {
     holidayInstance = this;
 }
示例#47
0
        /// <summary>
        /// Maps HolidayListItem to Holiday.
        /// </summary>
        /// <param name="holidayList">The holiday list.</param>
        /// <returns>List of Holiday</returns>
        private static IList<Holiday> MapHoliday(IList<HolidayListItem> holidayList)
        {
            IList<Holiday> holidays = new List<Holiday>();
            foreach (var item in holidayList)
            {
                var holiday = new Holiday();
                holiday.CountryID = item.CountryID;
                holiday.Date = item.Date;
                holiday.HolidayID = item.HolidayID;
                holiday.Subject = item.Subject;
                holiday.Remarks = item.Remarks;
                holiday.IsGone = item.Date.Date < DateTime.Now.Date ? true : false;
                holidays.Add(holiday);
            }

            return holidays;
        }
示例#48
0
        /// <summary>
        /// Function to save holiday details.
        /// </summary>
        /// <param name="holiday">holiday information.</param>
        public void InsertOrUpdate(Holiday holiday)
        {
            if (holiday == null)
            {
                throw new ArgumentNullException(HolidayConst);
            }

            this.holidayRepository.InsertOrUpdate(holiday);
            this.unitOfWork.Save();
        }
示例#49
0
        /// <summary>
        /// Processes a Holiday node from the XML configuration file.
        /// </summary>
        /// <param name="n">The Holdiay node to process.</param>
        /// <returns></returns>
        Holiday ProcessNode(XmlNode n)
        {
            Holiday h = new Holiday { HolidayName = n.Attributes["name"].Value };
            ArrayList childNodes = new ArrayList();

            foreach (XmlNode o in n.ChildNodes)
            {
                childNodes.Add(o.Name);
            }

            try
            {
                if (childNodes.Contains("WeekOfMonth"))
                {
                    XmlNode selectSingleNode = n.SelectSingleNode("./Month");
                    if (selectSingleNode != null)
                    {
                        int m = Int32.Parse(selectSingleNode.InnerXml);
                        XmlNode singleNode = n.SelectSingleNode("./WeekOfMonth");
                        if (singleNode != null)
                        {
                            int w = Int32.Parse(singleNode.InnerXml);
                            XmlNode xmlNode = n.SelectSingleNode("./DayOfWeek");
                            if (xmlNode != null)
                            {
                                int wd = Int32.Parse(xmlNode.InnerXml);
                                h.HolidayDate = GetDateByMonthWeekWeekday(m, w, wd, startingDate);
                            }
                        }
                    }
                }
                else if (childNodes.Contains("DayOfWeekOnOrAfter"))
                {
                    XmlNode selectSingleNode = n.SelectSingleNode("./DayOfWeekOnOrAfter/DayOfWeek");
                    if (selectSingleNode != null)
                    {
                        int dow = Int32.Parse(selectSingleNode.InnerXml);

                        if (dow > 6 || dow < 0)
                        {
                            throw new Exception(rm.GetString("holiday_dow"));
                        }

                        XmlNode singleNode = n.SelectSingleNode("./DayOfWeekOnOrAfter/Month");
                        if (singleNode != null)
                        {
                            int m = Int32.Parse(singleNode.InnerXml);
                            XmlNode xmlNode = n.SelectSingleNode("./DayOfWeekOnOrAfter/Day");
                            if (xmlNode != null)
                            {
                                int d = Int32.Parse(xmlNode.InnerXml);
                                h.HolidayDate = GetDateByWeekdayOnOrAfter(dow, m, d, startingDate);
                            }
                        }
                    }
                }
                else if (childNodes.Contains("WeekdayOnOrAfter"))
                {
                    XmlNode selectSingleNode = n.SelectSingleNode("./WeekdayOnOrAfter/Month");
                    if (selectSingleNode != null)
                    {
                        int m = Int32.Parse(selectSingleNode.InnerXml);
                        XmlNode singleNode = n.SelectSingleNode("./WeekdayOnOrAfter/Day");
                        if (singleNode != null)
                        {
                            int d = Int32.Parse(singleNode.InnerXml);
                            DateTime dt = new DateTime(startingDate.Year, m, d);

                            if (dt < startingDate)
                            {
                                dt = dt.AddYears(1);
                            }

                            while (dt.DayOfWeek.Equals(DayOfWeek.Saturday) || dt.DayOfWeek.Equals(DayOfWeek.Sunday))
                            {
                                dt = dt.AddDays(1);
                            }

                            h.HolidayDate = dt;
                        }
                    }
                }
                else if (childNodes.Contains("LastFullWeekOfMonth"))
                {
                    int m = Int32.Parse(n.SelectSingleNode("./LastFullWeekOfMonth/Month").InnerXml);
                    int weekday = Int32.Parse(n.SelectSingleNode("./LastFullWeekOfMonth/DayOfWeek").InnerXml);
                    DateTime dt = GetDateByMonthWeekWeekday(m, 5, weekday, startingDate);

                    if (dt.AddDays(6 - weekday).Month == m)
                    {
                        h.HolidayDate = dt;
                    }
                    else
                    {
                        h.HolidayDate = dt.AddDays(-7);
                    }
                }
                else if (childNodes.Contains("DaysAfterHoliday"))
                {
                    XmlNode basis = xHolidays.SelectSingleNode("/Holidays/Holiday[@name='"
                                                               + n.SelectSingleNode("./DaysAfterHoliday").Attributes["Holiday"].Value +
                                                               "']");
                    Holiday bHoliday = ProcessNode(basis);
                    int days = Int32.Parse(n.SelectSingleNode("./DaysAfterHoliday/Days").InnerXml);

                    // This check was added when this was converted to VB. It does not cause an error in C#, but it
                    // does in Visual Basic. This codes attempts to add negative days to 1/1/0001 which causes the error.
                    if (bHoliday.HolidayDate != new DateTime(1, 1, 1))
                    {
                        h.HolidayDate = bHoliday.HolidayDate.AddDays(days);
                    }
                }
                else if (childNodes.Contains("Easter"))
                {
                    h.HolidayDate = Easter();
                }
                else
                {
                    if (childNodes.Contains("Month") && childNodes.Contains("Day"))
                    {
                        int m = Int32.Parse(n.SelectSingleNode("./Month").InnerXml);
                        int d = Int32.Parse(n.SelectSingleNode("./Day").InnerXml);
                        var dt = new DateTime(startingDate.Year, m, d);

                        if (dt < startingDate)
                        {
                            dt = dt.AddYears(1);
                        }

                        if (childNodes.Contains("EveryXYears"))
                        {
                            int yearMult = Int32.Parse(n.SelectSingleNode("./EveryXYears").InnerXml);
                            int startYear = Int32.Parse(n.SelectSingleNode("./StartYear").InnerXml);

                            if (((dt.Year - startYear) % yearMult) == 0)
                            {
                                h.HolidayDate = dt;
                            }
                        }
                        else
                        {
                            h.HolidayDate = dt;
                        }
                    }
                }
            }
            catch
            {
            }
            return h;
        }
        private void faMonthView_DrawCurrentDay(object sender, FarsiLibrary.Win.Events.CustomDrawDayEventArgs e)
        {
            e.Handled = true;
            DateTime selectedDate = faMonthView.SelectedDateTime;
            DateTime eDate = PersianDateConverter.ToGregorianDateTime(new PersianDate(e.Year, e.Month, e.Day));
            string dayNo = toFarsi.Convert(e.Day.ToString());
            bool isAyyam = false;

            Holiday hd = new Holiday();
            hd.Date = eDate.Date;
            Holiday memHoliday = DataLayer.HasHoliday(hd);

            //see if e is public Holiday : color it and return
            string title;
            if ((title = Methods.ayyam(eDate)) != "")
            {
                isAyyam = true;
                if (test && selectedDate.Date == eDate.Date)
                {
                    lblHolidayTitle.Text = title;
                    //test = false;
                }
            }

            //see if is clicked to add or remove from holidays
            if (test && selectedDate.Date == eDate.Date)
            {
                if (memHoliday != null)
                {
                    Visit[] vis = DataLayer.HasHolidayVisit(memHoliday);
                    if (vis.Count() == 0 || Methods.ShowStandardMsgBox(FormMessageType.Question, "اخطار", "در این روز ویزیت تعریف شده است. آیا مایلید این روز تعطیل شود؟") == DialogResult.Yes)
                    {
                        DataLayer.Remove(memHoliday);
                        memHoliday = null;
                    }
                }
                else
                {
                    DataLayer.Insert(hd);
                    memHoliday = hd;
                }

                test = false;
            }

            //paint the calender depend on its holiday or not
            if (memHoliday != null)
            {
                using (LinearGradientBrush br2 = new LinearGradientBrush(e.Rectangle, Color.Red, Color.RosyBrown, 45, true))
                {
                    e.Graphics.FillRectangle(br2, e.Rectangle);
                    e.Graphics.DrawString(dayNo, font, holidayBrush, e.Rectangle, fmt);
                }
            }
            else if (!isAyyam)
            {
                using (LinearGradientBrush br2 = new LinearGradientBrush(e.Rectangle, Color.White, Color.White, 45, true))
                {
                    e.Graphics.FillRectangle(br2, e.Rectangle);
                    e.Graphics.DrawString(dayNo, font, normalBrush, e.Rectangle, fmt);
                }
            }
            else if (isAyyam)
            {
                using (LinearGradientBrush br2 = new LinearGradientBrush(e.Rectangle, Color.MediumSpringGreen, Color.RosyBrown, 45, true))
                {
                    e.Graphics.FillRectangle(br2, e.Rectangle);
                    e.Graphics.DrawString(dayNo, font, holidayBrush, e.Rectangle, fmt);
                }
            }
        }
 private void BuildTuristicObservanceMap(int year, Holiday holiday, Dictionary<DateTime, Holiday> map)
 {
     var holidayInstance = holiday.GetInstance(year);
     if (!holidayInstance.HasValue) {
         return;
     }
     map.Add(holidayInstance.Value, DayOfRespectForCulturalDiversity);
     //if holiday falls on tuesday, the holiday is also observed on the last monday
     if (holidayInstance.Value.DayOfWeek == DayOfWeek.Tuesday) {
         map.Add(holidayInstance.Value.LastDayOfWeek(DayOfWeek.Monday), holiday);
     }
     //if holiday falls on thursday, the holiday is also observed on the next friday
     if (holidayInstance.Value.DayOfWeek == DayOfWeek.Thursday) {
         map.Add(holidayInstance.Value.NextDayOfWeek(DayOfWeek.Friday), holiday);
     }
 }
 private void BuildNormalObservanceMap(int year, Holiday holiday, Dictionary<DateTime, Holiday> map)
 {
     var holidayInstance = holiday.GetInstance(year);
     if (!holidayInstance.HasValue) {
         return;
     }
     map.Add(holidayInstance.Value, DayOfRespectForCulturalDiversity);
 }
 private void BuildMoveableObservanceMap(int year, Holiday holiday, Dictionary<DateTime, Holiday> map )
 {
     var holidayInstance = holiday.GetInstance(year);
     if (!holidayInstance.HasValue) {
         return;
     }
     switch (holidayInstance.Value.DayOfWeek) {
         case DayOfWeek.Monday:
             map.Add(holidayInstance.Value, DayOfRespectForCulturalDiversity);
             break;
         //if holiday falls on tuesday or wednesday, the holiday is observed on the last monday
         case DayOfWeek.Tuesday:
         case DayOfWeek.Wednesday:
             map.Add(holidayInstance.Value.LastDayOfWeek(DayOfWeek.Monday), holiday);
             break;
         //if holiday falls on thu, fri, sat, sun, the holiday is observed on the next monday
         default:
             map.Add(holidayInstance.Value.NextDayOfWeek(DayOfWeek.Monday), holiday);
             break;
     }
 }
示例#54
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
		public HolidayPropertiesDlg()
		{
			InitializeComponent();

            holiday = null;

            cboMonth.DisplayMember = "Display";
            cboMonth.ValueMember = "Value";
            cboMonth.DataSource = RecurOptsDataSource.MonthsOfYear;

            cboOccurrence.DisplayMember = "Display";
            cboOccurrence.ValueMember = "Value";
            cboOccurrence.DataSource = RecurOptsDataSource.DayOccurrences;

            cboDayOfWeek.DisplayMember = "Display";
            cboDayOfWeek.ValueMember = "Value";
            cboDayOfWeek.DataSource = RecurOptsDataSource.DayOfWeek;
		}
示例#55
0
 /// <summary>
 /// Function to validate holiday.
 /// </summary>
 /// <param name="holiday">Holiday information</param>
 /// <param name="userId">The user identifier.</param>
 /// <returns>
 /// List of errors
 /// </returns>
 public ErrorListItem Validate(Holiday holiday, int userId)
 {
     return this.holidayRepository.Validate(holiday, userId);
 }
示例#56
0
 ///<summary>Checks whether this date is a יום טוב.</summary>
 public bool Is(Holiday holiday)
 {
     return holiday != null && holiday.Date.Is(Date);
 }
示例#57
0
        /// <summary>
        /// Processes a Holiday node from the XML configuration file.
        /// </summary>
        /// <param name="n">The Holdiay node to process.</param>
        /// <returns></returns>
        private Holiday processNode(XmlNode n)
        {
            Holiday h = new Holiday();
            h.Name = n.Attributes["name"].Value.ToString();
            ArrayList childNodes = new ArrayList();
            foreach (XmlNode o in n.ChildNodes)
            {
                childNodes.Add(o.Name.ToString());
            }
            if (childNodes.Contains("WeekOfMonth"))
            {
                int m = Int32.Parse(n.SelectSingleNode("./Month").InnerXml.ToString());
                int w = Int32.Parse(n.SelectSingleNode("./WeekOfMonth").InnerXml.ToString());
                int wd = Int32.Parse(n.SelectSingleNode("./DayOfWeek").InnerXml.ToString());
                h.Date = this.getDateByMonthWeekWeekday(m, w, wd, this.startingDate);
            }
            else if (childNodes.Contains("DayOfWeekOnOrAfter"))
            {
                int dow = Int32.Parse(n.SelectSingleNode("./DayOfWeekOnOrAfter/DayOfWeek").InnerXml.ToString());
                if (dow > 6 || dow < 0)
                    throw new Exception("DOW is greater than 6");
                int m = Int32.Parse(n.SelectSingleNode("./DayOfWeekOnOrAfter/Month").InnerXml.ToString());
                int d = Int32.Parse(n.SelectSingleNode("./DayOfWeekOnOrAfter/Day").InnerXml.ToString());
                h.Date = this.getDateByWeekdayOnOrAfter(dow, m, d, this.startingDate);
            }
            else if (childNodes.Contains("WeekdayOnOrAfter"))
            {
                int m = Int32.Parse(n.SelectSingleNode("./WeekdayOnOrAfter/Month").InnerXml.ToString());
                int d = Int32.Parse(n.SelectSingleNode("./WeekdayOnOrAfter/Day").InnerXml.ToString());
                DateTime dt = new DateTime(this.startingDate.Year, m, d);
                if (dt < this.startingDate)
                    dt = dt.AddYears(1);
                while (dt.DayOfWeek.Equals(DayOfWeek.Saturday) || dt.DayOfWeek.Equals(DayOfWeek.Sunday))
                {
                    dt = dt.AddDays(1);
                }
                h.Date = dt;
            }
            else if (childNodes.Contains("LastFullWeekOfMonth"))
            {
                int m = Int32.Parse(n.SelectSingleNode("./LastFullWeekOfMonth/Month").InnerXml.ToString());
                int weekday = Int32.Parse(n.SelectSingleNode("./LastFullWeekOfMonth/DayOfWeek").InnerXml.ToString());
                DateTime dt = this.getDateByMonthWeekWeekday(m, 5, weekday, this.startingDate);

                if (dt.AddDays(6 - weekday).Month == m)
                    h.Date = dt;
                else
                    h.Date = dt.AddDays(-7);
            }
            else if (childNodes.Contains("DaysAfterHoliday"))
            {
                XmlNode basis = xHolidays.SelectSingleNode("/Holidays/Holiday[@name='" + n.SelectSingleNode("./DaysAfterHoliday").Attributes["Holiday"].Value.ToString() + "']");
                Holiday bHoliday = this.processNode(basis);
                int days = Int32.Parse(n.SelectSingleNode("./DaysAfterHoliday/Days").InnerXml.ToString());
                h.Date = bHoliday.Date.AddDays(days);
            }
            else if (childNodes.Contains("Easter"))
            {
                h.Date = this.easter();
            }
            else
            {
                if (childNodes.Contains("Month") && childNodes.Contains("Day"))
                {
                    int m = Int32.Parse(n.SelectSingleNode("./Month").InnerXml.ToString());
                    int d = Int32.Parse(n.SelectSingleNode("./Day").InnerXml.ToString());
                    DateTime dt = new DateTime(this.startingDate.Year, m, d);
                    if (dt < this.startingDate)
                    {
                        dt = dt.AddYears(1);
                    }
                    if (childNodes.Contains("EveryXYears"))
                    {
                        int yearMult = Int32.Parse(n.SelectSingleNode("./EveryXYears").InnerXml.ToString());
                        int startYear = Int32.Parse(n.SelectSingleNode("./StartYear").InnerXml.ToString());
                        if (((dt.Year - startYear) % yearMult) == 0)
                        {
                            h.Date = dt;
                        }
                    }
                    else
                    {
                        h.Date = dt;
                    }
                }
            }
            return h;
        }
示例#58
0
 public void Remove(Holiday day)
 {
     mDays.Remove(day);
 }
示例#59
0
        //=====================================================================

        /// <summary>
        /// If loaded without setting a holiday object, create a new one
        /// </summary>
        private void HolidayPropertiesDlg_Load(object sender, System.EventArgs e)
        {
            if(holiday == null)
                this.HolidayInfo = new FixedHoliday(1, 1, true, String.Empty);
        }
示例#60
0
 public JsonResult RemoveDate(DateTime selecteddate)
 {
     var holiday = new Holiday() { ExcludedDate = selecteddate };
     _holidayLogic.Delete(holiday);
     return Json("Saved");
 }