public async Task ShouldRequireDescription() { var path = await SendAsync(new CreatePath { Title = "New Path", Key = "some-path", Description = "New Path Description" }); var module = await SendAsync(new CreateModule { Key = "module-key", Title = "New Module", Description = "New Module Description" }); var command = new UpdateModule { Id = module.Id, Title = "Updated Module", Description = "", Necessity = 0 }; FluentActions.Invoking(() => SendAsync(command)) .Should().ThrowAsync <ValidationException>().Where(ex => ex.Errors.ContainsKey("Description")) .Result.And.Errors["Description"].Should().Contain("Description is required."); }
public async Task ShouldUpdateModule() { var userId = await RunAsDefaultUserAsync(); var module = await SendAsync(new CreateModule { Key = "module-key", Title = "New Module", Description = "New Module Description" }); var command = new UpdateModule { Id = module.Id, Title = "Updated title", Key = "module-key", Description = "Updated Description", Necessity = 0 }; await SendAsync(command); var updatedModule = await FindAsync <Module>(module.Id); updatedModule.Title.Should().Be(command.Title); updatedModule.Description.Should().Be(command.Description); updatedModule.Key.Should().Be(module.Key); updatedModule.LastModifiedBy.Should().NotBeNull(); updatedModule.LastModifiedBy.Should().Be(userId); updatedModule.LastModified.Should().NotBeNull(); updatedModule.LastModified.Should().BeCloseTo(DateTime.Now, TimeSpan.FromMilliseconds(1000)); }
public async Task ShouldDisallowLongTitle() { var path = await SendAsync(new CreatePath { Title = "New Path", Key = "some-path", Description = "New Path Description" }); var module = await SendAsync(new CreateModule { Key = "module-key", Title = "New Module", Description = "New Module Description" }); var command = new UpdateModule { Id = module.Id, Title = "This module title is too long and exceeds one hundred characters allowed for module titles by UpdateModuleCommandValidator", Description = "New Description", Necessity = 0 }; FluentActions.Invoking(() => SendAsync(command)) .Should().ThrowAsync <ValidationException>().Where(ex => ex.Errors.ContainsKey("Title")) .Result.And.Errors["Title"].Should().Contain("Title must not exceed 100 characters."); }
internal static async Task UpdateModuleAsync([NotNull] UpdateModule srv) { var(success, message) = await TryUpdateModuleAsync(srv.Request.Id, srv.Request.Fields, srv.Request.Config); srv.Response.Success = success; srv.Response.Message = message ?? ""; }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { if (!UpdateModule.CheckIfGameRunning()) { UpdateMode(UpdateState.DownloadUpdate); timer.Enabled = false; } }
private void miProjectUpdate_Click(object sender, EventArgs e) { if (Powerpoint.Windows.Count == 0) { return; } UpdateModule.UpdateChart(ppt, _database.data); }
public static Module ToEntity(this UpdateModule updateModule) { return(new Module() { Id = updateModule.ModuleId , Name = updateModule.Name , CreateDate = DateTime.Now }); }
private void miProjectReplace_Click(object sender, EventArgs e) { if (Powerpoint.Windows.Count == 0) { return; } UpdateModule.ReplaceMissing(ppt, _database.data); }
public async Task <ActionResult <Module> > Update(int moduleId, [FromBody] UpdateModule command) { if (moduleId != command.Id) { return(BadRequest()); } return(Ok(await Mediator.Send(command))); }
public async Task Update_ReturnsBadRequest_WhenRequestedIdDoesNotMatchCommandId() { var updateCommand = new UpdateModule { Id = 2, Order = 0, Title = "Update title", Description = "Update Description" }; var controller = new ModulesController(moqMediator.Object); var result = await controller.Update(1, updateCommand); Assert.IsInstanceOf(typeof(BadRequestResult), result.Result); }
public RegisteredModule Update(UpdateModule updateRegistry) { using (HelpDeskDataContext helpDeskDataContext = new HelpDeskDataContext()) { var module = updateRegistry.ToEntity(); helpDeskDataContext.Modules.Attach(module); helpDeskDataContext.Entry(module).Property(x => x.Name).IsModified = true; helpDeskDataContext.SaveChanges(); return(module.ToDTO()); } }
public void ShouldRequireValidModuleId() { var command = new UpdateModule { Id = 99, Title = "New Title", Description = "New Description", Necessity = 0 }; FluentActions.Invoking(() => SendAsync(command)).Should().ThrowAsync <NotFoundException>(); }
public async Task Update_ReturnsUpdatedModule_WhenRequestedIdMatchesCommandId() { var updateCommand = new UpdateModule { Id = 1, Order = 0, Title = "Update title", Description = "Update Description" }; var controller = new ModulesController(moqMediator.Object); var result = await controller.Update(1, updateCommand); var content = GetObjectResultContent <Module>(result.Result); Assert.IsInstanceOf(typeof(OkObjectResult), result.Result); Assert.IsNotNull(content); Assert.AreEqual(1, content.Id); }
/// <summary>更新模块 /// </summary> public void Handle(ICommandContext context, UpdateModule command) { _lockService.ExecuteInLock(typeof(Module).Name, () => { _moduleService.Exist(command.ParentModule); var info = new ModuleEditableInfo( command.Name, command.ParentModule, command.ModuleType, command.LinkUrl, command.Sort, command.Describe, command.ReMark); context.Get <Module>(command.AggregateRootId).Update(info, command.VerifyType, command.IsVisible); }); }
static void Main(string[] args) { IDisplay display = new Display(); IAirspace airspace = new Airspace(); ILog log = new Log(); ITransponderReceiver transponderReceiver = TransponderReceiverFactory.CreateTransponderDataReceiver(); IObjectifyingModule objectifyingModule = new ObjectifyingModule(transponderReceiver); IFilterModule filterModule = new FilterModule(objectifyingModule, airspace); IUpdateModule updateModule = new UpdateModule(filterModule); ISeparationModule separationModule = new SeparationModule(updateModule, log); ISeparationRender separationRender = new SeparationRender(separationModule, display); ITrackRender trackRender = new TrackRender(updateModule, display); Console.ReadKey(); }
public UpdaterPanel() { InitializeComponent(); instalationMode = !UpdateModule.CheckIfInstalled(); UpdateModule.OnStatusTextChanged += UpdateModule_OnStatusTextChanged; if (instalationMode) { SetStartMode(UpdaterMode.Instalation); } else { SetStartMode(UpdaterMode.Update); } downloadPath = downloadInitialPath; timer.Interval = 1000; timer.Elapsed += Timer_Elapsed; }
// PUT: api/Module/5 update module public async Task <HandleResult> Put(string id, [FromBody] UpdateModuleDto dto) { var command = new UpdateModule(id, dto.Name, dto.ParentModule, dto.ModuleType, dto.VerifyType, dto.IsVisible, dto.LinkUrl, dto.Sort, dto.Describe, dto.ReMark); var result = await ExecuteCommandAsync(command); if (result.IsSuccess()) { return(HandleResult.FromSuccess("更新成功")); } return(HandleResult.FromFail(result.GetErrorMessage())); }
private void A_OnEndUpdateAction() { if (!CheckAccess()) { Dispatcher.Invoke(() => A_OnEndUpdateAction()); return; } if (mode == UpdaterMode.Instalation) { InstalationMode(InstalationState.EndInstalation); } else if (mode == UpdaterMode.Update) { if (UpdateState.CheckIfUpToDate == UpdateStep) { if (Program.NewestVersion.CompareTo(Program.Version) > 0) { if (UpdateModule.CheckIfGameRunning()) { UpdateMode(UpdateState.CheckIfRunning); } else { UpdateMode(UpdateState.DownloadUpdate); } } else { UpdateMode(UpdateState.UpdateNotAvailable); } } else if (UpdateState.DownloadUpdate == UpdateStep) { UpdateMode(UpdateState.UpdateEnd); } } }
/// <summary> /// Routes to a dynamically generated "Module Update" Page. Gathers information from the database. /// </summary> /// <param name="id">Id of the Module</param> /// <returns>A dynamic "Module Show" webpage which provides a form to input new module information.</returns> /// <example>GET : /Modle/Update/5</example> public ActionResult Update(int id) { UpdateModule ViewModel = new UpdateModule(); string url = "moduledata/findmodule/" + id; HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { ModuleDto SelectedModule = response.Content.ReadAsAsync<ModuleDto>().Result; ViewModel.module = SelectedModule; url = "moduledata/GetComponentsForModules/" + id; response = client.GetAsync(url).Result; IEnumerable<ComponentDto> SelectedComponents = response.Content.ReadAsAsync<IEnumerable<ComponentDto>>().Result; ViewModel.component = SelectedComponents; return View(ViewModel); } else { return RedirectToAction("Error"); } }
private void LoadBugInfoList() { try { mListBugInfos.Clear(); if (mDatabaseInfo == null) { return; } if (mCurrentVersion == null) { return; } string strVersion = mCurrentVersion.StrValue; string strSql; OperationReturn optReturn; switch (mDatabaseInfo.TypeID) { case 2: strSql = string.Format("SELECT * FROM T_UPDATE_LIST WHERE C001 LIKE '{0}%' ORDER BY C001", strVersion); optReturn = MssqlOperation.GetDataSet(mDBConnectionString, strSql); break; case 3: strSql = string.Format("SELECT * FROM T_UPDATE_LIST WHERE C001 LIKE '{0}%' ORDER BY C001", strVersion); optReturn = OracleOperation.GetDataSet(mDBConnectionString, strSql); break; default: ShowException(string.Format("DBType invalid.")); return; } if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } DataSet objDataSet = optReturn.Data as DataSet; if (objDataSet == null) { ShowException(string.Format("Fail. DataSet is null")); return; } int count = objDataSet.Tables[0].Rows.Count; for (int i = 0; i < count; i++) { DataRow dr = objDataSet.Tables[0].Rows[i]; UpdateModule info = new UpdateModule(); info.SerialNo = dr["C001"].ToString(); info.Type = Convert.ToInt32(dr["C002"]); info.ModuleID = Convert.ToInt32(dr["C003"]); info.ModuleName = dr["C004"].ToString(); info.OptDate = dr["C005"].ToString(); info.Level = Convert.ToInt32(dr["C006"]); info.Content = dr["C007"].ToString(); info.LangID = dr["C008"].ToString(); info.ModuleLangID = dr["C009"].ToString(); mListBugInfos.Add(info); } AppendMessage(string.Format("LoadBugInfoList end.\t{0}", count)); } catch (Exception ex) { ShowException(ex.Message); } }
private void AddBugInfos() { try { if (mCurrentVersion == null) { return; } UpdateModule info = new UpdateModule(); int serialNoIndex = GetBugSerialNoIndex(); serialNoIndex++; info.SerialNo = string.Format("{0}{1}", mCurrentVersion.StrValue, serialNoIndex.ToString("0000")); var bugType = ComboBugTypes.SelectedItem as ComboItem; if (bugType == null) { ShowException(string.Format("Bug Type invalid!")); return; } info.Type = bugType.IntValue; var module = ComboModules.SelectedItem as ComboItem; if (module == null) { ShowException(string.Format("Module invalid!")); return; } info.ModuleID = module.IntValue; info.ModuleName = module.Name; DateTime dtValue; if (!DateTime.TryParse(TxtUpdateDate.Text + " 00:00:00", out dtValue)) { ShowException(string.Format("UpdateDate invalid!")); return; } info.OptDate = dtValue.ToString("yyyyMMdd"); int intValue; if (!int.TryParse(TxtLevel.Text, out intValue) || intValue < 0 || intValue > 10) { ShowException(string.Format("Level invalid!")); return; } info.Level = intValue; info.Content = TxtContent.Text; int langIDIndex = GetBugLangIDIndex(info.ModuleID); langIDIndex++; info.LangID = string.Format("MC{0}{1}", info.ModuleID.ToString("0000"), langIDIndex.ToString("0000")); info.ModuleLangID = string.Format("M{0}", info.ModuleID.ToString("0000")); if (mDatabaseInfo == null) { return; } bool bIsSucess = false; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += (s, de) => { try { string strConn = mDatabaseInfo.GetConnectionString(); int dbType = mDatabaseInfo.TypeID; string strSql; IDbConnection objConn; IDbDataAdapter objAdapter; DbCommandBuilder objCmdBuilder; switch (dbType) { case 2: strSql = string.Format("SELECT * FROM T_UPDATE_LIST WHERE 1 = 2"); objConn = MssqlOperation.GetConnection(strConn); objAdapter = MssqlOperation.GetDataAdapter(objConn, strSql); objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter); break; case 3: strSql = string.Format("SELECT * FROM T_UPDATE_LIST WHERE 1 = 2"); objConn = OracleOperation.GetConnection(strConn); objAdapter = OracleOperation.GetDataAdapter(objConn, strSql); objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter); break; default: ShowException(string.Format("DatabaseType invalid!")); bIsSucess = false; return; } if (objConn == null || objAdapter == null || objCmdBuilder == null) { ShowException(string.Format("DBObject is null")); bIsSucess = false; return; } objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges; objCmdBuilder.SetAllValues = false; try { DataSet objDataSet = new DataSet(); objAdapter.Fill(objDataSet); DataRow dr = objDataSet.Tables[0].NewRow(); dr["C001"] = info.SerialNo; dr["C002"] = info.Type; dr["C003"] = info.ModuleID; dr["C004"] = info.ModuleName; dr["C005"] = info.OptDate; dr["C006"] = info.Level; dr["C007"] = info.Content; dr["C008"] = info.LangID; dr["C009"] = info.ModuleLangID; dr["C010"] = mCurrentVersion.Display; objDataSet.Tables[0].Rows.Add(dr); objAdapter.Update(objDataSet); objDataSet.AcceptChanges(); bIsSucess = true; } catch (Exception ex) { ShowException(string.Format("Fail.\t{0}", ex.Message)); bIsSucess = false; } finally { if (objConn.State == ConnectionState.Open) { objConn.Close(); } objConn.Dispose(); } } catch (Exception ex) { ShowException(ex.Message); } }; worker.RunWorkerCompleted += (s, re) => { worker.Dispose(); if (bIsSucess) { AppendMessage(string.Format("Add end.\t{0}", info.SerialNo)); ReloaddBugInfos(); } }; worker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
public async Task <IActionResult> Put(Guid moduleId, [FromBody] UpdateModule command) { await _wordsModuleService.UpdateAsync(UserId, moduleId, command.Name, command.Description); return(NoContent()); }
public override void RegisterOver() { updateModule = ModuleManager.Instance().FindModule <UpdateModule>(); }
private DockPanel CreateContentLabel(UpdateModule module) { DockPanel dpanel = null; Dispatcher.Invoke(new Action(() => { dpanel = new DockPanel(); dpanel.Style = this.FindResource("DockPanelInUpdateContent") as Style; DockPanel panImages = new DockPanel(); panImages.Width = 120; panImages.HorizontalAlignment = HorizontalAlignment.Right; panImages.SetValue(DockPanel.DockProperty, Dock.Right); dpanel.Children.Add(panImages); string strVersion = string.Empty; try { strVersion = module.SerialNo.Substring(0, 12); string str1 = strVersion.Substring(0, 1); string str2 = strVersion.Substring(1, 2); string str3 = strVersion.Substring(3, 3); string str4 = strVersion.Substring(6, 3); string str5 = strVersion.Substring(9); strVersion = str1 + "." + str2 + "." + str3 + "." + str4 + "." + str5; } catch { } TextBlock lbl = new TextBlock(); if (string.IsNullOrEmpty(strVersion)) { lbl.Text = App.GetLanguage(module.SerialNo, module.Content); } else { lbl.Text = App.GetLanguage(module.SerialNo, module.Content) + " [" + strVersion + "]"; } lbl.HorizontalAlignment = HorizontalAlignment.Left; lbl.VerticalAlignment = VerticalAlignment.Top; lbl.TextWrapping = TextWrapping.Wrap; dpanel.Children.Add(lbl); lbl.SetValue(DockPanel.DockProperty, Dock.Left); Image img = null; for (int i = 0; i < module.Level; i++) { img = new Image(); img.Source = new BitmapImage(new Uri(@"pack://application:,,,/Images/Level.ico", UriKind.Absolute)); img.HorizontalAlignment = HorizontalAlignment.Left; img.VerticalAlignment = System.Windows.VerticalAlignment.Top; img.Width = 12; img.Height = 12; if (i == module.Level - 1) { img.Margin = new Thickness(5, 0, 15, 0); } else { img.Margin = new Thickness(5, 0, 0, 0); } panImages.Children.Add(img); } })); return(dpanel); }
public ActionResult UpdateModule(UpdateModule updateModule) { var registeredModule = this._moduleService.Update(updateModule); return(Json(registeredModule)); }
private bool ShouldFlush(string moduleName, int majorVersion, Condition condition, UpdateModule updateModule = null) { if (condition.Invoke(this, moduleName, majorVersion) && ReadFromStream() && condition.Invoke(this, moduleName, majorVersion)) { updateModule?.Invoke(this, moduleName, majorVersion); return(true); } return(false); }