예제 #1
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            SiteUser siteUser = SiteUtils.GetCurrentSiteUser();

            if (siteUser == null)
            {
                return;
            }

            SharedFile sharedFile = new SharedFile(this.moduleId, this.itemId);

            sharedFile.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);
            if ((sharedFile.ItemId > 0) && (sharedFile.ModuleId == this.moduleId))
            {
                if (file1.HasFile && file1.FileName != null && file1.FileName.Trim().Length > 0)
                {
                    //SharedFile sharedFile = new SharedFile();
                    sharedFile.CreateHistory(upLoadPath, historyPath);
                    sharedFile.ModuleId = this.moduleId;
                    if (sharedFile.ModuleGuid == Guid.Empty)
                    {
                        Module m = new Module(moduleId);
                        sharedFile.ModuleGuid = m.ModuleGuid;
                    }
                    sharedFile.OriginalFileName = file1.FileName;
                    // FIXME: the following line probably doesn't work right when uploading from
                    // Windows to Unix because GetFileName will be looking for "\" and the FileName
                    // will contain "/".
                    sharedFile.FriendlyName = Path.GetFileName(file1.FileName);
                    sharedFile.SizeInKB     = (int)(file1.ContentLength / 1024);

                    //sharedFile.FolderID = this.CurrentFolderID;
                    sharedFile.UploadUserId = siteUser.UserId;

                    if (sharedFile.Save())
                    {
                        string destPath = upLoadPath + sharedFile.ServerFileName;
                        if (File.Exists(destPath))
                        {
                            File.Delete(destPath);
                        }
                        file1.MoveTo(destPath, MoveToOptions.Overwrite);
                    }
                }

                CurrentPage.UpdateLastModifiedTime();
                CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
                SiteUtils.QueueIndexing();
                WebUtils.SetupRedirect(this, Request.RawUrl);
            }
        }
예제 #2
0
        private void btnDeleteFile_Click(object sender, EventArgs e)
        {
            SharedFile sharedFile = new SharedFile(moduleId, itemId);

            sharedFile.ContentChanged += new ContentChangedEventHandler(sharedFile_ContentChanged);

            sharedFile.CreateHistory(this.upLoadPath, this.historyPath);
            //SharedFile.DeleteSharedFile(this.moduleId,this.itemId, this.upLoadPath);
            sharedFile.Delete(this.upLoadPath);
            CurrentPage.UpdateLastModifiedTime();
            CacheHelper.TouchCacheDependencyFile(cacheDependencyKey);
            SiteUtils.QueueIndexing();
            if (hdnReturnUrl.Value.Length > 0)
            {
                WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
                return;
            }

            WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
        }