public JsonResult Create(Knowlege entity) { if (entity != null) { string Title = entity.Title; string Author = entity.Author; string UpdateTime = entity.UpdateTime.Value.ToShortDateString(); string KeyWords = entity.KeyWords; string Content = entity.Content; entity.AllContent = string.Format("{0}|{1}|{2}|{3}", Title, Author, KeyWords, Content); if (Content != null && Content.Length > 300) { Content = Content.Substring(0, 300); } entity.Summary = string.Format("{0}<br/>{1}<br/>{2} {3} {4}", Content, KeyWords, Title, Author, UpdateTime); } using (MBREntities db = new MBREntities()) { KnowlegeService us = new KnowlegeService(db); if (us.Create(ref errors, entity)) { LogHandler.WriteServiceLog(LogonUser.RealName, "KnowlegeID:" + entity.KnowlegeID + ",Title:" + entity.Title, Resource.InsertSucceed, Resource.Create, "专家库管理"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed), JsonRequestBehavior.AllowGet)); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(LogonUser.RealName, "KnowlegeID:" + entity.KnowlegeID + ",Title:" + entity.Title, Resource.InsertFail, Resource.Create, "专家库管理"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol), JsonRequestBehavior.AllowGet)); } } }
private void LoadKonwlegeTree(string keyWord) { this.treeView1.Nodes.Clear(); string knowlegeList = jsonFileHelper.GetFileString(Globals.ThisAddIn.resourcesRootPath + "Configure\\knowlege.json"); List <Knowlege> tempJson = new List <Knowlege>(); tempJson = JsonConvert.DeserializeObject <List <Knowlege> >(knowlegeList); for (int i = 0; i < tempJson.Count; i++) { if (!keyWord.Equals("") && !tempJson[i].Name.ToString().Contains(keyWord)) { continue; } TreeNode node = new TreeNode(); node.Name = tempJson[i].Id.ToString(); node.Text = tempJson[i].Name.ToString(); Knowlege knowlege = tempJson[i] as Knowlege; this.treeView1.Nodes.Add(node); //if (!AddTreeNode(this.treeView1, knowlege)) // this.treeView1.Nodes.Add(node); } }
private bool AddTreeNode(TreeView tree, Knowlege knowlege) { foreach (TreeNode node in tree.Nodes) { if (node.Name.ToString().Equals(knowlege.FatherId.ToString())) { TreeNode temp = new TreeNode(); temp.Name = knowlege.Id.ToString(); temp.Text = knowlege.Name; node.Nodes.Add(temp); return(true); } if (node.Nodes.Count != 0) { foreach (TreeNode nodeSon in node.Nodes) { bool result = AddTreeNode(nodeSon.TreeView, knowlege); if (result) { return(true); } } } } return(false); }
public ActionResult Details(int id) { using (MBREntities db = new MBREntities()) { KnowlegeService us = new KnowlegeService(db); Knowlege entity = us.GetById(id); return(View(entity)); } }
public ActionResult Edit(int id) { Knowlege entity = null; using (MBREntities db = new MBREntities()) { entity = db.Knowlege.Find(id); } return(View(entity)); }
private void buttonSave_Click(object sender, EventArgs e) { bool result = false; if (this.comboBoxType.SelectedIndex > -1) { pointExercise.Type = this.comboBoxType.SelectedIndex + 1; } if (this.comboBox1.SelectedIndex > -1) { pointExercise.AnswerNumber = this.comboBox1.SelectedIndex + 1; } if (pointExercise.Type == 1 || pointExercise.Type == 2 || pointExercise.Type == 3) { string resultAnswer = ""; foreach (Control c in this.groupBoxAnswer.Controls) { if (c is Button) { Button button = c as Button; if (button.BackColor == Color.LightGray) { resultAnswer = resultAnswer + button.Name.ToString() + ","; } } } if (!resultAnswer.Equals("")) { pointExercise.Answer = resultAnswer.Substring(0, resultAnswer.Length - 1); } } int output; if (int.TryParse(this.textBox4.Text.ToString(), out output)) { pointExercise.Score = int.Parse(this.textBox4.Text.ToString()); } else { MessageBox.Show("分数格式不正确"); } if (int.TryParse(this.textBox3.Text.ToString(), out output)) { pointExercise.PredictDifficult = int.Parse(this.textBox3.Text.ToString()); } else { MessageBox.Show("难度格式不正确"); } if (int.TryParse(this.textBox5.Text.ToString(), out output)) { pointExercise.Split = int.Parse(this.textBox5.Text.ToString()); } else { MessageBox.Show("区分度格式不正确"); } pointExercise.KnowlegeList.Clear(); foreach (ListViewItem item in this.listView1.Items) { Knowlege temp = new Knowlege(); temp.Id = int.Parse(item.Name); temp.Name = item.Text; pointExercise.KnowlegeList.Add(temp); AddSelectedNodeTab(this.treeView1, temp.Id.ToString()); } if (this.textBox1.ForeColor != Color.LightGray) { pointExercise.Source = this.textBox1.Text.ToString(); } if (paper.PaperNodeList.Count != 0 && problemSet.ExerciseList.Count == 0) { exerciseOrderCount = 0; result = UpdateExercise(paper.PaperNodeList); } else if (paper.PaperNodeList.Count == 0 && problemSet.ExerciseList.Count != 0) { exerciseOrderCount = 0; result = UpdateExercise(problemSet.ExerciseList); } if (result) { if (paper.PaperNodeList.Count != 0 && problemSet.ExerciseList.Count == 0) { jsonFileHelper.WriteFileString(JsonConvert.SerializeObject(paper), Globals.ThisAddIn.exerciseJsonPath + paperName + ".json"); } else if (paper.PaperNodeList.Count == 0 && problemSet.ExerciseList.Count != 0) { jsonFileHelper.WriteFileString(JsonConvert.SerializeObject(problemSet), Globals.ThisAddIn.exerciseJsonPath + paperName + ".json"); } MessageBox.Show("保存成功"); //显示下一题 exerciseOrder += 1; Exercise tempEx = new Exercise(); exerciseOrderCount = 0; if (paper.PaperNodeList.Count != 0 && problemSet.ExerciseList.Count == 0) { tempEx = GetExerciseByOrder(paper.PaperNodeList as List <PaperNode>); } else if (paper.PaperNodeList.Count == 0 && problemSet.ExerciseList.Count != 0) { tempEx = GetExerciseByOrder(problemSet.ExerciseList as List <Exercise>); } if (tempEx.Question.Contains(".png")) { pointExercise = tempEx; ReSetQuestionDetail(); this.label11.BackColor = Color.White; this.label11.ForeColor = Color.Blue; this.label10.BackColor = Control.DefaultBackColor; this.label10.ForeColor = Label.DefaultForeColor; this.label12.BackColor = Control.DefaultBackColor; this.label12.ForeColor = Label.DefaultForeColor; this.label13.BackColor = Control.DefaultBackColor; this.label13.ForeColor = Label.DefaultForeColor; SetTabVisible(); this.ScrollControlIntoView(this.groupBoxQuestion); } else { MessageBox.Show("无更多题目"); exerciseOrder -= 1; foreach (Form f in Application.OpenForms) { if (f is PapersList) { f.WindowState = FormWindowState.Maximized; } } } } }