示例#1
0
 public static void RestartApplication(IHostApplicationLifetime applicationLifetime, RestartReason restartReason, Action <bool> restart = null)
 {
     try
     {
         if (applicationLifetime != null)
         {
             if (restartReason != null)
             {
                 KraftLogger.LogDebug($"Method: RestartApplication: Stopping application Reason: {restartReason.Reason} additional info {restartReason.Description}");
             }
             applicationLifetime.StopApplication();
             if (!applicationLifetime.ApplicationStopping.IsCancellationRequested)
             {
                 Task.Delay(10 * 1000, applicationLifetime.ApplicationStopping);
             }
             restart?.Invoke(true);
         }
         else
         {
             KraftLogger.LogDebug("Method: RestartApplication: applicationLifetime is null.");
         }
     }
     catch (Exception exception)
     {
         KraftLogger.LogError(exception, "Method: RestartApplication(IApplicationLifetime applicationLifetime)");
     }
 }
示例#2
0
        public ActionResult SignIn()
        {
            // Instruct the OIDC client middleware to redirect the user agent to the identity provider.
            // Note: the authenticationType parameter must match the value configured in Startup.cs
            KraftLogger.LogDebug("ActionResult SignIn");
            AuthenticationProperties authenticationProperties = new AuthenticationProperties
            {
                RedirectUri = Url.Action("Index", "Home")
            };

            return(Challenge(authenticationProperties, OpenIdConnectDefaults.AuthenticationScheme));
        }
示例#3
0
 private static async void OnApplicationStopping()
 {
     if (string.IsNullOrEmpty(_BaseUrl))
     {
         KraftLogger.LogDebug("Method: OnApplicationStopping: BaseUrl is null.");
         return;
     }
     using (HttpClient client = new HttpClient())
     {
         using (HttpResponseMessage responseMessage = await client.GetAsync(_BaseUrl))
         {
             using (HttpContent content = responseMessage.Content)
             {
                 KraftLogger.LogDebug($"Method: OnApplicationStopping: Calling the application {_BaseUrl} to keepalive.");
                 await content.ReadAsStringAsync();
             }
         }
     }
 }
示例#4
0
        /// <summary>
        /// Calls and executes plugin.
        /// </summary>
        /// <param name="execContext">Data loader context.</param>
        /// <param name="parameters">Dictionary or custom parameters of the Call Data Loader.</param>
        /// <param name="isWriteOperation">boolean parameter - the type of operation.</param>
        /// <returns>The called plugin result.</returns>
        private List <Dictionary <string, object> > ExecuteOperation(IDataLoaderContext execContext, Dictionary <string, object> parameters, bool isWriteOperation)
        {
            List <Dictionary <string, object> > result = new List <Dictionary <string, object> >();
            CustomSettings customSettings = new CustomSettings(execContext, isWriteOperation);

            if (execContext.ProcessingContext.InputModel.ProcessingContextRef is RequestExecutor requestExecutor)
            {
                parameters = ConcatDictionaries(parameters, GetChildrenFromKeyRecursive(execContext.ProcessingContext.InputModel.Data, execContext.CurrentNode.NodeKey) as IDictionary <string, object>);

                object getChildren = GetChildrenFromKeyRecursive(execContext.ProcessingContext.InputModel.Data, execContext.CurrentNode.NodeKey);

                if (getChildren != null && getChildren is IDictionary <string, object> children)
                {
                    parameters = ConcatDictionaries(parameters, children);
                }
                else
                {
                    parameters = ConcatDictionaries(parameters, execContext.ProcessingContext.InputModel.Data);

                    KraftLogger.LogDebug($"Key '{execContext.CurrentNode.NodeKey}' was not passed in the request data. The CallDataLoader will be executed with input model's data. For the request to node '{execContext.ProcessingContext.InputModel.Module}.{execContext.ProcessingContext.InputModel.NodeSet}.{execContext.CurrentNode.NodeKey}'.");
                }

                InputModelParameters inputModelParameters = new InputModelParameters()
                {
                    Module         = customSettings.ModuleValue,
                    Nodeset        = customSettings.NodesetValue,
                    Nodepath       = customSettings.NodepathValue,
                    Data           = parameters,
                    FormCollection = execContext.ParentResult,
                    KraftGlobalConfigurationSettings = execContext.ProcessingContext.InputModel.KraftGlobalConfigurationSettings,
                    IsWriteOperation = customSettings.OperationValue,
                    LoaderType       = execContext.ProcessingContext.InputModel.LoaderType,
                    SecurityModel    = execContext.ProcessingContext.InputModel.SecurityModel,
                    Server           = execContext.ProcessingContext.InputModel.Server != default(ReadOnlyDictionary <string, object>) ? execContext.ProcessingContext.InputModel.Server.ToDictionary(item => item.Key, item => item.Value) : null
                };

                IProcessingContext processingContext = new ProcessingContext(execContext.ProcessingContext.ProcessorHandler)
                {
                    InputModel = new InputModel(inputModelParameters)
                };

                requestExecutor.ExecuteReEntrance(processingContext, false);

                if (!processingContext.ReturnModel.Status.IsSuccessful)
                {
                    string message = string.Empty;
                    string space   = " ";

                    execContext.ProcessingContext.ReturnModel.Status.IsSuccessful = processingContext.ReturnModel.Status.IsSuccessful;

                    processingContext.ReturnModel.Status.StatusResults.ForEach(statusResult =>
                    {
                        if (message.Length != 0)
                        {
                            message += space + statusResult.Message;
                        }
                        else
                        {
                            message += statusResult.Message;
                        }
                    });

                    throw new Exception(message);
                }

                if (processingContext.ReturnModel.Data is List <Dictionary <string, object> > resultListOfDictionary)
                {
                    result = resultListOfDictionary;
                }
                else if (processingContext.ReturnModel.Data is Dictionary <string, object> resultDictionary)
                {
                    result.Add(resultDictionary);
                }
            }

            return(result);
        }