Beispiel #1
0
        public ActionResult DeliveryNote(Array rfqids)
        {
            string filename = "";

            GenerateExcel gn = new Models.GenerateExcel();

            filename = gn.NewDeliveryNote(rfqids);


            return(new JsonResult()
            {
                Data = new { FileName = filename + ".xlsx" }
            });
        }
Beispiel #2
0
        public ActionResult CreateExcel(Array rfqids)
        {
            string filename = "";

            GenerateExcel gn = new Models.GenerateExcel();

            filename = gn.NewQuotation(rfqids);

            //   var file = new DirectoryInfo(string.Format(@"D:\Sample\{0}.xlsx", filename));


            return(new JsonResult()
            {
                Data = new { FileName = filename + ".xlsx" }
            });
        }
Beispiel #3
0
        public ActionResult PricingCompleted(int fileid)
        {
            int logid = 0;

            try
            {
                var reflist = _context.ReferanceNumbers
                              .Where(r => r.IsDeleted == false)
                              .Where(f => f.FileId == fileid)
                              .Where(f => f.Stage == 4).AsEnumerable();

                string rfqs = "";


                var file   = _context.Files.FirstOrDefault(f => f.Id == fileid);
                var vessel = _context.Vessels.FirstOrDefault(v => v.Id == file.VesselId);


                List <string> ids = new List <string>();

                foreach (var item in reflist)
                {
                    item.Stage = 5;

                    rfqs = rfqs + item.Name + " ,";

                    ids.Add(item.Id.ToString());
                }

                if (rfqs.Length > 2)
                {
                    rfqs = rfqs.Remove(rfqs.Length - 1);
                }

                _context.SaveChanges();

                // sale dep mail gönderme

                var toadress = new MailAddress("*****@*****.**");

                var emaillog = new EmailLog
                {
                    Description = "Sale Dpt.",
                    FileId      = fileid,
                    Name        = "rfqs:" + rfqs,
                    ToAdress    = toadress.ToString(),
                    State       = "Sending"
                };
                _context.EmailLogs.Add(emaillog);
                _context.SaveChanges();
                logid = emaillog.Id;


                string header = string.Format("File is Ready {1}- ( {0} )", file.FileNumber, vessel.VesselName);
                string body   = string.Format("<strong> SALE TEAM </br> </strong> You could view details for {1}- {0} on the AppA Create Document Page. </br>   </br>  RFQs; {2}  </br>   </br> <b> Note;  {3} </b>", file.FileNumber, vessel.VesselName, rfqs, "");
                string link   = string.Format(@"http://192.168.2.4:5559/Sales/File/{0}", file.Id);

                List <MailAddress> ccadress = new List <MailAddress>();
                ccadress.Add(new MailAddress("*****@*****.**"));
                ccadress.Add(new MailAddress("*****@*****.**"));


                var temp      = new EmailTemplates();
                var eMailbody =
                    temp.e_mailbody_fiyat_isteme(header, body, link, User.Identity.GetUserName(), "*****@*****.**");


                var t = Task.Run(async() =>
                {
                    await _emailer.SendEmail(header, eMailbody, toadress, ccadress, logid);
                });

                emaillog.State = "Sent";
                _context.SaveChanges();

                // download excel

                GenerateExcel gn = new Models.GenerateExcel();

                string filename = gn.NewQuotation(ids.ToArray(), true);

                return(new JsonResult()
                {
                    Data = new { FileName = filename + ".xlsx" }
                });
            }
            catch (Exception e)
            {
                var errorMessage = e.Message;
                var emailLog     = _context.EmailLogs.FirstOrDefault(x => x.Id == logid);
                if (emailLog != null)
                {
                    emailLog.State = "Error:  " + errorMessage;
                }
                _context.SaveChanges();

                return(Json(false));
            }
        }