예제 #1
0
        public object DownFileData(int Restype, long SeqID, string ColumnName)
        {
            if (userLoginManager.LoginUser == null || userLoginManager.LoginUser.UserID < 1)
                return new { Rcode = -2, Rdata = "未登录" };

            string userIP = null;

            string tablename, serviceno, orderno;
            int costtype;
            decimal m_price, m_discount;
            int status = BaseBLL.GetFullPathResourceCheckCost(Restype, SeqID, userLoginManager.LoginUser.UserID, userLoginManager.LoginUser.Customerid, userIP, out tablename, out costtype, out m_price, out m_discount, out serviceno, out orderno, out errmsg);
            if (status == -1)
                return new { Rcode = -1, Rmsg = errmsg };

            if (status == 0)
                return new { Rcode = -3, Rmsg = "此资源需要付费才能下载,现在去付费", Rdata = orderno };

            BookInfo bookinfo = ResourcesBLL.GetFilePath(tablename, SeqID, 0, ColumnName, out errmsg);
            if (!string.IsNullOrEmpty(errmsg) || bookinfo == null)
                return new { Rcode = -1, Rmsg = "获取资源数据错误" + errmsg };
            if (string.IsNullOrEmpty(bookinfo.BookPath))
            {
                return new { Rcode = -1, Rmsg = "资源文件路径不存在" };
            }
            string pdffile = string.Format("{0}{1}", GlobalParameters.RootFilePath, bookinfo.BookPath).Replace("//", "/").Replace("/", "\\");
            if (!File.Exists(pdffile))
            {
                return new { Rcode = -1, Rmsg = "资源文件不存在" };
            }
            string filecode = StrFormatClass.Encrypt(bookinfo.BookPath + DateTime.Now.ToString("yyyyMMddHHmmss"), ref errmsg);
            return new { Rcode = 1, Rdata = filecode };
        }
예제 #2
0
 private void showOldResInfo(int resid)
 {
     try
     {
         ResourcesBLL  resource = new ResourcesBLL();
         ResourceModel res      = resource.GetResourcesById(resid);
         ViewState["ResID"]   = resid;
         this.txtResName.Text = res.ResName;
         this.txtjianjie.Text = res.ResDescription;
     }
     catch (Exception)
     {
     }
 }
예제 #3
0
    protected void btnDownExcel_Click(object sender, EventArgs e)
    {
        Response.AppendHeader("Content-Disposition", "attachment;filename=registerStore.xls");
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");

        ResourcesBLL resource = new ResourcesBLL();
        DataTable    dt       = resource.GetTableForExcel(ViewState["pagewhere"].ToString());

        StringBuilder sb = Excel.GetExcelTable(dt, GetTran("000653", "资料下载表"), new string[] { "ResName=" + GetTran("000204", "资料名称"), "FileName=" + GetTran("000278", "对应文件名"), "ResDescription=" + GetTran("000280", "资料简介"), "ResSize=" + GetTran("000282", "文件大小"), "ResTimes=" + GetTran("000287", "下载次数") });

        Response.Write(sb.ToString());
        Response.Flush();
        Response.End();
    }
예제 #4
0
    /// <summary>
    /// 检查文件名字
    /// </summary>
    /// <returns></returns>
    ///
    private bool CheckFileNames()
    {
        if (this.txtResName.Text.Trim() == "")
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + GetTran("001510", "资料名不能为空") + "!')", true);
            return(false);
        }
        ResourcesBLL resoucres = new ResourcesBLL();

        if (resoucres.CheckReourceResname(DisposeString.DisString(this.txtResName.Text.Trim().Trim())))
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + GetTran("001512", "存在同名资料") + "!')", true);
            return(false);
        }
        return(true);
    }
예제 #5
0
    private void UpdateResInfo(string resname, string filename, string resdes, string ressize)
    {
        ResourceModel res = new ResourceModel();

        res.ResID          = Convert.ToInt32(ViewState["ResID"].ToString());
        res.ResDateTime    = DateTime.Now.ToUniversalTime();
        res.ResDescription = resdes;
        res.ResName        = resname;
        res.ResSize        = ressize;
        res.FileName       = filename;
        res.DownTarget     = Convert.ToInt32(this.DropDownList2.SelectedValue);
        res.DownMenberLev  = Convert.ToInt32(this.DropDownList3.SelectedValue);
        ResourcesBLL resource = new ResourcesBLL();

        resource.UpdateResource(res);
    }
예제 #6
0
    /// <summary>
    /// 上传文件方法
    /// </summary>
    /// <param name="resname"></param>
    /// <param name="filename"></param>
    /// <param name="resdes"></param>
    /// <param name="ressize"></param>
    /// <param name="datetime"></param>
    private void RecordResInfo(string resname, string filename, string resdes, string ressize, string datetime)
    {
        ResourceModel res = new ResourceModel();

        res.ResDateTime    = DateTime.Now.ToUniversalTime();
        res.ResDescription = resdes;
        res.ResName        = resname;
        res.ResSize        = ressize;
        res.FileName       = filename;
        res.CPPCode        = Convert.ToInt32(this.DropDownList1.SelectedValue);
        res.DownMenberLev  = Convert.ToInt32(this.DropDownList3.SelectedValue);
        res.DownTarget     = Convert.ToInt32(this.DropDownList2.SelectedValue);
        ResourcesBLL resource = new ResourcesBLL();

        if (resource.InsertResource(res))
        {
            labUpInfo.Text = GetTran("001506", "上传成功") + "!!!";
        }
        else
        {
            labUpInfo.Text = GetTran("001508", "上传失败") + "!!!";
        }
    }
예제 #7
0
        public object GetItemQsEchart(int year, int wordnum = 0)
        {
            int    total;
            string errmsg;
            List <base_itemcontents> list = BLL.BaseBLL.GetItemContents("wx_yjqspicdata", false, 0, 10000, out total, out errmsg);

            if (year > 0)
            {
                list = list.FindAll(o => o.aboutdate == year.ToString());
            }
            Dictionary <string, int> wordlist  = new Dictionary <string, int>();
            Dictionary <string, int> nexuslist = new Dictionary <string, int>();
            List <EchartNode>        nodes     = new List <EchartNode>(); // category,name,value,label
            List <EchartLink>        links     = new List <EchartLink>(); // source,target,weight,name
            Random rand = new Random();

            foreach (base_itemcontents itemcontents in list)
            {
                if (!wordlist.ContainsKey(itemcontents.title))
                {
                    wordlist.Add(itemcontents.title, 1);
                    nodes.Add(new EchartNode()
                    {
                        category = itemcontents.author,
                        name     = itemcontents.title,
                        //   value = 1,
                        symbolSize = 1
                    });
                }
            }
            base_itemcontents tcon;

            foreach (EchartNode node in nodes)
            {
                tcon = list.Find(o => o.title == node.name);
                if (tcon != null && !string.IsNullOrEmpty(tcon.abstracts))
                {
                    foreach (string word in tcon.abstracts.Split('|'))
                    {
                        if (word.Length > 0 && wordlist.ContainsKey(word))
                        {
                            links.Add(new EchartLink()
                            {
                                weight = 1,
                                name   = "",
                                source = tcon.title,
                                target = word
                            });
                        }
                    }
                }
            }
            foreach (EchartNode node in nodes)
            {
                node.value = node.symbolSize = links.FindAll(o => o.source == node.name).Count;
            }
            if (wordnum > 0 && wordnum < nodes.Count)
            {
                nodes.Sort(delegate(EchartNode x, EchartNode y)
                {
                    return(y.value.CompareTo(x.value));
                });
                nodes = nodes.Take(wordnum).ToList <EchartNode>();
            }
            EchartLink tlink;
            EchartNode tsnode;
            EchartNode ttnode;

            for (int i = 0; i < links.Count; i++)
            {
                tlink  = links[i];
                tsnode = nodes.Find(o => o.name == tlink.source);
                ttnode = nodes.Find(o => o.name == tlink.target);
                if (tsnode == null || ttnode == null)
                {
                    links.Remove(tlink);
                    continue;
                }
                int count = links.FindAll(o => o.source == ttnode.name && o.target == tsnode.name).Count;
                if (count > 0)
                {
                    tlink.weight = tlink.weight * count + 2;
                }
                if (tsnode.category == ttnode.category)
                {
                    tlink.weight = tlink.weight * 8;
                }
            }
            DataTable     restable = ResourcesBLL.GetResTypeList(out errmsg);
            List <object> reslist  = new List <object>();

            foreach (DataRow dr in restable.Rows)
            {
                reslist.Add(new
                {
                    name  = dr["databasecname"].ToString(),
                    value = dr["databaseid"].ToString()
                });
            }
            return(new { nodes = nodes, links = links, categoryes = reslist });
        }
예제 #8
0
    protected void givshowFile_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int           id        = Convert.ToInt32(e.CommandArgument.ToString());
        ResourcesBLL  resource  = new ResourcesBLL();
        ResourceModel resuouces = resource.GetResourcesById(id);

        if (resuouces == null)
        {
            ScriptHelper.SetAlert(givshowFile, GetTran("001332", "该资料可能已经不存在") + "!!!");
            return;
        }

        if (e.CommandName.ToLower().Trim() == "del")
        {
            try
            {
                //从文件夹中删除指定的文件
                string path = Server.MapPath(@"..\company\upLoadRes\") + resuouces.FileName;

                System.IO.FileInfo file = new System.IO.FileInfo(path);
                if (file.Exists)
                {
                    file.Delete();
                }

                //删除数据库中文件的信息

                resource.DelResurces(Convert.ToInt32(id));
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("000008", "删除成功") + "!');</script>");
                PageBind();
            }
            catch
            {
            }
        }
        else if (e.CommandName.ToLower().Trim() == "download")
        {
            try
            {
                string             dlDir = "upLoadRes/";
                string             path  = Server.MapPath(dlDir + resuouces.FileName);
                System.IO.FileInfo file  = new System.IO.FileInfo(path);
                if (file.Exists)
                {
                    //修改最后下载时间
                    //  ResourcesBLL resource = new ResourcesBLL();
                    resource.UpdateResutcesResTime(Convert.ToInt32(id));

                    PageBind();

                    Response.Clear();
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(file.Name).Replace('+', ' '));
                    Response.AddHeader("Content-Length", file.Length.ToString());
                    Response.AddHeader("Content-Transfer-Encoding", "binary");
                    Response.ContentType     = "application/octet-stream";
                    Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                    Response.WriteFile(file.FullName);
                    Response.Flush();
                    Response.End();
                    string wheret = ViewState["pagewhere"].ToString();
                    Pager  pager  = Page.FindControl("Pager1") as Pager;
                    pager.PageBind(0, 10, "Resources", "ResID, ResName, FileName, ResDescription, ResSize, ResDateTime, ResTimes", wheret, "ResID", "givshowFile");
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + GetTran("000666", "您下载的文件不在文件夹中") + "!');</script>");
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                PageBind();
            }
        }
    }
예제 #9
0
        public object GetBookInfo(BookParm book)
        {
            string errmsg = null;

            if (book == null || book.did < 1 || book.sid < 1 || book.pid < 0)
            {
                return(new { Rcode = -1, Rmsg = "参数错误" });
            }
            if (userLoginManager.LoginUser == null || userLoginManager.LoginUser.UserID < 1)
            {
                return new { Rcode = -2, Rmsg = "未登录" }
            }
            ;
            string userIP = null;

            string  tablename, serviceno, orderno;
            int     costtype;
            decimal m_price, m_discount;
            int     status = BaseBLL.GetFullPathResourceCheckCost(book.did, book.sid, userLoginManager.LoginUser.UserID, userLoginManager.LoginUser.Customerid, userIP, out tablename, out costtype, out m_price, out m_discount, out serviceno, out orderno, out errmsg);

            if (status == -1)
            {
                return new { Rcode = -1, Rmsg = errmsg }
            }
            ;

            if (status == 0)
            {
                return new { Rcode = -3, Rmsg = "此资源需要付费才能在线阅读,现在去付费", Rdata = orderno }
            }
            ;

            BookInfo bookinfo = ResourcesBLL.GetFilePath(tablename, book.sid, book.pid, "fullpath", out errmsg);

            if (!string.IsNullOrEmpty(errmsg) || bookinfo == null)
            {
                return new { Rcode = -1, Rmsg = "获取资源数据错误" + errmsg }
            }
            ;
            if (string.IsNullOrEmpty(bookinfo.BookPath))
            {
                return(new { Rcode = -1, Rmsg = "资源文件路径不存在" });
            }
            string pdffile = string.Format("{0}{1}", GlobalParameters.RootFilePath, bookinfo.BookPath).Replace("//", "/").Replace("/", "\\");

            if (!File.Exists(pdffile))
            {
                return(new { Rcode = -1, Rmsg = "资源文件不存在" });
            }
            if (!Path.GetExtension(pdffile).Equals(".pdf", StringComparison.CurrentCultureIgnoreCase))
            {
                return(new { Rcode = -1, Rmsg = "此资源非在线阅读资源,请直接下载" });
            }
            BookInfo info = new BookInfo();

            info.IsCopy = false;
            info.IsDown = false;
            info.IsFind = false;

            string swfpath = Path.GetDirectoryName(pdffile) + "\\swf";

            if (!Directory.Exists(swfpath))
            {
                return(new { Rcode = -1, Rmsg = "资源文件未转换" });
            }
            string[] files = Directory.GetFiles(swfpath, "*.swf");
            if (files.Length == 0)
            {
                return(new { Rcode = -1, Rmsg = "资源文件未转换或转换失败" });
            }
            info.LimitPage = bookinfo.LimitPage;
            info.PageCount = files.Length;
            info.Domain    = string.Format("http://{0}", HttpContext.Current.Request.Url.Authority);
            info.BookPath  = Path.GetDirectoryName(bookinfo.BookPath) + "/swf";
            string[] fiarr = Directory.GetFiles(Path.GetDirectoryName(pdffile), "*.xml");
            if (fiarr.Length > 0)
            {
                try
                {
                    //解析xml目录文件

                    //string xmlstr = File.ReadAllText(fiarr[0]);
                    //XmlDocument xmldoc = new XmlDocument();
                    //xmldoc.LoadXml(xmlstr);
                    //XmlElement rootnode = (XmlElement)xmldoc.SelectSingleNode("Bookmark");
                    //RIPS.BaseModels.Options options = new RIPS.BaseModels.Options() { id = "0", text = "", children = new List<RIPS.BaseModels.Options>() };
                    //int idnum = 0;
                    //getChildren(rootnode, options, idnum);
                    //info.ThemeStr = options.children;
                }
                catch (Exception ex)
                {
                    info.ThemeStr = null;
                }
            }
            return(new { Rcode = 1, Rdata = info });
        }

        //private static void getChildren(XmlElement element, RIPS.BaseModels.Options option, int idnum)
        //{
        //    option.children = new List<RIPS.BaseModels.Options>();
        //    RIPS.BaseModels.Options op;
        //    string text;
        //    foreach (object obja in element.ChildNodes)
        //    {
        //        if (obja.GetType() == typeof(XmlElement))
        //        {
        //            XmlElement el = (XmlElement)obja;
        //            if (el.FirstChild != null)
        //                text = el.FirstChild.Value;
        //            else
        //                text = el.InnerText;
        //            text = text.Replace("\r\n", "");
        //            op = new RIPS.BaseModels.Options() { id = idnum.ToString() + "_" + el.GetAttribute("Page"), text = text, children = new List<RIPS.BaseModels.Options>() };
        //            idnum++;
        //            option.children.Add(op);
        //            if (el.ChildNodes.Count > 0)
        //            {
        //                getChildren(el, op, idnum);
        //            }
        //        }
        //    }
        //}
    }
}
예제 #10
0
    protected void btnUpLoad_Click(object sender, EventArgs e)
    {
        ResourcesBLL resources = new ResourcesBLL();

        string mfileName = "";

        if (this.txtjianjie.Text.Trim().Length > 50)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + GetTran("001502", "输入的简介超过50个字符") + "')");
            return;
        }

        if (this.txtResName.Text.Trim() == "")
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("006938", "资料名称和资料简介不能为空!") + "')</script>");
            return;
        }

        if (!System.IO.Directory.Exists(Server.MapPath("~/Company/upLoadRes/")))
        {
            System.IO.Directory.CreateDirectory(Server.MapPath("~/Company/upLoadRes/") + "\\");
        }

        if (Request.QueryString["action"] != "edit")
        {
            string filepath = upFile.PostedFile.FileName;//获取要上传的文件的说有字符,包括文件的路径,文件的名称文件的扩展名称

            //验证上传文件后缀名
            string s = filepath.Substring(filepath.LastIndexOf(".") + 1);
            s = s.ToLower();
            if (s != "rar" && s != "zip")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('您上传的文件格式不正确,请重新上传!')</script>");
                return;
            }


            try
            {
                string mPath = Server.MapPath("~/Company/upLoadRes/");
                mfileName = filepath.Substring(filepath.LastIndexOf("\\") + 1);

                if (mfileName.Length > 30)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('资料文件名不得大于30个字符!')</script>");
                }
                else
                {
                    int sizeLength = upFile.PostedFile.ContentLength;
                    if (sizeLength > 4 * 1024 * 1024)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "alert('上传文件不能超过4MB')", true);
                        return;
                    }
                    string ressize;//文件大小
                    if (sizeLength <= 1203)
                    {
                        ressize = upFile.PostedFile.ContentLength.ToString() + "B";
                    }
                    else
                    {
                        ressize = Convert.ToString(upFile.PostedFile.ContentLength / 1204) + "K";
                    }

                    string resname  = this.txtResName.Text.Trim();
                    string filename = filepath.Substring(filepath.LastIndexOf("\\") + 1);
                    string resdes   = this.txtjianjie.Text.Trim();


                    string realName = DateTime.Now.Millisecond.ToString() + mfileName;
                    upFile.PostedFile.SaveAs(mPath + "\\" + realName);

                    if (CheckFileForm(mPath + "\\" + realName) <= 0)
                    {
                        File.Delete(mPath + "\\" + realName);
                        ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + GetTran("000823", "上传文件格式不正确!") + "');", true);
                        return;
                    }//图片文件上传后进行压缩再删除原有图片
                    else if (CheckFileForm(mPath + "\\" + realName) == 2)
                    {
                        ZipClass zc       = new ZipClass();
                        string   err      = "";
                        string   zipPath1 = mPath + realName;
                        string   zipPath  = zipPath1.Replace(zipPath1.Substring(zipPath1.LastIndexOf(".") + 1), "rar");
                        realName = realName.Replace(realName.Substring(realName.LastIndexOf(".") + 1), "rar");
                        bool res = zc.ZipFile(zipPath1, zipPath, out err);
                        if (res)
                        {
                            File.Delete(zipPath1);
                        }
                        else
                        {
                            labUpInfo.Text = err;
                            return;
                        }
                    }

                    RecordResInfo(resname, realName, resdes, ressize, DateTime.UtcNow.ToLongDateString());
                    this.txtjianjie.Text = "";
                    this.txtResName.Text = "";
                }
            }
            catch (Exception)
            {
                //throw;
                labUpInfo.Text = "上传失败!该资料的操作权限不够,请设置权限再进行上传!";
            }
        }
        else
        {
            string resname = this.txtResName.Text.Trim();
            string resdes  = this.txtjianjie.Text.Trim();

            UpdateResInfo(resname, "", resdes, "");
            this.labUpInfo.Text = GetTran("001505", "资料修改成功") + "!";
        }
    }