Esempio n. 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/windows.css");

            if (this.IsPostBack)
            {
                string _containerName = (ContainerName != "") ? ContainerName : "FileLibrary";
                string _containerKey  = (ContainerKey != "") ? ContainerKey : hidCFUKey.Value;
                if (Mediachase.IBN.Business.Security.CurrentUser == null)
                {
                    CheckExternal(_containerKey);
                }
                int _folderId = (FolderId > 0) ? FolderId : int.Parse(hidFFUId.Value);
                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");
                string sFileName = hidFName.Value;
                //win fix
                if (sFileName.LastIndexOf("\\") >= 0)
                {
                    sFileName = sFileName.Substring(sFileName.LastIndexOf("\\") + 1);
                }
                //linux fix
                if (sFileName.LastIndexOf("/") >= 0)
                {
                    sFileName = sFileName.Substring(sFileName.LastIndexOf("/") + 1);
                }
                fs.SaveFile(_folderId, sFileName, textDescription.Text, McFileUp.PostedFile.InputStream);
            }
        }
Esempio n. 2
0
        public static bool CheckFileName(int ObjectTypeId, int ObjectId, string FileName)
        {
            // !! code duplication
            string ContainerName = "FileLibrary";
            string ContainerKey  = String.Empty;
            int    folderId      = 0;

            switch ((ObjectTypes)ObjectTypeId)
            {
            case ObjectTypes.Project:
                ContainerKey = "ProjectId_" + ObjectId.ToString();
                break;

            case ObjectTypes.Issue:
                ContainerKey = "IncidentId_" + ObjectId.ToString();
                break;

            case ObjectTypes.Task:
                ContainerKey = "TaskId_" + ObjectId.ToString();
                break;

            case ObjectTypes.CalendarEntry:
                ContainerKey = "EventId_" + ObjectId.ToString();
                break;

            case ObjectTypes.Folder:
                ContainerKey = "Workspace";
                if (ObjectId != 0)
                {
                    folderId     = ObjectId;
                    ContainerKey = Mediachase.IBN.Business.ControlSystem.DirectoryInfo.GetContainerKey(folderId);
                }
                break;

            case ObjectTypes.Document:
                ContainerKey = "DocumentId_" + ObjectId.ToString();
                break;

            case ObjectTypes.ToDo:
                ContainerKey = "ToDoId_" + ObjectId.ToString();
                break;
            }
            if (ContainerKey != String.Empty)
            {
                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 (folderId == 0)
                {
                    folderId = fs.Root.Id;
                }

                return(fs.FileExist(FileName, folderId));
            }
            else
            {
                return(false);
            }
        }
        protected override void CommitTransaction()
        {
            if (OpenedToWrite)
            {
                Mediachase.IBN.Business.ControlSystem.BaseIbnContainer bic =
                    Mediachase.IBN.Business.ControlSystem.BaseIbnContainer.Create("FileLibrary", _containerKey);
                Mediachase.IBN.Business.ControlSystem.FileStorage fs = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");
                if (InnerStream.CanSeek)
                {
                    InnerStream.Seek(0, SeekOrigin.Begin);
                }

                fs.SaveFile(_parentDirectoryId, _fileName, InnerStream);

                base.CommitTransaction();
            }
        }
Esempio n. 4
0
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            if (this.IsPostBack)
            {
                try
                {
                    string sUserLight = "userlight";

                    // check user's name and password here
                    UserLight currentUser = Security.GetUser(Login.Value, Password.Value);
                    if (currentUser == null)
                    {
                        throw new HttpException(405, null);
                    }

                    // Security Addon [3/2/2004]
                    UserLight retUser = null;
                    if (HttpContext.Current.Items.Contains(sUserLight))
                    {
                        retUser = (UserLight)HttpContext.Current.Items[sUserLight];
                        HttpContext.Current.Items.Remove(sUserLight);
                    }
                    HttpContext.Current.Items.Add(sUserLight, currentUser);
                    // End Security Addon [3/2/2004]

                    int AssetVersionId = Int32.Parse(VersionID.Value);

                    // New Folder System Addon [12/27/2005]
                    string ContainerName = "FileLibrary";
                    string ContainerKey  = "Workspace";

                    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");

                    fs.LoadFile(AssetVersionId, Response.OutputStream);

                    // EndNew Folder System Addon [12/27/2005]

                    /*
                     * int FolderId		= Int32.Parse(FolderID.Value);
                     * using (IDataReader assetVersion = Asset.GetAssetVersion(FolderId,ObjectTypes.Folder,AssetVersionId))
                     * {
                     *      if(assetVersion.Read())
                     *      {
                     *              string	fileUrl	= (string)assetVersion["URL"];
                     *              int		assetId = (int)assetVersion["AssetId"];
                     *
                     *              Asset.IncDownloadCount(assetId);
                     *
                     *              if((bool)assetVersion["IsInternal"])
                     *              {
                     *                      DSFile.DownloadFile(fileUrl,Response);
                     *              }
                     *              else
                     *              {
                     *                      Response.Redirect(fileUrl);
                     *              }
                     *      }
                     * }
                     */

                    // Security Addon [3/2/2004]
                    HttpContext.Current.Items.Remove(sUserLight);
                    HttpContext.Current.Items.Add(sUserLight, retUser);
                    // End Security Addon [3/2/2004]
                }
                catch
                {
                    throw new HttpException(405, null);
                }
                Response.End();
            }
        }