コード例 #1
0
        public void Program_GetEmployeeInformation_EmptyListReturnsEmptyEmployee()
        {
            var emptyEmployeeList = new List <Employee>();

            var result = EmployeeLookup.FindEmployeeFromAllEmployees(emptyEmployeeList, "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 List <EmployeeLookup> GetSupervisorsWithPendingReviews()
        {
            List <Employee>       allSups     = GetAllSupervisors();
            List <EmployeeLookup> pendingSups = new List <EmployeeLookup>();

            foreach (Employee sup in allSups)
            {
                if (GetEmployeesBySupWithPendingReviews(sup.Id).Count() > 0)
                {
                    EmployeeLookup e = new EmployeeLookup()
                    {
                        Id   = sup.Id,
                        Name = sup.LastName + ", " + sup.FirstName
                    };
                    pendingSups.Add(e);
                }
            }

            return(pendingSups.OrderBy(x => x.Name).ToList());
        }
コード例 #3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            dgvMatchingEmployees.DataSource = null;
            ResetFields();

            if (txtFilter.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Please enter a search text.");
                return;
            }

            EmployeeService employeeService = new EmployeeService();

            dynamic filter = null;

            if (int.TryParse(txtFilter.Text, out int id))
            {
                if (rdoLn.Checked)
                {
                    MessageBox.Show("Please enter a valid full/partial last name.");
                    return;
                }
                filter = id;
            }
            else
            {
                if (rdoId.Checked)
                {
                    MessageBox.Show("Employee Id must be 8 digits.");
                    return;
                }
                filter = txtFilter.Text;
            }

            List <Employee> employees = rdoId.Checked == true?employeeService.GetEmployeesByFilter((int)filter) : employeeService.GetEmployeesByFilter((string)filter);

            if (employees.Count == 0)
            {
                MessageBox.Show("No matching employees. Please try again.");
            }
            else if (employees.Count == 1)
            {
                dgvMatchingEmployees.DataSource = null;

                EmployeeDTO employeeDTO = employeeService.GetEmployeeInformation(employees[0].EmployeeId);
                PopulateFields(employeeDTO);
                //lstEmployeeInfo.DataSource = employeeInfo;
            }
            else
            {
                List <EmployeeLookup> employeesLookup = new List <EmployeeLookup>();

                foreach (Employee employee in employees)
                {
                    EmployeeLookup employeeLookup = new EmployeeLookup(employee.EmployeeId, $"{employee.FirstName}, {employee.LastName}");

                    employeesLookup.Add(employeeLookup);
                }

                dgvMatchingEmployees.DataSource = employeesLookup;
            }
        }
コード例 #4
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);
        }
コード例 #5
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;
        }