Ejemplo n.º 1
0
        private void SendWishBirthdays(EmployeeProfiles listOfEmpProfilesNeededToBeSentEmailForBirthdays)
        {
            int yearsDiffBirthday = 0;

            foreach (var item in listOfEmpProfilesNeededToBeSentEmailForBirthdays.listOfEmployeeProfiles)
            {
                yearsDiffBirthday = DateTime.Now.Year - item.DateOfBirthday.Year;

                // conditions for birthday
                if (item.birthdayWishSentForCurrentYear == false && item.DateOfBirthday.AddYears(yearsDiffBirthday).Date == DateTime.Now.Date.AddDays(1).Date)
                {
                    SendTomorrowBirthdaysReminderToManager(item);
                }
                if (item.birthdayWishSentForCurrentYear == false && item.DateOfBirthday.AddYears(yearsDiffBirthday).Date == DateTime.Now.Date)
                {
                    SendBirthDayWishForToday(item);
                    item.birthdayWishSentForCurrentYear = true;
                }
                if (item.birthdayWishSentForCurrentYear == false && item.DateOfBirthday.AddYears(yearsDiffBirthday).Date < DateTime.Now.Date)
                {
                    SendBirthdayWishBelated(item);
                    item.birthdayWishSentForCurrentYear = true;
                }
                if (item.birthdayWishSentForCurrentYear == false && item.DateOfBirthday.AddYears(yearsDiffBirthday).Date > DateTime.Now.Date && (item.DateOfBirthday.AddYears(yearsDiffBirthday).DayOfWeek == DayOfWeek.Saturday || item.DateOfBirthday.AddYears(yearsDiffBirthday).DayOfWeek == DayOfWeek.Sunday))
                {
                    SendBirthdayWishInAdvance(item);
                    item.birthdayWishSentForCurrentYear = true;
                }
            }

            UpdateDbAfterWishSent(listOfEmpProfilesNeededToBeSentEmailForBirthdays);
        }
Ejemplo n.º 2
0
        private void SendWishServiceDeliveries(EmployeeProfiles listOfEmpProfilesNeededToBeSentEmailForServiceDeliveries)
        {
            int yearsDiffJoining = 0;

            foreach (var item in listOfEmpProfilesNeededToBeSentEmailForServiceDeliveries.listOfEmployeeProfiles)
            {
                yearsDiffJoining = DateTime.Now.Year - item.DateOfJoining.Year;

                // conditions for service delivery anniversary

                if (item.serviceAnniversaryWishSentForCurrentYear == false && item.DateOfJoining.AddYears(yearsDiffJoining).Date == DateTime.Now.Date.AddDays(1).Date)
                {
                    SendTomorrowServiceDeliveryReminderToManager(item);
                }
                if (item.serviceAnniversaryWishSentForCurrentYear == false && item.DateOfJoining.AddYears(yearsDiffJoining).Date == DateTime.Now.Date)
                {
                    SendServiceAnniversaryWishForToday(item);
                    item.serviceAnniversaryWishSentForCurrentYear = true;
                }
                if (item.serviceAnniversaryWishSentForCurrentYear == false && item.DateOfJoining.AddYears(yearsDiffJoining).Date < DateTime.Now.Date)
                {
                    SendServiceAnniversaryWishBelated(item);
                    item.serviceAnniversaryWishSentForCurrentYear = true;
                }
                if (item.serviceAnniversaryWishSentForCurrentYear == false && item.DateOfJoining.AddYears(yearsDiffJoining).Date > DateTime.Now.Date && (item.DateOfJoining.AddYears(yearsDiffJoining).DayOfWeek == DayOfWeek.Saturday || item.DateOfJoining.AddYears(yearsDiffJoining).DayOfWeek == DayOfWeek.Sunday))
                {
                    SendServiceAnniversaryWishInAdvance(item);
                    item.serviceAnniversaryWishSentForCurrentYear = true;
                }
            }

            UpdateDbAfterWishSent(listOfEmpProfilesNeededToBeSentEmailForServiceDeliveries);
        }
Ejemplo n.º 3
0
        private void SendMonthlyReminderForServiceDeliveries(EmployeeProfiles shortlistedEmpsHavingServiceDeliveriesThisMonth)
        {
            string str = string.Empty;

            str  = "<HTML><head><style>table, th, td {border: 1px solid black;}</style></head>";
            str += "<table><tr><th>ALIAS</th><th>NAME</th><th>SERVICE ANNIVERSARY</th></tr>";
            foreach (var item in shortlistedEmpsHavingServiceDeliveriesThisMonth.listOfEmployeeProfiles)
            {
                str += "<tr><td>" +
                       item.Alias +
                       "</td><td>" +
                       item.EmpName +
                       "</td><td>" +
                       item.DateOfJoining.ToString("dd-MMMM-yyyy") +
                       "</td></tr>";
            }

            str += "</body></html>";

            Outlook.MailItem mailItem = (Outlook.MailItem)
                                        this.Application.CreateItem(Outlook.OlItemType.olMailItem);

            mailItem.Subject = "MONTHLY SERVICE DELIVERY REMINDER!!!";
            mailItem.To      = Application.Session.CurrentUser.
                               AddressEntry.GetExchangeUser().PrimarySmtpAddress;
            mailItem.HTMLBody = str;

            mailItem.Importance = Outlook.OlImportance.olImportanceHigh;
            mailItem.Send();
        }
Ejemplo n.º 4
0
        private void UpdateDbAfterWishSent(EmployeeProfiles empPros)
        {
            int index = -1;

            foreach (var item in empPros.listOfEmployeeProfiles)
            {
                index = empProfiles.listOfEmployeeProfiles.FindIndex(m => m.Alias == item.Alias);
                if (index >= 0 && index < empProfiles.listOfEmployeeProfiles.Count)
                {
                    empProfiles.listOfEmployeeProfiles[index].birthdayWishSentForCurrentYear           = item.birthdayWishSentForCurrentYear;
                    empProfiles.listOfEmployeeProfiles[index].serviceAnniversaryWishSentForCurrentYear = item.serviceAnniversaryWishSentForCurrentYear;
                }
            }

            if (File.Exists(serializedFileName))
            {
                string jsonString = JsonConvert.SerializeObject(empProfiles, Formatting.Indented);
                File.WriteAllText(serializedFileName, jsonString);
            }
        }
Ejemplo n.º 5
0
        private EmployeeProfiles GetEmployeeProfiles()
        {
            string           existingJsonString;
            EmployeeProfiles empProfiles = new EmployeeProfiles();

            empProfiles.listOfEmployeeProfiles = new List <EmployeeProfile>();

            if (!File.Exists(serializedFileName))
            {
                FileStream fs = File.Create(serializedFileName);
                fs.Close();
            }
            else
            {
                existingJsonString = File.ReadAllText(serializedFileName);
                if (!existingJsonString.Equals(""))
                {
                    empProfiles = JsonConvert.DeserializeObject <EmployeeProfiles>(existingJsonString);
                }
            }
            return(empProfiles);
        }
Ejemplo n.º 6
0
        private void TraverseToProcess()
        {
            if (lastDataTraversalDate != null && lastDataTraversalDate.Equals(DateTime.Now.Date))
            {
                return;
            }

            empProfiles = GetEmployeeProfiles();
            if (empProfiles.listOfEmployeeProfiles.Count == 0)
            {
                return;
            }

            var listOfEmpProfilesNeededToBeSentEmailForBirthdays = (EmployeeProfiles)GetEmpProfilesNeededToBeSentEmailForBirthdays(empProfiles, out EmployeeProfiles shortlistedEmpsHavingBdaysThisMonth);

            if (listOfEmpProfilesNeededToBeSentEmailForBirthdays.listOfEmployeeProfiles.Count != 0)
            {
                SendWishBirthdays(listOfEmpProfilesNeededToBeSentEmailForBirthdays);
            }
            if (shortlistedEmpsHavingBdaysThisMonth.listOfEmployeeProfiles.Count != 0)
            {
                SendMonthlyReminderForBdays(shortlistedEmpsHavingBdaysThisMonth);
            }

            var listOfEmpProfilesNeededToBeSentEmailForServiceDeliveries = (EmployeeProfiles)GetEmpProfilesNeededToBeSentEmailForServiceDeliveries(empProfiles, out EmployeeProfiles shortlistedEmpsHavingServiceDeliveriesThisMonth);

            if (listOfEmpProfilesNeededToBeSentEmailForServiceDeliveries.listOfEmployeeProfiles.Count != 0)
            {
                SendWishServiceDeliveries(listOfEmpProfilesNeededToBeSentEmailForServiceDeliveries);
            }
            if (shortlistedEmpsHavingServiceDeliveriesThisMonth.listOfEmployeeProfiles.Count != 0)
            {
                SendMonthlyReminderForServiceDeliveries(shortlistedEmpsHavingServiceDeliveriesThisMonth);
            }

            lastDataTraversalDate = DateTime.Now.Date;
        }
Ejemplo n.º 7
0
        private object GetEmpProfilesNeededToBeSentEmailForServiceDeliveries(EmployeeProfiles empProfiles, out EmployeeProfiles shortlistedEmpsHavingServiceDeliveriesThisMonth)
        {
            EmployeeProfiles shortlistedEmpProfilesForServiceDeliveries = new EmployeeProfiles();

            shortlistedEmpProfilesForServiceDeliveries.listOfEmployeeProfiles = new List <EmployeeProfile>();

            shortlistedEmpsHavingServiceDeliveriesThisMonth = new EmployeeProfiles();
            shortlistedEmpsHavingServiceDeliveriesThisMonth.listOfEmployeeProfiles = new List <EmployeeProfile>();

            int yearDiffJoining = 0;

            foreach (var item in empProfiles.listOfEmployeeProfiles)
            {
                yearDiffJoining = DateTime.Now.Year - item.DateOfJoining.Year;


                // conditions for wish to be sent on same day
                bool c2 = item.DateOfJoining.Date.Day == DateTime.Now.Date.Day && item.DateOfJoining.Date.Month == DateTime.Now.Date.Month;


                // conditions for advance wish
                bool c4 = (item.DateOfJoining.Date.Day == DateTime.Now.Date.AddDays(1).Day&& item.DateOfJoining.Date.Month == DateTime.Now.Date.AddDays(1).Month) && (DateTime.Now.Date.AddDays(1).DayOfWeek == DayOfWeek.Saturday);

                bool c6 = (item.DateOfJoining.Date.Day == DateTime.Now.Date.AddDays(2).Day&& item.DateOfJoining.Date.Month == DateTime.Now.Date.AddDays(2).Month) && (DateTime.Now.Date.AddDays(2).DayOfWeek == DayOfWeek.Sunday);


                // conditions for missed wish
                // Added the year difference b/w actual date of occasion and current date

                bool c8 = (item.DateOfJoining.Date.AddYears(yearDiffJoining) >= DateTime.Now.Date.AddDays(-7)) && (item.DateOfJoining.Date.AddYears(yearDiffJoining) < DateTime.Now.Date);


                // conditions to check status flag
                bool c10 = item.serviceAnniversaryWishSentForCurrentYear == false;


                // conditions for service deliveries tomorrow
                bool c12 = (item.DateOfJoining.Date.Day == DateTime.Now.Date.AddDays(1).Day&& item.DateOfJoining.Date.Month == DateTime.Now.Date.AddDays(1).Month);

                /*
                 * Below is the pseudo code for the below condition
                 *
                 * if
                 * (
                 *  (
                 *      2. doj matches current date
                 *      OR
                 *      4. current day +1 is doj AND doj day is saturday
                 *      OR
                 *      6. current day +2 is doj AND doj day is sunday
                 *      OR
                 *      8. doj is lesser or equals to current day - 7
                 *      OR
                 *      12. current day +1 is doj
                 *  )
                 *  AND
                 *  (
                 *      10. status of doj is false
                 *  )
                 * )*/



                if ((c2 || c4 || c6 || c8 || c12) && (c10))
                {
                    shortlistedEmpProfilesForServiceDeliveries.listOfEmployeeProfiles.Add(item);
                }

                if (DateTime.Now.Day == 1 && item.serviceAnniversaryWishSentForCurrentYear == false && item.DateOfJoining.Month == DateTime.Now.Month)
                {
                    shortlistedEmpsHavingServiceDeliveriesThisMonth.listOfEmployeeProfiles.Add(item);
                }
            }

            return(shortlistedEmpProfilesForServiceDeliveries);
        }
Ejemplo n.º 8
0
        private object GetEmpProfilesNeededToBeSentEmailForBirthdays(EmployeeProfiles empProfiles, out EmployeeProfiles shortlistedEmpsHavingBdaysThisMonth)
        {
            EmployeeProfiles shortlistedEmpProfilesForBirthdays = new EmployeeProfiles();

            shortlistedEmpProfilesForBirthdays.listOfEmployeeProfiles = new List <EmployeeProfile>();

            shortlistedEmpsHavingBdaysThisMonth = new EmployeeProfiles();
            shortlistedEmpsHavingBdaysThisMonth.listOfEmployeeProfiles = new List <EmployeeProfile>();

            int yearDiffBirthday = 0;


            foreach (var item in empProfiles.listOfEmployeeProfiles)
            {
                yearDiffBirthday = DateTime.Now.Year - item.DateOfBirthday.Year;


                // conditions for wish to be sent on same day
                bool c1 = item.DateOfBirthday.Date.Day == DateTime.Now.Date.Day && item.DateOfBirthday.Date.Month == DateTime.Now.Date.Month;


                // conditions for advance wish
                bool c3 = (item.DateOfBirthday.Date.Day == DateTime.Now.Date.AddDays(1).Day&& item.DateOfBirthday.Date.Month == DateTime.Now.Date.AddDays(1).Month) && (DateTime.Now.Date.AddDays(1).DayOfWeek == DayOfWeek.Saturday);

                bool c5 = (item.DateOfBirthday.Date.Day == DateTime.Now.Date.AddDays(2).Day&& item.DateOfBirthday.Date.Month == DateTime.Now.Date.AddDays(2).Month) && (DateTime.Now.Date.AddDays(2).DayOfWeek == DayOfWeek.Sunday);


                // conditions for missed wish
                // Added the year difference b/w actual date of occasion and current date
                bool c7 = (item.DateOfBirthday.Date.AddYears(yearDiffBirthday) >= DateTime.Now.Date.AddDays(-7)) && (item.DateOfBirthday.Date.AddYears(yearDiffBirthday) < DateTime.Now.Date);


                // conditions to check status flag
                bool c9 = item.birthdayWishSentForCurrentYear == false;


                // conditions for birthdays tomorrow
                bool c11 = (item.DateOfBirthday.Date.Day == DateTime.Now.Date.AddDays(1).Day&& item.DateOfBirthday.Date.Month == DateTime.Now.Date.AddDays(1).Month);

                /*
                 * Below is the pseudo code for the below condition
                 *
                 * if
                 * (
                 *  (
                 *      1. dob matches current date
                 *      OR
                 *      3. current day +1 is dob AND dob day is saturday
                 *      OR
                 *      5. current day +2 is dob AND dob day is sunday
                 *      OR
                 *      7. dob is lesser or equals to current day - 7
                 *      OR
                 *      11. curent day +1 is dob
                 *  )
                 *  AND
                 *  (
                 *      9. status of dob is false
                 *  )
                 * )*/



                if ((c1 || c3 || c5 || c7 || c11) && (c9))
                {
                    shortlistedEmpProfilesForBirthdays.listOfEmployeeProfiles.Add(item);
                }

                if (DateTime.Now.Day == 1 && item.birthdayWishSentForCurrentYear == false && item.DateOfBirthday.Month == DateTime.Now.Month)
                {
                    shortlistedEmpsHavingBdaysThisMonth.listOfEmployeeProfiles.Add(item);
                }
            }

            return(shortlistedEmpProfilesForBirthdays);
        }