Пример #1
0
        /// <summary>
        /// 后台管理员删除审核未通过或已下线文档
        /// </summary>
        private void DeleteWenKu()
        {
            int id;

            if (!int.TryParse(nv["id"], out id))
            {
                HttpContext.Current.Response.Write("参数错误");
                return;
            }
            E_WenKu data = new E_WenKu();

            data.WenKuID = id;
            data         = new T_WenKu().GetModel(data);
            string filename = data.FileUrl;
            bool   flag     = new T_WenKu().Delete(data);

            if (flag)//如果删除成功,则删掉对应的物理文件
            {
                string path = MLMGC.COMP.Config.GetWenKu(filename);
                if (File.Exists(path))//判断原文件是否存在
                {
                    File.Delete(path);
                }
                string swfpath = MLMGC.COMP.Config.GetWenKu("swf\\" + filename.Substring(0, filename.LastIndexOf(".")) + ".swf");
                if (File.Exists(swfpath)) //判断swf文件是否存在
                {
                    File.Delete(swfpath);
                }
            }
            HttpContext.Current.Response.Write(flag ? "1" : "0");
        }
Пример #2
0
        protected void databind()
        {
            //获取文库编号
            int id;
            if (!int.TryParse(Request["id"], out id))
            {
                Jscript.AlertAndRedirect(this, "参数错误", "List.aspx");
                return;
            }

            //根据编号获取文库详情
            E_WenKu data = new E_WenKu();
            data.WenKuID = id;
            data = new T_WenKu().GetModel(data);
            if (data == null)
            {
                Jscript.ShowMsg("未获取对象", this);
                return;
            }
            //判断swf文件是否存在,若不存在,则直接返回
            string flashpath = MLMGC.COMP.Config.GetWenKu("swf\\" + data.FileUrl.Substring(0, data.FileUrl.LastIndexOf(".")) + ".swf");
            
            if (!File.Exists(flashpath))
            {
                Jscript.CloseWindow("对应的文件未找到:"+flashpath);
                return;
            }

            lblCaption.Text = data.Caption;
            lblIntro.Text = data.Intro;
            lblKeyword.Text = data.Keywords;
            lblSize.Text = MLMGC.COMP.CommonMethod.FileSize(data.FileSize);
            FlashUrl = Config.GetWenKuUrl("swf/"+data.FileUrl.Substring(0, data.FileUrl.LastIndexOf(".")) + ".swf");
        }
Пример #3
0
        /// <summary>
        /// 添加下载记录
        /// </summary>
        private void Download()
        {
            //获取文库id
            int    id;
            string usertype = nv["usertype"];

            if (!int.TryParse(nv["id"], out id))
            {
                HttpContext.Current.Response.Write("参数错误");
                return;
            }
            E_WenKuDownload data = new E_WenKuDownload();

            data.WenKuID = id;
            //判断用户类型:1=企业用户,2=个人用户
            if (usertype == "1")
            {
                MLMGC.Security.EnterprisePage ep = new MLMGC.Security.EnterprisePage(true);
                data.UserID       = ep.UserID;
                data.EnterpriseID = ep.EnterpriceID;
                data.UserType     = MLMGC.DataEntity.User.UserType.企业用户;
            }
            else
            {
                MLMGC.Security.PersonalPage pp = new MLMGC.Security.PersonalPage(true);
                data.UserID   = pp.UserID;
                data.UserType = MLMGC.DataEntity.User.UserType.个人用户;
            }

            bool flag = new T_WenKuDownload().Add(data);
            //声明返回json对象
            JsonObjectCollection colDR = new JsonObjectCollection();

            colDR.Add(new JsonStringValue("flag", flag ? "1" : "0"));

            //成功添加数据之后 再次获取原文件的地址。
            E_WenKu dataW = new T_WenKu().GetModel(new E_WenKu()
            {
                WenKuID = id
            });

            if (dataW != null)
            {
                colDR.Add(new JsonStringValue("url", MLMGC.COMP.Config.GetWenKuUrl(dataW.FileUrl)));
            }

            HttpContext.Current.Response.Write(colDR.ToString());
        }
Пример #4
0
        /// <summary>
        /// 修改文库审核状态
        /// </summary>
        private void UpdateStatus()
        {
            int    status;
            string ids = nv["ids"];

            if (!int.TryParse(nv["status"], out status) || !MLMGC.COMP.StringUtil.IsStringArrayList(ids))
            {
                HttpContext.Current.Response.Write("参数错误");
                return;
            }
            E_WenKu data = new E_WenKu();

            data.WenKuIDs      = ids;
            data.SetStatusFlag = status;
            bool flag = new T_WenKu().UpdateStatus(data);

            HttpContext.Current.Response.Write(flag ? "1" : "0");
        }
Пример #5
0
        /// <summary>
        /// 判断上传的文档是否存在
        /// </summary>
        private void Exists()
        {
            string filename = nv["filename"];

            if (string.IsNullOrWhiteSpace(filename))
            {
                HttpContext.Current.Response.Write("参数错误");
                return;
            }

            E_WenKu data = new E_WenKu();

            data.FileName = filename;

            bool flag = new T_WenKu().Exists(data);

            HttpContext.Current.Response.Write(flag ? "1" : "0");
        }
Пример #6
0
        /// <summary>
        /// 批量删除文库
        /// </summary>
        private void BatchDelete()
        {
            string ids = nv["ids"];

            if (!MLMGC.COMP.StringUtil.IsStringArrayList(ids))//判断格式是否正确 格式:1,21,321
            {
                HttpContext.Current.Response.Write("参数错误");
                return;
            }

            E_WenKu data = new E_WenKu();

            data.WenKuIDs = ids;
            DataTable dt   = new T_WenKu().BatchDelete(data);
            bool      flag = false;

            if (dt != null)
            {
                if (dt.Rows[0]["WenKuID"].ToString() == "-1")//删除失败
                {
                }
                else
                {
                    //循环删除物理文件
                    foreach (DataRow row in dt.Rows)
                    {
                        string filename = row["FileUrl"].ToString();
                        string path     = MLMGC.COMP.Config.GetWenKu(filename);
                        if (File.Exists(path))//判断原文件是否存在
                        {
                            File.Delete(path);
                        }
                        string swfpath = MLMGC.COMP.Config.GetWenKu("swf\\" + filename.Substring(0, filename.LastIndexOf(".")) + ".swf");
                        if (File.Exists(swfpath)) //判断swf文件是否存在
                        {
                            File.Delete(swfpath);
                        }
                    }
                    flag = true;
                }
            }

            HttpContext.Current.Response.Write(flag ? "1" : "0");
        }
Пример #7
0
        protected void databind()
        {
            //加载文件基本信息
            int id = Requests.GetQueryInt("id", 0);

            E_Material data = new E_Material();

            data.MaterialID   = id;
            data.EnterpriseID = EnterpriceID;
            data              = new T_Material().GetModel(data);
            txtCaption.Text   = data.MaterialName;
            hlUrl.Text        = data.FileName;
            hlUrl.NavigateUrl = MLMGC.COMP.Config.GetEnterpriseMaterialUrl(EnterpriceID, data.Url);
            //用隐藏域存储附件信息
            hfFile.Value = string.Format("{0}|{1}|{2}|{3}", data.FileName, data.FileType, data.FileSize, data.Url);

            //验证要共享的文件是否存在,若存在则不能共享
            bool flag = new T_WenKu().Exists(new E_WenKu()
            {
                FileName = data.FileName
            });

            if (flag)
            {
                Jscript.AlertAndRedirect(this, "该文档已存在无法共享", "../Material/MaterialList.aspx");
                return;
            }


            //获取文库目录分类
            DataTable dt = new T_WenKuClass().GetList();

            if (dt == null)
            {
                return;
            }
            foreach (DataRow row in dt.Rows)
            {
                ddlCategory.Items.Add(new ListItem(row["WenKuClassName"].ToString(), row["WenKuClassID"].ToString()));
            }
            //绑定目录分类
            ddlCategory.Items.Add(new ListItem("其它", "0"));
        }
Пример #8
0
        /// <summary>
        /// 转换文档
        /// </summary>
        private void Convert()
        {
            string ids = nv["ids"];

            if (!MLMGC.COMP.StringUtil.IsStringArrayList(ids))//判断格式是否正确 格式:1,21,321
            {
                HttpContext.Current.Response.Write("参数错误");
                return;
            }

            E_WenKu data = new E_WenKu();

            data.WenKuIDs = ids;

            ///获取要转换的文库列表
            DataTable dt = new T_WenKu().ConvertList(data);

            try
            {
                foreach (DataRow row in dt.Rows)
                {
                    //先检测要创建的txt文本是否存在,若存在则删除
                    string path = MLMGC.COMP.Config.MonitorFilePath + row["WenKuID"].ToString() + ".txt";
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    //再创建 转换文档为swf
                    System.IO.FileStream   fs = new System.IO.FileStream(path, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                    System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
                    sw.WriteLine(string.Format("\r\n{0}|{1}", row["WenKuID"], row["FileUrl"]));
                    sw.Close();
                    fs.Close();
                }
                HttpContext.Current.Response.Write("1");
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write("0");
            }
        }
Пример #9
0
        /// <summary>
        /// 点击上传按钮处理事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string caption = txtCaption.Text.Trim();
            string intro   = txtIntro.Text.Trim();
            string keyword = txtKeyword.Text.Trim();
            string custom  = txtCustom.Text.Trim();
            int    value   = Convert.ToInt32(ddlCategory.SelectedValue);

            if (string.IsNullOrEmpty(caption))
            {
                Jscript.ShowMsg("请输入标题", this);
                return;
            }
            if (value == -1 && string.IsNullOrWhiteSpace(custom))
            {
                Jscript.ShowMsg("请输入自定义分类", this);
                return;
            }

            //获取附件基本信息
            string attach = hfFile.Value;

            string[] arr = attach.Split('|');
            if (arr.Length == 0)
            {
                return;
            }

            if (Convert.ToInt64(arr[2]) > sizelimit)
            {
                Jscript.ShowMsg("文件过大无法共享!", this);
                return;
            }

            //1.-------拷贝对象资料到WenKu目录-------
            //原文件的物理路径
            string filepath = MLMGC.COMP.Config.GetEnterpriseS(EnterpriceID, arr[3]);

            if (File.Exists(filepath))
            {
                //目标文件的物理路径
                string destpath = MLMGC.COMP.Config.GetWenKu(arr[3]);
                File.Copy(filepath, destpath, true);//拷贝原文件
            }
            //-----------------------------------

            //2.----------插入WenKu数据------------
            E_WenKu data = new E_WenKu();

            data.EnterpriseID    = EnterpriceID;
            data.UserID          = 0;
            data.Caption         = caption;
            data.Intro           = intro;
            data.Keywords        = keyword;
            data.WenKuClassID    = value;
            data.CustomClassName = custom;
            data.UserType        = MLMGC.DataEntity.User.UserType.企业用户;

            data.FileName     = arr[0];
            data.SetFileType2 = arr[1];
            data.FileSize     = Convert.ToInt32(arr[2]);
            data.FileUrl      = arr[3];
            data.StatusFlag   = EnumStatusFlag.待审核;

            bool flag = new T_WenKu().Add(data);

            //--------------------------------------------

            if (flag) //如果成功则继续
            {
                //3.-------------修改数据库,标识该资料已被共享------------------
                E_Material dataM = new E_Material();
                dataM.EnterpriseID = EnterpriceID;
                dataM.MaterialID   = Requests.GetQueryInt("id", 0);
                dataM.WenKuFlag    = EnumWenKuFlag.待审核;
                dataM.WenKuID      = data.WenKuID;

                flag = new T_Material().Share(dataM);
                //-------------------------------------------------------------

                //4.--------------------修改监控文件 生成swf文件-------------------
                //转换文档为swf
                System.IO.FileStream   fs = new System.IO.FileStream(MLMGC.COMP.Config.MonitorFilePath + data.WenKuID.ToString() + ".txt", System.IO.FileMode.Create, System.IO.FileAccess.Write);
                System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
                sw.WriteLine(string.Format("\r\n{0}|{1}", data.WenKuID, arr[3]));
                sw.Close();
                fs.Close();
                //----------------------------------------------------
            }

            if (flag)
            {
                Jscript.AlertAndRedirect(this, "共享成功", "/enterprise/material/studymateriallist.aspx");
            }
            else
            {
                Jscript.ShowMsg("共享失败", this);
            }
        }
Пример #10
0
        /// <summary>
        /// 点击上传按钮处理事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string caption = txtCaption.Text.Trim();
            string intro   = txtIntro.Text.Trim();
            string keyword = txtKeyword.Text.Trim();
            string custom  = txtCustom.Text.Trim();
            int    value   = Convert.ToInt32(ddlCategory.SelectedValue);

            if (string.IsNullOrEmpty(caption))
            {
                Jscript.ShowMsg("请输入标题", this);
                return;
            }
            if (value == -1 && string.IsNullOrWhiteSpace(custom))
            {
                Jscript.ShowMsg("请输入自定义分类", this);
                return;
            }

            //上传文件
            List <PFileInfo> list = FileUpload1.Upload();

            if (list == null || list.Count == 0)
            {
                MLMGC.COMP.Jscript.ShowMsg("上传文件失败", this);
                return;
            }

            //--------判断该文件是否已存在--------
            bool b = new T_WenKu().Exists(new E_WenKu()
            {
                FileName = list[0].FileName
            });

            if (b)
            {
                Jscript.ShowMsg("该文件已存在", this);
                return;
            }
            //-----------------------------------

            E_WenKu data = new E_WenKu();

            data.UserType        = MLMGC.DataEntity.User.UserType.个人用户;
            data.UserID          = UserID;
            data.Caption         = caption;
            data.Intro           = intro;
            data.Keywords        = keyword;
            data.WenKuClassID    = value;
            data.CustomClassName = custom;

            data.SetFileType2 = list[0].FileType;
            data.FileName     = list[0].FileName;
            data.FileUrl      = list[0].FileAddress;
            data.FileSize     = Convert.ToInt32(list[0].FileSize);
            data.StatusFlag   = EnumStatusFlag.待审核;

            bool flag = new T_WenKu().Add(data);

            if (flag)
            {
                try
                {
                    //转换文档为swf
                    System.IO.FileStream   fs = new System.IO.FileStream(MLMGC.COMP.Config.MonitorFilePath + data.WenKuID.ToString() + ".txt", System.IO.FileMode.Create, System.IO.FileAccess.Write);
                    System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
                    sw.WriteLine(string.Format("\r\n{0}|{1}", data.WenKuID, list[0].FileAddress));
                    sw.Close();
                    fs.Close();
                }
                catch
                {
                }
            }
            if (flag)
            {
                Jscript.AlertAndRedirect(this, "上传成功", "Add.aspx");
            }
            else
            {
                Jscript.ShowMsg("上传失败!", this);
            }
        }