/// <summary> /// 根据ID查询一条审批记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public Examine GetExaminById(int id) { IUserInfoService userService = new DAL.Power.UserInfoService(); string sql = "usp_GetExaminById"; Examine e = new Examine(); using (SqlDataReader reader = DBHelper.ExecuteReaderProc(sql, new SqlParameter("@Id", id))) { if (reader.Read()) { e.EID = Convert.ToInt32(reader["EID"]); e.EndTime = Convert.ToDateTime(reader["EndTime"]); e.ExamineIdea = reader["ExamineIdea"].ToString(); e.ExamineUID = userService.GetAllUserById(Convert.ToInt32(reader["ExamineUID"])); e.IsApproved = reader["IsApprove"].ToString(); e.RequisitionType = reader["RequisitionType"].ToString(); e.RequisitionID = Convert.ToInt32(reader["RequisitionID"]); reader.Close(); return(e); } else { reader.Close(); return(null); } } return(e); }
public void TestExamine() { string expected = "On one of the tables there is a book with the title 'Java: The final chapter'"; Description description = new Description(); description.Id = 5; description.Name = "JavaBook"; description.Text = "On one of the tables there is a book with the title 'Java: The final chapter'"; Item item = new Item(); item.ID = 3; item.Name = "JavaBook"; item.Description = description; Mock <IRepository> repository = new Mock <IRepository>(); repository.Setup(x => x.Examine("JavaBook", "")).Returns(item.Description.Text); var examine = new Examine(repository.Object); Assert.AreEqual(expected, examine.RunCommand("JavaBook", "")); Assert.AreNotEqual(expected, examine.RunCommand("Soap", "")); }
public bool SetSceneItemStatus(string sceneItemID, Examine examine) { try { if (string.IsNullOrEmpty(sceneItemID)) { throw new KnownException("id为空,无法设置!"); } var db = new MongoDbProvider <SceneItem>(); // var item = db.GetByCondition(x=>x.); //if (examine.ExamineStatus == ItemStatus.Final) //{ // SetSceneStatusFinal(sceneItemID); //} var tempstring = GetSceneItemByRelation(sceneItemID, db); var item = db.GetByCondition(x => x.Id == tempstring); item.Status = examine.ExamineStatus; examine.Time = DBTimeHelper.DBNowTime(); (item.Examines ?? new List <Examine>()).Add(examine); item.UpdateTime = examine.Time; db.Update(item); return(true); } catch (Exception ex) { throw ex; } }
public ActionResult CheckSceneItem(string SceneItemID, int status, string content) { string _enterpriseID = BCSession.User.EnterpriseID; int? _departmentID = BCSession.User.DepartmentID; string _userID = BCSession.User.UserID; var result = new StandardJsonResult <bool>(); result.Try(() => { //result.Value = _sceneItemService.SetSceneItemStatus(SceneItemID, (ItemStatus)status, DateTime.Now); Examine examine = new Examine() { UserID = BCSession.User.UserID, UserName = BCSession.User.UserName, ExamineStatus = (ItemStatus)status, }; var comment = new Comment { UserID = _userID, Content = (status == 1 ? "通过:" : "整改:") + content ?? "", }; result.Value = _sceneItemService.AddCommentItem(SceneItemID, comment, examine) != null; }); return(result); }
public ActionResult ArchiveSceneItem(string SceneItemID) { string _enterpriseID = BCSession.User.EnterpriseID; int? _departmentID = BCSession.User.DepartmentID; string _userID = BCSession.User.UserID; var result = new StandardJsonResult <bool>(); result.Try(() => { var comment = new Comment { UserID = _userID, Content = "归档了该条目.", Time = DateTime.Now }; var user = GetSession(); var examine = new Examine() { UserID = user.User.UserID, UserName = user.User.UserName, ExamineStatus = ItemStatus.Final, }; //_sceneItemService.AddCommentItem(SceneItemID, comment,ItemStatus.Final); result.Value = _sceneItemService.SetSceneItemStatus(SceneItemID, examine); }); return(result); }
private void HandleExamining() { Examine examineObject = HeldObject.GetComponent <Examine>(); if (!examineObject) { return; } if (Input.GetKeyDown(KeyCode.Mouse1)) { if (!IsExamining) { IsExamining = true; examineObject.StartExamining(); // Disable movment and camera control during examination of object GetComponent <PlayerMovement>().enabled = false; Camera.main.GetComponent <PlayerLook>().enabled = false; } else { IsExamining = false; examineObject.StopExamining(); GetComponent <PlayerMovement>().enabled = true; Camera.main.GetComponent <PlayerLook>().enabled = true; } } }
public ExamineWindow(Patient patient, Examine examine) { InitializeComponent(); this.examine = examine; this.patient = patient; }
public List <TablePatient> GetGridList() { List <Patient> patients = null; IOrderedQueryable <Examine> examinesPool = null; try { MongoRepository <Examine> examines = new MongoRepository <Examine>(); patients = context.Patients.OrderByDescending(p => p.Id).ToList(); var patientsIds = patients.Select(p => p.Id).ToList(); examinesPool = examines.Where(ex => patientsIds.Contains(ex.PatientId)) .OrderByDescending(ex => ex.CreatedAt); } catch (Exception e) { log.Error(string.Format("Can't select data from db. Reason: {0}", e.Message)); return(null); } List <TablePatient> tablePatients = new List <TablePatient>(); foreach (Patient patient in patients) { Examine examine = examinesPool.Where(ex => ex.PatientId == patient.Id).ToList().FirstOrDefault(); tablePatients.Add(new TablePatient(patient, examine)); } return(tablePatients); }
/// <summary> /// 通过传入html获取书籍信息的方法 /// </summary> /// <param name="html"></param> public void BookInfo(string html) { var htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(html); try { for (int i = 0; i < 3; i++) { var name = htmlDoc.DocumentNode.SelectNodes("//div[@class='book-mid-info']//h4/a")[i]; //var info = htmlDoc.DocumentNode.SelectNodes("//div[@class='book-mid-info']//p [@class='intro']")[i]; var info = htmlDoc.DocumentNode.SelectNodes("//div[@class='book-mid-info']//h4//a")[i].Attributes["href"].Value; var image = htmlDoc.DocumentNode.SelectNodes("//div[@class='book-img-box']//img")[i].Attributes["src"].Value; if (Examine.IsNull(name.InnerText, BookIntro(info), image)) { bookInfo.Add(name.InnerText, BookIntro(info)); StreamFill(BookImage(name.InnerText, image), name.InnerText, BookIntro(info)); } else { throw new NoFound(); } } } catch { throw new NoFound(); } }
// Use this for initialization void Start() { int count = RankManager.Count(); for (int i = 1; i <= 10; i++) { GameObject o = GameObject.Find("RankItem" + i); if (i < count) { Examine e = RankManager.Item(i - 1); Text rank = o.transform.FindChild("Rank").GetComponent <Text> (); Text date = o.transform.FindChild("Date").GetComponent <Text> (); Text rate = o.transform.FindChild("Rate").GetComponent <Text> (); Text score = o.transform.FindChild("Score").GetComponent <Text> (); Text time = o.transform.FindChild("Time").GetComponent <Text> (); Text _count = o.transform.FindChild("Count").GetComponent <Text> (); rank.text = i.ToString(); date.text = e.endTime.ToShortDateString() + " " + e.endTime.ToShortTimeString(); rate.text = e.Rate().ToString(); score.text = e.Score().ToString(); time.text = e.ElapseSeconds().ToString() + "秒"; _count.text = e.totalQuestionCount.ToString() + "题"; o.SetActive(true); } else { o.SetActive(false); } } }
/// <summary> /// Кастомизация индекса /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InsertExternalFields(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e) { if (!e.Fields.ContainsKey("criteria")) return; var criteriaString = e.Fields["criteria"]; var xCriteriaField = new Field("xCriteria", criteriaString.Replace(',', ' '), Field.Store.YES, Field.Index.ANALYZED_NO_NORMS, Field.TermVector.NO); e.Document.Add(xCriteriaField); }
public ActionResult Comment(CommentDataModel model) { _ilog.Info(string.Format("方法名:{0};参数:{1}", "Comment", Serializer.ToJson(model))); var result = new StandardJsonResult(); result.Try(() => { if (!ModelState.IsValid) { throw new KnownException(ModelState.GetFirstError()); } ItemStatus status = (ItemStatus)model.Status; var user = GetSession(); var examine = new Examine() { UserID = user.User.UserID, UserName = user.User.UserName, ExamineStatus = status }; var SN = GetSession(); service.AddCommentItem(model.MessageID, new Comment() { CommentGuid = model.Guid, Content = model.Content, Time = model.Time, UserID = SN.User.UserID, UserName = SN.User.UserName }, examine); }); _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "Comment", Serializer.ToJson(result))); return(result); }
public String AnnualReviewUpload(AnnualReviewViewPage AnnualReviewAdd, string idd) { Examine ExamineInfo = new Examine(); var UserInfo = db.UsersInfo.Where(a => a.UserName == idd).FirstOrDefault(); ExamineInfo.ExamineID = DateTime.Now.ToString("yyyyMMddHHmmss"); ExamineInfo.CompanyName = UserInfo.CompanyName; string name = "^[a-zA-Z0-9\u4e00-\u9fa5]{1,}$";//字母数字汉字 Regex rxname = new Regex(name); if (!rxname.IsMatch(AnnualReviewAdd.ExamineName)) { return("请输入正确格式"); } ExamineInfo.ExamineName = AnnualReviewAdd.ExamineName; ExamineInfo.PayCard = AnnualReviewAdd.PayCard; ExamineInfo.BusinessCard = AnnualReviewAdd.BusinessCard; ExamineInfo.ExamineState = ExamineState1.ExamineAccept; ExamineInfo.ExamineTime = DateTime.Now; db.Examine.Add(ExamineInfo); db.SaveChanges(); return("申请成功"); }
public ActionResult UpdateStatus(UpdateStatusModel model) { _ilog.Info(string.Format("方法名:{0};参数:{1}", "UpdateStatus", Serializer.ToJson(model))); var result = new StandardJsonResult(); result.Try(() => { if (!ModelState.IsValid) { throw new KnownException(ModelState.GetFirstError()); } ItemStatus status = (ItemStatus)model.Status; var user = GetSession(); var examine = new Examine() { ExamineStatus = status, UserID = user.User.UserID, UserName = user.User.UserName, }; service.SetSceneItemStatus(model.MessageID, examine); }); _ilog.Info(string.Format("方法名:{0};执行结果:{1}", "UpdateStatus", Serializer.ToJson(result))); return(result); }
private void SelectBookInfo(string bookname) { try { string path = "D:\\Fiction"; if (Directory.Exists(path)) { StreamReader sr = new StreamReader(path + "\\All.txt", Encoding.UTF8); while (!sr.EndOfStream) { string bookInfo = sr.ReadLine(); if (bookInfo.Contains(bookname)) { txtBookName.Text = Examine.PattBookInfo(1, bookInfo); pbFiction.LoadAsync(Examine.PattBookInfo(2, bookInfo)); txtBookIntro.Text = Examine.PattBookInfo(3, bookInfo); } } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public void InitExamine(Examine examine, bool isErrorQuestion) { isErrorQuestionMode = isErrorQuestion; if (currentQuests == null) { currentQuests = new List <Question> (); } else { currentQuests.Clear(); } totalQuestionCount = 0; foreach (Question q in examine.currentQuests) { if (isErrorQuestion) { if (!q.IsUserAnswerCorrect()) { currentQuests.Add(q); totalQuestionCount++; } } else { currentQuests.Add(q); totalQuestionCount++; } } }
/// <summary> /// 根据审批类型查询审批记录 /// </summary> /// <param name="type"></param> /// <returns></returns> public IList <Examine> SearchExamineByType(string type) { IUserInfoService userService = new DAL.Power.UserInfoService(); string sql = "usp_SearchExamineByType"; IList <Examine> list = new List <Examine>(); using (DataTable dt = DBHelper.GetDataTableProc(sql, new SqlParameter("@Type", type))) { foreach (DataRow row in dt.Rows) { Examine e = new Examine(); e.EID = Convert.ToInt32(row["EID"]); e.EndTime = Convert.ToDateTime(row["EndTime"]); e.ExamineIdea = row["ExamineIdea"].ToString(); e.ExamineUID = userService.GetAllUserById(Convert.ToInt32(row["ExamineUID"])); e.IsApproved = row["IsApprove"].ToString(); e.RequisitionType = row["RequisitionType"].ToString(); e.RequisitionID = Convert.ToInt32(row["RequisitionID"]); list.Add(e); } } return(list); }
/// <summary> /// 获取书籍封面的方法 /// </summary> /// <param name="url"></param> /// <returns></returns> public int BookImage(string bookname, string url) { try { url = String.Format("{0}" + url, "https:"); string id = Examine.Patt(url); HttpWebRequest http = WebRequest.Create(url) as HttpWebRequest; http.Timeout = 30 * 1000; HttpWebResponse https = http.GetResponse() as HttpWebResponse; string path = "D:\\Fiction"; if (Directory.Exists(path)) { DirectoryInfo info = Directory.CreateDirectory(path + "\\" + id); FileStream fs = new FileStream(info.FullName + "\\" + id + ".jpg", FileMode.Create); https.GetResponseStream().CopyTo(fs); fs.Close(); http.Abort(); http = null; https.Close(); https = null; bookIDCover.Add(bookname, info.FullName + "\\" + id + ".jpg"); } return(Convert.ToInt32(id)); } catch { throw new NoFound(); } }
protected void btnSubmit_OnClick(object sender, EventArgs e) { ReturnMsg msg = null; if (this.hfExamineId.Value == "") { //新增 var model = new Examine { Examine_OrderId = Guid.Parse(this.hfOrderId.Value), Examine_Result = this.ddlResult.SelectedValue, Examine_Reason = this.txtExamineContent.Value }; var res = examineSvc.Add(model); msg = res > 0 ? new ReturnMsg() { Code = StatusCode.Ok, Message = "编辑审核信息成功", Data = null } : new ReturnMsg() { Code = StatusCode.Ok, Message = "编辑审核信息失败", Data = null }; } else { //执行修改 var model = new Examine { Examine_Id = Guid.Parse(this.hfExamineId.Value), Examine_OrderId = Guid.Parse(this.hfOrderId.Value), Examine_Result = this.ddlResult.SelectedValue, Examine_Reason = this.txtExamineContent.Value, }; var res = examineSvc.Edit(model); msg = res > 0 ? new ReturnMsg() { Code = StatusCode.Ok, Message = "编辑审核信息成功", Data = null } : new ReturnMsg() { Code = StatusCode.Ok, Message = "编辑审核信息失败", Data = null }; } Session["Msg"] = msg; orderSvc.ContactOrder(Guid.Parse(this.hfOrderId.Value)); Response.Redirect("Order_List.aspx"); }
public void NoPass1(string id) { Examine Examine1 = db.Examine.Find(id); if (Examine1.ExamineState == ExamineState1.ExamineAccept) { Examine1.ExamineState = ExamineState1.ExamineNoPass; db.SaveChanges(); } }
public void OnPressRetry() { Report.gameObject.SetActive(false); Examine e = new Examine(); e.InitExamine(examine, true); examine = e; examine.StartExamine(); examine.NextQuestion(); UpdateQuestion(); }
public void StartWrongQuestion() { examine = new Examine(); #if UNITY_EDITOR examine.InitExamineWithWrongQuestion(5); #else examine.InitExamineWithWrongQuestion(20); #endif examine.NextQuestion(); UpdateQuestion(); }
/// <summary> /// Event handler to create a lower cased version of the node name, this is so we can support case-insensitive searching and still /// use the Whitespace Analyzer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void indexer_DocumentWriting(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e) { if (e.Fields.Keys.Contains("nodeName")) { //add the lower cased version e.Document.Add(new Field("__nodeName", e.Fields["nodeName"].ToLower(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO )); } }
public void Pass(Array arr) { for (var i = 0; i < arr.Length; i++) { var ExamineID = arr.GetValue(i); Examine Examine1 = db.Examine.Find(ExamineID); if (Examine1.ExamineState == ExamineState1.ExamineAccept) { Examine1.ExamineState = ExamineState1.ExaminePass; db.SaveChanges(); } } }
public void StartNewQuestion() { examine = new Examine(); #if UNITY_EDITOR examine.InitExamine(5); #else examine.InitExamine(20); #endif examine.StartExamine(); examine.NextQuestion(); UpdateQuestion(); }
/// <summary> /// 添加审批记录 /// </summary> /// <param name="e"></param> /// <returns></returns> public int AddExamine(Examine e) { string proName = "usp_AddExamine"; SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@RequisitionID", e.RequisitionID), new SqlParameter("@RequisitionType", e.RequisitionType), new SqlParameter("@ExamineUID", e.ExamineUID.UID), new SqlParameter("@ExamineIdea", e.ExamineIdea), new SqlParameter("@EndTime", e.EndTime), new SqlParameter("@IsApprove", e.IsApproved), }; return(DBHelper.ExecuteNonQueryProc(proName, pars)); }
public ExamineViewPage ExamineDetail(string id) { Examine ExamineInfo = new Examine(); ExamineViewPage xx = new ExamineViewPage(); ExamineInfo = db.Examine.Find(id); xx.ExamineID = ExamineInfo.ExamineID; xx.CompanyName = ExamineInfo.CompanyName; xx.ExamineName = ExamineInfo.ExamineName; xx.PayCard = ExamineInfo.PayCard; xx.BusinessCard = ExamineInfo.BusinessCard; xx.ExamineState = ExamineInfo.ExamineState; xx.ExamineTime = ExamineInfo.ExamineTime; return(xx); }
public void Add(ExamineViewPage ExamineAdd, string id) { Examine ExamineInfo = new Examine(); var UserInfo = (from b1 in db.UsersInfo where b1.UserID == id select b1.CompanyName).FirstOrDefault();//寻找当前id的数据 ExamineInfo.ExamineID = DateTime.Now.ToString("yyyyMMddHHmmss"); ExamineInfo.ExamineName = ExamineAdd.ExamineName; ExamineInfo.CompanyName = UserInfo.FirstOrDefault().ToString(); ExamineInfo.ExamineState = ExamineState1.ExamineAccept; ExamineInfo.ExamineTime = DateTime.Now; db.Examine.Add(ExamineInfo); db.SaveChanges(); }
public void BookInfo(string html) { lock ("book") { var bookname = ""; var intro = ""; var id = 0; GetBookInfoByHtml getBookInfo = new GetBookInfoByHtml(); var htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(html); try { for (int i = 0; i < 20; i++) { if (stop) { break; } var name = htmlDoc.DocumentNode.SelectNodes("//div[@class='book-mid-info']//h4/a")[i]; bookname = name.InnerText; var info = htmlDoc.DocumentNode.SelectNodes("//div[@class='book-mid-info']//h4//a")[i].Attributes["href"].Value; var image = htmlDoc.DocumentNode.SelectNodes("//div[@class='book-img-box']//img")[i].Attributes["src"].Value; if (Examine.IsNull(bookname, info, image)) { string path = ""; intro = getBookInfo.BookIntro(info); id = getBookInfo.BookImage(bookname, image); bookInfo.Add(bookname, intro); getBookInfo.StreamFill(id, bookname, intro); GetBookInfoByHtml.bookIDCover.TryGetValue(bookname, out path); getBookInfo.StreamAll(bookname, intro, path); this.Invoke(new Action(() => { lbInfo.Items.Add(bookname); })); } else { MessageBox.Show("未找到书籍!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
internal static DynamicNodeList ConvertSearchResultToDynamicNode(Examine.ISearchResults results) { var list = new DynamicNodeList(); var xd = new XmlDocument(); foreach (var result in results.OrderByDescending(x => x.Score)) { var item = new DynamicBackingItem(result.Id); if (item.Id == 0) continue; var node = (NodeFactory.Node)item.content; var examineResultXml = Umbraco.Core.XmlHelper.AddTextNode(xd, "examineScore", result.Score.ToString()); node.Properties.Add(new NodeFactory.Property(examineResultXml)); list.Add(new DynamicNode(item)); } return list; }
public override void OnHover(bool isOver) { base.OnHover(isOver); if (isOver && HasSession) { if (NumItems > 0) { if (Stack.TopItem.IsWorldItem) { Session.InfoDisplay.PostInfo(gameObject, Examine.GetExamineInfo(Stack.TopItem.worlditem)); } else { Session.InfoDisplay.PostInfo(gameObject, Examine.GetExamineInfo(Stack.TopItem.GetStackItem(WIMode.Stacked))); } } } }
static void ExamineEventsHandler_DocumentWriting(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e) { var indexer = sender as BaseIndexProvider; if (indexer == null) return; foreach (var examineEventsConsumer in _examineEventsConsumers) { if (examineEventsConsumer.ApplyOnIndex(indexer.Name)) try { examineEventsConsumer.OnDocumentWriting(e); } catch (Exception exception) { LogHelper.Error<ExamineEventsHandler>("Error With Event Consumer" ,exception); } } }
private void Loading() { try { string path = "D:\\Fiction"; DirectoryInfo fileInfo = new DirectoryInfo(path); FileInfo[] file = fileInfo.GetFiles("All.txt"); StreamReader sr = new StreamReader(path + "\\All.txt", Encoding.UTF8); while (!sr.EndOfStream) { string bookInfo = sr.ReadLine(); lbInfo.Items.Add(Examine.PattBookInfo(1, bookInfo)); } isTrigger = false; btnStart.Enabled = false; btnClear.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void ChangeSceneItemStatus(Examine examine, string SceneItemID) { try { if (null == examine) { throw new KnownException("传入审核状态为空"); } var db = new MongoDbProvider <SceneItem>(); var item = db.GetById(SceneItemID); if (null == item) { throw new KnownException("未找到该现场数据"); } item.Examines.Add(examine); db.Update(item); } catch (Exception e) { throw e; } }
/// <summary> /// Searhes content /// </summary> /// <param name="criteria"></param> /// <param name="searchProvider"></param> /// <returns></returns> public IEnumerable<IPublishedContent> TypedSearch(Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null) { var s = Examine.ExamineManager.Instance.DefaultSearchProvider; if (searchProvider != null) s = searchProvider; var results = s.Search(criteria); return results.ConvertSearchResultToPublishedContent(_contentCache); }
public LuceneSearchCriteria(string type, Analyzer analyzer, string[] fields, bool allowLeadingWildcards, Examine.SearchCriteria.BooleanOperation occurance) : base(type, analyzer, fields, allowLeadingWildcards, occurance) { }
public static IEnumerable<IPublishedContent> Search(this IPublishedContent d, Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null) { var s = Examine.ExamineManager.Instance.DefaultSearchProvider; if (searchProvider != null) s = searchProvider; var results = s.Search(criteria); return results.ConvertSearchResultToPublishedContent(PublishedContentStoreResolver.Current.PublishedContentStore); }
public DynamicPublishedContentList Search(Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null) { return new DynamicPublishedContentList( PublishedContentExtensions.Search(this, criteria, searchProvider)); }
public static IEnumerable<EntityBasic> ExamineSearchRaw(this EntityController controller, string query, UmbracoEntityTypes entityType) { string type; var searcher = Constants.Examine.InternalSearcher; var fields = new[] { "id", "bodyText" }; //TODO: WE should really just allow passing in a lucene raw query switch (entityType) { case UmbracoEntityTypes.Member: searcher = Constants.Examine.InternalMemberSearcher; type = "member"; fields = new[] { "id", "email", "loginName"}; break; case UmbracoEntityTypes.Media: type = "media"; break; case UmbracoEntityTypes.Document: type = "content"; break; default: throw new NotSupportedException("The " + typeof(EntityController) + " currently does not support searching against object type " + entityType); } var internalSearcher = ExamineManager.Instance.SearchProviderCollection[searcher]; //build a lucene query: // the __nodeName will be boosted 10x without wildcards // then __nodeName will be matched normally with wildcards // the rest will be normal without wildcards var sb = new StringBuilder(); //node name exactly boost x 10 sb.Append("+(__nodeName:"); sb.Append(query.ToLower()); sb.Append("^10.0 "); //node name normally with wildcards sb.Append(" __nodeName:"); sb.Append(query.ToLower()); sb.Append("* "); foreach (var f in fields) { //additional fields normally sb.Append(f); sb.Append(":"); sb.Append(query); sb.Append(" "); } //must match index type sb.Append(") +__IndexType:"); sb.Append(type); var raw = internalSearcher.CreateSearchCriteria().RawQuery(sb.ToString()); var result = internalSearcher.Search(raw); switch (entityType) { case UmbracoEntityTypes.Member: return MemberFromSearchResults(result); case UmbracoEntityTypes.Media: return MediaFromSearchResults(result); case UmbracoEntityTypes.Document: return ContentFromSearchResults(result); default: throw new NotSupportedException("The " + typeof(EntityController) + " currently does not support searching against object type " + entityType); } }
/// <summary> /// Searhes content /// </summary> /// <param name="criteria"></param> /// <param name="searchProvider"></param> /// <returns></returns> public dynamic Search(Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null) { return new DynamicPublishedContentList( TypedSearch(criteria, searchProvider)); }
public DynamicNodeList Search(Examine.SearchCriteria.ISearchCriteria criteria, Examine.Providers.BaseSearchProvider searchProvider = null) { var s = Examine.ExamineManager.Instance.DefaultSearchProvider; if (searchProvider != null) s = searchProvider; var results = s.Search(criteria); return ExamineSearchUtill.ConvertSearchResultToDynamicNode(results); }
/// <summary> /// Event handler to create a lower cased version of the node name, this is so we can support case-insensitive searching and still /// use the Whitespace Analyzer. This also ensures the 'Raw' values are added to the document. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void IndexerDocumentWriting(object sender, Examine.LuceneEngine.DocumentWritingEventArgs e) { //This ensures that the special __Raw_ fields are indexed var d = e.Document; foreach (var f in e.Fields.Where(x => x.Key.StartsWith(RawFieldPrefix))) { d.Add(new Field( f.Key, f.Value, Field.Store.YES, Field.Index.NO, //don't index this field, we never want to search by it Field.TermVector.NO)); } //add the lower cased version if (e.Fields.Keys.Contains("nodeName")) { e.Document.Add(new Field("__nodeName", e.Fields["nodeName"].ToLower(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO )); } }
public static Chapter CreateChapter(string xmlPath) { Chapter chapter = new Chapter(); XElement xml = XElement.Load(xmlPath); #region Objects foreach (XElement ele in xml.Elements("object")) { eAdventure.Object obj = new eAdventure.Object(); chapter.Objects.Add(obj); obj.Id = ele.Attribute("id").Value; XElement desc = ele.Element("description"); obj.Description = CreateDescription(desc); #region Resources foreach (XElement resourceEle in ele.Elements("resources")) { ResourceList resList = new ResourceList(); obj.Resources.Add(resList); foreach (XElement assetEle in resourceEle.Elements("asset")) { Asset asset = new Asset(); resList.Assets.Add(asset); asset.Type = assetEle.Attribute("type").Value; asset.Uri = assetEle.Attribute("uri").Value; } XElement conditionEle = resourceEle.Element("condition"); if (conditionEle != null) resList.Condition = CreateCondition(conditionEle); } #endregion #region Actions try { foreach (var action in ele.Element("actions").Elements()) { if (action.Name == "custom") { Custom custom = new Custom(); obj.Actions.Add(custom); custom.Name = action.Attribute("name").Value; var eff = action.Element("effect"); if (eff != null) custom.Effect = CreateEffect(eff); } else if (action.Name == "examine") { Examine examine = new Examine(); obj.Actions.Add(examine); var eff = action.Element("effect"); if (eff != null) examine.Effect = CreateEffect(eff); } else if (action.Name == "use") { Use use = new Use(); obj.Actions.Add(use); obj.Use = use; Effect effect = new Effect(); var effectEle = action.Element("effect"); if (effectEle != null) use.Effect = CreateEffect(effectEle); } } } catch { } #endregion } #endregion #region Scenes foreach (XElement sceneEle in xml.Elements("scene")) { Scene scene = new Scene(); chapter.Scenes.Add(scene); scene.Id = sceneEle.Attribute("id").Value; #region ActiveAreas var aaEle = sceneEle.Element("active-areas"); if(aaEle != null) { foreach (var aa in aaEle.Elements("active-area")) { ActiveArea a = new ActiveArea(); scene.ActiveAreas.Add(a); a.Id = aa.Attribute("id").Value; a.Description = CreateDescription(aa.Element("description")); a.Transform = CreateTransform(aa); var actionsEle = aa.Element("actions"); if (actionsEle != null) { foreach (var action in actionsEle.Elements()) { if (action.Name == "custom") { Custom custom = new Custom(); a.Actions.Add(custom); custom.Name = action.Attribute("name").Value; } else if (action.Name == "examine") { Examine examine = new Examine(); a.Actions.Add(examine); var eff = action.Element("effect"); if (eff != null) examine.Effect = CreateEffect(eff); } else if (action.Name == "use") { Use use = new Use(); a.Actions.Add(use); a.Use = use; Effect effect = new Effect(); var effectEle = action.Element("effect"); if (effectEle != null) use.Effect = CreateEffect(effectEle); } } } } } #endregion #region Resources foreach (XElement resourceEle in sceneEle.Elements("resources")) { ResourceList resList = new ResourceList(); scene.Resources.Add(resList); foreach (XElement assetEle in resourceEle.Elements("asset")) { Asset asset = new Asset(); resList.Assets.Add(asset); asset.Type = assetEle.Attribute("type").Value; asset.Uri = assetEle.Attribute("uri").Value; } XElement conditionEle = resourceEle.Element("condition"); if (conditionEle != null) resList.Condition = CreateCondition(conditionEle); } #endregion #region Characters var sceneCharacters = sceneEle.Element("characters"); if(sceneCharacters != null) { foreach (XElement item in sceneCharacters.Elements("character-ref")) { SceneCharacter sChar = new SceneCharacter(); scene.Characters.Add(sChar); sChar.CharacterId = item.Attribute("idTarget").Value; sChar.Scale = Convert.ToDecimal(item.Attribute("scale").Value); sChar.X = Convert.ToInt32(item.Attribute("x").Value); sChar.Y = Convert.ToInt32(item.Attribute("y").Value); sChar.Condition = CreateCondition(item.Element("condition")); } } #endregion #region Exits var exits = sceneEle.Element("exits"); if (exits != null) { foreach (XElement exitEle in exits.Elements("exit")) { Exit exit = new Exit(); scene.Exits.Add(exit); exit.Transform = CreateTransform(exitEle); exit.IsRectangular = exitEle.Attribute("rectangular").Value == "yes" ? true : false; exit.MouseOverDescription = exitEle.Element("exit-look").Attribute("text").Value; exit.TargetObjectId = exitEle.Attribute("idTarget").Value; XElement conditionEle = exitEle.Element("condition"); if (conditionEle != null) exit.Condition = CreateCondition(conditionEle); var effect = exitEle.Element("effect"); if (effect != null) exit.Effect = CreateEffect(effect); } } #endregion #region Objects if (sceneEle.Element("objects") != null) { foreach (var objectEle in sceneEle.Element("objects").Elements("object-ref")) { SceneObject obj = new SceneObject(); scene.Objects.Add(obj); obj.TargetId = objectEle.Attribute("idTarget").Value; obj.TargetObject = chapter.Objects.Single(x => x.Id == obj.TargetId); obj.X = Convert.ToInt32(objectEle.Attribute("x").Value); obj.Y = Convert.ToInt32(objectEle.Attribute("y").Value); obj.Layer = Convert.ToInt32(objectEle.Attribute("layer").Value); var cond = objectEle.Element("condition"); if (cond != null) obj.Condition = CreateCondition(cond); } } #endregion } #endregion #region Slidescenes foreach (XElement slideEle in xml.Elements("slidescene")) { SlideScene ss = new SlideScene(); chapter.SlideScenes.Add(ss); ss.Name = slideEle.Element("name").Value; ss.Id = slideEle.Attribute("id").Value; // ss.TargetScene = chapter.Scenes.First(x => x.SceneId == slideEle.Attribute("idTarget").Value); string slidesPath = slideEle.Element("resources").Element("asset").Attribute("uri").Value; int slideNumber = 1; while(true) { string uri = slidesPath + "_0" + slideNumber.ToString(); if (!File.Exists(Path + uri + ".jpg")) break; slideNumber++; Asset newSlide = new Asset(); ss.Slides.Add(newSlide); newSlide.Type = "slides"; newSlide.Uri = uri; } } #endregion #region Conversations foreach (var convEle in xml.Elements("graph-conversation")) { Conversation conv = new Conversation(); chapter.Conversations.Add(conv); conv.Id = convEle.Attribute("id").Value; foreach (var node in convEle.Elements()) { #region Dialogue Node if (node.Name == "dialogue-node") { DialogueNode dNode = new DialogueNode(); conv.Nodes.Add(dNode); dNode.NodeIndex = node.Attribute("nodeindex").Value; var end = node.Element("end-conversation"); if(end != null) { dNode.EndEffect = CreateEffect(end.Element("effect")); } foreach (var item in node.Elements()) { if (item.Name == "speak-char") { SpeakChar speak = new SpeakChar(); dNode.Dialogue.Add(speak); speak.TargetId = item.Attribute("idTarget").Value; speak.Text = item.Value; } else if (item.Name == "speak-player") { SpeakPlayer speak = new SpeakPlayer(); dNode.Dialogue.Add(speak); speak.Text = item.Value; } else if (item.Name == "child") { dNode.NextNodeId = item.Attribute("nodeindex").Value; } } } #endregion #region Option Node else if(node.Name == "option-node") { OptionNode oNode = new OptionNode(); conv.Nodes.Add(oNode); oNode.NodeIndex = node.Attribute("nodeindex").Value; foreach (var optionEle in node.Elements("speak-player")) { Option option = new Option(); oNode.Options.Add(option); SpeakPlayer speak = new SpeakPlayer(); option.SelectedOption = speak; speak.Text = optionEle.Value; option.NextNodeId = optionEle.ElementsAfterSelf("child").First().Attribute("nodeindex").Value; } } #endregion } } #endregion #region Characters foreach (var charEle in xml.Elements("character")) { Character character = new Character(); chapter.Characters.Add(character); character.Id = charEle.Attribute("id").Value; foreach (var item in charEle.Element("resources").Elements("asset")) { Asset asset = new Asset(); character.Assets.Add(asset); asset.Type = item.Attribute("type").Value; asset.Uri = item.Attribute("uri").Value; } character.Description = CreateDescription(charEle.Element("description")); character.TextColor = CreateTextColor(charEle.Element("textcolor")); } #endregion #region Macros var macros = xml.Elements("macro"); if (macros != null) { foreach (var macroEle in macros) { Macro m = new Macro(); chapter.Macros.Add(m); m.Id = macroEle.Attribute("id").Value; foreach (var item in macroEle.Elements()) { if(item.Name == "speak-player") { SpeakPlayerMacro sp = new SpeakPlayerMacro(item.Value); m.Actions.Add(sp); } else if (item.Name == "trigger-scene") { TriggerSceneMacro ts = new TriggerSceneMacro(item.Attribute("idTarget").Value); m.Actions.Add(ts); } else if (item.Name == "activate") { ActivateFlag af = new ActivateFlag(item.Attribute("flag").Value); m.Actions.Add(af); } } } } #endregion #region Second loop #region Scenes foreach (var scene in chapter.Scenes) { #region Exits foreach (var exit in scene.Exits) { exit.TargetObject = chapter.GetElementById(exit.TargetObjectId); } #endregion #region Active areas foreach (var area in scene.ActiveAreas) { if(area.Use != null) { if(area.Use.Effect != null) { var effect = area.Use.Effect; effect.TriggerSlideScene = (SlideScene) chapter.GetElementById(effect.TriggerSlideSceneId); effect.TriggerScene = (Scene) chapter.GetElementById(effect.TriggerSceneId); if(effect.TriggerConversationId != null) { effect.TriggerScene.Conversations.Add(chapter.Conversations.Single(x => x.Id == effect.TriggerConversationId)); } } } } #endregion #region Characters foreach (var item in scene.Characters) { item.Character = chapter.Characters.Single(x => x.Id == item.CharacterId); } #endregion } #endregion #region Objects foreach (var obj in chapter.Objects) { try { if (obj.Use.Effect.TriggerSlideSceneId != null) obj.Use.Effect.TriggerSlideScene = chapter.SlideScenes.Single(x => x.Id == obj.Use.Effect.TriggerSlideSceneId); if (obj.Use.Effect.TriggerSceneId != null) obj.Use.Effect.TriggerScene = chapter.Scenes.Single(x => x.Id == obj.Use.Effect.TriggerSceneId); } catch { } } #endregion #region Conversations foreach (var item in chapter.Conversations) { foreach (var node in item.Nodes) { var endEffect = node.EndEffect; if(endEffect != null) { if (endEffect.TriggerSlideSceneId != null) endEffect.TriggerSlideScene = chapter.SlideScenes.Single(x => x.Id == endEffect.TriggerSlideSceneId); if (endEffect.TriggerSceneId != null) endEffect.TriggerScene = chapter.Scenes.Single(x => x.Id == endEffect.TriggerSceneId); } if(node is DialogueNode) { var current = ((DialogueNode)node); if(current.NextNodeId != null) current.NextNode = item.Nodes.Single(x => x.NodeIndex == current.NextNodeId); } else { var current = ((OptionNode)node); foreach (var option in current.Options) { if(option.NextNodeId != null) option.NextNode = item.Nodes.Single(x => x.NodeIndex == option.NextNodeId); } } } } #endregion #endregion return chapter; }