public ActionResult SendCertificates(int FieldOperationsId, int ContractId, int TechId, string FullName, int PurchaseOrderId)
        {
            TechInfoAxi model = db.TechInfoAxis.Where(c => c.TechId == TechId).Single();

            Contract contract = db.Contracts.Find(ContractId);

            //foreach(var item in Model)

            //El correo de email debe ser el contacto del Farm (email)
            string email = contract.Rfq.Farm.Email;
            //string email = "*****@*****.**";

            //El correo de CC debe ser la persona que esta efecutando la acción

            var    users   = db.Users.Include(r => r.UserRoles).Where(r => r.UserRoles.RoleId == "3");
            string emailCC = "";
            bool   bd      = false;

            foreach (var item in users)
            {
                if (bd)
                {
                    emailCC = emailCC + "," + item.Email;
                }
                else
                {
                    bd      = true;
                    emailCC = item.Email;
                }
            }

            //string emailCC = "*****@*****.**";
            //string emailCC = "*****@*****.**";

            string path = "~/Documents/Teches/" + TechId + "/";

            try
            {
                FONMailer.Certificates(model, FullName, path, email, emailCC).Send();

                var FO = db.FieldOperations.Find(FieldOperationsId);
                FO.CertificatesStatus = "SENDING";
                db.Entry(FO).State    = EntityState.Modified;
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught in CreateTimeoutTestMessage(): {0}",
                                  ex.ToString());
            }


            return(RedirectToAction("Create", "FieldOperations", new { id = PurchaseOrderId, ContractId = ContractId }));
            // return RedirectToAction("Index");
        }
        // GET: TechInfoAxis/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TechInfoAxi techInfoAxi = db.TechInfoAxis.Find(id);

            if (techInfoAxi == null)
            {
                return(HttpNotFound());
            }
            return(View(techInfoAxi));
        }
        // GET: TechInfoAxis/Edit/5
        public ActionResult Edit(int id)
        {
            if (id < 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TechInfoAxi techInfoAxi = db.TechInfoAxis.Where(c => c.TechId == id).Single();

            if (techInfoAxi == null)
            {
                return(HttpNotFound());
            }
            techInfoAxi.TechId = id;
            return(View(techInfoAxi));
        }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "TechId,Photo,FirstName,LastName,Language,StreetAdderess,CityAdderess,State,Zip,Country,Cell,Email,EmailCompany,LocalAirport,SSN,DriveLicence,PayRate,DayliPerDiem,Medical,Passport,MaritalStatus,Children,Education")] Tech tech)
        {
            if (ModelState.IsValid)
            {
                tech.Status = "BANCH";
                db.Teches.Add(tech);
                db.SaveChanges();

                //Tech Info
                var techInfoAxi = new TechInfoAxi();

                techInfoAxi.TechId         = tech.TechId;
                techInfoAxi.ExperienceDate = DateTime.Now;

                db.TechInfoAxis.Add(techInfoAxi);
                db.SaveChanges();

                //Kit
                var techInfoKit = new TechInfoKit();
                techInfoKit.TechId = tech.TechId;
                techInfoKit.HarnessDateManufacture = DateTime.Now;
                techInfoKit.LaynarDateManufacture  = DateTime.Now;

                db.TechInfoKits.Add(techInfoKit);
                db.SaveChanges();

                //Cim
                var techInfoCim = new TechInfoCim();
                techInfoCim.TechId = tech.TechId;


                db.TechInfoCims.Add(techInfoCim);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(tech));
        }
        public ActionResult Edit([Bind(Include = "TechInfoAxiId,ExperienceDate,HasI9,HasW2,HasW4,HasApplicanceOffer,HasAxisLaborCode,TechnicalLevel,TechId")] TechInfoAxi techInfoAxi, HttpPostedFileBase I9File,
                                 HttpPostedFileBase W2File, HttpPostedFileBase W4File,
                                 HttpPostedFileBase ApplicanceOfferFile, HttpPostedFileBase AxisLaborCodeFile,
                                 HttpPostedFileBase Osha10, HttpPostedFileBase FirstAidCPR,
                                 HttpPostedFileBase TowerRescue, HttpPostedFileBase ConfinedSpace,
                                 HttpPostedFileBase Nfra70E, HttpPostedFileBase Loto,
                                 HttpPostedFileBase Ergonomics, HttpPostedFileBase Hazcom,
                                 HttpPostedFileBase CraneSafety, HttpPostedFileBase RiggingSignalMan,
                                 HttpPostedFileBase FireExtinguisher
                                 )

        {
            string _FileName;
            string path;

            if (ModelState.IsValid)
            {
                var techInfoAxi2 = db.TechInfoAxis.Find(techInfoAxi.TechInfoAxiId);
                techInfoAxi2.ExperienceDate     = techInfoAxi.ExperienceDate;
                techInfoAxi2.TechnicalLevel     = techInfoAxi.TechnicalLevel;
                techInfoAxi2.HasI9              = techInfoAxi.HasI9;
                techInfoAxi2.HasW2              = techInfoAxi.HasW2;
                techInfoAxi2.HasW4              = techInfoAxi.HasW4;
                techInfoAxi2.HasApplicanceOffer = techInfoAxi.HasApplicanceOffer;
                techInfoAxi2.HasAxisLaborCode   = techInfoAxi.HasAxisLaborCode;

                var dir = Server.MapPath("~/Documents/Teches/" + techInfoAxi.TechId);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                if (Osha10 != null)
                {
                    _FileName = System.IO.Path.GetFileName(Osha10.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    Osha10.SaveAs(path);
                    techInfoAxi2.Osha10 = _FileName;
                }

                if (FirstAidCPR != null)
                {
                    _FileName = System.IO.Path.GetFileName(FirstAidCPR.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    FirstAidCPR.SaveAs(path);
                    techInfoAxi2.FirstAidCPR = _FileName;
                }

                if (TowerRescue != null)
                {
                    _FileName = System.IO.Path.GetFileName(TowerRescue.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    TowerRescue.SaveAs(path);
                    techInfoAxi2.TowerRescue = _FileName;
                }

                if (ConfinedSpace != null)
                {
                    _FileName = System.IO.Path.GetFileName(ConfinedSpace.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    ConfinedSpace.SaveAs(path);
                    techInfoAxi2.ConfinedSpace = _FileName;
                }

                if (Nfra70E != null)
                {
                    _FileName = System.IO.Path.GetFileName(Nfra70E.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    Nfra70E.SaveAs(path);
                    techInfoAxi2.Nfra70E = _FileName;
                }

                if (Loto != null)
                {
                    _FileName = System.IO.Path.GetFileName(Loto.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    Loto.SaveAs(path);
                    techInfoAxi2.Loto = _FileName;
                }

                if (Ergonomics != null)
                {
                    _FileName = System.IO.Path.GetFileName(Ergonomics.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    Ergonomics.SaveAs(path);
                    techInfoAxi2.Ergonomics = _FileName;
                }

                if (Hazcom != null)
                {
                    _FileName = System.IO.Path.GetFileName(Hazcom.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    Hazcom.SaveAs(path);
                    techInfoAxi2.Hazcom = _FileName;
                }

                if (CraneSafety != null)
                {
                    _FileName = System.IO.Path.GetFileName(CraneSafety.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    CraneSafety.SaveAs(path);
                    techInfoAxi2.CraneSafety = _FileName;
                }

                if (RiggingSignalMan != null)
                {
                    _FileName = System.IO.Path.GetFileName(RiggingSignalMan.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    RiggingSignalMan.SaveAs(path);
                    techInfoAxi2.RiggingSignalMan = _FileName;
                }

                if (FireExtinguisher != null)
                {
                    _FileName = System.IO.Path.GetFileName(FireExtinguisher.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    FireExtinguisher.SaveAs(path);
                    techInfoAxi2.FireExtinguisher = _FileName;
                }

                if (I9File != null && techInfoAxi.HasI9)
                {
                    _FileName = System.IO.Path.GetFileName(I9File.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    I9File.SaveAs(path);
                    techInfoAxi2.I9File = _FileName;
                }

                if (W2File != null && techInfoAxi.HasW2)
                {
                    _FileName = System.IO.Path.GetFileName(W2File.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    W2File.SaveAs(path);
                    techInfoAxi2.W2File = _FileName;
                }


                if (W4File != null && techInfoAxi.HasW4)
                {
                    _FileName = System.IO.Path.GetFileName(W4File.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    W4File.SaveAs(path);
                    techInfoAxi2.W4File = _FileName;
                }

                if (ApplicanceOfferFile != null && techInfoAxi.HasApplicanceOffer)
                {
                    _FileName = System.IO.Path.GetFileName(ApplicanceOfferFile.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    ApplicanceOfferFile.SaveAs(path);
                    techInfoAxi2.ApplicanceOfferFile = _FileName;
                }

                if (AxisLaborCodeFile != null && techInfoAxi.HasAxisLaborCode)
                {
                    _FileName = System.IO.Path.GetFileName(AxisLaborCodeFile.FileName);
                    path      = System.IO.Path.Combine(dir, _FileName);
                    AxisLaborCodeFile.SaveAs(path);
                    techInfoAxi2.AxisLaborCodeFile = _FileName;
                }


                db.Entry(techInfoAxi2).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index", "TechInfoAxis"));
            }
            ViewBag.Message = "Save error";
            return(View(techInfoAxi));
        }
Beispiel #6
0
        public virtual MvcMailMessage Certificates(TechInfoAxi model, string FullName, string path, string email, string emailCC)
        {
            ViewBag.FullName = FullName;
            var mailMessage = new MvcMailMessage
            {
                Subject  = "Axis Employee Safety Certifications",
                ViewName = "Axis Employee Safety Certifications"
            };
            var attachmentPath = "";
            var file           = "";

            if (model.Osha10 != null)
            {
                file           = path + model.Osha10;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.FirstAidCPR != null)
            {
                file           = path + model.FirstAidCPR;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.TowerRescue != null)
            {
                file           = path + model.TowerRescue;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.ConfinedSpace != null)
            {
                file           = path + model.ConfinedSpace;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.Nfra70E != null)
            {
                file           = path + model.Nfra70E;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.Loto != null)
            {
                file           = path + model.Loto;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.Ergonomics != null)
            {
                file           = path + model.Ergonomics;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.Hazcom != null)
            {
                file           = path + model.Hazcom;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.CraneSafety != null)
            {
                file           = path + model.CraneSafety;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.RiggingSignalMan != null)
            {
                file           = path + model.RiggingSignalMan;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.FireExtinguisher != null)
            {
                file           = path + model.FireExtinguisher;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.I9File != null)
            {
                file           = path + model.I9File;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.W2File != null)
            {
                file           = path + model.W2File;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.W4File != null)
            {
                file           = path + model.W4File;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.ApplicanceOfferFile != null)
            {
                file           = path + model.ApplicanceOfferFile;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }

            if (model.AxisLaborCodeFile != null)
            {
                file           = path + model.AxisLaborCodeFile;
                attachmentPath = System.Web.HttpContext.Current.Server.MapPath(file);
                if (System.IO.File.Exists(attachmentPath))
                {
                    mailMessage.Attachments.Add(new Attachment(attachmentPath));
                }
            }



            mailMessage.To.Add(email);
            mailMessage.CC.Add(emailCC);
            PopulateBody(mailMessage, "Certificates", null);


            SmtpClient mailClient = new SmtpClient();

            mailClient.Timeout = 10;
            return(mailMessage);
        }