Ejemplo n.º 1
0
        public void EmailAssignments(EmailHelper email)
        {
            string prevEmailTo = "";
            string emailTo;
            string firstName;
            string wmsPriority;
            string wmsCategory;
            string siteId;
            string folderName;
            string description;
            string wmsComments;
            double wmsEffort;
            long   efolderId;

            using (OleDbCommand cmd = AccessDatalayer.Instance.Connection.CreateCommand())
            {
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "SELECT Person.Email, Person.Firstname, EworkItem.WmsPriority, EworkItem.WmsCategory, " +
                                  "EworkItem.SiteId, EworkItem.FolderName, EworkItem.Description, EworkItem.WmsComments, " +
                                  "EworkItem.WmsEffort, EworkItem.EfolderId " +
                                  "FROM Person INNER JOIN EworkItem ON Person.PersonId = EworkItem.WmsAssignedTo " +
                                  "WHERE (((Person.WmsCore)=True) AND ((EworkItem.EworkStatus)=\"06 WMS Team for Action\")) " +
                                  "ORDER BY Person.Email, EworkItem.WmsPriority, EworkItem.WmsCategory ";
                OleDbDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    emailTo = ""; if (!reader.IsDBNull(0))
                    {
                        emailTo = reader.GetString(0);
                    }
                    firstName = ""; if (!reader.IsDBNull(1))
                    {
                        firstName = reader.GetString(1);
                    }
                    wmsPriority = ""; if (!reader.IsDBNull(2))
                    {
                        wmsPriority = reader.GetString(2);
                    }
                    wmsCategory = ""; if (!reader.IsDBNull(3))
                    {
                        wmsCategory = reader.GetString(3);
                    }
                    siteId = ""; if (!reader.IsDBNull(4))
                    {
                        siteId = reader.GetString(4);
                    }
                    folderName = ""; if (!reader.IsDBNull(5))
                    {
                        folderName = reader.GetString(5);
                    }
                    description = ""; if (!reader.IsDBNull(6))
                    {
                        description = reader.GetString(6);
                    }
                    wmsComments = ""; if (!reader.IsDBNull(7))
                    {
                        wmsComments = reader.GetString(7);
                    }
                    wmsEffort = 0; if (!reader.IsDBNull(8))
                    {
                        wmsEffort = double.Parse(reader.GetValue(8).ToString());
                    }
                    efolderId = 0; if (!reader.IsDBNull(9))
                    {
                        efolderId = long.Parse(reader.GetValue(9).ToString());
                    }

                    if (prevEmailTo != emailTo)
                    {
                        if (prevEmailTo.Length > 0)
                        {
                            email.SendAssignments();
                        }
                        email.PrepareAssignments(emailTo, firstName);
                    }

                    email.AddAssignment(efolderId, folderName, wmsPriority, wmsCategory, siteId, description, wmsComments, wmsEffort);

                    prevEmailTo = emailTo;
                }

                email.SendAssignments();
            }
        }