Using Xafari Server. Local Mode

This topic describes how to use FileSearcher module as part of the Xafari Server.

  • Add FileSearcher assembly to the DemoApp.Module project references.
  • Invoke DemoAppModule module designer and add FileSearcherModule.
  • Customize Application Model to provide the view of the Message Queue. Invoke Model Editor and navigate to the NavigationItem|Xafari Server Demo node, add MQMessage_ListView to it. Through the use NavigationItemAttibute, SearchFiles_ListView item also is presented in this node, this provide the view the result of the server processing.
  • Implement logic to add Message to the Message Queue. For it, add WindowController with one Simple Action to the DemoApp.Module  
  • c#
  • VB

public class SearchFilesController : WindowController
  public SearchFilesController()
    TargetWindowType = WindowType.Main;
    new SimpleAction(this, "FindFiles", PredefinedCategory.Unspecified) { Caption = "Find Files" }.Execute += FindFiles_Execute;
  private void FindFiles_Execute(object sender, SimpleActionExecuteEventArgs e)
    using (var objectSpace = Application.CreateObjectSpace())
      var messageData = objectSpace.CreateObject<SearchFiles>();
      messageData.SearchPattern = "*.dll";
      messageData.Path = Environment.CurrentDirectory;
      MQManager.Instance.InsertMessage(messageData, SearchFiles.Tag, "Find .dll files in current directory");
    MessageObject.CreateMessageInfo(e.ShowViewParameters, Application, "Information", "Search files message is queued.");

Public Class SearchFilesController
  Inherits WindowController
  Public Sub New()
    TargetWindowType = WindowType.Main
    New SimpleAction(Me, "FindFiles", PredefinedCategory.Unspecified) With {.Caption = "Find Files"}.Execute += FindFiles_Execute
  End Sub
  Private Sub FindFiles_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs)
    Using objectSpace = Application.CreateObjectSpace()
      Dim messageData = objectSpace.CreateObject(Of SearchFiles)()
      messageData.SearchPattern = "*.dll"
      messageData.Path = Environment.CurrentDirectory
      MQManager.Instance.InsertMessage(messageData, SearchFiles.Tag, "Find .dll files in current directory")
    End Using
    MessageObject.CreateMessageInfo(e.ShowViewParameters, Application, "Information", "Search files message is queued.")
  End Sub
End Class

Code above create SearchFiles instance before inserting the Message into a queue in the DB, this instance is a data for the Message. The search parameters are the "*.dll" mask and the current directory of the application. MQManager.Instance.InsertMessage method inserts a Message into a Message Queue. The method receives an instance of an object with additional data, the type of Message (SearchFiles.Tag) and a brief description of the Message.

The application is ready to work with Xafari Server in local mode.

Run application and see the Message Queue and found files. Until the lists are empty.

Execute Find Files Action from the toolbox. The new Message appears in the Message Queue. After its status changes to "Completed", you can open the SearchFiles list and see the result of SearcFilesHandler handler.