Exemple #1
0
    void LoadDatabaseSettings (string filePath, string fileName)
    {
      DatabaseConnection = DatabaseConnection ?? new TDatabaseConnection (filePath, fileName);

      // database
      if (DatabaseConnection.Request ()) {
        // notify factory database
        // SQL
        var message = new TShellMessage (TMessageAction.Response, TypeInfo);
        message.Support.Argument.Types.ConnectionData.CopyFrom (DatabaseConnection.Request (TAuthentication.SQL));

        DelegateCommand.PublishModuleMessage.Execute (message);

        // Windows
        message = new TShellMessage (TMessageAction.Response, TypeInfo);
        message.Support.Argument.Types.ConnectionData.CopyFrom (DatabaseConnection.Request (TAuthentication.Windows));

        DelegateCommand.PublishModuleMessage.Execute (message);

        // settings validating
        TDispatcher.Invoke (RequestServiceValidationDispatcher);
      }

      else {
        var errorMessage = new TErrorMessage (Properties.Resource.RES_ERROR, Properties.Resource.RES_LOAD_DATABASE, (string) DatabaseConnection.Result.ErrorContent)
        {
          Severity = TSeverity.Hight
        };

        TDispatcher.BeginInvoke (ShowErrorBoxDispatcher, errorMessage);
      }
    }
Exemple #2
0
    void DatabaseSettingsSuccessDispatcher ()
    {
      // notify main process
      NotifyProcess (TCommandComm.Success);

      // update INI file
      var filePath = System.Environment.CurrentDirectory;
      var fileName = TNames.SettingsIniFileName;

      var data = new TDatabaseConnection (filePath, fileName);

      if (data.Request ()) {
        TDispatcher.Invoke (CloseSnackbarDispatcher);

        Model.SnackbarContent.SetMessage (Properties.Resource.RES_WELLCOME);
        TDispatcher.BeginInvoke (ShowSnackbarDispatcher, false);

        TDispatcher.Invoke (DatabaseValidateDispatcher);
      }

      else {
        var errorMessage = new TErrorMessage (Properties.Resource.RES_ERROR, Properties.Resource.RES_LOAD, (string) data.Result.ErrorContent)
        {
          Severity = TSeverity.Hight
        };

        TDispatcher.BeginInvoke (ShowErrorBoxDispatcher, errorMessage);
      }
    }
Exemple #3
0
    void SaveSettingsDispatcher (TDatabaseAuthentication databaseAuthentication)
    {
      var filePath = System.Environment.CurrentDirectory;
      var fileName = TNames.SettingsIniFileName;

      DatabaseConnection = DatabaseConnection ?? new TDatabaseConnection (filePath, fileName);

      if (DatabaseConnection.Save (databaseAuthentication)) {
        DatabaseConnection.Request (); // update

        // notify edit
        var message = new TShellMessage (TMessageAction.Response, TypeInfo);
        message.Support.Argument.Types.ConnectionData.CopyFrom (databaseAuthentication);

        DelegateCommand.PublishModuleMessage.Execute (message);

        // settings validating
        TDispatcher.Invoke (RequestServiceValidationDispatcher);
      }

      else {
        TDispatcher.Invoke (CloseSnackbarDispatcher);

        var errorMessage = new TErrorMessage (Properties.Resource.RES_ERROR, Properties.Resource.RES_SAVE, (string) DatabaseConnection.Result.ErrorContent)
        {
          Severity = TSeverity.Hight
        };

        TDispatcher.BeginInvoke (ShowErrorBoxDispatcher, errorMessage);
      }
    }
Exemple #4
0
    internal void NotifyDatabaseErrorHandler (TErrorMessage errorMessage)
    {
      //notify shell database error
      var message = new TServicesMessage (TMessageAction.SettingsValidated, TypeInfo);
      message.Support.Select (TActionStatus.Error);

      PublishInvoke (message);

      // show error message
      var msg = new TServicesMessage (TMessageAction.Error, TypeInfo);
      msg.Support.ErrorMessage.CopyFrom (errorMessage);

      PublishInvoke (msg);
    }
Exemple #5
0
    void LoadSupportSettings (string filePath, string fileName)
    {
      SupportSettings = SupportSettings ?? TSupportSettings.Create (filePath, fileName);

      // supprt
      if (SupportSettings.Validate ().IsFalse ()) {
        var errorMessage = new TErrorMessage (Properties.Resource.RES_ERROR, Properties.Resource.RES_LOAD_SUPPORT, (string) SupportSettings.Result.ErrorContent)
        {
          Severity = TSeverity.Hight
        };

        TDispatcher.BeginInvoke (ShowErrorBoxDispatcher, errorMessage);
      }
    }
Exemple #6
0
        protected override void Communicate(out TErrorMessage errorMsg)
        {
            if (reqBody == null)
            {
                Exception error = new Exception("请求报文 [TREQOPCServerTagList] 类未实例化");
                error.Data["ErrCode"] = 999999;
                error.Data["ErrText"] = error.Message;
                throw error;
            }

            respBody =
                Call <TRESPOPCServerTagListSet>(
                    reqBody,
                    out errorMsg);
        }
Exemple #7
0
        async Task OperationAsync(TServiceAction <IEntityAction> serviceAction)
        {
            if (Service.NotNull())
            {
                var    param        = serviceAction.Param as IEntityAction;
                string messageError = $"[{param.Operation.CategoryType.Category} - {param.Operation.Operation} - {param.Operation.Extension}]";

                try {
                    var task = Service.OperationAsync(param);

                    if (task == await Task.WhenAny(task).ConfigureAwait(false))
                    {
                        if (task.Result.Result.IsValid.IsFalse())
                        {
                            var error = new TErrorMessage("Database ERROR Services", messageError, task.Result.Result.ErrorContent as string)
                            {
                                Severity = TSeverity.Low
                            };


                            ErrorToShow(error);
                        }

                        serviceAction.ServiceArgs.Complete(task.Result, null);
                    }
                }

                catch (Exception exception) {
                    string msg = rr.Library.Helper.THelper.ExceptionStringFormat(serviceAction.ServiceArgs.CompletedCallbackName, exception);

                    var error = new TErrorMessage(Properties.Resource.RES_ERROR, messageError, msg)
                    {
                        Severity = TSeverity.Low
                    };

                    ErrorToShow(error);

                    serviceAction.ServiceArgs.Error = exception;
                    serviceAction.ServiceArgs.Complete(param, null);
                }
            }
        }
Exemple #8
0
    public TShellModelReference ()
    {
      ProgressValue = 0;
      IsViewEnabled = false;

      DatabaseOnVisibility = Visibility.Collapsed;
      DatabaseOffVisibility = Visibility.Visible;

      SQLAuthenticationVisibility = Visibility.Collapsed;
      WindowsAuthenticationVisibility = Visibility.Collapsed;

      LockedVisibility = Visibility.Visible;

      ServiceReportVisibility = Visibility.Collapsed;

      ErrorBoxContent = TErrorMessage.CreateDefault;

      Message = string.Empty;
      ServiceReportMessage = string.Empty;
    }
Exemple #9
0
    void SettingsValidatingDispatcher ()
    {
      var filePath = System.Environment.CurrentDirectory;
      var fileName = TNames.SettingsIniFileName;

      var data = new TDatabaseConnection (filePath, fileName);

      // success
      if (data.Request ()) {
        if (data.IsValidate) {
          SelectConnectionString (data);

          // notify shell database success
          var message = new TServicesMessage (TMessageAction.SettingsValidated, TypeInfo);
          message.Support.Select (TActionStatus.Success);
          message.Support.Argument.Types.Select (data.Authentication);

          PublishInvoke (message);
        }

        else {
          var errorMessage = new TErrorMessage (Properties.Resource.RES_ERROR, Properties.Resource.RES_LOAD_SETTINGS, Properties.Resource.RES_BAD_CONNECTION)
          {
            Severity = TSeverity.Hight
          };

          // notify shell database error
          NotifyDatabaseErrorHandler (errorMessage);
        }
      }

      else {
        var errorMessage = new TErrorMessage (Properties.Resource.RES_ERROR, Properties.Resource.RES_LOAD_SETTINGS, (string) data.Result.ErrorContent)
        {
          Severity = TSeverity.Hight
        };

        // notify shell database error
        NotifyDatabaseErrorHandler (errorMessage);
      }
    }
Exemple #10
0
    public void ShowErrorBox (TErrorMessage errorMessage)
    {
      if (errorMessage != null) {
        ErrorBoxContent.CopyFrom (errorMessage);
        IsErrorBoxOpen = true;

        if (errorMessage.IsSeverity (TSeverity.Low)) {
          ClearPanels ();
          Unlock ();
        }

        if (errorMessage.IsSeverity (TSeverity.Hight)) {
          ClearPanels ();
          Unlock ();
          DatabaseStatus (false);
        }

        if (errorMessage.IsSeverity (TSeverity.Danger)) {
          ClearPanels ();
          Lock ();
          DatabaseStatus (false);
        }
      }
    }
Exemple #11
0
 protected override void Communicate(out TErrorMessage errorMsg)
 {
     throw new NotImplementedException();
 }
Exemple #12
0
 public TErrorEventArgs(TErrorMessage error)
 {
     Error = TErrorMessage.CreateDefault;
     Error.CopyFrom(error);
 }
Exemple #13
0
 void ErrorToShow(TErrorMessage error)
 {
     ShowError?.Invoke(this, new TErrorEventArgs(error));
 }
Exemple #14
0
    public void ShowErrorBoxDispatcher (TErrorMessage errorMessage)
    {
      Model.ShowErrorBox (errorMessage);

      ApplyChanges ();
    }
Exemple #15
0
 void ShowError (TErrorMessage error)
 {
   DelegateCommand.NotifyDatabaseError.Execute (error);
 }