Ejemplo n.º 1
0
 /// <summary>
 /// 上传保存Excel文件,返回保存物理路径
 /// </summary>
 /// <param name="FileUpExcel"></param>
 /// <returns></returns>
 public static string Saveupexcel(FileUpload FileUpExcel)
 {
     if (FileUpExcel.HasFile)
     {
         string excelfile = FileUpExcel.PostedFile.FileName;
         string exceltype = WordProcess.getext(excelfile);
         string newexcel  = "student" + DateTime.Now.Millisecond.ToString();
         string excelpath = HttpContext.Current.Server.MapPath("~/UpExcel/").ToString();
         if (exceltype.ToLower() == "xls")
         {
             if (!Directory.Exists(excelpath))
             {
                 Directory.CreateDirectory(excelpath);
             }
             string savepath = excelpath + newexcel + "." + exceltype;
             FileUpExcel.PostedFile.SaveAs(savepath);
             return(savepath);
         }
         else
         {
             return("");
         }
     }
     else
     {
         return("");
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 将上传的原模型预处理为对应的主机名
        /// </summary>
        /// <param name="xmlpath"></param>
        public static void PreMachineName(string xmlpath)
        {
            XmlDocument xmlcmp = ReadXml(xmlpath);

            {
                LearnSite.BLL.Computers pbll = new BLL.Computers();
                DataTable   dtcomputer       = pbll.GetPipPmachine();
                XmlNode     root             = xmlcmp.SelectSingleNode("classmodel");
                XmlNodeList nodeList         = root.ChildNodes;
                if (nodeList[0].Name != "student")
                {
                    XmlNode newroot = root.SelectSingleNode("students");
                    nodeList = newroot.ChildNodes;
                }
                foreach (XmlNode xn in nodeList)
                {
                    XmlNode addressNode = xn.SelectSingleNode("address");
                    string  ip          = addressNode.Attributes["IP"].Value;
                    string  Sname       = GetMachineByIp(dtcomputer, ip);  //根据IP,获取主机名
                    if (!string.IsNullOrEmpty(Sname) && !WordProcess.IsZh(Sname))
                    {
                        XmlNode nameNode = xn.SelectSingleNode("name");
                        nameNode.InnerText = Sname;//如果有则修改
                    }
                }
                xmlcmp.Save(xmlpath);//保存生成的主机名模型
            };
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> AsyncCheckTextSpelling(string textToCheck)
        {
            Task <List <string> > unrecognizedWords = WordProcess.GetUnrecognizedWordsFromText(textToCheck);

            ViewData["unidentifiedWords"] = await unrecognizedWords;

            return(PartialView("_CheckText"));
        }
Ejemplo n.º 4
0
        public void ProcessSampleWordCountTest()
        {
            string str = "Hello World! Hello! Hello World Masters";
            //Select Top Criteria
            int topselection = 1;
            //Get the Top Words as a Dictionary
            var worddict   = WordProcess.ProcessWordCount(str, topselection);
            var countvalue = worddict["Hello"];

            Assert.AreEqual(countvalue, 3);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据班级模型读取IP的x坐标和y坐标
        /// </summary>
        /// <param name="xdoc"></param>
        /// <param name="classname"></param>
        public static int SetIpxy(string xmlfile, string Pm)
        {
            XmlDocument xmlsave = new XmlDocument();

            xmlsave = ReadXml(xmlfile);

            XmlNode     root     = xmlsave.SelectSingleNode("classmodel");
            XmlNodeList nodeList = root.ChildNodes;

            if (nodeList[0].Name != "student")
            {
                XmlNode newroot = root.SelectSingleNode("students");
                nodeList = newroot.ChildNodes;
            }

            LearnSite.BLL.Computers cbll = new BLL.Computers();
            foreach (XmlNode xn in nodeList)
            {
                XmlNode addressNode = xn.SelectSingleNode("address");
                string  ip          = addressNode.Attributes["IP"].Value;
                XmlNode posNode     = xn.SelectSingleNode("posThumb");
                string  px          = posNode.Attributes["x"].Value;
                string  py          = posNode.Attributes["y"].Value;
                string  machine     = xn.SelectSingleNode("name").InnerText;//主机名
                if (WordProcess.IsZh(machine))
                {
                    machine = "";                           //如果班级模型的主机名是中文,则留空
                }
                if (!cbll.UpdateIpPxPy(ip, Int32.Parse(px), Int32.Parse(py), Pm))
                {
                    //如果没更新,则插入一条
                    LearnSite.Model.Computers cmodel = new Model.Computers();
                    cmodel.Pdate    = DateTime.Now;
                    cmodel.Pip      = ip;
                    cmodel.Plock    = true;
                    cmodel.Pm       = Pm;
                    cmodel.Pmachine = machine;
                    cmodel.Px       = Int32.Parse(px);
                    cmodel.Py       = Int32.Parse(py);
                    cbll.AddModel(cmodel);
                }
            }
            return(nodeList.Count);
        }
Ejemplo n.º 6
0
        public static string DownLoadOut(string downfilename)
        {
            string str = "";

            if (downfilename.EndsWith("/"))
            {
                string cururl = HttpContext.Current.Request.Url.ToString();
                int    cur    = cururl.IndexOf("Plugins") - 1;
                string weburl = cururl.Substring(0, cur) + downfilename.Replace("~", "");// +"index.htm";
                HttpContext.Current.Response.Redirect(weburl);
                str = weburl;
            }
            else
            {
                string ft = WordProcess.getext(downfilename);

                switch (ft)
                {
                case "rar":
                    DownLoadrar(downfilename);
                    break;

                case "swf":
                case "docx":
                case "pptx":
                case "xlsx":
                case "e":
                case "gif":
                    DownLoadold(downfilename);
                    break;

                default:
                    DownLoadold(downfilename);
                    //DownLoad(downfilename); 作品重新提交后无法下载,难道有缓存?
                    break;
                }
            }
            return(str);
        }
Ejemplo n.º 7
0
        public static Image SetText(Bitmap bp, int mlimit)
        {
            int    ow           = bp.Width;
            int    oh           = bp.Height;
            string WatemarkText = ow.ToString() + "×" + oh.ToString();
            int    mwidth       = ow;
            int    mheight      = oh;

            if (mwidth > mlimit)
            {
                mheight = mheight * mlimit / mwidth;
                mwidth  = mlimit;
            }
            Image image = new Bitmap(bp, mwidth, mheight);

            bp.Dispose();
            if (mwidth > 100)
            {
                string WatemarkFont       = "Arial";         //水印字体
                int    WatemarkFontSize   = 12;
                int    WatemarkPosY       = mheight - 20;
                int    WatemarkPosX       = 2 + WordProcess.GetRandomNum(mwidth - 100);//水平方向上随机取X坐标
                System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
                //将图片绘制到graphics中
                g.DrawImage(image, 0, 0, mwidth, mheight);
                //设置文字的属性
                System.Drawing.Font f  = new System.Drawing.Font(WatemarkFont, WatemarkFontSize);
                System.Drawing.Font ff = new System.Drawing.Font(WatemarkFont, WatemarkFontSize);
                //设置字体的颜色
                System.Drawing.Brush b  = new System.Drawing.SolidBrush(System.Drawing.Color.Gray);
                System.Drawing.Brush bb = new System.Drawing.SolidBrush(System.Drawing.Color.White);
                //写字
                g.DrawString(WatemarkText, ff, bb, WatemarkPosX - 1, WatemarkPosY - 1); //写白字
                g.DrawString(WatemarkText, f, b, WatemarkPosX, WatemarkPosY);           //写灰字
                //释放graphics
                g.Dispose();
            }
            return(image);
        }
Ejemplo n.º 8
0
        public ActionResult Verifica(FormCollection collection)
        {
            var fileName = string.Empty;

            if (ModelState.IsValid)
            {
                var file1 = Request.Files[0];
                if (file1 != null)
                {
                    var           file  = (HttpPostedFileWrapper)file1;
                    var           words = FileProcess.GetWordsFromFile(file);
                    StringBuilder sb    = new StringBuilder();
                    foreach (var item in words)
                    {
                        sb.Append(item + Environment.NewLine);
                    }
                    Task <List <string> > unrecognizedWords = WordProcess.GetUnrecognizedWordsFromText(sb.ToString());

                    fileName = Path.GetFileNameWithoutExtension(file.FileName) + ".txt";
                    FileProcess.SaveFile(fileName, sb.ToString());
                }
            }
            return(RedirectToAction("Result", "Text", new { fileName = fileName }));
        }
Ejemplo n.º 9
0
    static void Main()
    {
        using (WebClient client = new WebClient())
        {
            //Given Top Selection Criteria
            int topselection = 10;

            //Given Web Link to get the Text Data
            string weblink = "https://archive.org/stream/TheLordOfTheRing1TheFellowshipOfTheRing/The+Lord+Of+The+Ring+1-The+Fellowship+Of+The+Ring_djvu.txt";

            //Download the Html Data for the Given Web Link
            string texthtml = client.DownloadString(weblink);

            if (texthtml == null)
            {
                Console.WriteLine("No Data found  to process....");
            }


            else
            {
                //Get the Top Words as a Dictionary Value
                var worddict = WordProcess.ProcessWordCount(texthtml, topselection);

                if (worddict != null)

                {
                    //Display Top Occurance from the Word Dictionary
                    foreach (var word in worddict)
                    {
                        Console.WriteLine("{0} {1}", word.Key, word.Value);
                    }
                }
            }
        }
    }