public void GetMethodInfoFailTest() { var workCommand = WorkCommand.Create(typeof(ReflectionHelperTest), nameof(NoneStaticExample)); var info = workCommand.GetMethodInfo(); Assert.IsNull(info); }
/// <summary> /// Build a new WorkCommand /// </summary> /// <param name="action"></param> /// <param name="parameters"></param> /// <returns></returns> protected WorkCommand BuildWorkCommand(Delegate action, object[] parameters = null) { var objectType = HostedObjecType ?? action.Method.DeclaringType; var parameterTypes = action.Method.GetParameters().Select(p => p.ParameterType).ToArray(); var newWorkCommand = WorkCommand.Create(objectType, action.Method.Name, parameters, parameterTypes); return(newWorkCommand); }
public void GetMethodInfoTest() { var workCommand = WorkCommand.Create(typeof(ReflectionHelperTest), nameof(StaticExample)); var info = workCommand.GetMethodInfo(); Assert.NotNull(info); Assert.AreEqual(typeof(ReflectionHelperTest), info.DeclaringType); Assert.AreEqual(nameof(StaticExample), info.Name); }
public async Task <Unit> Handle(WorkCommand command, CancellationToken cancellationToken) { await BeginChangeStatus(new PlayerStatusModel { PlayerId = command.PlayerId, Status = PlayerStatusEnum.打工 }); return(Unit.Value); }
private void OnPublicationTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs) { var identifier = Guid.NewGuid(); var workCommand = new WorkCommand { Identifier = identifier }; _endpointInstance.Send(Endpoints.Consumer, workCommand).Inline(); Console.WriteLine($"Sent a WorkEvent with Identifier: {identifier}"); }
public async Task <OkResult> Update([FromBody] Update update) // Handling bot updates { var message = update.Message; var courier = _dbContext.Couriers.FirstOrDefault(c => c.TelegramUsrName == message.From.Username); var client = Bot.Bot.GetClient(); if (courier == null) // Check registration(is he courier) { await client.SendTextMessageAsync(message.Chat.Id, "Sorry u're not registed. More info at https://github.com/RNRNRNR/deliverysystemAPI"); return(Ok()); } switch (courier.Status) { case 3: var confirm = new ConfirmCommand(); if (message.Text.Contains(confirm.Name)) { confirm.Execute(message, client, _dbContext); } else { await client.SendTextMessageAsync(message.Chat.Id, "To confirm delivery type /confirmdelivery"); } break; case 1: var work = new WorkCommand(); if (message.Text.Contains(work.Name)) { work.Execute(message, client, _dbContext); } break; case 2: await client.SendTextMessageAsync(message.Chat.Id, "Receive ur packages"); break; case null: var start = new StartCommand(); if (message.Text.Contains(start.Name)) { start.Execute(message, client, _dbContext); } break; } return(Ok()); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { //- this.ParentEntityView = this.GetNearestDominantOfType<IEntityView>(); var SelectedFontIndex = Display.AvailableFontFamilies.IndexOfMatch(font => font.Source == this.TextEditor.FontFamily.Source); if (SelectedFontIndex >= 0) { TextFont.SelectedIndex = SelectedFontIndex; } TextSize.SelectedItem = Convert.ToInt32(this.TextEditor.FontSize); WorkCommand NewCommand = null; NewCommand = new GenericCommand("ToggleBold"); NewCommand.Apply = (obj => { if (this.TextEditor.Selection.IsEmpty) { this.TextEditor.CurrentSwitchBold = this.TextBold.IsChecked.IsTrue(); } }); NewCommand.CanApply = (obj => true); this.TextBold.CommandBindings.Add(new CommandBinding(NewCommand)); NewCommand = new GenericCommand("ToggleUnderline"); NewCommand.Apply = (obj => { if (this.TextEditor.Selection.IsEmpty) { this.TextEditor.CurrentSwitchUnderline = this.TextUnderline.IsChecked.IsTrue(); } }); NewCommand.CanApply = (obj => true); this.TextUnderline.CommandBindings.Add(new CommandBinding(NewCommand)); NewCommand = new GenericCommand("ToggleItalic"); NewCommand.Apply = (obj => { if (this.TextEditor.Selection.IsEmpty) { this.TextEditor.CurrentSwitchItalic = this.TextItalic.IsChecked.IsTrue(); } }); NewCommand.CanApply = (obj => true); this.TextItalic.CommandBindings.Add(new CommandBinding(NewCommand)); //T trying to avoid resizing excess (not working)... this.TextEditor.PostCall(rte => rte.MaxWidth = double.PositiveInfinity); this.ParentWindow = this.GetNearestDominantOfType <Window>(); if (this.ParentWindow != null) { this.ParentWindow.Deactivated -= ParentWindow_Deactivated; this.ParentWindow.Deactivated += ParentWindow_Deactivated; } }
/// <summary> /// Start a new work job /// </summary> /// <param name="newWorkCommand"></param> /// <returns></returns> protected Guid StartWork(WorkCommand newWorkCommand) { var methodInfo = newWorkCommand.GetMethodInfo(HostedObjecType); if (!methodInfo.CheckMethodInfo()) { return(Guid.Empty); } m_IpcCommunication.SendData(newWorkCommand); return(newWorkCommand.Guid); }
public async Task <IActionResult> AcceptReceiving(int courierId) { var courier = _dbContext.Couriers.FirstOrDefault(c => c.Id == courierId); if (courier == null) { return(BadRequest("Courier not found")); } if (courier.Status != 2) { return(BadRequest("Courier is not waiting for packages")); } await WorkCommand.AcceptPackageReceiving(_dbContext, courierId); return(Ok()); }
public static WorkCommand FromBaseObject(BaseObject baseObj) { if (baseObj == null || baseObj.NativeObject == IntPtr.Zero) { return(null); } WorkCommand obj = baseObj as WorkCommand; if (object.Equals(obj, null)) { obj = new WorkCommand(CreatedWhenConstruct.CWC_NotToCreate); obj.BindNativeObject(baseObj.NativeObject, "CWorkCommand"); obj.IncreaseCast(); } return(obj); }
/// <summary> /// Get the MethodInfo from a WorkCommand /// </summary> /// <param name="workCommand"></param> /// <param name="type"></param> /// <returns></returns> public static MethodInfo GetMethodInfo(this WorkCommand workCommand, Type type = null) { if (workCommand == null) { return(null); } if (workCommand.ParameterTypes?.Length > 0 && workCommand.ParameterTypes?.Length == workCommand.Parameter?.Length) { for (int i = 0; i < workCommand.ParameterTypes.Length; i++) { var parameterType = workCommand.ParameterTypes[i]; var parameterValue = workCommand.Parameter[i]; var value = ConvertValueToParameterType(parameterType, parameterValue); if (value.GetType() != parameterType) { var exceptionText = $"Parameter {i} Type is: {parameterValue.GetType()} but should be {parameterType}"; throw new ArgumentException(exceptionText); } } } var parameterTypes = workCommand.ParameterTypes ?? new Type[0]; if (type != null) { var methodInfo = workCommand.Type.GetMethod(workCommand.Method, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance, null, CallingConventions.Any, parameterTypes, null); if (methodInfo != null) { return(methodInfo); } } var methodInfoStatic = workCommand.Type.GetMethod(workCommand.Method, BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, CallingConventions.Any, parameterTypes, null); if (methodInfoStatic != null) { return(methodInfoStatic); } return(null); }
public void MicroServiceThrowsException() { // Arrange var options = new BusOptions() { QueueName = "ExceptionThrowingTest01" }; using (var host = new MicroserviceHost <ExceptionThrowingService>(options)) using (var proxy = new MicroserviceProxy(options)) { host.Open(); // Act WorkCommand command = new WorkCommand { Name = "Marco" }; Action action = () => proxy.Execute(command); // Assert Assert.Throws <NotImplementedException>(action); } }
/// <summary> /// Exposes the commands which can be consumed. /// </summary> public void ExposeCommands() { WorkCommand ExposedWorkCommand = null; // ========================================================================================================= SimpleElement ExposedArea = new SimpleElement("Domain", "Domain"); SimpleElement ExposedGroup = new SimpleElement("Definition", "Definition"); this.CommandAreas_.Add(ExposedArea); this.CommandGroups_.PutIntoSublist(ExposedArea.TechName, ExposedGroup); // ------------------------------------------------------------------------------------- ExposedWorkCommand = new GenericCommand("EditDomain"); ExposedWorkCommand.Apply = (par => { var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Doc == null) { return; } DomainServices.DomainEdit(Doc.TargetComposition.CompositeContentDomain); }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Edit Domain...", ExposedWorkCommand.Name, "Edit the Domain of the current Composition", "book_edit.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- /* this would confuse the user? */ ExposedWorkCommand = new GenericCommand("NewDomain"); ExposedWorkCommand.Apply = (par => ProductDirector.CompositionDirector.CreateComposition(true)); ExposedWorkCommand.CanApply = (par => true); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("New Domain", ExposedWorkCommand.Name, "Creates a new Domain (and its empty template Composition).", "book_star.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); ExposedWorkCommand = new GenericCommand("OpenDomain"); ExposedWorkCommand.Apply = (par => ProductDirector.CompositionDirector.OpenDomainAndCreateCompositionOfIt(true)); ExposedWorkCommand.CanApply = (par => true); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Open Domain", ExposedWorkCommand.Name, "Opens a Domain for editing (and creates its emtpy template Composition).", "folder_book.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- ExposedWorkCommand = new GenericCommand("SaveDomainAs"); ExposedWorkCommand.Apply = (par => { var Engine = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Engine == null) { return; } var Confirmation = Display.DialogMessage("Confirmation", "Save also the current Composition as Domain's Template for create new ones?\n" + "(Note: Later, it can be used or just start empty Compositions)", EMessageType.Question, MessageBoxButton.YesNoCancel, MessageBoxResult.Yes); if (Confirmation == MessageBoxResult.Cancel || Confirmation == MessageBoxResult.None) { return; } var SaveTemplate = (Confirmation == MessageBoxResult.Yes); //T Console.WriteLine("Saving Domain as..."); var InitialRoute = (Engine.DomainLocation != null ? Engine.DomainLocation.LocalPath : (Engine.FullLocation == null ? Path.Combine(AppExec.UserDataDirectory, Engine.TargetComposition.CompositeContentDomain.TechName) : Path.Combine(Path.GetDirectoryName(Engine.FullLocation.LocalPath), Engine.TargetComposition.CompositeContentDomain.TechName))); var TargetRoute = Display.DialogGetSaveFile("Save Domain as", FileDataType.FileTypeDomain.Extension, FileDataType.FileTypeDomain.FilterForSave, InitialRoute); if (TargetRoute == null) { return; } var CurrentWindow = Display.GetCurrentWindow(); CurrentWindow.Cursor = Cursors.Wait; var TargetDomain = Engine.TargetComposition.CompositeContentDomain; Visual Snapshot = null; if (SaveTemplate && TargetDomain.OwnerComposition.ActiveView != null) { Snapshot = TargetDomain.OwnerComposition.ActiveView .ToVisualSnapshot(DocumentEngine.PART_SNAPSHOT_WIDTH, DocumentEngine.PART_SNAPSHOT_HEIGHT); } TargetDomain.SetTemplateSaving(SaveTemplate); var Result = DocumentEngine.StoreToLocation <Domain>(TargetDomain, Domain.__ClassDefinitor.Name, TargetDomain.Classification.ContentTypeCode, TargetRoute, DomainDocumentUri, true, false, TargetDomain, Snapshot); if (!Result.IsAbsent()) { CurrentWindow.Cursor = Cursors.Arrow; Display.DialogMessage("Error!", "Cannot save Domain.\n\nProblem: " + Result, EMessageType.Warning); return; } Engine.DomainLocation = TargetRoute; this.WorkspaceDirector.ShellProvider.RefreshSelection(); CurrentWindow.Cursor = Cursors.Arrow; }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Save Domain As", ExposedWorkCommand.Name, "Saves the current Domain to the specified file.", "book_saveas.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- // Ordered list of quick access commands this.QuickExposedCommands.Add(this.CommandExpositors["NewDomain"]); this.QuickExposedCommands.Add(this.CommandExpositors["OpenDomain"]); this.QuickExposedCommands.Add(this.CommandExpositors["EditDomain"]); this.QuickExposedCommands.Add(this.CommandExpositors["SaveDomainAs"]); // ------------------------------------------------------------------------------------- ExposedWorkCommand = new GenericCommand("Concept Definitions..."); ExposedWorkCommand.Apply = (par => { var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Doc == null) { return; } DomainServices.DefineDomainConcepts(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain); }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Concept Defs...", ExposedWorkCommand.Name, "Edit the Concept Definitions of the Domain", "imtc_concept.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- ExposedWorkCommand = new GenericCommand("Relationship Definitions..."); ExposedWorkCommand.Apply = (par => { var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Doc == null) { return; } DomainServices.DefineDomainRelationships(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain); }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Relationship Defs...", ExposedWorkCommand.Name, "Edit the Relationship Definitions of the Domain", "imtc_relationship.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- ExposedWorkCommand = new GenericCommand("Link-Role Variant Definitions..."); ExposedWorkCommand.Apply = (par => { var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Doc == null) { return; } DomainServices.DefineDomainLinkRoleVariants(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain); }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Link-Role Variant Defs...", ExposedWorkCommand.Name, "Edit the Link-Role Variant Definitions of the Domain", "link_role_variants.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- ExposedWorkCommand = new GenericCommand("Marker Definitions..."); ExposedWorkCommand.Apply = (par => { var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Doc == null) { return; } DomainServices.DefineDomainMarkers(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain); }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Marker Defs...", ExposedWorkCommand.Name, "Edit the Marker Definitions of the Domain", "award_star_edit.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- ExposedWorkCommand = new GenericCommand("Table-Structure Definitions..."); ExposedWorkCommand.Apply = (par => { var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Doc == null) { return; } DomainServices.EditDomainTableDefinitions(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain); }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Table-Structure Defs...", ExposedWorkCommand.Name, "Edit the Table-Structure Definitions of the Domain", "table_alter.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); ExposedWorkCommand = new GenericCommand("Base Tables..."); ExposedWorkCommand.Apply = (par => { var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Doc == null) { return; } DomainServices.EditDomainBaseTables(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain); }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Base Tables...", ExposedWorkCommand.Name, "Edit the Base Tables of the Domain", "table_multiple.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- ExposedWorkCommand = new GenericCommand("External Languages..."); ExposedWorkCommand.Apply = (par => { var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Doc == null) { return; } DomainServices.DefineDomainExternalLanguages(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain); }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("External Languages...", ExposedWorkCommand.Name, "Edit the External Languages declared for the Domain", "page_white_code_red.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- ExposedWorkCommand = new GenericCommand("Idea-Def Clusters..."); ExposedWorkCommand.Apply = (par => { var Doc = (CompositionEngine)this.WorkspaceDirector.ActiveDocumentEngine; if (Doc == null) { return; } DomainServices.DefineDomainIdeaDefClusters(Doc.CurrentView.OwnerCompositeContainer.CompositeContentDomain); }); ExposedWorkCommand.CanApply = (par => (this.WorkspaceDirector.ActiveDocument != null)); this.CommandExpositors.Add(ExposedWorkCommand.Name, new WorkCommandExpositor("Idea-Def Clusters...", ExposedWorkCommand.Name, "Edit the Idea-Definition Clusters of the Domain", "def_clusters.png", EShellCommandCategory.Document, ExposedArea.TechName, ExposedGroup.TechName, ExposedWorkCommand)); // ------------------------------------------------------------------------------------- }
public BaseObject Create() { WorkCommand emptyInstance = new WorkCommand(CreatedWhenConstruct.CWC_NotToCreate); return(emptyInstance); }