private Guid OpenDocumentID(string documentID)
        {
            var unitOfWork = new DocumentsUnitOfWork();

            var documentItem     = unitOfWork.ItemRepository.GetByID(long.Parse(documentID));
            var documentItemInfo = new DocumentItemInfo(documentItem);

            var editorType = documentItemInfo.DocumentProcessorType;
            OfficeWorkSessionControl editor = null;

            if (editorType == OfficeDocumentProcessorType.Spreadsheet)
            {
                var spreadsheetControl = new ASPxSpreadsheet();
                spreadsheetControl.Open(
                    documentItemInfo.Id,
                    (DevExpress.Spreadsheet.DocumentFormat)DocumentFormatUtils.GetDocumentFormat(documentItemInfo.NameExtension),
                    () => documentItem.Content.Data);

                editor = spreadsheetControl;
            }

            if (editorType == OfficeDocumentProcessorType.RichEdit)
            {
                var richEditControl = new ASPxRichEdit();
                richEditControl.Open(
                    documentItemInfo.Id,
                    (DevExpress.XtraRichEdit.DocumentFormat)DocumentFormatUtils.GetDocumentFormat(documentItemInfo.NameExtension),
                    () => documentItem.Content.Data);

                editor = richEditControl;
            }

            return(editor.GetWorkSessionID());
        }
Ejemplo n.º 2
0
    private void OpenExcelFile(string fileFullPath)
    {
        ASPxSpreadsheet spreadsheet = new ASPxSpreadsheet();

        spreadsheet.ID = "spreadsheet";
        ASPxPopupControl1.Controls.Add(spreadsheet);
        spreadsheet.Open(fileFullPath);
    }
Ejemplo n.º 3
0
    protected void btnDownloadExistingFile_Command(object sender, CommandEventArgs e)
    {
        ASPxSpreadsheet.Visible = false;
        if (e.CommandName == "DownloadExistingFile")
        {
            string filename = e.CommandArgument.ToString();

            if (File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/DataDownloads/" + filename)))
            {
                LogDownload(filename);
                DownloadFile(filename);
            }
            else
            {
                string result = "Sorry, the file [" + filename + "] was not found.";
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + result + "');", true);
            }
        }
        else if (e.CommandName == "LoadXLSX")
        {
            string filename = e.CommandArgument.ToString();

            if (File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/DataDownloads/" + filename)))
            {
                ASPxSpreadsheet.Open(HttpContext.Current.Server.MapPath("~/App_Data/DataDownloads/" + filename));
                ASPxSpreadsheet.Visible = true;
            }
            else
            {
                string result = "Sorry, the file [" + filename + "] was not found.";
                ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + result + "');", true);
            }
        }
        else if (e.CommandName == "DownloadExistingFile_xls")
        {
            string filename = e.CommandArgument.ToString().Replace(".xlsx", ".xls");

            if (File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/DataDownloads/" + filename)))
            {
                LogDownload(filename);
                DownloadFile(filename);
            }
            else
            {
                if (File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/DataDownloads/" + e.CommandArgument.ToString())))
                {
                    //convert to .xls here
                    try
                    {
                        SpreadsheetGearUtils.Save_xls_from_xlsx(e.CommandArgument.ToString());

                        LogDownload(filename);
                        DownloadFile(filename);
                    }
                    catch (Exception ex)
                    {
                        string x      = ex.Message;
                        string result = "Sorry, the file [" + filename + "] was not found. We have tried to create it but an error occurred.";
                        ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + result + "');", true);
                    }
                }
                else
                {
                    string result = "Sorry, the file [" + filename + "] was not found.";
                    ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + result + "');", true);
                }
            }
        }

        else if (e.CommandName == "ViewSummary")
        {
            string filename = e.CommandArgument.ToString();


            string pageurl = "DataProjectStats.aspx";
            pageurl += "?filename=" + e.CommandArgument.ToString() + "&pk=" + Request.QueryString["pk"];
            Response.Redirect(pageurl);
        }
    }