public ContractInfoController(ContractInfoManager contractManager, FileScopeManager fim, FileInfoManager fileInfoManager, RestClient rsc)
 {
     _fileScopeManager    = fim;
     _fileInfoManager     = fileInfoManager;
     _contractInfoManager = contractManager;
     _restClient          = rsc;
 }
Example #2
0
    protected void gvFile_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int a = this.gvFile.SelectedIndex;

        if (e.CommandName == "details")
        {
            int fileId = Convert.ToInt32(e.CommandArgument.ToString());
            MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(fileId);
            //判断是链接到文件详细还是文件夹详细
            if (file.FileType.FileTypeId == 1)
            {
                Response.Redirect("FolderDetails.aspx?fileId=" + file.FileId);
            }
            else
            {
                Response.Redirect("FileDetails.aspx?fileId=" + file.FileId);
            }
        }
        else if (e.CommandName == "del")
        {
            int fileId = Convert.ToInt32(e.CommandArgument.ToString());
            FileInfoManager.update_IfDelete_ByFileId(fileId);
            this.gvFile.DataBind();
        }
    }
Example #3
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         context.Response.ContentType = "text/plain";
         if (null == context.Request.Form["fid"])
         {
             throw new Exception("未传文件名称!");
         }
         string            fid   = context.Request.Form["fid"].ToString();
         OAEntity.FileInfo fl    = new FileInfo();
         FileInfoManager   flMgr = new FileInfoManager();
         fl = flMgr.GetItemById(new Guid(fid));
         if (DeleteFile("../" + fl.FILEPATH, context)) //删除文件
         {
             flMgr.DelateById(new Guid(fid));          //删除数据库记录
             context.Response.Write("sucess");
         }
         else
         {
             context.Response.Write("failed");
         }
     }
     catch (Exception ex)
     {
         context.Response.Write(ex.Message);
     }
 }
Example #4
0
    protected void btnExit_Click1(object sender, ImageClickEventArgs e)
    {
        try
        {
            int fileId = Convert.ToInt32(Request.QueryString["fileId"]);
            MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(fileId);
            if (Directory.Exists(this.lblFilePath.Text))
            {
                Directory.Delete(this.lblFilePath.Text, true);
            }
            IList <int> childFileLists = new List <int>();
            FileInfoManager.GetAllChildByFileId(childFileLists, Convert.ToInt32(Request.QueryString["fileId"]));
            foreach (int delfileId in childFileLists)
            {
                FileInfoManager.DelFileById(delfileId);
            }
            FileInfoManager.DelFileById(Convert.ToInt32(Request.QueryString["fileId"]));

            Response.Redirect("FileMain.aspx?fileId=" + file.ParentId + "&fileTypeId=1");
        }
        catch (Exception ex)
        {
            throw;
        }
    }
Example #5
0
    protected void imgbtnSave_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            //获得文件正确的地址
            string fullPath = this.lblFilePath.Text.ToString().Trim().Replace("/", Path.AltDirectorySeparatorChar.ToString()) + this.txtFileName.Text;

            if (!Directory.Exists(fullPath))
            {
                Directory.CreateDirectory(fullPath);
            }
            string filePath = fullPath.Replace(IniFile.IniReadValue(((User)Session["Login"]).UserId), "");
            MyOffice.Models.FileInfo file = new MyOffice.Models.FileInfo();
            file.FileName            = this.txtFileName.Text;
            file.IfDelete            = 0;
            file.FileType.FileTypeId = 1;
            file.FileOwner           = ((User)Session["Login"]);
            file.Remark     = this.txtRemark.Text;
            file.CreateDate = DateTime.Now;
            file.ParentId   = Convert.ToInt32(Request.QueryString["parentId"]);
            file.FilePath   = filePath;

            FileInfoManager.AddFile(file);

            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!');location='FileMain.aspx?fileId=" + Request.QueryString["parentId"] + "';</script>");
        }
        catch (Exception ex)
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');location='FileMain.aspx?fileId=" + Request.QueryString["parentId"] + "';</script>");
        }
    }
Example #6
0
    /// <summary>
    /// 显示文件详细信息时绑定页面的空间
    /// </summary>
    /// <param name="fileIdStr"></param>
    private void BindPage(string fileIdStr)
    {
        int fileId = Convert.ToInt32(fileIdStr);

        MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(fileId);
        this.txtFileName.Text   = file.FileName;
        this.txtRemark.Text     = file.Remark;
        this.lblCreateTime.Text = file.CreateDate.ToString();
        this.lblFileOwer.Text   = file.FileOwner.UserName;
        this.lblFilePath.Text   = IniFile.IniReadValue(((User)Session["Login"]).UserId) + file.FilePath;
        //显示修改按钮隐藏添加按钮
        this.imgbtnSave.Visible   = false;
        this.imgbtnSave.Enabled   = false;
        this.imgbtnUpdate.Visible = true;
        this.imgbtnUpdate.Enabled = true;
        //不启用验证文件上传控件的控件
        RequiredFieldValidator4.Enabled = false;

        foreach (ListItem rdo in this.rboFileIcoList.Items)
        {
            if (file.FileType.FileTypeId.ToString() == rdo.Value)
            {
                rdo.Selected = true;
            }
        }
    }
Example #7
0
    protected void imgbtnMove_ServerClick(object sender, ImageClickEventArgs e)
    {
        HtmlInputImage imgbtnMove = sender as HtmlInputImage;

        ViewState["Move_FileId"] =
            this.gvFile.DataKeys[Convert.ToInt32(imgbtnMove.Value) - 1].Value.ToString();

        MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(Convert.ToInt32(this.gvFile.DataKeys[Convert.ToInt32(imgbtnMove.Value) - 1].Value));
        this.txtMoveFileName.Text = file.FileName;
    }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sbtmpl = @" 
		    <tr>
                <td height='30' align='center' bgcolor='#FFFFFF' class='zx'>{0}</td>
                <td align='center' bgcolor='#FFFFFF' class='zx'>&nbsp;<font class='book_kk'>{1}</font><!--故障设备置顶--></td>
                <td align='center' bgcolor='#FFFFFF' class='zx'>{2}</td>
                <td align='center' bgcolor='#FFFFFF' class='zx'>{3}</td>
                <td align='center' bgcolor='#FFFFFF' class='zx'>共<span class='title12b'>{4}</span>次故障</td>
                <td align='center' bgcolor='#FFFFFF' class='zx'>共<span class='title12b'>{5}</span>次更换</td>
            </tr>";


            if (!IsPostBack)
            {
                string sresult =
                    @"<table width='100%' border='0' cellpadding='0' cellspacing='0' class='dx'>
                      <tbody><tr>
                        <td width='12%' height='25' align='center' bgcolor='#F8F8F8' class='zx'>编号</td>
                        <td width='14%' align='center' bgcolor='#F8F8F8' class='zx'>设备状态</td>
                        <td width='22%' align='center' bgcolor='#F8F8F8' class='zx'>设备名称</td>
                        <td width='16%' align='center' bgcolor='#F8F8F8' class='zx'>缩略图</td>
                        <td width='18%' align='center' bgcolor='#F8F8F8' class='zx'>故障统计</td>
                        <td width='18%' align='center' bgcolor='#F8F8F8' class='zx'>更换统计</td>
                      </tr>";
                ShebeiInfoManager sbMgr = new ShebeiInfoManager();
                DataTable         dt_sb = sbMgr.GetDataTable();

                int scount = 0;
                foreach (DataRow row in dt_sb.Rows)
                {
                    scount++;
                    if (scount > 100)
                    {
                        return;
                    }
                    OAManager.FileInfoManager flMgr = new FileInfoManager();
                    DataTable dtimg    = flMgr.GetDataTable(row["ID"].ToString());
                    string    img_html = string.Empty;
                    if (dtimg.Rows.Count > 0)
                    {
                        string src = dtimg.Rows[0]["FILEPATH"].ToString();
                        img_html = "<a href='" + src + "'><img src='" + src + "' width='50' height='40' alt='图标'></a>";
                    }
                    else
                    {
                        img_html = "无缩略图";
                    }

                    sresult += string.Format(sbtmpl, row["Code"].ToString(), row["State"].ToString(), "<a href='" + row["PATH"].ToString() + "' target='sbiframe'>" + row["Name"].ToString() + "</a>", img_html, row["GZTJ"].ToString(), row["GHTJ"].ToString());
                }
                sresult         += "</tbody></table>";
                sbinfo.InnerHtml = sresult;
            }
        }
Example #9
0
 public ContractFileController(
     FileInfoManager fim,
     FileScopeManager fsm,
     ContractInfoManager cim,
     RestClient rsc)
 {
     _fileInfoManager     = fim;
     _fileScopeManager    = fsm;
     _contractInfoManager = cim;
     _restClient          = rsc;
 }
Example #10
0
    /// <summary>
    /// 递归添加节点(只添加文件夹)
    /// </summary>
    /// <param name="parentId">父节点ID</param>
    /// <param name="treeNodeCollection">需要被添加节点的节点</param>
    private void CreateNode(int parentId, TreeNodeCollection treeNodeCollection)
    {
        IList <MyOffice.Models.FileInfo> lists = FileInfoManager.GetFolderByParentId(parentId);

        foreach (MyOffice.Models.FileInfo fileInfo in lists)
        {
            //生成树的节点
            TreeNode tn = new TreeNode(fileInfo.FileName, fileInfo.FileId.ToString(), fileInfo.FileType.FileTypeImage.Replace("../../", "~/"));
            CreateNode(fileInfo.FileId, tn.ChildNodes);
            treeNodeCollection.Add(tn);
        }
    }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string          sid     = context.Request.Form["sid"].ToString();//获取id值
            FileInfoManager manager = new FileInfoManager();

            DataTable dt     = manager.GetDataTable(sid);
            string    result = JsonConvert.Convert2Json(dt);

            context.Response.Write(result);
            context.Response.End();
        }
Example #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindRL();
            try
            {
                string fileIdStr = Request.QueryString["fileId"];
                //当前页面功能为显示文件信息
                if (fileIdStr != "" && fileIdStr != null)
                {
                    this.FileType.Style.Add("display", "none");
                    MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(Convert.ToInt32(fileIdStr));
                    this.imgbtnUp.PostBackUrl = "FileMain.aspx?fileId=" + file.ParentId + "&fileTypeId=1";
                    BindPage(fileIdStr);
                }
                //当前页面功能为新增文件
                else
                {
                    this.imgbtnUp.PostBackUrl = "FileMain.aspx?fileId=" + Request.QueryString["parentId"] + "&fileTypeId=1";
                    this.btnExit.PostBackUrl  = "FileMain.aspx?fileId=" + Request.QueryString["parentId"] + "&fileTypeId=1";
                    //获得当前文件的上级目录(文件夹)ID
                    int parentId = Convert.ToInt32(Request.QueryString["parentId"]);
                    //上级目录不是根目录  可以从数据库中查找
                    if (parentId != 0)
                    {
                        MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(parentId);
                        this.lblFilePath.Text = IniFile.IniReadValue(((User)Session["Login"]).UserId) + file.FilePath + "\\";
                    }
                    //上级目录是根目录   数据库中没有根目录的数据记录
                    else
                    {
                        this.lblFilePath.Text = IniFile.IniReadValue(((User)Session["Login"]).UserId);
                    }

                    this.lblFileOwer.Text   = ((User)Session["Login"]).UserName;
                    this.lblCreateTime.Text = DateTime.Now.ToString();
                    //显示添加按钮隐藏修改按钮
                    this.imgbtnSave.Visible   = true;
                    this.imgbtnSave.Enabled   = true;
                    this.imgbtnUpdate.Visible = false;
                    this.imgbtnUpdate.Enabled = false;
                    //启用验证文件上传控件的控件
                    RequiredFieldValidator4.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("~/index.aspx");
            }
        }
    }
Example #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string fileIdStr = Convert.ToString(Request.QueryString["fileId"]);

            Page_FileId = fileIdStr;

            int fileId = int.Parse(fileIdStr);
            if (fileId == 0)
            {
                this.txtFolderPath.Text = "文件管理" + "\\";
                this.imgbtnUp.Enabled   = false;
            }
            else
            {
                this.imgbtnUp.Enabled = true;
                //找到页面所对应的上级文件夹对象  得到本页面的上一级文件夹ID  并为界面中“上一级”按钮赋URL
                MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(fileId);
                this.imgbtnUp.PostBackUrl = "FileMain.aspx?fileId=" + file.ParentId + "&fileTypeId=1";


                if (file == null)
                {
                    this.txtFolderPath.Text = "文件管理" + "\\";
                }
                else
                {
                    this.txtFolderPath.Text = file.FilePath + "\\";
                }
            }
            //没有修改当前文件路径的情况下 禁用转到按钮
            this.imgbtnGoto.Enabled = false;
        }
        catch (Exception ex)
        {
            if (!IsPostBack)
            {
                Response.Redirect("FileMain.aspx?fileId=0&fileTypeId=1");
            }
        }

        //给更改当前所在界面所需的树绑定事件
        (this.FolderTree1.FindControl("tvFolder") as TreeView).SelectedNodeChanged += new EventHandler(ChangeFileTree);

        if (!IsPostBack)
        {
            BindTV();
        }
    }
Example #14
0
    private void BindPage()
    {
        string fileIdStr = Request.QueryString["fileId"];

        MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(Convert.ToInt32(fileIdStr));
        this.txtFileName.Text   = file.FileName;
        this.txtRemark.Text     = file.Remark;
        this.lblCreateTime.Text = file.CreateDate.ToString();
        this.lblFileOwer.Text   = file.FileOwner.UserName;
        this.lblFilePath.Text   = IniFile.IniReadValue(((User)Session["Login"]).UserId) + file.FilePath;
        //显示修改按钮隐藏添加按钮
        this.imgbtnSave.Visible   = false;
        this.imgbtnSave.Enabled   = false;
        this.imgbtnUpdate.Visible = true;
        this.imgbtnUpdate.Enabled = true;
    }
Example #15
0
 public FileInfoController(FileInfoManager fileInfoManager,
                           CustomerInfoManager customerInfoManager,
                           FileScopeManager fileScopeManager,
                           CustomerDealManager customerDealManager,
                           RestClient restClient,
                           IMapper mapper,
                           PermissionExpansionManager permissionExpansionManager)
 {
     _permissionExpansionManager = permissionExpansionManager ?? throw new ArgumentNullException(nameof(permissionExpansionManager));
     _fileInfoManager            = fileInfoManager;
     _icustomerInfoManager       = customerInfoManager;
     _fileScopeManager           = fileScopeManager;
     _customerDealManager        = customerDealManager;
     _restClient = restClient;
     _mapper     = mapper;
 }
Example #16
0
    protected void imgbtnUpdate_Click(object sender, ImageClickEventArgs e)
    {
        MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(Convert.ToInt32(Request.QueryString["fileId"]));
        try
        {
            file.FileName            = this.txtFileName.Text;
            file.FileType.FileTypeId = 1;
            file.Remark = this.txtRemark.Text;

            FileInfoManager.UpdateFile(file);
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');location='FolderDetails.aspx?fileId=" + file.FileId + "';</script>");
        }
        catch (Exception ex)
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败!');location='FolderDetails.aspx?fileId=" + file.FileId + "';</script>");
        }
    }
Example #17
0
    protected void tvMove_SelectedNodeChanged(object sender, EventArgs e)
    {
        int fileId = Convert.ToInt32(this.tvMove.SelectedValue);

        MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(fileId);

        if (file == null)
        {
            this.txtMove.Text = "文件管理" + "\\";
        }
        else
        {
            this.txtMove.Text = file.FilePath + "\\";
        }
        this.btnMove.Enabled       = true;
        ViewState["moveTo_FileId"] = fileId;
    }
Example #18
0
 protected void btnExit_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         int fileId = Convert.ToInt32(Request.QueryString["fileId"]);
         MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(fileId);
         if (File.Exists(this.lblFilePath.Text))
         {
             File.Delete(this.lblFilePath.Text);
         }
         FileInfoManager.DelFileById(fileId);
         Response.Redirect("FileMain.aspx?fileId=" + file.ParentId + "&fileTypeId=1");
     }
     catch (Exception ex)
     {
         throw;
     }
 }
 public FileInfoController(FileInfoManager fileInfoManager,
                           FileScopeManager fileScopeManager,
                           BuildingsManager buildingsManager,
                           UpdateRecordManager updateRecordManager,
                           BuildingNoticeManager buildingNoticeManager,
                           ShopsManager shopsManager,
                           RestClient restClient,
                           IMapper mapper)
 {
     _fileInfoManager       = fileInfoManager;
     _fileScopeManager      = fileScopeManager;
     _buildingsManager      = buildingsManager;
     _updateRecordManager   = updateRecordManager;
     _buildingNoticeManager = buildingNoticeManager;
     _shopsManager          = shopsManager;
     _restClient            = restClient;
     _mapper = mapper;
 }
Example #20
0
    void ChangeFileTree(object sender, EventArgs e)
    {
        TreeView tv     = (this.FolderTree1.FindControl("tvFolder") as TreeView);
        int      fileId = Convert.ToInt32(tv.SelectedValue);

        //获得选中文件夹对象
        MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(fileId);
        if (file == null)
        {
            this.txtFolderPath.Text = "文件管理" + "\\";
        }
        else
        {
            this.txtFolderPath.Text = file.FilePath + "\\";
        }
        //启用转到按钮
        this.imgbtnGoto.Enabled     = true;
        this.imgbtnGoto.PostBackUrl = "FileMain.aspx?fileId=" + file.FileId;
    }
Example #21
0
    private void SearchFileInfo()
    {
        if (txtCreateUser.Text.Trim() == "")
        {
            this.gvFileSearch.DataSource = FileInfoManager.GetFileInfoByFileName(this.txtFileName.Text.Trim(), this.txtCreateUser.Text.Trim(), this.txtBeginTime.Text.Trim(), this.txtEndTime.Text.Trim());
        }
        else
        {
            IList <User> u = UserManager.GetAllUserByUserName(this.txtCreateUser.Text.Trim());

            foreach (User us in u)
            {
                this.gvFileSearch.DataSource = FileInfoManager.GetFileInfoByFileName(this.txtFileName.Text.Trim(), us.UserId, this.txtBeginTime.Text.Trim(), this.txtEndTime.Text.Trim());
            }
        }

        this.gvFileSearch.DataBind();
        info.Visible = true;
    }
Example #22
0
 protected void gvFileDelete_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "revert")
     {
         int fileId = Convert.ToInt32(e.CommandArgument);
         FileInfoManager.revert_IfDelete_ByFileId(fileId);
         this.gvFileDelete.DataBind();
     }
     else if (e.CommandName == "del")
     {
         try
         {
             int      fileId = Convert.ToInt32(e.CommandArgument);
             FileInfo file   = FileInfoManager.GetFileByFileId(fileId);
             //从本地删除文件(夹)
             if (file.FileType.FileTypeId == 1)
             {
                 System.IO.Directory.Delete(IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + file.FilePath, true);
             }
             else
             {
                 System.IO.File.Delete(IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + file.FilePath);
             }
             //将要删除的子(子)文件集合   如果被删除的是文件  delLists.count为0
             IList <int> delLists = new List <int>();
             FileInfoManager.GetAllChildByFileId(delLists, fileId);
             //先删除本文件(夹)
             FileInfoManager.DelFileById(fileId);
             //如果是文件夹则要删除其下所有文件(夹)
             foreach (int delFileId in delLists)
             {
                 FileInfoManager.DelFileById(delFileId);
             }
             this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除成功!');location='RecycleBin.aspx'</script>");
         }
         catch
         {
             this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除失败!');location='RecycleBin.aspx'</script>");
         }
     }
 }
Example #23
0
    /// <summary>
    /// 递归添加节点
    /// </summary>
    /// <param name="parentId">父节点ID</param>
    /// <param name="treeNodeCollection">需要被添加节点的节点</param>
    private void CreateNode(int parentId, TreeNodeCollection treeNodeCollection)
    {
        IList <FileInfo> lists = FileInfoManager.GetFileByParentId(parentId);

        foreach (FileInfo fileInfo in lists)
        {
            //生成树的节点
            TreeNode tn = new TreeNode(fileInfo.FileName, fileInfo.FileId.ToString(), fileInfo.FileType.FileTypeImage);
            if (fileInfo.FileType.FileTypeId == 1)
            {
                //链接到文件夹显示界面
                tn.NavigateUrl = "FileMain.aspx?fileId=" + fileInfo.FileId + "&fileTypeId=1";
            }
            else
            {
                //跳转到文件详细页面
                tn.NavigateUrl = "FileDetails.aspx?fileId=" + fileInfo.FileId;
            }
            CreateNode(fileInfo.FileId, tn.ChildNodes);
            treeNodeCollection.Add(tn);
        }
    }
Example #24
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void imgbtnUpdate_Click(object sender, ImageClickEventArgs e)
 {
     MyOffice.Models.FileInfo file = FileInfoManager.GetFileByFileId(Convert.ToInt32(Request.QueryString["fileId"]));
     try
     {
         file.FileName = this.txtFileName.Text;
         file.FileType = FileTypeManager.GetFileTypeById(Convert.ToInt32(this.rboFileIcoList.SelectedValue));
         file.Remark   = this.txtRemark.Text;
         if (fuFile.FileName != null && !"".Equals(fuFile.FileName))
         {
             File.Delete(IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + file.FilePath);
             //获得此文件的上级文件夹   为了得到上级文件夹的路径,来保存新的文件
             MyOffice.Models.FileInfo parentFile = FileInfoManager.GetFileByFileId(file.ParentId);
             //新文件的路径  (判断上级是否为空)
             if (parentFile == null)
             {
                 file.FilePath = this.fuFile.FileName;
             }
             else
             {
                 file.FilePath = parentFile.FilePath + "\\" + this.fuFile.FileName;
             }
             fuFile.SaveAs(IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + file.FilePath);
             FileInfoManager.UpdateFileAndFilePath(file);
         }
         else
         {
             FileInfoManager.UpdateFile(file);
         }
         this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');location='FileDetails.aspx?fileId=" + file.FileId + "';</script>");
     }
     catch (Exception ex)
     {
         this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败!');location='FileDetails.aspx?fileId=" + file.FileId + "';</script>");
     }
 }
Example #25
0
    //移动
    protected void btnMove_Click(object sender, EventArgs e)
    {
        try
        {
            //被移动的文件夹
            MyOffice.Models.FileInfo move_File = FileInfoManager.GetFileByFileId(Convert.ToInt32(ViewState["Move_FileId"]));
            if (!ViewState["Move_FileId"].ToString().Equals(ViewState["moveTo_FileId"].ToString()))
            {
                IList <int> childFileLists = new List <int>();
                FileInfoManager.GetAllChildByFileId(childFileLists, move_File.FileId);
                if (!childFileLists.Contains(Convert.ToInt32(ViewState["moveTo_FileId"])))
                {
                    //移动到的文件夹
                    MyOffice.Models.FileInfo moveTo_File = FileInfoManager.GetFileByFileId(Convert.ToInt32(ViewState["moveTo_FileId"]));

                    //移动磁盘中的文件或文件夹
                    if (move_File.FileType.FileTypeId == 1)
                    {
                        MoveFolder(IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + move_File.FilePath, IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + moveTo_File.FilePath);
                    }
                    else
                    {
                        MoveFile(IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + move_File.FilePath, IniFile.IniReadValue(((MyOffice.Models.User)Session["Login"]).UserId) + moveTo_File.FilePath);
                    }

                    //判断是否是根目录
                    string fileName = move_File.FilePath.Substring(move_File.FilePath.LastIndexOf("\\") + 1);
                    if (moveTo_File == null)
                    {
                        move_File.ParentId = 0;
                        move_File.FilePath = fileName;
                    }
                    else
                    {
                        move_File.ParentId = moveTo_File.FileId;
                        move_File.FilePath = moveTo_File.FilePath + "\\" + fileName;
                    }

                    //移动文件 即修改文件的父ID 和FilePath
                    FileInfoManager.MoveFile(move_File);
                    ViewState["Move_FileId"]   = null;
                    ViewState["moveTo_FileId"] = null;
                    this.txtMove.Text          = "";
                    this.txtMoveFileName.Text  = "";
                    this.btnMove.Enabled       = false;
                    this.gvFile.DataBind();
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('移动成功!');location='FileMain.aspx?fileId=" + Request.QueryString["fileId"] + "'</script>");
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('移动失败:目标文件是源文件夹的子文件夹!');location='FileMain.aspx?fileId=" + Request.QueryString["fileId"] + "'</script>");
                }
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('移动失败:目标文件和源文件夹相同!');location='FileMain.aspx?fileId=" + Request.QueryString["fileId"] + "'</script>");
            }
        }
        catch (Exception ex)
        {
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('移动失败!');location='FileMain.aspx?fileId=" + Request.QueryString["fileId"] + "'</script>");
        }
    }
Example #26
0
        static void Main(string[] args)
        {
            //if(args.Length < 1 || (args[0].ToLower() != "true" || args[0].ToLower() != "false"))
            //{
            //    Console.WriteLine("Syntax: FileView.SeedData <bool ResetAll>");
            //    Console.WriteLine("eg. FileView.SeedData true");
            //    Environment.Exit(0);
            //}

            //bool resetAll = args[0].ToLower() == "true" ? true : false;
            var resetAll = true;

            // The code provided will print ‘Hello World’ to the console.
            // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
            var connectionString = args.Length > 0 ? args[0] : ConfigurationManager.ConnectionStrings[0].ToString();

            Console.WriteLine("Import Seed Data: " + connectionString);

            string csvPath     = $"{Environment.CurrentDirectory}\\..\\..\\Seed_Data\\";
            string employeeCsv = $"{csvPath}employee_seed.csv";
            string fileInfoCsv = $"{csvPath}fileInfo_seed.csv";
            //IO.StreamReader sr = new IO.StreamReader(employeeCsv);
            //CsvReader reader = new CsvReader(sr);

            //IEnumerable<Employee> employees = reader.GetRecords<Employee>();
            //foreach(var employee in employees)
            //{
            //    Console.WriteLine($"Firstname: {employee.FirstName}\t LastName: {employee.LastName}");
            //}

            var employeeManager = new EmployeeManager();
            var employeeCount   = 0;

            try
            {
                if (resetAll)
                {
                    Task.Run(() => employeeManager.DeleteAllEmployeeAsync()).Wait();
                    Console.WriteLine("Deleted All Employees!");
                }

                string[] contents = IO.File.ReadAllText(employeeCsv).Split('\n');
                foreach (var line in contents)
                {
                    var fields   = line.Substring(0, line.Length - 1).Split(',').ToArray();
                    var employee = new Employee();
                    employee.LastLogin    = Convert.ToDateTime(fields[0]);
                    employee.Id           = Convert.ToInt32(fields[1]);
                    employee.FirstName    = fields[3];
                    employee.LastName     = fields[4];
                    employee.Email        = fields[5];
                    employee.Level        = Convert.ToInt32(fields[6]);
                    employee.ManagerId    = Convert.ToInt32(fields[7]);
                    employee.BusinessArea = fields[9];

                    var employeeId = Task.Run(() => employeeManager.InsertEmployeeAsync(employee)).Result;
                    employeeCount++;
                    Console.WriteLine($"Inserted Employee[{employeeCount}] EmployeeId: {employeeId}");
                }
            }
            finally
            {
                employeeManager.Dispose();
            }

            var fileInfoManager = new FileInfoManager();
            var fileInfoCount   = 0;

            try
            {
                if (resetAll)
                {
                    Task.Run(() => fileInfoManager.DeleteAllFileInfoAsync()).Wait();
                    Console.WriteLine("Deleted All FileInfos!");
                }

                string[] contents = IO.File.ReadAllText(fileInfoCsv).Split('\n');
                foreach (var line in contents)
                {
                    var fields   = line.Substring(0, line.Length - 1).Split(',').ToArray();
                    var fileInfo = new FileInfo();
                    fileInfo.FileName               = fields[0];
                    fileInfo.FilePath               = fields[1];
                    fileInfo.Volume                 = fields[2];
                    fileInfo.Size                   = Convert.ToInt32(fields[3]);
                    fileInfo.CreatedTime            = Convert.ToDateTime(fields[4]);
                    fileInfo.ModifiedTime           = Convert.ToDateTime(fields[5]);
                    fileInfo.AccessTime             = Convert.ToDateTime(fields[6]);
                    fileInfo.MD5                    = fields[7];
                    fileInfo.SecurityClassification = fields[8];
                    fileInfo.BusinessClassification = fields[9];
                    fileInfo.Extension              = fields[10];
                    fileInfo.MimeType               = fields[11];
                    fileInfo.EmployeeId             = Convert.ToInt32(fields[12]);

                    var fileInfoId = Task.Run(() => fileInfoManager.InsertFileInfoAsync(fileInfo)).Result;
                    fileInfoCount++;
                    Console.WriteLine($"Inserted FileInfo[{fileInfoCount}] FileInfoId: {fileInfoId}");
                }
            }
            finally
            {
                fileInfoManager.Dispose();
            }

            Console.WriteLine();
            Console.WriteLine($"Employees Imported: {employeeCount}");
            Console.WriteLine($"FilerInfo's Imported: {fileInfoCount}");
            Console.WriteLine();
            Console.WriteLine("Import Complete!");
        }