Exemple #1
0
 private void BindValues()
 {
     Mediachase.IBN.Business.ControlSystem.FileInfo fi = fs.GetFile(FileId);
     if (fi != null)
     {
         txtTitle.Text         = fi.Name;
         textDescription.Text  = fi.Description;
         cbKeepHistory.Checked = fi.AllowHistory;
     }
 }
Exemple #2
0
        private void GetCurrentFolderAndMoveObjects()
        {
            bic = BaseIbnContainer.Create(ContainerName, ContainerKey);
            fs  = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

            string sFolders = Request["Folders"].ToString();
            string sFiles   = Request["Files"].ToString();

            while (sFolders.Length > 0)
            {
                alFolders.Add(sFolders.Substring(0, sFolders.IndexOf(",")));
                sFolders = sFolders.Remove(0, sFolders.IndexOf(",") + 1);
            }
            while (sFiles.Length > 0)
            {
                alFiles.Add(sFiles.Substring(0, sFiles.IndexOf(",")));
                sFiles = sFiles.Remove(0, sFiles.IndexOf(",") + 1);
            }
            if (alFolders.Count > 0)
            {
                ParentFolderId = fs.GetDirectory(int.Parse(alFolders[0].ToString())).ParentDirectoryId;
            }
            else if (alFiles.Count > 0)
            {
                int      i  = int.Parse(alFiles[0].ToString());
                FileInfo fi = fs.GetFile(i);
                ParentFolderId = fi.ParentDirectoryId;
            }
            ctrlDirTree.DisFolderId = ParentFolderId;
        }
Exemple #3
0
        public ArrayList GetFileExistence(string fName, string ContainerName, string ContainerKey, string ParentFolderId)
        {
            ArrayList values = new ArrayList();

            string sFName = fName;

            if (sFName.LastIndexOf("\\") >= 0)
            {
                sFName = sFName.Substring(sFName.LastIndexOf("\\") + 1);
            }

            Mediachase.IBN.Business.ControlSystem.BaseIbnContainer bic = Mediachase.IBN.Business.ControlSystem.BaseIbnContainer.Create(ContainerName, ContainerKey);
            Mediachase.IBN.Business.ControlSystem.FileStorage      fs  = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

            if (fs.FileExist(sFName, int.Parse(ParentFolderId)))
            {
                if (fs.GetFile(int.Parse(ParentFolderId), sFName).AllowHistory)
                {
                    values.Add(2);
                }
                else
                {
                    values.Add(1);
                }
            }
            else
            {
                values.Add(0);
            }

            return(values);
        }
Exemple #4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int iIconId = -1;

            if (CTypeId > 0)
            {
                using (IDataReader reader = Mediachase.IBN.Business.ContentType.GetContentType(CTypeId))
                {
                    if (reader.Read())
                    {
                        if (Big && reader["BigIconFileId"] != DBNull.Value)
                        {
                            iIconId = (int)reader["BigIconFileId"];
                        }
                        if (!Big && reader["IconFileId"] != DBNull.Value)
                        {
                            iIconId = (int)reader["IconFileId"];
                        }
                    }
                }
            }

            Response.ContentType = "image/jpeg";
            if (Big && Request["ContainerKey"] != null && Request["FileId"] != null)
            {
                string CKey = Request["ContainerKey"].ToString();
                int    FId  = int.Parse(Request["FileId"].ToString());
                Size   sz   = new Size(90, 90);
                if (Mediachase.IBN.Business.ImageThumbnail.Create(ImageThumbnailMode.SaveProportion | ImageThumbnailMode.SkipSmallImage, CKey, FId, sz, System.Drawing.Imaging.ImageFormat.Jpeg, Response.OutputStream))
                {
                    return;
                }
            }
            if (iIconId > 0)
            {
                string           ContainerName = "FileLibrary";
                string           ContainerKey  = "ContentType";
                BaseIbnContainer bic           = BaseIbnContainer.Create(ContainerName, ContainerKey);
                Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");
                FileInfo fi = fs.GetFile(iIconId);
                Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                Mediachase.IBN.Business.ControlSystem.FileStorage.LightLoadFile(fi, Response.OutputStream);
            }
            else
            {
                if (Big)
                {
                    Response.Redirect("~/Layouts/Images/filetypes/unknown48.gif");
                }
                else
                {
                    Response.Redirect("~/Layouts/Images/filetypes/unknown16.gif");
                }
            }
        }
Exemple #5
0
        private void BindDG()
        {
            int iCount = 10;

            if (pc["ClipboardItemsCount"] != null)
            {
                iCount = int.Parse(pc["ClipboardItemsCount"].ToString());
            }
            string sNewFilesClip = "";

            if (pc["ClipboardFiles"] != null)
            {
                sNewFilesClip = pc["ClipboardFiles"].ToString();
            }
            string    sCheck = sNewFilesClip;
            DataTable dt     = new DataTable();

            dt.Columns.Add(new DataColumn("FileId", typeof(int)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            DataRow dr;

            while (sCheck.Length > 0)
            {
                if (sCheck.IndexOf("|") >= 0)
                {
                    dr = dt.NewRow();
                    int elemId = int.Parse(sCheck.Substring(0, sCheck.IndexOf("|")));
                    dr["FileId"] = elemId;
                    FileInfo fi = fs.GetFile(elemId);
                    if (fi != null && fi.ParentDirectoryId != FolderId)
                    {
                        dr["Name"] = fi.Name;
                        dt.Rows.Add(dr);
                    }
                    sCheck = sCheck.Substring(sCheck.IndexOf("|") + 1);
                }
            }
            if (dt.Rows.Count == 0)
            {
                dgFiles.Visible  = false;
                lblAlert.Visible = true;
                lblAlert.Text    = LocRM.GetString("tNoItems");
            }
            else
            {
                dgFiles.Visible    = true;
                lblAlert.Visible   = false;
                dgFiles.DataSource = dt.DefaultView;
                dgFiles.DataBind();
            }
        }
Exemple #6
0
        private void btnPublish_ServerClick(object sender, EventArgs e)
        {
            int iDestFolder = -1;

            try
            {
                iDestFolder = ctrlDirTree.FolderId;
            }
            catch { }
            if (iDestFolder == -1)
            {
                lblNotValid.Visible = true;
                return;
            }

            BaseIbnContainer sourceBic = BaseIbnContainer.Create(ContainerName, ContainerKey);

            Mediachase.IBN.Business.ControlSystem.FileStorage sourceFS = (Mediachase.IBN.Business.ControlSystem.FileStorage)sourceBic.LoadControl("FileStorage");
            FileInfo sourceFi = sourceFS.GetFile(FileId);

            string cKey = DirectoryInfo.GetContainerKey(iDestFolder);

            if (String.IsNullOrEmpty(cKey))
            {
                cKey = "Workspace";
            }
            BaseIbnContainer destBic = BaseIbnContainer.Create("FileLibrary", cKey);

            Mediachase.IBN.Business.ControlSystem.FileStorage destFS = (Mediachase.IBN.Business.ControlSystem.FileStorage)destBic.LoadControl("FileStorage");
            DirectoryInfo destDi = destFS.GetDirectory(iDestFolder);

            try
            {
                destFS.CopyFile(sourceFi, destDi);
            }
            catch (SqlException exception)
            {
                if (exception.Number == 2627 || exception.Number == 50000)
                {
                    lblErrorMessage.Text = LocRM.GetString("tDuplicateName");
                    trError.Visible      = true;
                    return;
                }
            }

            Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                    "try {window.opener.location.href=window.opener.location.href;window.close();}" +
                                                    "catch (e){}", true);
        }
Exemple #7
0
        private void BindValues()
        {
            FileInfo fi    = fs.GetFile(FileId);
            string   sLink = "";

            if (fi.FileBinaryContentType.ToLower().IndexOf("url") >= 0)
            {
                sLink = Util.CommonHelper.GetLinkText(fs, fi);
            }
            if (sLink == "")
            {
                sLink = Util.CommonHelper.GetAbsoluteDownloadFilePath(fi.Id, fi.Name, ContainerName, ContainerKey);
            }

            string sNameLocked = CommonHelper.GetLockerText(sLink);

            lblName.Text = String.Format(CultureInfo.InvariantCulture,
                                         "<img src='{3}' width='16' height='16' border='0' align='absmiddle'/>&nbsp;<a href=\"{0}\" title='{4}'{2}>{1}</a> {5}",
                                         sLink,
                                         Util.CommonHelper.GetShortFileName(fi.Name, 40),
                                         Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType) ? " target='_blank'" : "",
                                         ResolveUrl("~/Common/ContentIcon.aspx?IconID=" + fi.FileBinaryContentTypeId),
                                         fi.Name,
                                         sNameLocked);

            string ParentLink = "";
            string ParentName = "";

            if (fi.ContainerKey.StartsWith("Workspace"))
            {
                lblPath.Text = BuildPath(fi.ParentDirectoryId);
            }
            else
            {
                Util.CommonHelper.GetParentContainer(fi.ContainerKey, fi.ParentDirectory, out ParentName, out ParentLink);
                lblPath.Text = ParentName + " \\ " + BuildPath(fi.ParentDirectoryId);
            }

            lblDescription.Text = fi.Description;
            lblCreator.Text     = Util.CommonHelper.GetUserStatusPureName(fi.CreatorId);
            lblCreated.Text     = fi.Created.ToShortDateString() + " " + fi.Created.ToShortTimeString();
            lblModifier.Text    = Util.CommonHelper.GetUserStatusPureName(fi.ModifierId);
            lblModified.Text    = fi.Modified.ToShortDateString() + " " + fi.Modified.ToShortTimeString();
            lblKeepHistory.Text = String.Format(CultureInfo.InvariantCulture,
                                                "<img align='absmiddle' border='0' src='{0}' />&nbsp;{1}",
                                                (fi.AllowHistory) ? ResolveUrl("~/layouts/images/accept.gif") :
                                                ResolveUrl("~/layouts/images/deny.gif"),
                                                LocRM.GetString("tKeepHistory"));
            lblViewCount.Text = fi.DownloadCount.ToString();
            if (fi.AllowHistory)
            {
                dgFiles.Visible      = true;
                trManage.Visible     = true;
                lblNoHistory.Visible = false;

                dgFiles.Columns[1].HeaderText = LocRM.GetString("tName");
                dgFiles.Columns[2].HeaderText = LocRM.GetString("tUpdatedBy");
                dgFiles.Columns[3].HeaderText = LocRM.GetString("tUpdDate");
                dgFiles.Columns[4].HeaderText = LocRM.GetString("tSize");

                FileHistoryInfo[] _fhi = fi.GetHistory();
                DataTable         dt   = new DataTable();
                dt.Columns.Add(new DataColumn("Id", typeof(int)));
                dt.Columns.Add(new DataColumn("Weight", typeof(int)));
                dt.Columns.Add(new DataColumn("Name", typeof(string)));
                dt.Columns.Add(new DataColumn("Modified", typeof(DateTime)));
                dt.Columns.Add(new DataColumn("Modifier", typeof(string)));
                dt.Columns.Add(new DataColumn("Size", typeof(string)));
                DataRow dr;
                foreach (FileHistoryInfo fhi in _fhi)
                {
                    dr           = dt.NewRow();
                    dr["Id"]     = fhi.Id;
                    dr["Weight"] = 1;

                    string sLinkH = "";
                    if (fhi.FileBinaryContentType.ToLower().IndexOf("url") >= 0)
                    {
                        sLinkH = CommonHelper.GetLinkText(fs, fhi);
                    }
                    if (sLinkH == "")
                    {
                        sLinkH = CommonHelper.GetAbsoluteDownloadFilePath(fi.Id, fi.Name, fhi.Id, ContainerName, ContainerKey);
                    }

                    string sNameLockedH = CommonHelper.GetLockerText(sLinkH);

                    dr["Name"] = String.Format(CultureInfo.InvariantCulture,
                                               "<a href=\"{0}\" title='{3}'{2}>{1}</a> {4}",
                                               sLinkH,
                                               CommonHelper.GetShortFileName(fhi.Name, 40),
                                               Mediachase.IBN.Business.Common.OpenInNewWindow(fhi.FileBinaryContentType) ? " target='_blank'" : "",
                                               fhi.Name,
                                               sNameLockedH
                                               );

                    dr["Modified"] = fhi.Modified;
                    dr["Modifier"] = Util.CommonHelper.GetUserStatusPureName(fhi.ModifierId);
                    dr["Size"]     = FormatBytes((long)fhi.Length);
                    dt.Rows.Add(dr);
                }
                dr           = dt.NewRow();
                dr["Id"]     = fi.Id;
                dr["Weight"] = 0;
                dr["Name"]   = String.Format(CultureInfo.InvariantCulture,
                                             "<a href='{0}' title='{3}'{2}>{1}</a>",
                                             sLink,
                                             Util.CommonHelper.GetShortFileName(fi.Name, 40),
                                             Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType) ? " target='_blank'" : "",
                                             fi.Name
                                             );
                dr["Modified"] = fi.Modified;
                dr["Modifier"] = Util.CommonHelper.GetUserStatusPureName(fi.ModifierId);
                dr["Size"]     = FormatBytes((long)fi.Length);
                dt.Rows.Add(dr);

                DataView dv = dt.DefaultView;
                dv.Sort = "Weight, Modified DESC";

                dgFiles.DataSource = dv;
                dgFiles.DataBind();
            }
            else
            {
                dgFiles.Visible      = false;
                trManage.Visible     = false;
                lblNoHistory.Visible = true;
                lblNoHistory.Text    = LocRM.GetString("tHistoryIsNot");
            }
        }
Exemple #8
0
        /// <summary>
        /// Gets the web dav URL by WebDavTicket.
        /// </summary>
        /// <param name="ticket">The ticket.</param>
        /// <returns></returns>
        public static string GetWebDavUrl(string ticket)
        {
            string retVal = string.Empty;
            WebDavTicket webDavTicket = WebDavTicket.Parse(ticket);

            //Попытаемся определить имя файла
            if (String.IsNullOrEmpty(webDavTicket.AbsolutePath.FileName))
            {
                if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_FileStorage)
                {
                    FileStorageAbsolutePath fsAbsPath = webDavTicket.AbsolutePath as FileStorageAbsolutePath;
                    if (fsAbsPath != null)
                    {
                        FileStorage fs = new FileStorage();
                        Mediachase.IBN.Business.ControlSystem.FileInfo fileInfo = fs.GetFile(fsAbsPath.UniqueId);
                        if (fileInfo != null)
                        {
                            webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                        }
                    }

                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaData)
                {
                    MetaDataAbsolutePath mdAbsPath = webDavTicket.AbsolutePath as MetaDataAbsolutePath;
                    if (mdAbsPath != null)
                    {
                        Mediachase.Ibn.Data.Meta.FileInfo fileInfo = new Mediachase.Ibn.Data.Meta.FileInfo(mdAbsPath.FileUID);
                        webDavTicket.AbsolutePath.FileName = fileInfo.Name;
                    }
                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_MetaDataPlus)
                {
                    MetaDataPlusAbsolutePath mdpAbsPath = webDavTicket.AbsolutePath as MetaDataPlusAbsolutePath;
                    if (mdpAbsPath != null)
                    {
                        Mediachase.MetaDataPlus.MetaObject obj = MetaDataWrapper.LoadMetaObject(mdpAbsPath.MetaObjectId, mdpAbsPath.MetaObjectType);
                        MetaFile mf = obj[mdpAbsPath.MetaFieldName] as MetaFile;
                        if (mf != null)
                        {
                            webDavTicket.AbsolutePath.FileName = mf.Name;
                        }
                    }

                }
                else if (webDavTicket.AbsolutePath.StorageType == ObjectTypes.File_Incident)
                {
                    EmailStorageAbsolutePath emlAbsPath = webDavTicket.AbsolutePath as EmailStorageAbsolutePath;
                    if (emlAbsPath != null)
                    {
                        EMailMessageInfo emlInfo = EMailMessageInfo.Load(emlAbsPath.EmailMsgId);
                        AttachmentInfo attachInfo = emlInfo.Attachments[emlAbsPath.EmailAttachmentIndex];
                        webDavTicket.AbsolutePath.FileName = attachInfo.FileName;
                    }
                }
            }

            retVal = GetWebDavUrl(webDavTicket.AbsolutePath, true);

            return retVal;
        }
Exemple #9
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.Cache.SetNoStore();
            try
            {
                int userId     = UserId;
                int originalId = OriginalId;

                if (userId < 0 && originalId > 0)
                {
                    using (IDataReader reader = Mediachase.IBN.Business.User.GetUserInfoByOriginalId(originalId))
                    {
                        if (reader.Read())
                        {
                            userId = (int)reader["UserId"];
                        }
                    }
                }

                string pictureUrl = string.Empty;
                using (IDataReader rdr = Mediachase.IBN.Business.User.GetUserProfile(userId))
                {
                    if (rdr.Read())
                    {
                        if (rdr["PictureUrl"] != DBNull.Value)
                        {
                            pictureUrl = (string)rdr["PictureUrl"];
                        }
                    }
                }

                int fileId = -1;
                if (!string.IsNullOrEmpty(pictureUrl))
                {
                    fileId = DSFile.GetFileIDFromURL(pictureUrl);
                }

                if (fileId > 0)
                {
                    const string     containerName = "FileLibrary";
                    const string     containerKey  = "SystemPicture";
                    BaseIbnContainer bic           = BaseIbnContainer.Create(containerName, containerKey);
                    Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");
                    FileInfo fi = fs.GetFile(fileId);
                    Response.ContentType = "image/jpeg";
                    Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                    Mediachase.IBN.Business.ControlSystem.FileStorage.LightLoadFile(fi, Response.OutputStream);
                }
                else
                {
                    Response.ContentType = "image/jpeg";
                    Response.Redirect("~/Layouts/Images/nofoto.gif");
                }
            }
            catch
            {
                Response.Redirect("~/Layouts/Images/nofoto.gif", true);
            }

            Response.End();
        }
Exemple #10
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.ContentType = "application/octet-stream";

            int FileId = int.Parse(Request.QueryString["Id"]);

            if (Request.QueryString["CName"] != null && Request.QueryString["CKey"] != null)
            {
                string           ContainerName = Request.QueryString["CName"];
                string           ContainerKey  = Request.QueryString["CKey"];
                BaseIbnContainer bic           = BaseIbnContainer.Create(ContainerName, ContainerKey);
                Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

                Mediachase.IBN.Business.ControlSystem.FileInfo fi = fs.GetFile(FileId);
                if (fi == null)
                {
                    throw new NotExistingIdException();
                }
                FileHistoryInfo fhiLoad = null;
                if (Request["VId"] != null)
                {
                    FileHistoryInfo[] _fhi = fi.GetHistory();
                    foreach (FileHistoryInfo fhi in _fhi)
                    {
                        if (fhi.Id == int.Parse(Request["VId"]))
                        {
                            fhiLoad = fhi;
                            break;
                        }
                    }
                }
                if (fhiLoad == null)
                {
                    Response.ContentType = fi.FileBinaryContentType;
                    if (fi.FileBinaryContentType.ToLower().IndexOf("url") >= 0)
                    {
                        MemoryStream memStream = new MemoryStream();
                        fs.LoadFile(FileId, memStream);
                        memStream.Position = 0;
                        StreamReader reader = new StreamReader(memStream, Encoding.Unicode);
                        string       data   = reader.ReadLine();
                        string       sLink  = "";
                        while (data != null)
                        {
                            if (data.IndexOf("URL=") >= 0)
                            {
                                sLink = data.Substring(data.IndexOf("URL=") + 4);
                                break;
                            }
                            data = reader.ReadLine();
                        }
                        if (sLink != "")
                        {
                            if (!sLink.StartsWith("http://"))
                            {
                                sLink = "http://" + sLink;
                            }
                            Response.Redirect(sLink);
                            return;
                        }
                    }

                    if (Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType))
                    {
                        Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                    }
                    else
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                    }
                    fs.LoadFile(FileId, Response.OutputStream);
                }
                else
                {
                    Response.ContentType = fhiLoad.FileBinaryContentType;
                    if (Mediachase.IBN.Business.Common.OpenInNewWindow(fhiLoad.FileBinaryContentType))
                    {
                        Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fhiLoad.Name)));
                    }
                    else
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fhiLoad.Name)));
                    }
                    fs.LoadFile(fhiLoad, Response.OutputStream);
                }
            }
            else
            {
                Mediachase.IBN.Business.ControlSystem.FileInfo fi = Mediachase.IBN.Business.ControlSystem.FileStorage.GetFile(Mediachase.IBN.Business.Security.CurrentUser.UserID, "Read", FileId);
                if (fi == null)
                {
                    throw new NotExistingIdException();
                }
                Response.ContentType = fi.FileBinaryContentType;
                if (Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType))
                {
                    Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                }
                else
                {
                    Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                }
                Mediachase.IBN.Business.ControlSystem.FileStorage.LightLoadFile(fi, Response.OutputStream);
            }


            Response.End();
        }
Exemple #11
0
        private void GetCurrentFolderAndMoveObjects()
        {
            bic = BaseIbnContainer.Create(ContainerName, ContainerKey);
            fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

            string sFolders = Request["Folders"].ToString();
            string sFiles = Request["Files"].ToString();
            while (sFolders.Length > 0)
            {
                alFolders.Add(sFolders.Substring(0, sFolders.IndexOf(",")));
                sFolders = sFolders.Remove(0, sFolders.IndexOf(",") + 1);
            }
            while (sFiles.Length > 0)
            {
                alFiles.Add(sFiles.Substring(0, sFiles.IndexOf(",")));
                sFiles = sFiles.Remove(0, sFiles.IndexOf(",") + 1);
            }
            if (alFolders.Count > 0)
                ParentFolderId = fs.GetDirectory(int.Parse(alFolders[0].ToString())).ParentDirectoryId;
            else if (alFiles.Count > 0)
            {
                int i = int.Parse(alFiles[0].ToString());
                FileInfo fi = fs.GetFile(i);
                ParentFolderId = fi.ParentDirectoryId;
            }
            ctrlDirTree.DisFolderId = ParentFolderId;
        }
Exemple #12
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Check Security
            if (Security.CurrentUser == null)
            {
                int iObjectTypeId = -1;
                int iObjectId     = -1;

                using (IDataReader reader = Mediachase.IBN.Business.User.GetGateByGuid(ExternalID))
                {
                    if (reader.Read())
                    {
                        iObjectTypeId = (int)reader["ObjectTypeId"];
                        iObjectId     = (int)reader["ObjectId"];
                    }
                }

                if (iObjectTypeId != (int)ObjectTypes.Issue)
                {
                    throw new AccessDeniedException();
                }
            }

            // Download
            Response.ContentType = "application/octet-stream";
            int    FileId        = int.Parse(Request.QueryString["Id"]);
            string ContainerName = Request.QueryString["CName"];
            string ContainerKey  = Request.QueryString["CKey"];

            if (!String.IsNullOrEmpty(ContainerName) && !String.IsNullOrEmpty(ContainerKey))
            {
                BaseIbnContainer bic = BaseIbnContainer.Create(ContainerName, ContainerKey);
                Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

                FileInfo fi = fs.GetFile(FileId);
                if (fi == null)
                {
                    throw new NotExistingIdException();
                }

                FileHistoryInfo fhiLoad = null;
                if (Request["VId"] != null)
                {
                    FileHistoryInfo[] _fhi = fi.GetHistory();
                    foreach (FileHistoryInfo fhi in _fhi)
                    {
                        if (fhi.Id == int.Parse(Request["VId"]))
                        {
                            fhiLoad = fhi;
                            break;
                        }
                    }
                }

                if (fhiLoad == null)
                {
                    Response.ContentType = fi.FileBinaryContentType;

                    if (Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType))
                    {
                        Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                    }
                    else
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                    }
                    fs.LoadFile(FileId, Response.OutputStream);
                }
                else
                {
                    Response.ContentType = fhiLoad.FileBinaryContentType;
                    if (Mediachase.IBN.Business.Common.OpenInNewWindow(fhiLoad.FileBinaryContentType))
                    {
                        Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fhiLoad.Name)));
                    }
                    else
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fhiLoad.Name)));
                    }
                    fs.LoadFile(fhiLoad, Response.OutputStream);
                }
            }
            else
            {
                Mediachase.IBN.Business.ControlSystem.FileInfo fi = Mediachase.IBN.Business.ControlSystem.FileStorage.GetFile(Mediachase.IBN.Business.Security.CurrentUser.UserID, "Read", FileId);
                if (fi == null)
                {
                    throw new NotExistingIdException();
                }
                Response.ContentType = fi.FileBinaryContentType;
                if (Mediachase.IBN.Business.Common.OpenInNewWindow(fi.FileBinaryContentType))
                {
                    Response.AddHeader("content-disposition", String.Format("inline; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                }
                else
                {
                    Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", GetNameForCurrentBrowser(fi.Name)));
                }
                Mediachase.IBN.Business.ControlSystem.FileStorage.LightLoadFile(fi, Response.OutputStream);
            }

            Response.End();
        }