コード例 #1
0
 protected void btnSelect_Click(object sender, EventArgs e)
 {
     if (OpenDropDownList.SelectedValue == string.Empty)
     {
         StatusLabel.Text = "There are no current issues!";
     }
     else
     {
         Issue existingIssue = MagazineData.OpenIssue(OpenDropDownList.SelectedValue);
         ResolutionDropDownList.Text    = existingIssue.Resolution;
         QualityTextBox.Text            = existingIssue.Quality;
         TxtAliasingDropDownList.Text   = existingIssue.TextAntialiasing;
         GraphAliasingDropDownList.Text = existingIssue.GraphicsAntialiasing;
         CreateXML.CreatePagesXMLFile(existingIssue.IssueId);
         btnPreview.Visible        = true;
         btnUploadOnServer.Visible = true;
         IssuePanel.Visible        = true;
         Panel1.Visible            = true;
         IssueNameLabel.Visible    = true;
         NameTextBox.Visible       = false;
         btnCreate.Visible         = false;
         btnUpdate.Visible         = true;
         IssueNameLabel.Text       = "Issue name: " + existingIssue.IssueId.ToUpper();
     }
 }
コード例 #2
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        if (FileUpload.HasFile)
        {
            UploadPdfFile();
        }
        string[] pdfFiles    = Directory.GetFiles(Server.MapPath("~/pdf"));
        string[] orgPdfFiles = Directory.GetFiles(Server.MapPath("~/content/" + OpenDropDownList.SelectedValue), "*.pdf");
        if (pdfFiles.Length == 0)
        {
            File.Copy(orgPdfFiles[0], Server.MapPath("~/pdf/") + "temp.pdf");
        }
        string[] jpgFiles = Directory.GetFiles(Server.MapPath("~/content/" + OpenDropDownList.SelectedValue), "*.jpg");
        foreach (string file in jpgFiles)
        {
            File.Delete(file);
        }

        Issue newIssue = new Issue();

        newIssue.IssueId              = OpenDropDownList.SelectedValue;
        newIssue.IssueDirectory       = ConfigurationManager.AppSettings["imagepath"] + OpenDropDownList.SelectedValue;
        newIssue.Resolution           = ResolutionDropDownList.SelectedValue;
        newIssue.Quality              = QualityTextBox.Text;
        newIssue.TextAntialiasing     = TxtAliasingDropDownList.SelectedValue;
        newIssue.GraphicsAntialiasing = GraphAliasingDropDownList.SelectedValue;
        StatusLabel.Text              = CreateImages.CreateImagesGhostScript(newIssue);
        string pdfpath        = HttpContext.Current.Server.MapPath("~/pdf");
        string sourcePDF      = pdfpath + @"\temp.pdf";
        string destinationPDF = newIssue.IssueDirectory + @"\" + newIssue.IssueId + ".pdf";

        File.Copy(sourcePDF, destinationPDF, true);
        File.Delete(sourcePDF);
        MagazineData.UpdateIssue(newIssue);
        CreateXML.CreatePagesXMLFile(newIssue.IssueId);
        Panel1.Visible     = true;
        btnPreview.Visible = true;
        RequiredFieldValidator4.Visible = false;
    }
コード例 #3
0
        public string LISVPNList(string sHospID, string sXMLDate)
        {
            string sResult = String.Empty;

            // 切割資料取得日期
            if (!String.IsNullOrEmpty(sXMLDate))
            {
                DateTime dtXMLDate = Convert.ToDateTime(sXMLDate);
                string   sdt       = (dtXMLDate.Year - 1911).ToString("000") + (dtXMLDate.Month).ToString("00") + (dtXMLDate.Day).ToString("00") + "0000";

                if (!String.IsNullOrEmpty(sHospID))
                {
                    GetLink();
                    LIS_HISEntities db_his = new LIS_HISEntities(myClass.GetSQLConnectionString(dbs2, "his" + sHospID, userid, password, LIS_HISEntities_String));

                    #region XML產出到系統數設定的指定目錄
                    try
                    {
                        var db_ic = (from vpnh in db_his.lisVPNHData
                                     where vpnh.h19.CompareTo(sdt) >= 0 && vpnh.h19.CompareTo(sdt) <= 0
                                     join vpnr in db_his.lisVPNRData on vpnh.VHDRowid equals vpnr.VHDRowid
                                     group new { vpnh, vpnr } by new
                        {
                            vpnh.h1,
                            vpnh.h2,
                            vpnh.h3,
                            vpnh.h4,
                            vpnh.h5,
                            vpnh.h6,
                            vpnh.h7,
                            vpnh.h8,
                            vpnh.h9,
                            vpnh.h10,
                            vpnh.h11,
                            vpnh.h12,
                            vpnh.h13,
                            vpnh.h14,
                            vpnh.h15,
                            vpnh.h16,
                            vpnh.h17,
                            vpnh.h18,
                            vpnh.h19,
                            vpnh.h20,
                            vpnh.h21,
                            vpnh.h22,
                            vpnh.h23,
                            vpnh.h24,
                            vpnh.h25,
                            vpnr.r1,
                            vpnr.r2,
                            vpnr.r3,
                            vpnr.r4,
                            vpnr.r5,
                            vpnr.r61,
                            vpnr.r62,
                            vpnr.r7,
                            vpnr.r81,
                            vpnr.r82,
                            vpnr.r83,
                            vpnr.r84,
                            vpnr.r85,
                            vpnr.r86,
                            vpnr.r87,
                            vpnr.r88,
                            vpnr.r89,
                            vpnr.r9,
                            vpnr.r10,
                            vpnr.r11,
                            vpnr.r12,
                            vpnr.r13,
                            vpnr.r14
                        } into gr
                                     select new
                        {
                            gr.Key.h1,
                            gr.Key.h2,
                            gr.Key.h3,
                            gr.Key.h4,
                            gr.Key.h5,
                            gr.Key.h6,
                            gr.Key.h7,
                            gr.Key.h8,
                            gr.Key.h9,
                            gr.Key.h10,
                            gr.Key.h11,
                            gr.Key.h12,
                            gr.Key.h13,
                            gr.Key.h14,
                            gr.Key.h15,
                            gr.Key.h16,
                            gr.Key.h17,
                            gr.Key.h18,
                            gr.Key.h19,
                            gr.Key.h20,
                            gr.Key.h21,
                            gr.Key.h22,
                            gr.Key.h23,
                            gr.Key.h24,
                            gr.Key.h25,
                            gr.Key.r1,
                            gr.Key.r2,
                            gr.Key.r3,
                            gr.Key.r4,
                            gr.Key.r5,
                            gr.Key.r61,
                            gr.Key.r62,
                            gr.Key.r7,
                            gr.Key.r81,
                            gr.Key.r82,
                            gr.Key.r83,
                            gr.Key.r84,
                            gr.Key.r85,
                            gr.Key.r86,
                            gr.Key.r87,
                            gr.Key.r88,
                            gr.Key.r89,
                            gr.Key.r9,
                            gr.Key.r10,
                            gr.Key.r11,
                            gr.Key.r12,
                            gr.Key.r13,
                            gr.Key.r14
                        }).AsEnumerable().Where(t => decimal.TryParse(t.r4, out decimal i));

                        if (db_ic != null)
                        {
                            DataTable table   = myClass.LinqQueryToDataTable(db_ic);
                            string    sYYMMDD = (dtXMLDate.Year - 1911).ToString("000") + (dtXMLDate.Month).ToString("00") + (dtXMLDate.Day).ToString("00");
                            //string sXMLTarget = Server.MapPath("~/") + @"FileCloud\LISTemp\" + sHospID + @"\";        //  得到應用程式目錄(含\)
                            //string sXMLTarget = System.Web.Hosting.HostingEnvironment.MapPath("~") + @"FileCloud\LISTemp\" + sHospID + @"\";        //  得到應用程式目錄(含\)
                            string sXMLTarget = Server.MapPath("~/FileCloud") + @"/LISTemp/" + sHospID + "/";
                            string sXMLPath   = sXMLTarget + @"LISXML/" + sYYMMDD + @"/"; // XML暫存檔
                            string sZIPPath   = sXMLTarget + @"LISZIP/" + sYYMMDD + @"/"; // 壓縮檔存檔位置

                            if (Directory.Exists(sXMLPath) == false)                      // XML暫存檔
                            {
                                Directory.CreateDirectory(sXMLPath);                      //新增資料夾
                            }
                            if (Directory.Exists(sZIPPath) == false)                      //壓縮檔存檔位置
                            {
                                Directory.CreateDirectory(sZIPPath);                      //新增資料夾
                            }

                            CreateXML lis   = new CreateXML();
                            int       nCode = lis.ConvertXML(table, sXMLTarget, sYYMMDD);

                            sResult = String.Empty;
                            if (nCode == 200)
                            {
                                sResult = String.Format("Code({0}): TOTFA.ZIP 已完成下載 !! ", nCode);
                            }
                            else
                            {
                                sResult = String.Format("Code({0}):XML檔案建立失敗,請查明原因 !{1}", nCode, "");
                            }
                        }
                        else
                        {
                            sResult = "Code(9):沒有資料可供建立XML檔案,建立失敗,請查明原因!";
                        }
                    }
                    catch (Exception ex)
                    {
                        sResult = "Code(999):" + ex.ToString();
                    }
                    #endregion
                }
            }

            return(sResult);
        }
コード例 #4
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        string temp2 = UploadPdfFile();

        if (temp2 == "File uploaded!")
        {
            string temp1 = NameTextBox.Text;
            int    chk   = temp1.IndexOf(" ");
            if ((IsAlphaNumeric(NameTextBox.Text)) && chk == -1)
            {
                Issue newIssue = new Issue();
                newIssue.IssueId        = NameTextBox.Text;
                newIssue.IssueDirectory = ConfigurationManager.AppSettings["imagepath"] + NameTextBox.Text;
                if (Directory.Exists(newIssue.IssueDirectory))
                {
                    StatusLabel.Text = "Folder already exists!";
                }
                else
                {
                    if (!File.Exists(HttpContext.Current.Server.MapPath("~/pdf") + @"\temp.pdf"))
                    {
                        StatusLabel.Text = "Please upload PDF file first!";
                    }
                    else
                    {
                        Directory.CreateDirectory(newIssue.IssueDirectory);
                        newIssue.Resolution           = ResolutionDropDownList.SelectedValue;
                        newIssue.Quality              = QualityTextBox.Text;
                        newIssue.TextAntialiasing     = TxtAliasingDropDownList.SelectedValue;
                        newIssue.GraphicsAntialiasing = GraphAliasingDropDownList.SelectedValue;
                        //StatusLabel.Text = CreateImages.CreateImagesGhostScript(newIssue);
                        string        pdfpath   = HttpContext.Current.Server.MapPath("~/pdf");
                        string        sourcePDF = pdfpath + @"\temp.pdf";
                        List <string> fileList;
                        GhostScript.DeviceOption[] options = GhostScript.DeviceOptions.jpg(int.Parse(newIssue.Quality), int.Parse(newIssue.TextAntialiasing), int.Parse(newIssue.GraphicsAntialiasing));
                        GhostScript gs = new GhostScript(ConfigurationManager.AppSettings["gspath"]);
                        fileList = gs.Convert(GhostScript.OutputDevice.jpeg, options, sourcePDF, newIssue.IssueDirectory, "%d.jpg", pdfpath, int.Parse(newIssue.Resolution));
                        gs.Dispose();
                        string destinationPDF = newIssue.IssueDirectory + @"\" + newIssue.IssueId + ".pdf";
                        File.Move(sourcePDF, destinationPDF);
                        if (fileList.Count == 0)
                        {
                            MagazineData.CreateIssue(newIssue);
                            CreateXML.CreatePagesXMLFile(newIssue.IssueId);
                            btnPreview.Visible        = true;
                            btnUploadOnServer.Visible = true;
                            StatusLabel.Text          = "Image files created!";
                        }
                        else
                        {
                            StatusLabel.Text = "Error!";
                        }
                    }
                }
            }
            else
            {
                StatusLabel.Text = "Enter valid Issue name";
            }
        }
        else
        {
            StatusLabel.Text = temp2;
        }
    }