コード例 #1
0
        public void Program_GetEmployeeInformation_EmployeeNotFoundInListReturnsEmptyEmployee()
        {
            var result = EmployeeLookup.FindEmployeeFromAllEmployees(EmployeeList, "Joe");

            Assert.IsInstanceOf(typeof(Employee), result);
            Assert.AreEqual(result.Name, string.Empty);
            Assert.AreEqual(result.EmailAddress, string.Empty);
            Assert.AreEqual(result.EmployeeId, string.Empty);
            Assert.AreEqual(result.Name, string.Empty);
        }
コード例 #2
0
        public void Program_GetEmployeeInformation_EmployeeFoundByUpperCaseEmployeeNameReturnsEmployee(int index)
        {
            var result = EmployeeLookup.FindEmployeeFromAllEmployees(EmployeeList, EmployeeList[index].Name.ToUpper());

            Assert.IsInstanceOf(typeof(Employee), result);
            Assert.AreEqual(result.Name, EmployeeList[index].Name);
            Assert.AreEqual(result.EmailAddress, EmployeeList[index].EmailAddress);
            Assert.AreEqual(result.EmployeeId, EmployeeList[index].EmployeeId);
            Assert.AreEqual(result.Name, EmployeeList[index].Name);
        }
コード例 #3
0
ファイル: QuoteNeeded.cs プロジェクト: jhanisch/JUST-PO
        private static string FormatEmailBody(List <Quote> quotes, DatabaseRepository dbRepository, string defaultMessage)
        {
            string date = DateTime.Now.ToShortDateString();

            var emailBody = string.Format(EmailBodyHeader, RunDate);

            if (quotes.Count == 0)
            {
                emailBody += string.Format(EmailBodyTableWorkOrderLine, defaultMessage, String.Empty);
                emailBody += EmailBodyFooter;
                return(emailBody);
            }

            long row = 1;

            emailBody += EmailBodyTableHr;

            foreach (Quote quote in quotes)
            {
                emailBody += string.Format(EmailBodyTableWorkOrderLine, "Work Order", quote.WorkOrder);
                //, quote.WorkTicket, quote.CustomerName, quote.SiteName, quote.DescriptionOfWork, quote.TicketNote);
//                log.Info("[FormatEmailBody 3] " + emailBody);

                emailBody += string.Format(EmailBodyTableDoubleLineItem, "Work Ticket", quote.WorkTicket, "Site Name", quote.SiteName);
                emailBody += string.Format(EmailBodyTableDoubleLineItem, "Manaufactuer/Model", quote.Manufacturer + " / " + quote.Model, "Serial Number", quote.SerialNumber);
                emailBody += (quote.ServiceTech.Length > 0) ? string.Format(EmailBodyTableSingleLineItem, "Service Person", EmployeeLookup.FindEmployeeFromAllEmployees(dbRepository.GetEmployees(), quote.ServiceTech).Name) : string.Empty;
                emailBody += (quote.DescriptionOfWork.Length > 0) ? string.Format(EmailBodyTableSingleLineItem, "Original Description", quote.DescriptionOfWork) : string.Empty;
                emailBody += (quote.TicketNote.Length > 0) ? string.Format(EmailBodyTableSingleLineItem, "Ticket Note", quote.TicketNote) : string.Empty;

                emailBody += EmailBodyTableHr;
                row++;
            }

            emailBody += EmailBodyFooter;
//            log.Info(emailBody);

            return(emailBody);
        }
コード例 #4
0
        private static void ProcessPOData()
        {
            try
            {
                OdbcConnection cn;
                var            notifiedlist = new ArrayList();

                // user_1 = receiving rack location
                // user_2 = Receiver
                // user_3 = Received Date
                // user_4 = Bin Cleared Date
                // user_5 = Notified
                //                POQuery = "Select icpo.buyer, icpo.ponum, icpo.user_1, icpo.user_2, icpo.user_3, icpo.user_4, icpo.user_5, icpo.defaultjobnum, vendor.name as vendorName, icpo.user_6, icpo.defaultworkorder, icpo.attachid from icpo inner join vendor on vendor.vennum = icpo.vennum where icpo.user_3 is not null and icpo.user_5 = 0 order by icpo.ponum asc";

                OdbcConnectionStringBuilder just = new OdbcConnectionStringBuilder
                {
                    Driver = "ComputerEase"
                };
                just.Add("Dsn", "Company 0");
                just.Add("Uid", config.Uid);
                just.Add("Pwd", config.Pwd);

                cn = new OdbcConnection(just.ConnectionString);
                cn.Open();
                log.Info("[ProcessPOData] Connection to database opened successfully");
                var dbRepository = new DatabaseRepository(cn, log, config.POAttachmentBasePath);

                List <PurchaseOrder> purchaseOrdersToNotify;
                try
                {
                    purchaseOrdersToNotify = dbRepository.GetPurchaseOrdersToNotify();
                    log.Info("purchaseOrdersToNotify found " + purchaseOrdersToNotify.Count.ToString() + " items.");

                    foreach (PurchaseOrder po in purchaseOrdersToNotify)
                    {
                        var job                    = dbRepository.GetEmailBodyInformation(po.JobNumber, po.PurchaseOrderNumber, po.WorkOrderNumber);
                        var buyerEmployee          = EmployeeLookup.FindEmployeeFromAllEmployees(dbRepository.GetEmployees(), po.Buyer);
                        var projectManagerEmployee = job.ProjectManagerName.Length > 0 ? EmployeeLookup.FindEmployeeFromAllEmployees(dbRepository.GetEmployees(), job.ProjectManagerName) : new Employee();

                        log.Info("[ProcessPOData] ----------------- Found PO Number " + po.PurchaseOrderNumber + " -------------------");

                        var emailSubject = String.Format(EmailSubject, po.PurchaseOrderNumber, po.Vendor);
                        var emailBody    = FormatEmailBody(po.ReceivedOnDate, po.PurchaseOrderNumber, po.ReceivedBy, po.Bin, buyerEmployee.Name, po.Vendor, job, po.Notes);

                        ArrayList primaryRecipients = new ArrayList();
                        ArrayList bccList           = new ArrayList();
                        if ((config.Mode == live) || (config.Mode == monitor))
                        {
                            primaryRecipients.Add(buyerEmployee.EmailAddress);
                            if (projectManagerEmployee.EmailAddress.Length > 0 && buyerEmployee.EmailAddress != projectManagerEmployee.EmailAddress)
                            {
                                primaryRecipients.Add(projectManagerEmployee.EmailAddress);
                            }
                        }

                        if (((config.Mode == monitor) || (config.Mode == debug)) &&
                            (config.MonitorEmailAddresses != null && config.MonitorEmailAddresses.Count > 0))
                        {
                            foreach (string monitorEmailAddress in config.MonitorEmailAddresses)
                            {
                                bccList.Add(monitorEmailAddress);
                            }
                        }

                        if ((primaryRecipients.Count == 0) && (bccList.Count > 0))
                        {
                            primaryRecipients.Add(bccList[0]);
                        }

                        if (sendEmail(primaryRecipients, bccList, emailSubject, emailBody, po.Attachments))
                        {
                            notifiedlist.Add(po.PurchaseOrderNumber);
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.Info(ex.Message);
                }

                foreach (string poNum in notifiedlist)
                {
                    try
                    {
                        dbRepository.MarkPOAsNotified(poNum);
                    }
                    catch (Exception x)
                    {
                        log.Error(String.Format("[ProcessPOData] Error updating PO {0} to be Notified: {1}", poNum, x.Message));
                    }
                }

                cn.Close();
            }
            catch (Exception x)
            {
                log.Error("[ProcessPOData] Exception: " + x.Message);
                return;
            }

            return;
        }