Пример #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 btnDelete_Click(object sender, EventArgs e)
 {
     if (OpenDropDownList.SelectedValue == string.Empty)
     {
         StatusLabel.Text = "There are no current issues!";
     }
     else
     {
         CreateImages.DeleteImages(OpenDropDownList.SelectedValue);
         StatusLabel.Text = MagazineData.DeleteIssue(OpenDropDownList.SelectedValue);
         OpenDropDownList.DataBind();
         Panel1.Visible     = true;
         IssuePanel.Visible = false;
     }
 }
Пример #3
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;
    }
Пример #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;
        }
    }