public SearchServiceImpl(ConstituentRepository constituentRepository, EmailRepository emailRepository, PhoneRepository phoneRepository, OccupationRepository occupationRepository, EducationDetailRepository educationDetailRepository, AddressRepository addressRepository) { this.constituentRepository = constituentRepository; this.addressRepository = addressRepository; this.educationDetailRepository = educationDetailRepository; this.occupationRepository = occupationRepository; this.phoneRepository = phoneRepository; this.emailRepository = emailRepository; }
public void Setup() { StructureMapBootStrapper.ConfigureDependencies("test"); _uow = ObjectFactory.GetInstance<IUnitOfWork>(); _trackingStatusRepository = new TrackingStatusRepository(_uow); _emailRepo = new EmailRepository(_uow); _trackingStatus = new TrackingStatus<EmailDO>(_trackingStatusRepository, _emailRepo); _fixture = new FixtureData(_uow); }
static void Main(string[] args) { try { EmailValidator emailValidator = new EmailValidator(); EmailRepository emailRepository = new EmailRepository(emailValidator, "emails.xml"); UserValidator userValidator = new UserValidator(); UserRepository userRepository = new UserRepository(userValidator,"users.xml"); //userRepository.save(new User("admin","admin")); //userRepository.save(new User("narcis", "narcis")); Service service = new Service(emailRepository, userRepository); ConsoleUi console = new ConsoleUi(service); console.run(); } catch (Exception e) { Console.WriteLine("something went wrong {0}",e.Message); Console.ReadKey(); } }
internal HttpResponseMessage Emails(HttpRequestMessage request, EmailDTO cqDTO) { string key; var aur = new AppUserRepository(); var companyId = 0; var userId = aur.ValidateUser(cqDTO.Key, out key, ref companyId); if (userId > 0) { var ur = new EmailRepository(); var u = new Email(); var predicate = ur.GetPredicate(cqDTO, u, companyId); var data = ur.GetByPredicate(predicate); var col = new Collection <Dictionary <string, string> >(); data = data.OrderBy(x => x.EmailAddress).ToList(); foreach (var item in data) { var dic = new Dictionary <string, string>(); dic.Add("EmailID", item.EmailID.ToString()); dic.Add("EmailAddress", item.EmailAddress); dic.Add("ReceiveDailyReport", item.ReceiveDailyReport.ToString()); col.Add(dic); var ufdic = new Dictionary <string, string>(); } var ur2 = new EmailListRepository(); var u2 = new EmailList(); var predicate2 = ur2.GetPredicate(cqDTO, u2, companyId); var data2 = ur2.GetByPredicate(predicate); var col2 = new Collection <Dictionary <string, string> >(); data2 = data2.OrderBy(x => x.EmailListName).ToList(); foreach (var item in data2) { var dic = new Dictionary <string, string>(); dic.Add("EmailListId", item.EmailListId.ToString()); dic.Add("EmailListName", item.EmailListName); col2.Add(dic); var ufdic = new Dictionary <string, string>(); } //var ur3 = new ListEmailRepository(); //var u3 = new ListEmail(); //var predicate3 = ur3.GetPredicate(cqDTO, u3, companyId); //var data3 = ur3.GetByPredicate(predicate); //var col3 = new Collection<Dictionary<string, string>>(); //data3 = data3.ToList(); //foreach (var item in data3) //{ // var dic = new Dictionary<string, string>(); // dic.Add("ListId", item.ListId.ToString()); // dic.Add("EmailId", item.EmailId.ToString()); // col3.Add(dic); // var ufdic = new Dictionary<string, string>(); //} var retValList = new List <GenericDTO>(); var retVal = new GenericDTO { Key = key, ReturnData = col }; retValList.Add(retVal); var retVal2 = new GenericDTO { Key = key, ReturnData = col2 }; retValList.Add(retVal2); //var retVal3 = new GenericDTO //{ // Key = key, // ReturnData = col3 //}; //retValList.Add(retVal3); return(Request.CreateResponse(HttpStatusCode.OK, retValList)); } var message = "validation failed"; return(request.CreateResponse(HttpStatusCode.NotFound, message)); }
public EmailController() { emailListRepository = new EmailRepository(); }
public EmailOrderService(OrderRepository orderRepo, EmailRepository emailRepository) : base(orderRepo) { _emailRepository = emailRepository; }
public void EmailRepository_Test_EmailInstance() { EmailRepository repo = new EmailRepository(); Couchbase.CouchbaseClient instance = CouchbaseManager.EmailInstance; Assert.IsInstanceOfType(instance, typeof(Couchbase.CouchbaseClient)); }
public OrderService() { _orderRepository = new OrderRepository(); _emailRepository = new EmailRepository(); }
public void createemail(Email_serviceViewModel emails)//, HttpPostedFileBase fileUploader) { PatientBusiness dbl = new PatientBusiness(); using (var emailrepo = new EmailRepository()) { List <MailAddress> l = new List <MailAddress>(); MailMessage mail = new MailMessage(); if (emails.To == null) { foreach (Patient f in dbl.GetPatients())//for each friend { //get the email address and convert to MailAddress l.Add(new MailAddress(f.Email));//add to the list of receivers } to = l; foreach (MailAddress ma in to) //get each MailAddress in the list { mail.To.Add(ma); //use to set the to list Email_services _email = new Email_services { emailID = emails.emailID, To = ma.ToString(), Cc = emails.Cc, Bcc = emails.Bcc, Subject = emails.Subject, StaffName = emails.StaffName, Body = emails.Body }; emailrepo.Create(_email); } //mail.To.Add(l); } else { string[] ToMuliId = emails.To.Split(','); foreach (string ToEMailId in ToMuliId) { mail.To.Add(new MailAddress(ToEMailId)); //adding multiple TO Email Id } } /*mail.To.Add(emails.To);*/ mail.From = new MailAddress("*****@*****.**"); if (!string.IsNullOrEmpty(emails.Cc)) { string[] CCId = emails.Cc.Split(','); foreach (string CCEmail in CCId) { mail.CC.Add(new MailAddress(CCEmail)); //Adding Multiple CC email Id } } if (!string.IsNullOrEmpty(emails.Bcc)) { string[] bccid = emails.Bcc.Split(','); foreach (string bccEmailId in bccid) { mail.Bcc.Add(new MailAddress(bccEmailId)); //Adding Multiple BCC email Id } } #region /* if (emails.Cc == null) * { * mail.CC.Add("*****@*****.**"); * } * else * { * string[] CCId = emails.Cc.Split(','); * foreach (string CCEmail in CCId) * { * * mail.CC.Add(new MailAddress(CCEmail)); //Adding Multiple CC email Id * } * }*/ /* if (emails.Bcc == null) * { * mail.Bcc.Add("*****@*****.**"); * } * else * { * string[] bccid = emails.Bcc.Split(','); * foreach (string bccEmailId in bccid) * { * * mail.Bcc.Add(new MailAddress(bccEmailId)); //Adding Multiple BCC email Id * } * * } */ #endregion #region //else //{ // mail.CC.Add(emails.Cc); //} //if (emails.Bcc == null) //{ // mail.Bcc.Add("*****@*****.**"); //} //else //{ // mail.Bcc.Add(emails.Bcc); //} #endregion if (!string.IsNullOrEmpty(emails.Subject)) { mail.Subject = emails.Subject; } /* if (emails.Subject == null) * { * mail.Subject = "No subject"; * } * else * { * mail.Subject = emails.Subject; * } */ string Body = emails.Body; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); #region configurations is in the web.config /* smtp.Host = "localhost";//"smtp.live.com"; * //smtp.Host = "smtp.live.com"; * * smtp.Port = 25; //587; * // smtp.Port=587; */ #endregion smtp.Host = "smtp.sendgrid.net"; smtp.Port = 2525; smtp.UseDefaultCredentials = false; smtp.EnableSsl = true; smtp.Credentials = new System.Net.NetworkCredential("bigiayomide", "123adenike");// enter seders user name and password smtp.Send(mail); if (emails.emailID == 0) { Email_services _email = new Email_services { emailID = emails.emailID, To = emails.To, Cc = emails.Cc, Bcc = emails.Bcc, Subject = emails.Subject, StaffName = emails.StaffName, Body = emails.Body }; emailrepo.Create(_email); } } }
private HttpResponseMessage ProcessNewEmailRecord(HttpRequestMessage request, EmailDTO uDto, string key, int EmailId, int userId) { var ur = new EmailRepository(); var user = new Email(); var validationErrors = GetValidationErrors(ur, user, uDto, EmailId, userId); if (validationErrors.Any()) { return ProcessValidationErrors(request, validationErrors, key); } user = ur.Save(user); uDto.Key = key; uDto.EmailID = user.EmailID.ToString(); var response = request.CreateResponse(HttpStatusCode.Created, uDto); response.Headers.Location = new Uri(Url.Link("Default", new { id = user.EmailID })); return response; }
public async Task Create_EmailIsNull_ThrowsArgumentNullException() { var sut = new EmailRepository(_requestFactory); await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Create(null)); }
private List<DbValidationError> GetValidationErrors(EmailRepository pr, Email contact, EmailDTO cqDto, int YieldID, int userId) { contact.ProcessRecord(cqDto); return pr.Validate(contact); }
private HttpResponseMessage ProcessExistingEmailRecord(HttpRequestMessage request, EmailDTO cqDto, int contactId, string key, int EmailId, int userId) { var ur = new EmailRepository(); var user = new Email(); user = ur.GetById(contactId); var validationErrors = GetValidationErrors(ur, user, cqDto, EmailId, userId); if (validationErrors.Any()) { return ProcessValidationErrors(request, validationErrors, key); } ur.Save(user); cqDto.Key = key; return request.CreateResponse(HttpStatusCode.Accepted, cqDto); }
internal HttpResponseMessage Emails(HttpRequestMessage request, EmailDTO cqDTO) { string key; var aur = new AppUserRepository(); var companyId = 0; var userId = aur.ValidateUser(cqDTO.Key, out key, ref companyId); if (userId > 0) { var ur = new EmailRepository(); var u = new Email(); var predicate = ur.GetPredicate(cqDTO, u, companyId); var data = ur.GetByPredicate(predicate); var col = new Collection<Dictionary<string, string>>(); data = data.OrderBy(x => x.EmailAddress).ToList(); foreach (var item in data) { var dic = new Dictionary<string, string>(); dic.Add("EmailID", item.EmailID.ToString()); dic.Add("EmailAddress", item.EmailAddress); dic.Add("ReceiveDailyReport", item.ReceiveDailyReport.ToString()); col.Add(dic); var ufdic = new Dictionary<string, string>(); } var retVal = new GenericDTO { Key = key, ReturnData = col }; return Request.CreateResponse(HttpStatusCode.OK, retVal); } var message = "validation failed"; return request.CreateResponse(HttpStatusCode.NotFound, message); }
public EmailsController(EmailRepository repo) { _repo = repo; }
public EmailService() { _emailRepository = new EmailRepository(); _mailboxRepository = new MailboxRepository(); }
private void InitRepo() { CloseRepo(); context = new ApplicationContext(ConfigHelper.GetConnectionString()); repo = new EmailRepository(context); }
public ActionResult SendEmailWithAttachment(string mailTo, string mailTo2, int contactid, int type) { var email = string.Empty; if (!mailTo.IsStringNullOrEmpty()) { email += mailTo; } if (!mailTo2.IsStringNullOrEmpty()) { email += ";" + mailTo2; } var model = new MailModel { To = email, TypeEmail = type, ContactId = contactid }; var info = EmailRepository.GetEmailTemplate(type); model.Subject = info.Subject; model.Body = info.Content; var user = UserContext.GetCurrentUser(); if (user != null && !user.SignEmailSend.IsStringNullOrEmpty()) { model.Body += "<br />" + user.SignEmailSend; } if (type == 4) { string chuoi = ""; chuoi = "<input type=\"checkbox\" name=\"anh_041\" value=\"\" checked=\"true\" disabled=\"disabled\">huongdantestphongvan04.png"; chuoi += "</br>"; chuoi += "<input type=\"checkbox\" name=\"docx_042\" value=\"\" checked=\"true\" disabled=\"disabled\">CASEC_Huongdandanhchothisinh04.docx"; ViewBag.html4 = chuoi; } else { ViewBag.html4 = ""; } if (type == 7) { string chuoi = ""; chuoi = "<input type=\"checkbox\" name=\"anh_071\" value=\"\" checked=\"true\" disabled=\"disabled\">huongdantestphongvan07.png"; chuoi += "</br>"; chuoi += "<input type=\"checkbox\" name=\"docx_072\" value=\"\" checked=\"true\" disabled=\"disabled\">Huongdansudungbaithilythuyet.doc"; ViewBag.html7 = chuoi; } else { ViewBag.html7 = ""; } if (type == 6) { string sb; sb = "<input type=\"checkbox\" name=\"\" value=\"\" checked=\"true\" disabled=\"disabled\">File lộ trình học tập SB100"; ViewBag.html6 = sb; } else { ViewBag.html6 = ""; } return(View(model)); }
public HttpResponseMessage EmailDailyReport() { //Update Shift Weights List<ShiftWeight> shiftResults = new List<ShiftWeight>(); //SGApp.DTOs.GenericDTO dto = new GenericDTO(); SGApp.DTOs.GenericDTO dto = new GenericDTO(); var dic = Request.GetQueryNameValuePairs().ToDictionary(x => x.Key, x => x.Value, StringComparer.OrdinalIgnoreCase); var sDate = DateTime.ParseExact(dic.First().Value, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).Date; var eDate = DateTime.ParseExact(dic.Last().Value, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture).Date; dto.StartDate = sDate; dto.EndDate = eDate; //dto.StartDate = DateTime.Now.AddDays(-1).Date; //dto.EndDate = DateTime.Now.Date; //dto.StartDate = DateTime.Now.AddDays(1).Date; //dto.EndDate = DateTime.Now.AddDays(2).Date; var client = new HttpClient { //BaseAddress = new Uri("http://323-booth-svr2:3030/") //BaseAddress = new Uri("http://64.139.95.243:7846/") BaseAddress = new Uri("http://64.139.95.243:7846/") //BaseAddress = new Uri(baseAddress) }; try { var response = client.PostAsJsonAsync("api/Remote/GetDailyProductionTotal", dto).Result; response.EnsureSuccessStatusCode(); JavaScriptSerializer json_serializer = new JavaScriptSerializer(); //Sampling[] samplingResultsArray = json_serializer.Deserialize<Sampling[]>(response.Content.ReadAsStringAsync().Result); // new List<Sampling>(); //Sampling[] samplingResultsArray = response.Content.ReadAsAsync<Sampling[]>().Result; //samplingResults = samplingResultsArray.ToList(); //JavaScriptSerializer json_serializer = new JavaScriptSerializer(); //Object[] samplingResultsArray = json_serializer.Deserialize<Sampling[]>(Constants.testdata); //string teststuff = "[{\"station\":10,\"nominal\":34038.25,\"weight\":35469.6},{\"station\":12,\"nominal\":7950.0,\"weight\":8062.02},{\"station\":13,\"nominal\":3165.0,\"weight\":3213.56},{\"station\":14,\"nominal\":3920.0,\"weight\":3990.14},{\"station\":15,\"nominal\":8342.0,\"weight\":8987.8},{\"station\":16,\"nominal\":10580.0,\"weight\":10862.35}]"; //ShiftWeight[] samplingResultsArray = json_serializer.Deserialize<ShiftWeight[]>(Constants.testprod); ShiftWeight[] samplingResultsArray = json_serializer.Deserialize<ShiftWeight[]>(response.Content.ReadAsStringAsync().Result); shiftResults = samplingResultsArray.ToList(); //shiftResults = shiftResults.GroupBy(x => x.farmPond).Select(group => group.First()).ToList(); //var result = response.Content.ReadAsStringAsync().Result; //return Request.CreateResponse(HttpStatusCode.OK, result); } catch (Exception e) { throw new HttpException("Error occurred: " + e.Message); } List<string> iqfstations = new List<string>(); iqfstations.Add("9"); iqfstations.Add("10"); var IQFweight = shiftResults.Where(x => iqfstations.Contains(x.Station)).Sum(x => decimal.Parse(x.Nominal)).ToString(); var BaggerWeightRecord = shiftResults.Where(x => x.Station == "7").FirstOrDefault(); var BaggerWeight = BaggerWeightRecord != null ? BaggerWeightRecord.Nominal : "0"; List<string> stations = new List<string>(); stations.Add("8"); stations.Add("2"); stations.Add("4"); stations.Add("3"); var FreshWeight = shiftResults.Where(x => stations.Contains(x.Station)).Sum(x => decimal.Parse(x.Nominal)).ToString(); var reportdate = DateTime.Now; //reportdate = DateTime.Parse(DateTime.Now.AddDays(-1).ToShortDateString()); reportdate = dto.StartDate; //dto.StartDate = DateTime.Now.AddDays(-1).Date; //reportdate = DateTime.Parse(DateTime.Now.AddDays(11).ToShortDateString()); var ptr = new ProductionTotalRepository(); var dtr = new DepartmentTotalRepository(); var wbr = new WeighBackRepository(); var ar = new AbsenceRepository(); var dr = new DownTimeRepository(); var fsrr = new FilletScaleReadingRepository(); var iqfw = dtr.GetByDateAndDepartment(reportdate, 5); if (iqfw != null && IQFweight != null) { iqfw.ShiftWeight = decimal.Parse(IQFweight); dtr.Save(iqfw); } else { iqfw = new DepartmentTotal(); if (IQFweight != null) { iqfw.ShiftWeight = decimal.Parse(IQFweight); } iqfw.DepartmentID = 5; iqfw.DTDate = reportdate; dtr.Save(iqfw); } var freshw = dtr.GetByDateAndDepartment(reportdate, 4); if (freshw != null && FreshWeight != null) { freshw.ShiftWeight = decimal.Parse(FreshWeight); dtr.Save(freshw); } else { freshw = new DepartmentTotal(); freshw.DepartmentID = 4; freshw.DTDate = reportdate; if (FreshWeight != null) { freshw.ShiftWeight = decimal.Parse(FreshWeight); } dtr.Save(freshw); } var bagw = dtr.GetByDateAndDepartment(reportdate, 6); if (bagw != null && BaggerWeight != null) { bagw.ShiftWeight = decimal.Parse(BaggerWeight); dtr.Save(bagw); } else { bagw = new DepartmentTotal(); bagw.DepartmentID = 6; bagw.DTDate = reportdate; if (BaggerWeight != null) { bagw.ShiftWeight = decimal.Parse(BaggerWeight); } dtr.Save(bagw); } List<Sampling> samplingResults = new List<Sampling>(); try { var response = client.PostAsJsonAsync("api/Remote/GetKeithsData", dto).Result; response.EnsureSuccessStatusCode(); JavaScriptSerializer json_serializer = new JavaScriptSerializer(); //Sampling[] samplingResultsArray = json_serializer.Deserialize<Sampling[]>(response.Content.ReadAsStringAsync().Result); // new List<Sampling>(); //Sampling[] samplingResultsArray = response.Content.ReadAsAsync<Sampling[]>().Result; //samplingResults = samplingResultsArray.ToList(); //JavaScriptSerializer json_serializer = new JavaScriptSerializer(); //Sampling[] samplingResultsArray = json_serializer.Deserialize<Sampling[]>(Constants.testdata); Sampling[] samplingResultsArray = json_serializer.Deserialize<Sampling[]>(response.Content.ReadAsStringAsync().Result); samplingResults = samplingResultsArray.ToList(); var samplingResultsData = samplingResults.GroupBy(x => new { x.farm, x.pond, x.farmPond, x.rangeName }) .Select(group => new { Key = group.Key, Weight = group.Sum(s => decimal.Parse(s.weight)), Count = group.Count() }).ToList(); //var result = response.Content.ReadAsStringAsync().Result; //return Request.CreateResponse(HttpStatusCode.OK, result); List<Sampling> samplingReport = new List<Sampling>(samplingResultsData.Capacity); foreach (var rec in samplingResultsData) { Sampling fee2 = new Sampling(); fee2.farm = rec.Key.farm; fee2.pond = rec.Key.pond; fee2.farmPond = rec.Key.farmPond; fee2.rangeName = rec.Key.rangeName; fee2.weight = rec.Weight.ToString(); fee2.count = rec.Count.ToString(); samplingReport.Add(fee2); } samplingResults = samplingReport; } catch (Exception e) { throw new HttpException("Error occurred: " + e.Message); } var pts = ptr.GetByDate(reportdate); var dts = dtr.GetByDate(reportdate); var wbs = wbr.GetByDate(reportdate); var abs = ar.GetByDate(reportdate); var dsl = dr.GetByDate(reportdate); var fsrs = fsrr.GetByDate(reportdate); decimal headedweighttotal = 0; decimal plweight = 0; decimal wbweight = 0; decimal avgyield = 100; foreach (ProductionTotal pt in pts) { if (pt.PlantWeight != null) {plweight = pt.PlantWeight.Value;} if (pt.WeighBacks != null) {wbweight = pt.WeighBacks.Value;} if (pt.AverageYield != null) {avgyield = pt.AverageYield.Value;} headedweighttotal += (plweight - wbweight) * avgyield / 100; plweight = 0; wbweight = 0; avgyield = 100; } decimal notzero = pts.Sum(x => x.PlantWeight).Value - pts.Sum(x => x.WeighBacks).Value; decimal avgTotal = 1; if (notzero == 0) { avgTotal = 0; } else { avgTotal = headedweighttotal * 100 / (pts.Sum(x => x.PlantWeight).Value - pts.Sum(x => x.WeighBacks).Value); } //decimal avgTotal = headedweighttotal * 100 / (pts.Sum(x => x.PlantWeight).Value - pts.Sum(x => x.WeighBacks).Value); string filletscale = fsrs == null ? "0" : fsrs.FilletScaleReading1.ToString(); string subject = ""; string body = ""; body += "<style>table, td, th {border: 1px solid #ddd; text-align: left;}table {border-collapse: collapse; width: 100%;} th, td {padding: 5px;} tr:nth-child(2) {background-color: #f8f8f8;} th {background-color: #ddd;}</style>"; subject = "Harvest Select Daily Production Report"; body += "Report Date: " + reportdate.ToShortDateString() + "<br /><br />"; body += "Fillet Scale Reading: " + filletscale + "<br /><br />"; body += "<b>Live Fish Receiving</b><br />"; body += "<table style='border: 1px solid #ddd; text-align:left; border-collapse: collapse; width: 100%;'><tr><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'></th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Pond Weight</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Plant Weight</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Difference</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>WeighBacks</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Net Live Weight</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Yield %</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Headed Yield</th></tr>"; body += "<tr style='background-color: #A1D490; font-weight: bold;'><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>TOTAL</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + pts.Sum(x => x.PondWeight).Value.ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + pts.Sum(x => x.PlantWeight).Value.ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + (pts.Sum(x => x.PondWeight).Value - pts.Sum(x => x.PlantWeight).Value).ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + pts.Sum(x => x.WeighBacks).Value.ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + (pts.Sum(x => x.PlantWeight).Value - pts.Sum(x => x.WeighBacks).Value).ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + avgTotal.ToString("#.####") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + headedweighttotal.ToString("#") + "</td></tr>"; foreach (ProductionTotal pt in pts) { decimal plantweight = pt.PlantWeight.HasValue ? pt.PlantWeight.Value : 0; decimal pondweight = pt.PondWeight.HasValue ? pt.PondWeight.Value : 0; decimal weighbacks = pt.WeighBacks.HasValue ? pt.WeighBacks.Value : 0; decimal averageyield = pt.AverageYield.HasValue ? pt.AverageYield.Value : 0; body += "<tr><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + pt.Pond.Farm.InnovaName + " - " + pt.Pond.PondName + "</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + pondweight.ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + plantweight.ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + (pondweight - plantweight).ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + weighbacks.ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + (plantweight - weighbacks).ToString("#") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + averageyield.ToString("#.####") + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + ((plantweight - weighbacks) * averageyield / 100).ToString("#") + "</td></tr>"; } body += "</table><br /><br />"; body += "<b>Samplings</b><br />"; body += "<table style='border: 1px solid #ddd; text-align:left; border-collapse: collapse; width: 100%;'><tr>"; body += "<th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Farm</th>"; body += "<th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Pond</th>"; body += "<th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Fish Size</th>"; body += "<th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Count</th>"; body += "<th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>% of Count</th>"; body += "<th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Weight (lbs)</th>"; body += "<th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>% of Weight</th>"; body += "<th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Avg Weight (lbs)</th>"; body += "</tr>"; List<Sampling> sresultsRanges = new List<Sampling>(); List<Sampling> sresultsPonds = new List<Sampling>(); List<Sampling> sresultsFarms = new List<Sampling>(); sresultsRanges = samplingResults.GroupBy(x => x.rangeName).Select(group => group.First()).ToList(); sresultsFarms = samplingResults.GroupBy(x => x.farm).Select(group => group.First()).ToList(); sresultsPonds = samplingResults.GroupBy(x => x.pond).Select(group => group.First()).ToList(); var totalScount = samplingResults.Sum(x => decimal.Parse(x.count)); var totalSweight = samplingResults.Sum(x => decimal.Parse(x.weight)); var totalSaverage = totalScount == 0 ? 0 : (totalSweight / totalScount); body += "<tr style='background-color: #A1D490;'>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>All Farms</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", totalScount) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", totalSweight) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", totalSaverage) + "</td>"; body += "</tr>"; foreach (Sampling sam3 in sresultsRanges) { body += "<tr>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + sam3.rangeName + "</td>"; var thispondScount = samplingResults.Where(x => x.rangeName == sam3.rangeName).Sum(x => decimal.Parse(x.count)); var thispondScountpercent = totalScount == 0 ? 0 : (thispondScount / totalScount) * 100; var thispondSweight = samplingResults.Where(x => x.rangeName == sam3.rangeName).Sum(x => decimal.Parse(x.weight)); var thispondSweightpercent = totalSweight == 0 ? 0 : (thispondSweight / totalSweight) * 100; var thisSaverage = thispondScount == 0 ? 0 : thispondSweight / thispondScount; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", thispondScount) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}%", thispondScountpercent) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", thispondSweight) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}%", thispondSweightpercent) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", thisSaverage) + "</td>"; body += "</tr>"; } foreach (Sampling sam in sresultsFarms) { var totalfarmcount = samplingResults.Where(x => x.farm == sam.farm).Sum(x => decimal.Parse(x.count)); var totalfarmweight = samplingResults.Where(x => x.farm == sam.farm).Sum(x => decimal.Parse(x.weight)); var totalfarmaverage = totalfarmcount == 0 ? 0 : (totalfarmweight / totalfarmcount); body += "<tr style='background-color: #A1D490;'>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + sam.farm + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>Farm Total</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", totalfarmcount) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", totalfarmweight) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", totalfarmaverage) + "</td>"; body += "</tr>"; foreach (Sampling sam1 in sresultsPonds.Where(x => x.farm == sam.farm)) { bool pNameLabel = true; var totalpondcount = samplingResults.Where(x => x.pond == sam1.pond && x.farm == sam.farm).Sum(x => decimal.Parse(x.count)); var totalpondweight = samplingResults.Where(x => x.pond == sam1.pond && x.farm == sam.farm).Sum(x => decimal.Parse(x.weight)); var totalaverage = totalpondcount == 0 ? 0 : (totalpondweight / totalpondcount); body += "<tr style='background-color: #CED490;'>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + sam1.pond + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>Pond Total</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", totalpondcount) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", totalpondweight) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", totalaverage) + "</td>"; body += "</tr>"; foreach (Sampling sam2 in sresultsRanges) { body += "<tr>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + sam2.rangeName + "</td>"; var thispondcount = samplingResults.Where(x => x.pond == sam1.pond && x.rangeName == sam2.rangeName && x.farm == sam.farm).Sum(x => decimal.Parse(x.count)); var thispondcountpercent = totalpondcount == 0 ? 0 : (thispondcount / totalpondcount) * 100; var thispondweight = samplingResults.Where(x => x.pond == sam1.pond && x.rangeName == sam2.rangeName && x.farm == sam.farm).Sum(x => decimal.Parse(x.weight)); var thispondweightpercent = totalpondweight == 0 ? 0 : (thispondweight / totalpondweight) * 100; var thisaverage = thispondcount == 0 ? 0 : thispondweight / thispondcount; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", thispondcount) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}%", thispondcountpercent) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", thispondweight) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}%", thispondweightpercent) + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + string.Format("{0:N2}", thisaverage) + "</td>"; body += "</tr>"; } } } //body += "<tr style='background-color: #A1D490; font-weight: bold;'><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'></td>"; //foreach (Sampling sam in sresultsRanges) //{ // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>Weight</td>"; // body += "<td style='border: 1px solid #ddd; border-right: 2px solid #222; text-align:left; padding: 5px;'>Count</td>"; //} //body += "</tr>"; //body += "<tr style='background-color: #A1D490; font-weight: bold;'><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>TOTAL (Weight | Count)</td>"; //foreach (Sampling sam in sresultsRanges) //{ // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + samplingResults.Where(x => x.rangeName == sam.rangeName).Sum(x => decimal.Parse(x.weight)).ToString() + "</td>"; // body += "<td style='border: 1px solid #ddd; border-right: 2px solid #222; text-align:left; padding: 5px;'>" + samplingResults.Where(x => x.rangeName == sam.rangeName).Sum(x => decimal.Parse(x.count)).ToString() + "</td>"; //} //body += "</tr>"; //foreach (Sampling sam1 in sresultsPonds) //{ // body += "<tr><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + sam1.farmPond + "</td>"; // foreach (Sampling sam in sresultsRanges) // { // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + samplingResults.Where(x => x.rangeName == sam.rangeName && x.farmPond == sam1.farmPond).Select(x => x.weight).FirstOrDefault() + "</td>"; // body += "<td style='border: 1px solid #ddd; border-right: 2px solid #222; text-align:left; padding: 5px;'>" + samplingResults.Where(x => x.rangeName == sam.rangeName && x.farmPond == sam1.farmPond).Select(x => x.count).FirstOrDefault() + "</td>"; // } // body += "</tr>"; //} body += "</table><br /><br />"; body += "<b>Production By Department</b><br />"; body += "<table style='border: 1px solid #ddd; text-align:left; border-collapse: collapse; width: 100%;'><tr><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'></th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Absences</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Finish Time</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Production Total</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Downtime</th></tr>"; body += "<tr style='background-color: #A1D490; font-weight: bold;'><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>TOTAL</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + dts.Sum(x => x.Absences).Value.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>---</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + dts.Sum(x => x.ShiftWeight).Value.ToString() + " lbs</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + dts.Sum(x => x.DownTime).Value.ToString() + "</td></tr>"; foreach (DepartmentTotal dt in dts) { string finishtime = dt.FinishTime.HasValue ? dt.FinishTime.Value.ToShortTimeString() : "---"; string shiftweight = dt.ShiftWeight.HasValue ? dt.ShiftWeight.Value.ToString() : "---"; if (dt.DepartmentID == 3) { shiftweight = filletscale; } string downtime = dt.DownTime.HasValue ? dt.DownTime.Value.ToString() : "---"; string absences = dt.Absences.HasValue ? dt.Absences.Value.ToString() : "---"; body += "<tr><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + dt.Department.DepartmentName + "</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + absences + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + finishtime + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + shiftweight + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + downtime + "</td></tr>"; } body += "</table><br /><br />"; //body += "<b>WeighBack Details</b><br />"; //body += "<table style='border: 1px solid #ddd; text-align:left; border-collapse: collapse; width: 100%;'><tr><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'></th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Turtle/Trash</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Shad/Carp/Bream</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Live Disease</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Dressed Disease</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>~~Backs</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Red Fillet</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Big Fish</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>DOAs</th></tr>"; //body += "<tr style='background-color: #A1D490; font-weight: bold;'><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>TOTAL</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Sum(x => x.Turtle).Value.ToString() + "</td>"; //body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Sum(x => x.Shad).Value.ToString() + "</td>"; //body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Sum(x => x.LiveDisease).Value.ToString() + "</td>"; //body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Sum(x => x.DressedDisease).Value.ToString() + "</td>"; //body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Sum(x => x.Backs).Value.ToString() + "</td>"; //body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Sum(x => x.RedFillet).Value.ToString() + "</td>"; //body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Sum(x => x.BigFish).Value.ToString() + "</td>"; //body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Sum(x => x.DOAs).Value.ToString() + "</td></tr>"; //List<int> ponds = new List<int>(); //foreach (WeighBack wb in wbs) //{ // if (!ponds.Contains(wb.PondID)){ // body += "<tr><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wb.Pond.Farm.FarmName + " - " + wb.Pond.PondName + "</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Where(x => x.PondID == wb.PondID).Sum(x => x.Turtle).Value.ToString() + "</td>"; // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Where(x => x.PondID == wb.PondID).Sum(x => x.Shad).Value.ToString() + "</td>"; // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Where(x => x.PondID == wb.PondID).Sum(x => x.LiveDisease).Value.ToString() + "</td>"; // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Where(x => x.PondID == wb.PondID).Sum(x => x.DressedDisease).Value.ToString() + "</td>"; // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Where(x => x.PondID == wb.PondID).Sum(x => x.Backs).Value.ToString() + "</td>"; // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Where(x => x.PondID == wb.PondID).Sum(x => x.RedFillet).Value.ToString() + "</td>"; // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Where(x => x.PondID == wb.PondID).Sum(x => x.BigFish).Value.ToString() + "</td>"; // body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + wbs.Where(x => x.PondID == wb.PondID).Sum(x => x.DOAs).Value.ToString() + "</td></tr>"; // } // ponds.Add(wb.PondID); //} //body += "</table><br /><br />"; body += "<b>Employee Absence Details</b><br />"; body += "<table style='border: 1px solid #ddd; text-align:left; border-collapse: collapse; width: 100%;'><tr><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'></th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Reg Out</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Reg Late</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Reg Left Early</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Temp Out</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Temp Late</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Temp Left Early</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Inmate Out</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Inmate Left Early</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Vacation</th></tr>"; body += "<tr style='background-color: #A1D490; font-weight: bold;'><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>TOTAL</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + abs.Sum(x => x.RegEmpOut).Value.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + abs.Sum(x => x.RegEmpLate).Value.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + abs.Sum(x => x.RegEmpLeftEarly).Value.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + abs.Sum(x => x.TempEmpOut).Value.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + abs.Sum(x => x.TempEmpLate).Value.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + abs.Sum(x => x.TempEmpLeftEarly).Value.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + abs.Sum(x => x.InmateOut).Value.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + abs.Sum(x => x.InmateLeftEarly).Value.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + abs.Sum(x => x.EmployeesOnVacation).Value.ToString() + "</td></tr>"; foreach (Absence ab in abs) { string RegEmpOut = ab.RegEmpOut.HasValue ? ab.RegEmpOut.Value.ToString() : "---"; string RegEmpLate = ab.RegEmpLate.HasValue ? ab.RegEmpLate.Value.ToString() : "---"; string RegEmpLeftEarly = ab.RegEmpLeftEarly.HasValue ? ab.RegEmpLeftEarly.Value.ToString() : "---"; string TempEmpOut = ab.TempEmpOut.HasValue ? ab.TempEmpOut.Value.ToString() : "---"; string TempEmpLate = ab.TempEmpLate.HasValue ? ab.TempEmpLate.Value.ToString() : "---"; string TempEmpLeftEarly = ab.TempEmpLeftEarly.HasValue ? ab.TempEmpLeftEarly.Value.ToString() : "---"; string InmateOut = ab.InmateOut.HasValue ? ab.InmateOut.Value.ToString() : "---"; string InmateLeftEarly = ab.InmateLeftEarly.HasValue ? ab.InmateLeftEarly.Value.ToString() : "---"; string EmployeesOnVacation = ab.EmployeesOnVacation.HasValue ? ab.EmployeesOnVacation.Value.ToString() : "---"; body += "<tr><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + ab.Department.DepartmentName + "</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + RegEmpOut + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + RegEmpLate + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + RegEmpLeftEarly + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + TempEmpOut + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + TempEmpLate + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + TempEmpLeftEarly + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + InmateOut + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + InmateLeftEarly + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + EmployeesOnVacation + "</td></tr>"; } body += "</table><br /><br />"; body += "<b>Downtime Details</b><br />"; body += "<table style='border: 1px solid #ddd; text-align:left; border-collapse: collapse; width: 100%;'><tr><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'></th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Type</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Minutes</th><th style='border: 1px solid #ddd; text-align:left; padding: 5px; background-color: #ddd;'>Note</th></tr>"; body += "<tr style='background-color: #A1D490; font-weight: bold;'><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>TOTAL</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>---</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + dsl.Sum(x => x.Minutes).ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>---</td></tr>"; foreach (DownTime dt in dsl) { string DownTimeNote = dt.DownTimeNote != null ? dt.DownTimeNote : "---"; body += "<tr><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + dt.DownTimeType.Department.DepartmentName + "</td><td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + dt.DownTimeType.DownTimeName + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + dt.Minutes.ToString() + "</td>"; body += "<td style='border: 1px solid #ddd; text-align:left; padding: 5px;'>" + dt.DownTimeNote + "</td></tr>"; } body += "</table><br /><br />"; body += "</table>"; //, [email protected] string elist = ""; EmailRepository er = new EmailRepository(); List<Email> emails = er.GetEmails(); foreach (Email em in emails) { elist += em.EmailAddress + ", "; } elist = elist.Substring(0, elist.Length - 2); //SendMail("[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]", subject, body); SendMail(elist, subject, body); return Request.CreateResponse(HttpStatusCode.OK); }
public OrderService(OrderRepository orderRepository, EmailRepository emailRepository) { _orderRepository = orderRepository; _emailRepository = emailRepository; }
public override T CreateProcessor() { switch (typeof(T).Name) { case "IAuthRepository": IAuthRepository _processor = new AuthRepository(config); return((T)_processor); case "IJobPostRepository": IJobPostRepository _jobPostprocessor = new JobPostRepository(config); return((T)_jobPostprocessor); case "IHomeRepositories": IHomeRepositories _homeRepositories = new HomeRepositories(config); return((T)_homeRepositories); case "ISearchJobRepository": ISearchJobRepository _searchJobRepository = new SearchJobRepository(config); return((T)_searchJobRepository); case "IUserProfileRepository": IUserProfileRepository _userProfileRepository = new UserProfileRepository(config); return((T)_userProfileRepository); case "ISearchResumeRepository": ISearchResumeRepository _searchResumeRepository = new SearchResumeRepository(config); return((T)_searchResumeRepository); case "IManageUserRepository": IManageUserRepository _manageUserRepository = new ManageUsersRepository(config); return((T)_manageUserRepository); case "IEmpProfileRepository": IEmpProfileRepository _empProfileRepository = new EmpProfileRepository(config); return((T)_empProfileRepository); case "IJobIndustryAreaRepository": IJobIndustryAreaRepository _jobIndustryAreaRepository = new JobIndustryAreaRepositroy(config); return((T)_jobIndustryAreaRepository); case "IJobTitleRepositroy": IJobTitleRepositroy _jobTitleRepositroy = new JobTitleRepository(config); return((T)_jobTitleRepositroy); case "IDesignationRepository": IDesignationRepository _designationRepository = new DesignationRepository(config); return((T)_designationRepository); case "IResumeBuilderRepository": IResumeBuilderRepository rBuilderRepository = new ResumeBuilderRepository(config); return((T)rBuilderRepository); case "IMasterDataRepository": IMasterDataRepository masterDataRepository = new MasterDataRepository(config); return((T)masterDataRepository); case "ISuccessStoryVideoRepository": ISuccessStoryVideoRepository successStoryVideoRepository = new SuccessStoryVideoRepository(config); return((T)successStoryVideoRepository); case "IBulkJobPostRepository": IBulkJobPostRepository bulkJobRepository = new BulkJobPostRepository(config); return((T)bulkJobRepository); case "IEmailRepository": IEmailRepository _emailRepository = new EmailRepository(config); return((T)_emailRepository); case "IUsersReviewsRepository": IUsersReviewsRepository usersReviewsRepository = new UsersReviewsRepository(config); return((T)usersReviewsRepository); case "IManageJobsRepository": IManageJobsRepository manageJobsRepository = new ManageJobsRepository(config); return((T)manageJobsRepository); case "IDashboardRepository": switch (typeof(T).FullName) { case "JobPortal.Data.Interfaces.Employer.IDashboardRepository": Data.Interfaces.Employer.IDashboardRepository employerDashboard = new Data.Repositories.Employer.DashboardRepository(config); return((T)employerDashboard); case "JobPortal.Data.Interfaces.TrainingPartner.IDashboardRepository": Data.Interfaces.TrainingPartner.IDashboardRepository tpDashboard = new Data.Repositories.TrainingPartner.DashboardRepository(config); return((T)tpDashboard); case "JobPortal.Data.Interfaces.Admin.IDashboardRepository": Data.Interfaces.Admin.IDashboardRepository adminDashboard = new Data.Repositories.Admin.DashboardRepository(config); return((T)adminDashboard); default: throw new Exception("Can not create object"); } case "ITrainingPartnerProfileRepository": ITrainingPartnerProfileRepository trainingPartnerProfileRepository = new TrainingPartnerProfileRepository(config); return((T)trainingPartnerProfileRepository); case "IManageCityStateRepository": IManageCityStateRepository manageCityStateRepository = new ManageCityStateRepository(config); return((T)manageCityStateRepository); case "INotificationRepository": INotificationRepository nRepository = new NotificationRepository(config); return((T)nRepository); case "IPlacedCandidateRepository": IPlacedCandidateRepository placedCandidateRepository = new PlacedCandidateRepository(config); return((T)placedCandidateRepository); case "IAdvertisementsRepository": IAdvertisementsRepository advertisementsRepository = new AdvertisementsRepository(config); return((T)advertisementsRepository); case "IEmailTemplateRepository": IEmailTemplateRepository emailTemplateRepository = new EmailTemplateRepository(config); return((T)emailTemplateRepository); default: throw new Exception("Can not create object"); } }
protected void btn_SubmitTrip_Click(object sender, EventArgs e) { try { if (!this.IsValid) { return; } long _driverID = 0; long?CodriverID = null; long vehicleId = 0; long vehicleTypeId = 0; if (cboVehiclesType.SelectedIndex > 0) { vehicleTypeId = Convert.ToInt64(cboVehiclesType.SelectedValue); } //var card = new GarageCardRepository().GetCard(txtBoxBnkCard.Text); //if (card != null) //{ // CardCID = card.GarageCardId; //} if (driverDD.SelectedIndex > 0) { _driverID = Convert.ToInt64(driverDD.SelectedValue); } if (coDriverDD.SelectedIndex > 0) { CodriverID = Convert.ToInt64(coDriverDD.SelectedValue); } //if (RESPCdeDD.SelectedIndex > 0) //{ // RESPCodeID = Convert.ToInt32(RESPCdeDD.SelectedValue); //} long tripId = 0; if (this.Mode == OperationMode.Add) { tripId = m_Repository.AddTrip(vehicleId, _driverID, CodriverID, tripDescpText.Text, ProJTxt.Text, DateTime.ParseExact(_tripDate.Text, "dd/MM/yyyy", null), DateTime.ParseExact(returnDate.Text, "dd/MM/yyyy", null), this.UserName, startPoint.Text, destination.Text, vehicleTypeId); string body = string.Format("Dear {0} \r\n\r\nThere is a trip request waiting to your athorisation. Kindly logon to vehicle management system to authorise the trip. \r\n\r\nRegards", this.ManagerName); var success = new EmailRepository().SendEmail(this.ManagerAddress, this.ManagerName, "Trip request for authorisation", body); } else { if (!long.TryParse(this.RedirectId, out tripId)) { this.RedirectPage(Pages.TRIP_CLOSURE); return; } m_Repository.UpdateTrip(tripId, vehicleId, _driverID, CodriverID, tripDescpText.Text, ProJTxt.Text, DateTime.ParseExact(_tripDate.Text, "dd/MM/yyyy", null), DateTime.ParseExact(returnDate.Text, "dd/MM/yyyy", null), this.UserName, startPoint.Text, destination.Text, vehicleTypeId); } this.RedirectPage(Pages.TRIP_PASSENGERS, tripId.ToString()); } catch (Exception ex) { this.HandleException(ex); } }
public EmailController() { _emailRepository = new EmailRepository(); }
private void Init() { _studentRepo = new StudentRepository(_dbProvider); _courseRepo = new CourseRepository(_dbProvider); _courseRosterRepo = new CourseRosterRepository(_dbProvider); _emailRepo = new EmailRepository(_dbProvider); _coureCodeCache = new CourseCodeCache(_dbProvider); _semesterCache = new SemesterCache(_dbProvider); _coureCodeCache.Refresh(); _semesterCache.Refresh(); }
static void ProcessEvent(MailjetEvent mailjetEvent) { if (mailjetEvent.AttemptCount > 0) { logger.Debug("{1} Повторная обработка события с сервера Mailjet. Попытка {2}/{3} \n{0}", mailjetEvent, GetThreadInfo(), mailjetEvent.AttemptCount, MaxSendAttemptsCount); } else { logger.Debug("{1} Обработка события с сервера Mailjet \n{0}", mailjetEvent, GetThreadInfo()); } //Запись информации о письме в базу using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { var emailAction = EmailRepository.GetStoredEmailByMessageId(uow, mailjetEvent.MessageID.ToString()); if (emailAction == null) { int mailId; if (int.TryParse(mailjetEvent.CustomID, out mailId)) { emailAction = uow.GetById <StoredEmail>(mailId); } } if (emailAction != null) { var eventDate = UnixTimeStampToDateTime(mailjetEvent.Time); if (eventDate > emailAction.StateChangeDate) { emailAction.StateChangeDate = eventDate; switch (mailjetEvent.Event) { case "sent": emailAction.State = StoredEmailStates.Delivered; break; case "open": emailAction.State = StoredEmailStates.Opened; break; case "spam": emailAction.State = StoredEmailStates.MarkedAsSpam; break; case "bounce": case "blocked": emailAction.State = StoredEmailStates.Undelivered; emailAction.AddDescription(mailjetEvent.GetErrorInfo()); break; } try { uow.Save(emailAction); uow.Commit(); } catch (Exception ex) { mailjetEvent.AttemptCount++; if (mailjetEvent.AttemptCount <= MaxEventSaveAttemptsCount) { unsavedEventsQueue.Add(mailjetEvent); } logger.Error("{1} Произошла ошибка при сохранении: {0}", ex.Message, GetThreadInfo()); } } } else { logger.Error("{0} Событие проигнорировано. Не найдено письмо в БД связанное с событием с сервера Mailjet.", GetThreadInfo()); } } }
public static async Task SendMail(Email email, Config config, TemplateData templateData, EmailRepository emailRepo) { try { using (var smtpClient = BuildSmtpClient(email, config)) using (var message = BuildMailMessage(email, config, templateData)) { var emails = email.To.Trim().Split(";"); foreach (var e in emails) { message.To.Add(new MailAddress(e.Trim())); } foreach (var a in email.Attachments) { message.Attachments.Add(new Attachment(new MemoryStream(a.Bytes), a.Name)); } await smtpClient.SendMailAsync(message); } } catch (Exception e) { emailRepo.UpdateError(email.Id, e.Message); throw e; } }
public EmailsController(EmailRepository repository, IRepository <Contact, string> contactRepository) { this.repository = repository; this.repositoryContacts = contactRepository; }
public RegisterService(IHttpContextAccessor accessor, UserRepository userRepository, EmailRepository emailRepository) : base(accessor, userRepository) { _userRepository = userRepository; _emailRepository = emailRepository; }
private List <DbValidationError> GetValidationErrors(EmailRepository pr, Email contact, EmailDTO cqDto, int YieldID, int userId) { contact.ProcessRecord(cqDto); return(pr.Validate(contact)); }
public EmailFileManager(EmailRepository repository, EmailPermissionManager emailPermissionManager, UserContext userContext) { this.repository = repository; this.emailPermissionManager = emailPermissionManager; this.userContext = userContext; }
public static void GenerateEmail(string To, string Subject, string Message) { MailMessage mail = new MailMessage(); mail.To.Add(To); mail.From = new MailAddress(EmailRepository.getSMTPUsername()); mail.Subject = Subject; mail.Body = Message; //mail.IsBodyHtml = true; SmtpClient SmtpMail = new SmtpClient(EmailRepository.getSMTPHost(), EmailRepository.getSMTPPort()); SmtpMail.EnableSsl = EmailRepository.SMTPIsUseSSL(); SmtpMail.UseDefaultCredentials = false; SmtpMail.Credentials = new System.Net.NetworkCredential(EmailRepository.getSMTPUsername(), EmailRepository.getSMTPPassword()); SmtpMail.Send(mail); #region body //ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010); ////service.AutodiscoverUrl("*****@*****.**"); ////service.Url = new Uri("https://outlook.office365.com/ews/Exchange.asmx"); //service.Url = new Uri("https://oa.wp.corpshared.net/ews/Exchange.asmx"); //service.UseDefaultCredentials = false; //service.Credentials = new WebCredentials("*****@*****.**", "Jakarta123"); //EmailMessage message = new EmailMessage(service); //message.Subject = Subject; //message.Body = Message; //message.ToRecipients.Add(To); //message.Save(); //message.SendAndSaveCopy(); //oMsg.IsBodyHtml = true; //Message = "Dear " + To + ", <br />"; //Message += "------------------------------------------------------------------------------------------------ <br/> <br/>"; ////Project Schedule Monitoring <bulan tahun> untuk project <nama project>, telah di <action> oleh <Project Administrator> //Message += "<b> Project Schedule Monitoring " + DateTime.Now.ToString("MMM") + " - " + DateTime.Now.Year + " untuk project " + namaproject + " telah di Submit oleh " + ProjectAdministrator + " </b>"; //Message += " <br /> <br /> <br />"; //Message += "<i> Mohon bantuannya untuk melakukan review update progress project tersebut dengan menekan link berikut : <br /> <br /> "; ////Message += " <a href=\"" + _URL + "\">Task </a> </i> <br /> <br />"; //Message += "<i>Hormat Kami, <br /> "; //Message += "Administratot "; //Message += "</i> "; //SmtpMail.Host = webapp.OutboundMailServiceInstance.Parent.Name;//GetSMTPHostName(); //"smtp.sinarmasland.com"; #endregion }
public void SaveNewUserDetails(NewUserRegistrationSupport NewUserDeatils) { GenericRepository <Phone> PhoneRepository; GenericRepository <Email> EmailRepository; GenericRepository <Address> AddressRepository; GenericRepository <UserDetailAddress> UserDetailAddressRepository; GenericRepository <UserDetail> UserDetailRepository; try { using (UnitOfWork unitOfWork = new UnitOfWork()) { try { #region Phone PhoneRepository = unitOfWork.GetRepoInstance <Phone>(); Phone phone = new Phone(); phone.Number = NewUserDeatils.PhoneNumber; PhoneRepository.Insert(phone); #endregion #region Email EmailRepository = unitOfWork.GetRepoInstance <Email>(); Email email = new Email(); email.ID = NewUserDeatils.Email; EmailRepository.Insert(email); #endregion #region Address AddressRepository = unitOfWork.GetRepoInstance <Address>(); Address Add = new Address(); Add.Address1 = NewUserDeatils.Address1; Add.Address2 = NewUserDeatils.Address2; Add.Address3 = NewUserDeatils.Address3; Add.Phone = phone; Add.Email = email; AddressRepository.Insert(Add); #endregion #region User Address Details UserDetailAddressRepository = unitOfWork.GetRepoInstance <UserDetailAddress>(); UserDetailAddress UDA = new UserDetailAddress(); UDA.Address = Add; UserDetailAddressRepository.Insert(UDA); #endregion #region User Details UserDetailRepository = unitOfWork.GetRepoInstance <UserDetail>(); UserDetail newUser = new UserDetail(); newUser.FirstName = NewUserDeatils.FirstName; newUser.LastName = NewUserDeatils.LastName; newUser.MiddleName = NewUserDeatils.MiddleName; newUser.DateofBirth = NewUserDeatils.Dob; UDA.UserDetail = newUser; //newUser.UserDetailAddress.=UDA; UserDetailRepository.Insert(newUser); #endregion unitOfWork.SaveChanges(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("System Stack :: " + ex.StackTrace + " System Exception Message :: " + ex.Message); } } } catch (Exception ex) { LogHelper.WriteErrorLog(ex); } }