private void DeleteUser() { try { if (DataMethod.CheckRoot(_userStruct.userId)) { MessageBox.Show("Нельзя удалить главного администратора.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (_userActive.userId == _userStruct.userId) { MessageBox.Show("Вы не можете удалить собственную учетную запись.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (MessageBox.Show("Вы действительно желаете удалить данного пользователя и все принадлежащие ему файлы?", "Удалить пользователя", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DataMethod.DeleteUser(_userStruct.userId); FillTable(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public IEnumerable <object[]> GetData(MethodInfo methodInfo) { if (DataMethod == null) { DataMethod = MethodClass.GetMethod(DataMethodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (DataMethod == null) { throw new InvalidOperationException($"could not resolve test data source method:" + $" class=[{MethodClass.FullName}]" + $" method=[{DataMethodName}]"); } } if (TestMethod == null) { TestMethod = methodInfo; } object[] methodParams = null; if (DataMethod.GetParameters().Length > 0) { methodParams = new object[] { this } } ; return((IEnumerable <object[]>)DataMethod.Invoke(null, methodParams)); }
private void FillForm() { FillTable(); try { _statusFile = DataMethod.CheckStatusFile(_fileStruct.fileId); _statusFavorite = DataMethod.CheckFavorite(_userActive.userId, _fileStruct.fileId); Text = "Свойства файла: " + _fileStruct.name + _fileStruct.extension; textBoxName.Text = _fileStruct.name; richTextBoxComment.Text = _fileStruct.comment; textBoxExpansion.Text = _fileStruct.extension.ToUpper(); textBoxAT.Text = _fileStruct.dateTimeAT.ToString(); textBoxUP.Text = _fileStruct.dateTimeUP.ToString(); linkLabelLogin.Text = _userStruct.login; textBoxSize.Text = FileMethod.FileSize(Convert.ToDouble(_fileStruct.size)); labelStatusFile.Text = _statusFile; labelStatusFile.ForeColor = (_statusFile == "Проект") ? Color.DarkGreen : (_statusFile == "На проверке") ? Color.DarkOrange : Color.DarkRed; buttonUpdate.Enabled = (_userStruct.userId == _userActive.userId || _userActive.levelName != "Пользователь"); buttonFavorite.Text = (_statusFavorite == true) ? "Убрать из избранного" : "Добавить в избранное"; buttonStatus.Text = (_statusFile == "На проверке") ? "Отменить проверку" : "Отправить на проверку"; buttonStatus.Visible = (_userStruct.userId == _userActive.userId && _userActive.levelName == "Пользователь" && _statusFile != "Проект"); buttonYes.Visible = (_userActive.levelName != "Пользователь"); buttonYes.Enabled = (_statusFile != "Проект"); buttonNo.Visible = (_userActive.levelName != "Пользователь"); buttonNo.Enabled = (_statusFile != "Черновик"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonReview_Click(object sender, EventArgs e) { EnabledForm(false); try { if (_statusFile == "На проверке") { DataMethod.UpdateStatusFile(_userActive.userId, _fileStruct.fileId, StatusFileEnum.Draft); MessageBox.Show("Проверка файла отменена."); } else { DataMethod.UpdateStatusFile(_userActive.userId, _fileStruct.fileId, StatusFileEnum.Review); MessageBox.Show("Файл отправлен на проверку."); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } EnabledForm(true); FillForm(); }
private void FillTable() { try { if (textBoxSearch.Text.Trim() == "") { dataGridViewAccounts.DataSource = DataMethod.UsersTable(); } else { dataGridViewAccounts.DataSource = DataMethod.SearchUsers(textBoxSearch.Text); } if (dataGridViewAccounts.DataSource != null) { EnabledForm(true); dataGridViewAccounts.Columns[0].Visible = false; dataGridViewAccounts.Columns[5].HeaderText = "Дата регистрации"; dataGridViewAccounts.RowHeadersDefaultCellStyle.Padding = new Padding(dataGridViewAccounts.RowHeadersWidth); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void FillTable() { try { if (textBoxSearch.Text.Trim() == "") { dataGridViewHistory.DataSource = DataMethod.ChangesTable(_fileStruct.fileId); } else { dataGridViewHistory.DataSource = DataMethod.SearchChanges(_fileStruct.fileId, textBoxSearch.Text); } if (dataGridViewHistory.DataSource != null) { dataGridViewHistory.Columns[0].HeaderText = "Что изменилось"; dataGridViewHistory.Columns[1].HeaderText = "Кто изменил"; dataGridViewHistory.Columns[2].HeaderText = "Дата изменения"; dataGridViewHistory.RowHeadersDefaultCellStyle.Padding = new Padding(dataGridViewHistory.RowHeadersWidth); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FileProperties(int fileId, int userId) { try { _fileStruct = DataMethod.GetFile(fileId); _userStruct = DataMethod.GetUser(_fileStruct.userId); _userActive = DataMethod.GetUser(userId); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } InitializeComponent(); FillForm(); buttonUpdate.Text = "Изменить"; richTextBoxComment.Enabled = false; textBoxName.Enabled = false; EnabledForm(true); textBoxName.Validated += textBoxName_Validated; richTextBoxComment.Validated += richTextBoxComment_Validated; textBoxName.MaxLength = 50; richTextBoxComment.MaxLength = 250; Icon = Properties.Resources.info; }
/// <summary> /// 创建新活动 /// </summary> /// <param name="startUrl"></param> /// <param name="method"></param> public void New(string projectName, string startUrl, DataMethod method) { this.ProjectName = projectName; //设置项目路径 AppSettings.Instance.CurrentExecutePath = Path.Combine(AppSettings.Instance.LibraryPath, projectName); this.StartUrl = startUrl; this.DataMethod = method; IActionRepository rep = Repository as IActionRepository; rep.New(projectName); if (!string.IsNullOrEmpty(StartUrl)) { App.Invoke(() => { AppContext.Current.Browser.Navigate(StartUrl); }, true); } AddAction(new ActionNavigate() { URL = startUrl, AppContext = AppContext.Current }); if (DataSourceChanged != null) { DataSourceChanged(MainActionModel); } }
private void ReviewFile() { if (_statusReview == true) { if (MessageBox.Show("Вы действительно желаете отменить проверку данного файла?", "Отмена", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _statusReview = false; DataMethod.UpdateStatusFile(_userActive.userId, _fileStruct.fileId, StatusFile.Draft); this.buttonStatus.Text = "Отправить на проверку"; } } else { if (MessageBox.Show("Вы действительно желаете отправить данный файл на проверку?", "Проверка", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _statusReview = true; DataMethod.UpdateStatusFile(_userActive.userId, _fileStruct.fileId, StatusFile.Review); this.buttonStatus.Text = "Отменить проверку"; } } this.FillForm(); }
private void UpdateFile() { if (_statusUpdate == true) { if (MessageBox.Show("Вы действительно желаете изменить информацию о файле?", "Изменение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _statusUpdate = false; _userStruct = DataMethod.GetUser(_userStruct.userId); _fileStruct = DataMethod.GetFile(_fileStruct.fileId); _changeStruct = DataMethod.GetChange(_fileStruct.fileId); DataMethod.UpdateFile(_userActive.userId, _fileStruct.fileId, textBoxName.Text, richTextBoxComment.Text, comboBoxStatusFile.Text); this.textBoxName.Enabled = false; this.richTextBoxComment.Enabled = false; this.comboBoxStatusFile.Enabled = false; this.buttonUpdate.Text = "Изменить"; } } else { _statusUpdate = true; this.textBoxName.Enabled = true; this.richTextBoxComment.Enabled = true; this.comboBoxStatusFile.Enabled = true; this.buttonUpdate.Text = "Сохранить"; } this.FillForm(); }
private void DeleteFile() { try { if (_statusFile == StatusFileEnum.Archive || (_userActive.levelName == "Администратор" && _userActive.userId != _fileStruct.userId)) { if (MessageBox.Show("Вы действительно желаете безвозвратно удалить данный файл?", "Удалить файл", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DataMethod.DeleteFile(_fileStruct.fileId); FillTable(); } } else { DataMethod.FileToArchive(_userActive.userId, _fileStruct.fileId, true); MessageBox.Show("Файл помещен в архив."); FillTable(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void openProject(ref LMSProject project, bool isRetrieveHierarchy, DataMethod clearProjectControls, DataMethod associateProjectData, TextBox textBoxPath) { clearStatus(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "LMS Test.Lab 15A Project (*.lms)|*.lms"; openFileDialog.FilterIndex = 1; openFileDialog.RestoreDirectory = true; DialogResult dialogResult = openFileDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { string filePath = openFileDialog.FileName; project = new LMSProject(filePath, isRetrieveHierarchy); clearProjectControls(); textBoxPath.Text = filePath; associateProjectData(); setStatus("The project was successfully opened"); } else if (dialogResult != DialogResult.Cancel) { setStatus("An error occured while choosing a project file"); return; } else { return; } }
private void FillForm() { try { Text = _userActive.levelName + ": " + _userActive.name + " " + _userActive.surname + " (" + _userActive.login.ToLower() + ")"; buttonAccounts.Visible = (_userActive.levelName == "Администратор"); buttonReview.Visible = (_userActive.levelName != "Пользователь"); buttonAll.Visible = (_userActive.levelName != "Пользователь"); label2.Visible = (_userActive.levelName != "Пользователь"); label3.Visible = (_userActive.levelName == "Администратор"); if (dataGridViewFiles.Rows.Count > 0) { _fileStruct = DataMethod.GetFile(_fileStruct.fileId); _checkStatusFile = DataMethod.CheckStatusFile(_fileStruct.fileId); _checkFavorite = DataMethod.CheckFavorite(_userActive.userId, _fileStruct.fileId); reviewToolStripMenuItem.Text = (_checkStatusFile == "На проверке") ? "Отменить проверку" : "Отправить на проверку"; reviewToolStripMenuItem.Visible = (_fileStruct.userId == _userActive.userId && _userActive.levelName == "Пользователь" && _checkStatusFile != "Проект" && _statusFile != StatusFileEnum.Archive); favoriteToolStripMenuItem.Text = (_checkFavorite == true) ? "Убрать из избранного" : "Добавить в избранное"; favoriteToolStripMenuItem.Visible = (_statusFile != StatusFileEnum.Archive); showToolStripMenuItem.Visible = (_statusFile != StatusFileEnum.Archive); downloadToolStripMenuItem.Visible = (_statusFile != StatusFileEnum.Archive); undeleteStripMenuItem.Visible = (_statusFile == StatusFileEnum.Archive); deleteToolStripMenuItem.Visible = (_fileStruct.userId == _userActive.userId || _userActive.levelName == "Администратор"); toolStripSeparator2.Visible = (_statusFile != StatusFileEnum.Archive); toolStripSeparator3.Visible = (_statusFile != StatusFileEnum.Archive && (_fileStruct.userId == _userActive.userId || _userActive.levelName == "Администратор")); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddUser() { if (MessageBox.Show("Вы действительно желаете добавить данного пользователя?", "Добавление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DataMethod.InsertUser(textBoxName.Text, textBoxSurname.Text, textBoxLogin.Text, DataMethod.GetHash(textBoxPassword.Text), DateTime.Now, _userStruct.binary, CheckLevel(comboBoxLevel.Text)); } }
public FileForm(int fileId, int userId) { _fileStruct = DataMethod.GetFile(fileId); _changeStruct = DataMethod.GetChange(fileId); _userStruct = DataMethod.GetUser(_fileStruct.userId); _userActive = DataMethod.GetUser(userId); this.InitializeComponent(); }
public void EmptyDescription() { DataMethod methodEmpty = new DataMethod { StringMethod = "Метод()" }; Assert.AreEqual(string.Empty, methodEmpty.Description); }
public async Task RefreshItems() { if (DataMethod != null) { SetLoadingState(true); Items = await DataMethod.Invoke(); SetLoadingState(false); await ItemsLoaded(); } }
private static void WriteResultParseMethodName(DataMethod method) { Console.WriteLine($"StringMethod:\n{method.StringMethod}"); Console.WriteLine(); Console.WriteLine($"Description:\n{method.Description}"); Console.WriteLine(); Console.WriteLine("Text error:"); Console.WriteLine(method.TextError); Console.WriteLine("--------------------------------------"); Console.WriteLine(); }
private void Login_FormClosed(object sender, FormClosedEventArgs e) { try { DataMethod.DisposeDB(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CheckIn() { EnabledForm(false); try { if (textBoxLogin.Text != "" && textBoxPassword.Text != "") { if (!DataMethod.incorrectChar.IsMatch(textBoxLogin.Text) && !DataMethod.incorrectChar.IsMatch(textBoxPassword.Text)) { if (textBoxLogin.Text.Length <= 50 && textBoxPassword.Text.Length <= 50) { if (DataMethod.CheckUser(textBoxLogin.Text, DataMethod.GetHash(textBoxPassword.Text))) { _userActive.userId = DataMethod.GetUserId(textBoxLogin.Text); Main main = new Main(_userActive.userId) { Owner = this }; main.Show(); Hide(); textBoxLogin.Text = ""; textBoxPassword.Text = ""; } else { MessageBox.Show("Неверный логин или пароль.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Длина полей должна быть не больше 50 символов.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(@"Логин и пароль не должны содержать следующих символов: \ / : ? "" < > |", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Необходимо заполнить все поля.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } EnabledForm(true); }
private void UpdateUser() { try { if (MessageBox.Show("Вы действительно желаете изменить информацию о данном пользователе?", "Измененить пользователя", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DataMethod.UpdateUser(_userStruct.userId, textBoxName.Text, textBoxSurname.Text, textBoxLogin.Text, DataMethod.GetHash(textBoxPassword.Text), _userStruct.binary, (int)comboBoxLevel.SelectedValue); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void undeleteStripMenuItem_Click(object sender, EventArgs e) { try { DataMethod.FileToArchive(_userActive.userId, _fileStruct.fileId, false); MessageBox.Show("Файл восстановлен."); FillTable(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void TestClone() { DataMethod method = new DataMethod("dataMethod"); DataSource source = new DataSource("source.assembly", "source.class", method); DataSource copySource = source.Clone() as DataSource; Assert.IsNotNull(copySource); Assert.AreNotEqual(source.Identifier, copySource.Identifier); // Non translatable language items have a guid Assert.AreEqual(source.Name.Identifier, copySource.Name.Identifier); Assert.AreEqual(Guid.Empty, copySource.Name.Identifier); Assert.AreEqual(source.Name.Value, copySource.Name.Value); }
public UserProperties(int userId) { try { _userStruct = DataMethod.GetUser(userId); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } InitializeComponent(); Icon = Properties.Resources.info; }
public UserList(int userId) { InitializeComponent(); try { _userActive = DataMethod.GetUser(userId); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } _userStruct = new UserStruct(); Icon = Properties.Resources.list; }
private void RestoreFile() { try { if (MessageBox.Show("Вы действительно желаете восстановить данный файл?", "Восстановить файл", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DataMethod.FileToArchive(_userActive.userId, _fileStruct.fileId, false); FillTable(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddUser() { try { if (MessageBox.Show("Вы действительно желаете добавить данного пользователя?", "Добавить пользователя", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DataMethod.InsertUser(textBoxName.Text, textBoxSurname.Text, textBoxLogin.Text, DataMethod.GetHash(textBoxPassword.Text), DateTime.Now, _userStruct.binary, (int)comboBoxLevel.SelectedValue); ClearForm(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public UserEdit(int userId) { try { _userStruct = DataMethod.GetUser(userId); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } _statusUpdate = true; InitializeComponent(); buttonAction.Text = "Изменить"; }
private void FillForm() { this.Text += _userStruct.login; this.textBoxLogin.Text = _userStruct.login; this.textBoxLevel.Text = _userStruct.levelName; this.textBoxName.Text = _userStruct.name; this.textBoxSurname.Text = _userStruct.surname; this.textBoxProject.Text = DataMethod.CountFiles(_userStruct.userId, StatusFile.Project).ToString(); this.textBoxReview.Text = DataMethod.CountFiles(_userStruct.userId, StatusFile.Review).ToString(); this.textBoxDraft.Text = DataMethod.CountFiles(_userStruct.userId, StatusFile.Draft).ToString(); this.textBoxAllFiles.Text = DataMethod.CountFiles(_userStruct.userId, StatusFile.My).ToString(); this.textBoxSizeFiles.Text = FileMethod.FileSize(DataMethod.SizeAllFiles(_userStruct.userId)); this.textBoxDatetimeAT.Text = _userStruct.dateTimeAT.ToString(); this.pictureBoxUser.SizeMode = PictureBoxSizeMode.StretchImage; this.pictureBoxUser.Image = (_userStruct.binary != null) ? ImageMethod.BinaryToImage(_userStruct.binary) : null; }
private void FillForm() { StatusFile statusFile = DataMethod.CheckStatusFile(_fileStruct.fileId); _statusReview = (statusFile == StatusFile.Review) ? true : false; this.RefreshTable(); this.comboBoxStatusFile.Text = (statusFile == StatusFile.Project) ? "Проект" : "Черновик"; this.Text = "Свойства файла: " + _fileStruct.name + _fileStruct.expansion.ToLower(); this.textBoxName.Text = _fileStruct.name; this.richTextBoxComment.Text = _fileStruct.comment; this.textBoxExpansion.Text = _fileStruct.expansion.ToUpper(); this.textBoxAT.Text = _changeStruct.dateTimeAT.ToString(); this.textBoxUP.Text = _changeStruct.dateTimeUP.ToString(); this.linkLabelLogin.Text = _userStruct.login; this.textBoxSize.Text = FileMethod.FileSize(Convert.ToDouble(_fileStruct.size)); }
private void buttonNo_Click(object sender, EventArgs e) { EnabledForm(false); try { DataMethod.UpdateStatusFile(_userActive.userId, _fileStruct.fileId, StatusFileEnum.Draft); MessageBox.Show("Файл отклонен."); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } EnabledForm(true); FillForm(); }
public void TestClone2() { IDataMethod fileMethod = new DataMethod("CurrentFile"); IDataSource dataSource = new DataSource("this", "this", fileMethod); IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource); IParameter parameter = new Parameter("file", dataElement); IParameter parameterCopy = ((PolicyObject)parameter).Clone() as IParameter; Assert.AreNotEqual(parameter.Identifier, parameterCopy.Identifier, "unexpected identifier in condition.dataleft.data.method.parameters[0]"); Assert.AreEqual(parameter.Name.Identifier, parameterCopy.Name.Identifier, "unexpected name in condition.dataleft.data.method.parameters[0]"); //nontranslateable Assert.AreEqual(parameter.Name.Value, parameterCopy.Name.Value, "unexpected name in condition.dataleft.data.method.parameters[0]"); IDataElement dataElementCopy = parameterCopy.Value as IDataElement; Assert.IsNotNull(dataElementCopy, "unexpected object type in condition1copy.dataleft.data.method.parameters[0].value"); Assert.AreNotEqual(dataElement.Identifier, dataElementCopy.Identifier); Assert.AreEqual(dataElement.Name.Identifier, dataElementCopy.Name.Identifier); Assert.AreEqual(dataElement.Name.Value, dataElementCopy.Name.Value); Assert.AreEqual(dataElement.DisplayName.Identifier, dataElementCopy.DisplayName.Identifier); Assert.AreEqual(dataElement.DisplayName.Value, dataElementCopy.DisplayName.Value); Assert.AreEqual(dataElement.Type, dataElementCopy.Type); }
public void TestClone_DataLeft_DataSource() { Condition condition = new Condition(Guid.NewGuid(), "className", new TranslateableLanguageItem(Guid.NewGuid()), OperatorType.Equals, false); DataMethod method = new DataMethod("dataMethod"); DataSource source = new DataSource("source.assembly", "source.class", method); DataElement item = new DataElement( Guid.NewGuid(), new TranslateableLanguageItem(), new TranslateableLanguageItem("DataLeft"), DataType.Object, source ); condition.DataLeft = item; Condition copyCondition = condition.Clone() as Condition; Assert.IsNotNull(copyCondition); Assert.IsNotNull(copyCondition.DataLeft); Assert.IsNotNull(item.Data as DataSource); }