private void InsertSql(TMM.Model.DDocInfo doc) { Service.Bll.Doc.DDocInfoBLL bll = new TMM.Service.Bll.Doc.DDocInfoBLL(); doc.IsMajia = true; int docId = bll.Insert(doc); InsertTag(doc.Tags, docId); }
public void Import() { try { string ext = string.Empty; long fileLength = 0; string fileName = string.Empty; string p = CopyFile(this.docInfo.FilePath, ref ext, out fileLength, out fileName); fileName = fileName.Replace("." + ext, ""); TMM.Model.DDocInfo model = new TMM.Model.DDocInfo() { Title = this.docInfo.Title, Description = this.docInfo.Description, PhysicalPath = p, Price = this.docInfo.Price, Tags = this.docInfo.Tags, CateId = this.docInfo.ClassId, CreateTime = DateTime.Now, DocType = ext, FileId = Guid.NewGuid(), FileLength = (int)fileLength, FileName = fileName, UserId = Utils.ConfigHelper.UserIds[new Random().Next(0, Utils.ConfigHelper.UserIds.Length - 1)] }; InsertSql(model); if (dataRowImportOk != null) { dataRowImportOk(CurrentRow, true, null); } } catch (Exception ex) { if (dataRowImportOk != null) { dataRowImportOk(CurrentRow, false, ex.Message); } throw ex; } }
public ArrayList DataToList(DataSet ds,string keyWords,bool isHighlight) { ArrayList result = new ArrayList(); foreach (System.Data.DataRow row in ds.Tables[0].Rows) { Model.DDocInfo doc = new TMM.Model.DDocInfo(); doc.Title = row["Title"].ToString(); doc.Description = row["Description"].ToString(); doc.DocType = row["DocType"].ToString(); doc.DocId = int.Parse( row["DocumentId"].ToString() ); doc.UserId = int.Parse( row["UserId"].ToString()); doc.CreateTime = DateTime.Parse( row["CreateTime"].ToString()); doc.UpCount = int.Parse(row["UpCount"].ToString()); doc.ViewCount = int.Parse(row["ViewCount"].ToString()); if (isHighlight) { SimpleHTMLFormatter simpleHTMLFormatter = new SimpleHTMLFormatter("<font color=\"red\">", "</font>"); Highlighter titleHighlighter; Highlighter contentHighlighter; if (titleAnalyzerName.Equals("PanGuSegment", StringComparison.CurrentCultureIgnoreCase)) { titleHighlighter = new Highlighter(simpleHTMLFormatter, new PanGuAnalyzer()); } else if (titleAnalyzerName.Equals("EnglishAnalyzer", StringComparison.CurrentCultureIgnoreCase)) { titleHighlighter = new Highlighter(simpleHTMLFormatter, new Hubble.Core.Analysis.EnglishAnalyzer()); } else { titleHighlighter = new Highlighter(simpleHTMLFormatter, new Hubble.Core.Analysis.SimpleAnalyzer()); } if (descAnalyzerName.Equals("PanGuSegment", StringComparison.CurrentCultureIgnoreCase)) { contentHighlighter = new Highlighter(simpleHTMLFormatter, new PanGuAnalyzer()); } else if (descAnalyzerName.Equals("EnglishAnalyzer", StringComparison.CurrentCultureIgnoreCase)) { contentHighlighter = new Highlighter(simpleHTMLFormatter, new Hubble.Core.Analysis.EnglishAnalyzer()); } else { contentHighlighter = new Highlighter(simpleHTMLFormatter, new Hubble.Core.Analysis.SimpleAnalyzer()); } titleHighlighter.FragmentSize = 50; contentHighlighter.FragmentSize = 50; doc.SearchSummary = contentHighlighter.GetBestFragment(keyWords, doc.Description); string titleHighlight = titleHighlighter.GetBestFragment(keyWords, doc.Title); if (!string.IsNullOrEmpty(titleHighlight)) { doc.Title = titleHighlight; } } result.Add(doc); } return result; }
public void Import() { try { string ext = string.Empty; long fileLength = 0; string fileName = string.Empty; string p = CopyFile(this.docInfo.FilePath,ref ext,out fileLength,out fileName); fileName = fileName.Replace("." + ext,""); TMM.Model.DDocInfo model = new TMM.Model.DDocInfo() { Title = this.docInfo.Title, Description = this.docInfo.Description, PhysicalPath = p, Price = this.docInfo.Price, Tags = this.docInfo.Tags, CateId = this.docInfo.ClassId, CreateTime = DateTime.Now, DocType = ext, FileId = Guid.NewGuid(), FileLength = (int)fileLength, FileName = fileName, UserId = Utils.ConfigHelper.UserIds[new Random().Next(0, Utils.ConfigHelper.UserIds.Length - 1)] }; InsertSql(model); if (dataRowImportOk != null) { dataRowImportOk(CurrentRow,true,null); } } catch(Exception ex) { if (dataRowImportOk != null) { dataRowImportOk(CurrentRow, false,ex.Message); } throw ex; } }