Beispiel #1
0
        public static void SendEmails(Occasions occasion)
        {
            EmployeeService employeeService = new EmployeeService();
            List <Employee> employees       = employeeService.GetEmployeesByOccassion(occasion);
            EmailSender     emailSender     = new EmailSender();

            emailSender.SendEmail(employees, occasion);
        }
Beispiel #2
0
        private async void SendEmail(Employee e, Occasions occassion)
        {
            try
            {
                MailMessage mailMsg = new MailMessage();
                // To
                mailMsg.To.Add(new MailAddress($"{e.Alias}@microsoft.com"));

                // From
                mailMsg.From = new MailAddress(ConfigurationSettings.AppSettings["FromAddress"], "EAS Fun Team");
                mailMsg.CC.Add(new MailAddress(ConfigurationSettings.AppSettings["CCAddress"]));

                string HTMLcontent;
                if (occassion == Occasions.Birthday)
                {
                    string image = BirthdayImages();
                    HTMLcontent        = "<h3>Hi " + e.Name.Split(' ')[0] + ", <h3><h3> Wish you a very Happy Birthday!! May this day bring special moments to your life and make it much more wonderful.</h3><img src='" + image + "'";
                    mailMsg.Subject    = "Happy Birthday " + e.Name + " !!";
                    mailMsg.IsBodyHtml = true;
                    mailMsg.Body       = HTMLcontent;
                }
                if (occassion == Occasions.Anniversary)
                {
                    string year;
                    string image       = AnniImages();
                    var    PresentYear = DateTime.Now.Year;
                    var    AnniYear    = e.DateOfJoining.Year;
                    var    TotalYears  = PresentYear - AnniYear;
                    if (TotalYears == 1)
                    {
                        year = "year";
                    }
                    else
                    {
                        year = "years";
                    }
                    HTMLcontent        = "<h4> Hi " + e.Name.Split(' ')[0] + ", </h4><h4>Happy Work Anniversary!!! Congratulations on completing " + TotalYears + " " + year + " in Microsoft !!! Wishing you many more successful and happy years ahead. </h4> <img src='" + image + "'";
                    mailMsg.Subject    = "Congratulations " + e.Name + " on completing " + TotalYears + " " + year + " in Microsoft";
                    mailMsg.IsBodyHtml = true;
                    mailMsg.Body       = HTMLcontent;
                }

                // Init SmtpClient and send
                SmtpClient smtpClient = new SmtpClient(Convert.ToString(ConfigurationSettings.AppSettings["SendgridHostName"]), Convert.ToInt32(587));
                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(Convert.ToString(ConfigurationSettings.AppSettings["SendgridUserName"]), Convert.ToString(ConfigurationSettings.AppSettings["SendgridPassWord"]));
                smtpClient.Credentials = credentials;

                smtpClient.Send(mailMsg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #3
0
        private SendGridMessage CreateEmail(Employee e, Occasions occassion)
        {
            var msg = new SendGridMessage();

            msg.SetFrom(new EmailAddress(ConfigurationSettings.AppSettings["FromAddress"], "EAS Fun Team"));

            msg.AddTo($"{e.Alias}@microsoft.com");
            //List<string> EmailsForBCC = new List<string>(_alias);
            //EmailsForBCC.Remove(e.Alias);

            //List<EmailAddress> EmailAddressForBCC = new List<EmailAddress>();
            //foreach (string email in EmailsForBCC)
            //{
            //    EmailAddress emailAddress = new EmailAddress(email);
            //    EmailAddressForBCC.Add(emailAddress);
            //}
            msg.AddCc(ConfigurationSettings.AppSettings["CCAddress"]);
            //if (EmailAddressForBCC.Count != 0)
            //{
            //    msg.AddBccs(EmailAddressForBCC);
            //}

            string HTMLcontent;

            if (occassion == Occasions.Birthday)
            {
                string image = BirthdayImages();
                HTMLcontent = "<h3>Hi " + e.Name.Split(' ')[0] + ", <h3><h3> Wish you a very Happy Birthday!! May this day bring special moments to your life and make it much more wonderful.</h3><img src='" + image + "'";
                msg.SetSubject("Happy Birthday " + e.Name + " !!");
                msg.AddContent(MimeType.Html, HTMLcontent);
            }
            if (occassion == Occasions.Anniversary)
            {
                string year;
                string image       = AnniImages();
                var    PresentYear = DateTime.Now.Year;
                var    AnniYear    = e.DateOfJoining.Year;
                var    TotalYears  = PresentYear - AnniYear;
                if (TotalYears == 1)
                {
                    year = "year";
                }
                else
                {
                    year = "years";
                }
                HTMLcontent = "<h4> Hi " + e.Name.Split(' ')[0] + ", </h4><h4>Happy Work Anniversary!!! Congratulations on completing " + TotalYears + " " + year + " in Microsoft !!! Wishing you many more successful and happy years ahead. </h4> <img src='" + image + "'";
                msg.SetSubject("Congratulations " + e.Name + " on completing " + TotalYears + " " + year + " in Microsoft");
                msg.AddContent(MimeType.Html, HTMLcontent);
            }

            return(msg);
        }
Beispiel #4
0
 public List <Employee> GetEmployeesByOccassion(Occasions occasion)
 {
     if (occasion == Occasions.Birthday)
     {
         var employee = db.Employees.Where(x => x.DateOfBirth.Day == DateTime.Today.Day && x.DateOfBirth.Month == DateTime.Today.Month).ToList();
         return(employee);
     }
     else
     {
         //var employee = db.Employees.ToList();
         var employee = db.Employees.Where(x => x.DateOfJoining.Day == DateTime.Today.Day && x.DateOfJoining.Month == DateTime.Today.Month).ToList();
         return(employee);
     }
 }
Beispiel #5
0
        public async void SendEmail(List <Employee> employees, Occasions occassion)
        {
            try
            {
                if (employees.Count != 0)
                {
                    foreach (Employee e in employees)
                    {
                        // var email = CreateEmail(e, occassion);
                        // await SendEmail(email);
                        SendEmail(e, occassion);
                    }
                }
            }

            catch (Exception ex)
            {
                // logger
            }
        }
Beispiel #6
0
        public override bool IsValid(params ILegalPerson[] persons)
        {
            var defendant = this.Defendant(persons);

            if (defendant == null || Occasions == null)
            {
                return(false);
            }
            var title = defendant.GetLegalPersonTypeName();
            var ipa   = IsPresentAbility(defendant);
            var iaa   = IsApparentAbility(defendant);

            if (!ipa && !iaa)
            {
                AddReasonEntry($"{title} {defendant.Name}, {nameof(IsPresentAbility)} is false");
                AddReasonEntry($"{title} {defendant.Name}, {nameof(IsApparentAbility)} is false");
                return(false);
            }

            var numOccurances = Occasions.Count();

            if (numOccurances <= 1)
            {
                AddReasonEntry($"{title} {defendant.Name}, {nameof(Occasions)} count is {numOccurances}");
                return(false);
            }

            numOccurances = 0;
            foreach (var agitate in Occasions)
            {
                var isAgitateValid = agitate?.IsValid(persons) ?? false;
                if (isAgitateValid)
                {
                    numOccurances += 1;
                }
                AddReasonEntryRange(agitate?.GetReasonEntries());
            }

            return(numOccurances > 1);
        }
Beispiel #7
0
        internal override void Plus(XDocument xdoc)
        {
            foreach (var element in xdoc.Root.Elements())
            {
                var val = element.Value;
                int valI;
                int.TryParse(val, out valI);

                switch (element.Name.LocalName)
                {
                case "id":
                    break;

                case "race_id":
                    if (valI != -1 && World.Races.ContainsKey(valI))
                    {
                        Race = World.Races[valI];
                    }
                    break;

                case "type":
                    if (!Types.Contains(val))
                    {
                        Types.Add(val);
                    }
                    _entityType = (short)Types.IndexOf(val);
                    break;

                case "site_link":
                    var newSl = new EntitySiteLink(element, this);
                    if (SiteLinks == null)
                    {
                        SiteLinks = new Dictionary <int, List <EntitySiteLink> >();
                    }
                    if (!SiteLinks.ContainsKey(newSl.LinkType))
                    {
                        SiteLinks.Add(newSl.LinkType, new List <EntitySiteLink>());
                    }
                    SiteLinks[newSl.LinkType].Add(newSl);
                    break;

                case "entity_link":
                    var newEl = new EntityEntityLink(element, this);
                    if (EntityLinks == null)
                    {
                        EntityLinks = new Dictionary <int, List <EntityEntityLink> >();
                    }
                    if (!EntityLinks.ContainsKey(newEl.LinkType))
                    {
                        EntityLinks.Add(newEl.LinkType, new List <EntityEntityLink>());
                    }
                    EntityLinks[newEl.LinkType].Add(newEl);
                    break;

                case "children":
                    ChildrenIDs = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList();
                    break;

                case "worship_id":
                    WorshipHfid = valI;
                    break;

                case "coords":
                    if (Coords == null)
                    {
                        Coords = new List <Point>();
                    }
                    foreach (var coordSplit in val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(coord => coord.Split(',')).Where(coordSplit => coordSplit.Length == 2))
                    {
                        Coords.Add(new Point(Convert.ToInt32(coordSplit[0]), Convert.ToInt32(coordSplit[1])));
                    }
                    break;

                case "claims":
                    Claims = val.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                             .Select(coord => coord.Split(','))
                             .Where(coordSplit => coordSplit.Length == 2)
                             .Select(split => new Point(Convert.ToInt32(split[0]), Convert.ToInt32(split[1])))
                             .ToList();
                    break;

                case "entity_position":
                    var newPosition = new EntityPosition(element, this);
                    if (Positions == null)
                    {
                        Positions = new List <EntityPosition>();
                    }
                    Positions.Add(newPosition);
                    break;

                case "entity_position_assignment":
                    var newPositionAssignment = new EntityPositionAssignment(element, this);
                    if (PositionAssignments == null)
                    {
                        PositionAssignments = new List <EntityPositionAssignment>();
                    }
                    PositionAssignments.Add(newPositionAssignment);
                    break;

                case "histfig_id":
                    if (MemberHfids == null)
                    {
                        MemberHfids = new List <int>();
                    }
                    MemberHfids.Add(valI);
                    break;

                case "histfig_ids":
                    MemberHfids = val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList();
                    break;

                case "occasion":
                    var newOccasion = new EntityOccasion(element, this);
                    if (Occasions == null)
                    {
                        Occasions = new List <EntityOccasion>();
                    }
                    Occasions.Add(newOccasion);
                    break;

                default:
                    DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName + "\t", element, xdoc.Root.ToString());
                    break;
                }
            }
        }
 private Occasion GetClosestOccasion()
 {
     return(Occasions.OrderBy(x => x.ClosestDate).FirstOrDefault(x => x.ClosestDate >= DateTime.Now.Date));
 }
Beispiel #9
0
 public ActionResult setOccasions(Occasions occasions)
 {
     return(Ok(occasions));
 }