private void Page_Load(object sender, System.EventArgs e)
        {
            this.EnableViewState = false;   // 禁用ViewState

            fileId = Request["id"];
            Stream iStream = null;

            try
            {
                if (!String.IsNullOrEmpty(fileId))
                {
                    FileItem file = FileItem.Find(fileId);

                    // 下载大附件的方法
                    iStream = new FileStream(file.FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    ResponseFile(iStream, file.Name);
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script language=JScript>");
                Response.Write("alert(\"" + ex.Message + ",下载Id=" + fileId + " 的文件时发生系统级错误\");");
                Response.Write("</script>");
            }
            finally
            {
                if (iStream != null)
                {
                    iStream.Close();
                }

                Response.End();
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id = RequestData.Get <string>("id");
            if (!string.IsNullOrEmpty(id))
            {
                ent = SignRequest.Find(id);
            }
            switch (RequestActionString)
            {
            case "delete":
                if (!string.IsNullOrEmpty(ent.Attachment))
                {
                    foreach (string str in ent.Attachment.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        FileItem fiEnt = FileItem.Find(str);
                        fiEnt.DoDelete();
                    }
                }
                ent.DoDelete();
                break;

            case "submit":
                StartFlow();
                break;

            case "AutoExecuteFlow":
                AutoExecuteFlow();
                break;

            default:
                DoSelect();
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 由fullid获取FileItem
        /// </summary>
        /// <param name="fullId"></param>
        /// <returns></returns>
        public static FileItem GetFileItemByFullID(string fullId)
        {
            string fid = GetFileIDByFullID(fullId);

            FileItem fi = FileItem.Find(fid);

            return(fi);
        }
 private void DoDelete()
 {
     try
     {
         FileItem.Find(ent.VedioFile).DoDelete();
         ent.DoDelete();
     }
     catch
     {
         ent.DoDelete();
     }
 }
Exemplo n.º 5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string fileId = Request.Params["FileId"];

            fileName = Server.UrlDecode(Request.Params["FileMainName"]);
            if (string.IsNullOrEmpty(fileId))
            {
                FileFolder folder = FileFolder.FindAllByProperties(FileFolder.Prop_FolderKey, "Portal")[0];
                FileInfo   file   = new FileInfo(Path.Combine(folder.FolderPath, "Empty.doc"));
                //FileInfo file = new FileInfo(Path.Combine(folder.FolderPath, fileName + ".doc"));
                //string subKey = Request.Params["SubKeyId"];
                //string fileName = Guid.NewGuid().ToString();
                FileItem newfitem = FileService.CreateFileItem(file.FullName, "Portal");
                File.Copy(file.FullName, Path.Combine(folder.FolderPath, FileService.GetFullID(newfitem.Id, newfitem.Name)));
                FileInfo fileN = new FileInfo(Path.Combine(folder.FolderPath, FileService.GetFullID(newfitem.Id, newfitem.Name)));
                fileN.MoveTo(Path.Combine(folder.FolderPath, FileService.GetFullID(newfitem.Id, fileName))); //+ newfitem.ExtName
                newfitem.Name = fileName;                                                                    //+ newfitem.ExtName
                newfitem.Save();
                item = newfitem;
            }
            else
            {
                item = FileItem.Find(fileId);
            }
            string       newFile = item.FilePath;
            BinaryReader bReader = new BinaryReader(Request.InputStream);
            string       strTemp = System.Text.Encoding.GetEncoding("gb2312").GetString(
                bReader.ReadBytes((int)bReader.BaseStream.Length), 0, (int)bReader.BaseStream.Length);
            string match = "Content-Type: application/msword\r\n\r\n";
            int    pos   = strTemp.IndexOf(match) + match.Length;

            bReader.BaseStream.Seek(pos, SeekOrigin.Begin);

            FileStream   newDoc  = new FileStream(newFile, FileMode.Create, FileAccess.Write);
            BinaryWriter bWriter = new BinaryWriter(newDoc);

            bWriter.BaseStream.Seek(0, SeekOrigin.End);


            while (bReader.BaseStream.Position < bReader.BaseStream.Length - 38)
            {
                bWriter.Write(bReader.ReadByte());
            }
            bReader.Close();
            bWriter.Flush();
            bWriter.Close();
            Response.Write(FileService.GetFullID(item.Id, item.Name));
            Response.End();
        }
Exemplo n.º 6
0
        private void Delete()
        {
            string Jarray = Request["Jarray"];

            string[] idArray = Jarray.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < idArray.Length; i++)
            {
                FIEnt = FileItem.Find(idArray[i]);
                if (FIEnt != null)
                {
                    sql = "delete FileItem where id='" + FIEnt.Id + "'";
                    DataHelper.ExecSql(sql);
                    sql = "delete FileFolder where id='" + FIEnt.FolderId + "'";
                    DataHelper.ExecSql(sql);
                }
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                SysUser suEnt  = SysUser.Find(UserInfo.UserID);
                string  action = Request["action"] + "";
                switch (action)
                {
                case "upload":
                    string fileId = Request["fileId"];
                    if (!string.IsNullOrEmpty(suEnt.Ext2))
                    {
                        fiEnt = FileItem.Find(suEnt.Ext2);
                        fiEnt.DoDelete();    //如果存在旧的图像将旧的图像文件删除
                        FileInfo fi = new FileInfo(@"D:\RW\Files\AppFiles\Portal\Default\" + fiEnt.Id + "_" + fiEnt.Name);
                        if (fi.Exists)
                        {
                            fi.Delete();
                        }
                    }
                    suEnt.Ext2 = fileId;
                    suEnt.DoUpdate();
                    Response.Write(fileId);
                    Response.End();
                    break;

                default:
                    if (!string.IsNullOrEmpty(suEnt.Ext2))
                    {
                        fiEnt = FileItem.Find(suEnt.Ext2);
                        this.userimage.Src = @"/Document/" + fiEnt.Id + "_" + fiEnt.Name;
                    }
                    break;
                }
                IniPersonalCenter();
                IniWeather();
                IniNotice();
                IniNews();
                IniMyLink();
                IniTaskWebPart();
                //PromptWin();
            }
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (Request["action"])
            {
            case "load":
                sql = @"select * from FileItem";
                DataTable dt = DataHelper.QueryDataTable(GetPageSql(sql));
                Response.Write("{total:" + totalProperty + ",rows:" + JsonHelper.GetJsonStringFromDataTable(dt) + "}");
                Response.End();
                break;

            case "delete":
                string   id    = Request["id"];
                FileItem fiEnt = FileItem.Find(id);
                File.Delete(@"D:\RW\Files\AppFiles\Portal\Default\" + fiEnt.Name);
                fiEnt.DoDelete();
                Response.Write("{success:true}");
                Response.End();
                break;
            }
        }
Exemplo n.º 9
0
        // 当文件保存在本机时, 由文件Id获取文件路径
        public static string GetFilePathByFileID(string fileid)
        {
            FileItem fitem = FileItem.Find(fileid);

            return(fitem.FilePath);
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Aim.Portal.Web.WebPortalService.CheckLogon();
            }
            catch
            {
                Response.Write("<script> window.parent.location.href = '/Login.aspx';</script>");
                Response.End();
            }
            string    action = Request["action"];
            string    sql    = "";
            DataTable dt     = null;
            string    node   = Request["node"];
            JObject   json   = null;

            if (!string.IsNullOrEmpty(node))
            {
                json = JsonHelper.GetObject <JObject>(node);
            }
            switch (action)
            {
            case "loadtreedata":
                switch (json.Value <string>("level"))
                {
                case "0":
                    sql = @"select GroupID as id,replace(Name,'江西瑞林建设监理有限公司','') as name,GroupID as groupid,'' as projectid,'1' as level,'false' as leaf,
                            '' as firsttypeid,'' as secondtypeid from SysGroup where ParentId='" + json.Value <string>("id") + "' order by Code asc";
                    break;

                case "1":
                    sql = @"select Id as id,projectName as name,'{0}' as groupid,Id as projectid,'' as firsttypeid,'' as secondtypeid,'2' as level,'false' as leaf
                            from NCRL_SP..Project where BelongCmp = 'JL' and BelongDeptId = '{0}'";
                    sql = string.Format(sql, json.Value <string>("id"));
                    break;

                case "2":
                    sql = @"select EnumerationID as id,Name as name,'{0}' as groupid,'{1}' as projectid,EnumerationID as firsttypeid,'' as secondtypeid,'3' as level,'false' as leaf
                            from sysenumeration where parentid='cf38bd7a-79d1-46fb-bf06-640b30f61654' order by SortIndex asc";
                    sql = string.Format(sql, json.Value <string>("groupid"), json.Value <string>("id"));
                    break;

                case "3":
                    sql = @"select EnumerationID as id,Name as name,'{0}' as groupid,'{1}' as projectid,'{2}' as firsttypeid,EnumerationID as secondtypeid,'4' as level,'true' as leaf
                            from sysenumeration where ParentID='{3}'";
                    sql = string.Format(sql, json.Value <string>("groupid"), json.Value <string>("projectid"), json.Value <string>("firsttypeid"), json.Value <string>("id"));
                    break;
                }
                dt = DataHelper.QueryDataTable(sql);
                Response.Write(JsonHelper.GetJsonStringFromDataTable(dt));
                Response.End();
                break;

            case "loadfile":
                switch (json.Value <string>("level"))
                {
                case "0":        //加载所有文档
                    sql = @"select a.Id,a.Name,a.CreatorName as CreateName,a.CreateTime,b.ProjectName,C.Name SecondTypeName,d.Path as FolderName from FileItem a 
                            left join NCRL_SP..Project b on a.ProjectId=b.Id 
                            left join SysEnumeration c on a.SecondTypeId=c.EnumerationId
                            left join FileFolder d on a.FolderId=d.Id where b.BelongCmp='JL'";
                    break;

                case "1":        //加载某一部门的文档
                    sql = @"select a.Id,a.Name,a.CreatorName as CreateName,a.CreateTime,b.ProjectName,C.Name SecondTypeName,d.Path as FolderName from FileItem a 
                            left join NCRL_SP..Project b on a.ProjectId=b.Id 
                            left join SysEnumeration c on a.SecondTypeId=c.EnumerationId
                            left join FileFolder d on a.FolderId=d.Id where  b.BelongCmp='JL' and a.GroupId='" + json.Value <string>("id") + "'";
                    break;

                case "2":        //加载某一项目的文档
                    sql = @"select a.Id,a.Name,a.CreatorName as CreateName,a.CreateTime,b.ProjectName,C.Name SecondTypeName,d.Path as FolderName from FileItem a 
                            left join NCRL_SP..Project b on a.ProjectId=b.Id 
                            left join SysEnumeration c on a.SecondTypeId=c.EnumerationId
                            left join FileFolder d on a.FolderId=d.Id where  a.ProjectId='" + json.Value <string>("projectid") + "'";
                    break;

                case "3":        //加载某一项目某一大类文档
                    sql = @"select a.Id,a.Name,a.CreatorName as CreateName,a.CreateTime,b.ProjectName,C.Name SecondTypeName,d.Path as FolderName from FileItem a 
                            left join NCRL_SP..Project b on a.ProjectId=b.Id 
                            left join SysEnumeration c on a.SecondTypeId=c.EnumerationId
                            left join FileFolder d on a.FolderId=d.Id where a.ProjectId='{0}' and  a.FirstTypeId='{1}'";
                    sql = string.Format(sql, json.Value <string>("projectid"), json.Value <string>("firsttypeid"));
                    break;

                case "4":        //加载某一项目某一大类的某一小类文档
                    sql = @"select a.Id,a.Name,a.CreatorName as CreateName,a.CreateTime,b.ProjectName,C.Name SecondTypeName,d.Path as FolderName from FileItem a 
                            left join NCRL_SP..Project b on a.ProjectId=b.Id 
                            left join SysEnumeration c on a.SecondTypeId=c.EnumerationId
                            left join FileFolder d on a.FolderId=d.Id where a.ProjectId='{0}' and  a.FirstTypeId='{1}' and a.SecondTypeId='{2}'";
                    sql = string.Format(sql, json.Value <string>("projectid"), json.Value <string>("firsttypeid"), json.Value <string>("secondtypeid"));
                    break;

                case "5":
                    string filename        = Request["filename"];
                    string projectnamecode = Request["projectnamecode"];
                    string where = "";
                    if (!string.IsNullOrEmpty(filename))
                    {
                        where += " and a.Name like '%" + filename + "%'";
                    }
                    if (!string.IsNullOrEmpty(projectnamecode))
                    {
                        where += " and (b.ProjectName like '%" + projectnamecode + "%' or b.ProjectCode like '%" + projectnamecode + "%')";
                    }
                    sql = @"select a.Id,a.Name,a.CreatorName as CreateName,a.CreateTime,b.ProjectName,C.Name SecondTypeName,d.Path as FolderName from FileItem a 
                                left join NCRL_SP..Project b on a.ProjectId=b.Id 
                                left join SysEnumeration c on a.SecondTypeId=c.EnumerationId
                                left join FileFolder d on a.FolderId=d.Id where 1=1 " + where;
                    break;
                }
                dt = DataHelper.QueryDataTable(GetPageSql(sql));
                Response.Write("{'rows':" + JsonHelper.GetJsonStringFromDataTable(dt) + ",total:'" + totalProperty + "'}");
                Response.End();
                break;

            case "delete":
                string     fileid = Request["fileid"];
                FileItem   fiEnt  = FileItem.Find(fileid);
                FileFolder ffEnt  = FileFolder.Find(fiEnt.FolderId);
                if (File.Exists(@"D:\RW\Files\AppFiles\Portal\" + ffEnt.Path + @"\" + fiEnt.Id + "_" + fiEnt.Name))
                {
                    File.Delete(@"D:\RW\Files\AppFiles\Portal\" + ffEnt.Path + @"\" + fiEnt.Id + "_" + fiEnt.Name);
                }
                fiEnt.DoDelete();
                Response.Write("{success:true}");
                Response.End();
                break;
            }
        }