Exemplo n.º 1
0
        private void Send(string toEmailAddress, string body, string subject)
        {
            try
            {
                SmtpClient c = new SmtpClient("smtp.gmail.com", 587);

                MailAddress to   = new MailAddress(toEmailAddress);
                MailAddress from = new MailAddress(RedmineEmailAddress);
                MailMessage msg  = new MailMessage();

                msg.To.Add(to);
                msg.From         = from;
                msg.BodyEncoding = Encoding.UTF8;
                msg.IsBodyHtml   = false;
                msg.Subject      = subject;
                msg.Body         = body;
                c.Credentials    = new System.Net.NetworkCredential(RedmineEmailAddress, password);
                c.EnableSsl      = true;
                c.Send(msg);
                Console.WriteLine("email send to " + toEmailAddress);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in sending email! " + ex);
                SaveError.SaveMessage(ex.ToString());
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            SaveError.CreateLog("error.log");
            Manage manage = new Manage("188.242.201.77", "70b1a875928636d8d3895248309344ea2bca6a5f");

            manage.StartMakeNotification(2);
            //manage.MakeNotificationToTime();

            SaveError.Close();
            Console.WriteLine(DateTime.Now.ToString() + " program stop working!");
            Console.ReadLine();
        }
Exemplo n.º 3
0
        public void GetUserOpenIssue()
        {
            listUserRedmine.Clear();

            try
            {
                NameValueCollection param = new NameValueCollection {
                    { "Id", "*" }
                };
                foreach (var user in redmineManager.GetObjects <User>(param))
                {
                    UserRedmine userRedmine = new UserRedmine();
                    userRedmine.Value = user;
                    listUserRedmine.Add(userRedmine);

                    if (userRedmine.Value.LastName.Equals("Чамин"))
                    {
                        userRedmine.EmailAddress = "*****@*****.**";
                    }
                }

                param = new NameValueCollection {
                    { "status_id", "open" }
                };
                foreach (var issue in redmineManager.GetObjects <Issue>(param))
                {
                    UserRedmine userRedmine = null;

                    if (issue.AssignedTo == null)
                    {
                        userRedmine = listUserRedmine.Find(x => x.Value.Id == issue.Author.Id);
                    }
                    else
                    {
                        userRedmine = listUserRedmine.Find(x => x.Value.Id == issue.AssignedTo.Id);
                    }

                    UserIssue userIssue = new UserIssue();
                    userIssue.issue = issue;

                    userRedmine.ListUserIssue.Add(userIssue);
                }

                this.Sort();
            }
            catch (Exception ex)
            {
                Console.WriteLine(DateTime.Now.ToString() + " Error in GetUserOpenIssue: {0}", ex);
                SaveError.SaveMessage(ex.ToString());
            }
        }
Exemplo n.º 4
0
        public void SetUserIssueNotification()
        {
            float planPercent;

            foreach (var userRedmine in listUserRedmine)
            {
                foreach (var userIssue in userRedmine.ListUserIssue)
                {
                    try
                    {
                        if ((userIssue.issue.DueDate == null) || (IsOutDate(userIssue.issue.DueDate.Value, 1)))
                        {
                            userRedmine.isNeedToSend = true;
                            SetMessage(userIssue, 1);
                        }

                        if (IsOutPercent(userIssue, out planPercent))
                        {
                            userRedmine.isNeedToSend = true;
                            SetMessage(userIssue, 2, planPercent);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(DateTime.Now.ToString() + " Error in " + ex);
                        SaveError.SaveMessage(ex.ToString());
                    }

                    //foreach (var customField in userIssue.issue.CustomFields)
                    //{
                    //    Console.WriteLine("customField = {0}", customField.Values[0].Info);
                    //    if (customField.Values[0].Info != "")
                    //    {
                    //        customField.Values[0].Info = "-";
                    //        redmineManager.UpdateObject(userIssue.issue.Id.ToString(), userIssue.issue);
                    //    }
                    //    Console.WriteLine("id = {0}, name = {1}", userIssue.issue.Id.ToString(), userIssue.issue.Author.Name.ToString());
                    //}
                }
            }
        }
Exemplo n.º 5
0
        public Manage(string host, string key)
        {
            dayTimeStart[0].dayOfWeek = DayOfWeek.Monday;
            dayTimeStart[0].timeStart = "9:00";

            dayTimeStart[1].dayOfWeek = DayOfWeek.Wednesday;
            dayTimeStart[1].timeStart = "9:00";

            dayTimeStart[2].dayOfWeek = DayOfWeek.Friday;
            dayTimeStart[2].timeStart = "9:00";

            noEmailSend = new[] { "Арбузов Владимир Леонидович" };

            try
            {
                email          = new Email();
                redmineManager = new RedmineManager(host, key);
            }
            catch (Exception ex)
            {
                Console.WriteLine(DateTime.Now.ToString() + " Could not connect to redmine host! " + ex);
                SaveError.SaveMessage(ex.ToString());
            }
        }