Пример #1
0
        public M_CDownload getCertificateLinks(string RequestId)
        {
            try
            {
                M_CDownload Cu = new M_CDownload();
                using (DBLinqDataContext datacontext = new DBLinqDataContext())
                {
                    datacontext.Connection.ConnectionString = Connection_;
                    var lst = datacontext._getDownloadCertificateByID(RequestId).SingleOrDefault();
                    if (lst != null)
                    {
                        Cu.RequestID = lst.RequestId;
                        Cu.InvoiceNo = lst.InvoiceNo;
                        Cu.CertPath  = lst.CertificatePath;
                        Cu.CPath     = lst.CertificateName;
                        Cu.RefNo     = lst.CertificateId;
                    }
                }

                return(Cu);
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex);
                return(null);
            }
        }
Пример #2
0
        public List <M_CDownload> getCertificateDownload(string RequestId,
                                                         string CustID,
                                                         string certID, string seal, string invoiceNo, string ParentId)
        {
            try
            {
                List <M_CDownload> lstpackage = new List <M_CDownload>();
                using (DBLinqDataContext datacontext = new DBLinqDataContext())
                {
                    datacontext.Connection.ConnectionString = Connection_;
                    System.Data.Linq.ISingleResult <_getDownloadCertificateResult> lst = datacontext._getDownloadCertificate(RequestId,
                                                                                                                             CustID,
                                                                                                                             certID,
                                                                                                                             seal,
                                                                                                                             invoiceNo,
                                                                                                                             ParentId);
                    foreach (_getDownloadCertificateResult result in lst)
                    {
                        M_CDownload cd = new M_CDownload();
                        if (result.SealRequired == "True")
                        {
                            cd.IsStamped = "Yes";
                        }
                        else
                        {
                            cd.IsStamped = "No";
                        }
                        cd.IsDownloaded = result.IsDownloaded;
                        cd.RequestBy    = result.CreatedBy;
                        cd.RefNo        = result.CertificateId;
                        cd.CertPath     = result.CertificatePath;
                        cd.IsDownloaded = result.IsDownloaded;
                        cd.IsPrinted    = result.IsDownloaded;
                        cd.RequestID    = result.RequestId;
                        cd.ClientName   = result.CustomerName;
                        cd.ReqType      = result.Ctype;

                        cd.ApproveDate = result.CreatedDate.ToString("dd/MMM/yy");
                        cd.RequestDate = result.RequestDate.ToString("dd/MMM/yy");
                        cd.InvoiceNo   = result.InvoiceNo;
                        cd.ApprovedBy  = result.created;
                        cd.ParentN     = result.ParentName;
                        cd.CertPath    = result.CertificatePath;
                        lstpackage.Add(cd);
                    }
                }

                return(lstpackage);
            }
            catch (Exception ex)
            {
                ErrorLog.LogError(ex);
                return(null);
            }
        }
Пример #3
0
        public ActionResult BulkDownload(string IDs)
        {
            try
            {
                var      strin = new JavaScriptSerializer().DeserializeObject(IDs);
                string[] arr   = strin.ToString().Split(',');

                if (System.IO.File.Exists(Server.MapPath
                                              ("~/Temp/Certificates.zip")))
                {
                    System.IO.File.Delete(Server.MapPath
                                              ("~/Temp/Certificates.zip"));
                }
                ZipArchive zip = ZipFile.Open(Server.MapPath
                                                  ("~/Temp/Certificates.zip"), ZipArchiveMode.Create);

                for (int a = 0; a < arr.Length; a++)
                {
                    M_CDownload D = new M_CDownload();
                    List <M_SupportDocument> sD = new List <M_SupportDocument>();
                    D  = objCd.getCertificateLinks(arr[a]);
                    sD = objCd.getSignedSupportDocs(arr[a]);

                    string Folder  = arr[a] + "/";
                    string Support = Folder + "Supportdoc/";

                    zip.CreateEntryFromFile(Server.MapPath
                                                (D.CertPath), Folder + D.CPath);
                    if (sD.Count != 0)
                    {
                        foreach (M_SupportDocument N in sD)
                        {
                            zip.CreateEntryFromFile(Server.MapPath
                                                        (N.Download_Path), Support + N.SupportingDocument_Name + ".pdf");
                        }
                    }
                }
                zip.Dispose();
                return(File(Server.MapPath("~/Temp/Certificates.zip"),
                            "application/zip", DateTime.Now.ToString("dd.MM.yyyy.ss") + ".zip"));
                //byte[] fileBytes = System.IO.File.ReadAllBytes(Server.MapPath("~/Temp/Certificates.zip"));
                //return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, DateTime.Now.ToString("dd.MM.yyyy.ss") + ".zip");
            }
            catch (Exception Ex)
            {
                ErrorLog.LogError(Ex);
                return(View());
            }
        }