private void searchAncwer(string question) { double minVal = 0; int minId = -1; List <Double> q = new List <double>(); q = token(question); var a = (from p in model.DemandDescriptions where p.TypeDemand.GroupDemand.SystemCollectionId == systemCollection.Id select p).ToList(); for (int i = 0; i < a.Count; i++) { List <Double> answer = new List <double>(); answer = token(a[i].Description); double rast = 0; double znamenat1 = 0; double znamenat2 = 0; double cheslit = 0; for (int o = 0; o < answer.Count; o++) { cheslit = q[o] * answer[o] + cheslit; znamenat1 = Math.Pow(q[o], 2) + znamenat1; znamenat2 = Math.Pow(answer[o], 2) + znamenat2; } rast = Math.Sqrt(znamenat1) * Math.Sqrt(znamenat2); rast = Math.Abs(cheslit) / rast; if (rast >= minVal && rast != 0) { minId = a[i].Id; minVal = rast; } } if (minId != -1) { UserQuestions userQuestions = new UserQuestions(); userQuestions.QuestionBody = question; userQuestions.UserSystemsId = systemCollection.Id; userQuestions.DemandDescriptionId = minId; userQuestions.DemandDescription = model.DemandDescriptions.Find(minId); model.UserQuestions.Add(userQuestions); model.SaveChanges(); richTextBox1.SelectionColor = Color.Teal; richTextBox1.AppendText(userQuestions.DemandDescription.Description); } else { UserQuestions userQuestions = new UserQuestions(); userQuestions.QuestionBody = question; userQuestions.UserSystemsId = systemCollection.Id; userQuestions.DemandDescriptionId = null; model.UserQuestions.Add(userQuestions); model.SaveChanges(); richTextBox1.SelectionColor = Color.Teal; richTextBox1.AppendText("Нет ответа на данный вопрос"); } }
private void User_creation() { UserData userData = new UserData(); if (checkText.IsMatch(textBoxLogin.Text) && checkText.IsMatch(textBoxName.Text) && checkText.IsMatch(textBoxPassword.Text) && checkText.IsMatch(textBoxReturnPassword.Text) && textBoxPassword.Text == textBoxReturnPassword.Text) { userData.LoginUser = textBoxLogin.Text; userData.NameUser = textBoxName.Text; userData.PasswordUser = textBoxPassword.Text; if (radioButton1.Checked == true) { userData.RoleUser = "******"; } else { userData.RoleUser = "******"; } userData.Hidden = false; model.UserDatas.Add(userData); model.SaveChanges(); Alert("Success", Form_Alerts.enmType.Success); this.Close(); } else { Alert("Error", Form_Alerts.enmType.Error); } }
private void button_WOC1_Click(object sender, EventArgs e) { model.UserDatas.Remove(user); model.SaveChanges(); Form_user_list form = new Form_user_list(model); form.ShowList(); this.Close(); }
private void AdditionToGlossary(string s, SystemCollection system) { ILemmatizer lmtz = new LemmatizerPrebuiltFull(LanguagePrebuilt.Russian); List <String> wordsInText = new List <string>(); wordsInText.AddRange(s.Split(new char[] { '.', '?', '!', '(', ')', ',', ':', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries)); for (int i = 0; i < wordsInText.Count; i++) { wordsInText[i] = wordsInText[i].ToLower(); wordsInText[i] = lmtz.Lemmatize(wordsInText[i]); for (int w = 0; w < stopWords.Count; w++) { if (wordsInText[i] == stopWords[w]) { wordsInText.RemoveAt(i); i--; break; } } } List <String> words = new List <string>(); foreach (var a in wordsInText.Distinct <string>()) { words.Add(a); } for (int i = 0; i < words.Count; i++) { bool t = false; GlossarySystem glossarySystem = new GlossarySystem(); var gos = (from p in model.GlossarySystems where p.SystemCollectionId == system.Id select p).ToList(); for (int g = 0; g < gos.Count; g++) { if (gos[g].WordGlossary == words[i]) { glossarySystem = model.GlossarySystems.Find(gos[g].Id); t = true; break; } } if (t != true) { glossarySystem.WordGlossary = words[i]; glossarySystem.SystemCollectionId = system.Id; glossarySystem.WordValue = 1; glossarySystem.SystemCollection = system; model.GlossarySystems.Add(glossarySystem); model.SaveChanges(); } else { glossarySystem.WordValue++; model.SaveChanges(); } } }
private void button_Create_Click(object sender, EventArgs e) { UserSystems user_Systems = new UserSystems(); user_Systems.UserDataId = user.Id; user_Systems.UserData = user; user_Systems.SystemCollectionId = ((SystemCollection)(comboBoxSystems.SelectedValue)).Id; user_Systems.SystemCollection = model.SystemCollections.Find(((SystemCollection)(comboBoxSystems.SelectedValue)).Id); model.UserSystems.Add(user_Systems); model.SaveChanges(); Close(); }