Exemple #1
0
        private void ActionManagerTest()
        {
            var        am = Program.GetServices().GetRequiredService <IActionManager>();
            ActionInfo ai = am.GetActionInfo("Sys.LoginRequest");

            _logger.LogDebug(ai.GetInputParamTable().ToString());
            _logger.LogDebug(ai.GetOutputParamTable().ToString());
            var dt = ai.GetOutputParamTable();

            dt.AddNew();
            dt["PublicKey"] = "123456789";
            dt.Update();
        }
Exemple #2
0
        public async Task <DataPackage> InvokeInternalAsync(ActionInfo ai, DataPackage dp)
        {
            //var ctx = ai.GetContext();
            string totals = string.Empty;

            string testName  = (string)dp["@ObjectName"];
            int    loopCount = ((string)dp["@IDs"]).Split(',')[0].ToIntOrDefault();

            switch (testName)
            {
            case "Test":
                totals = BlankProcedureForCallSpeedTests();
                break;

            case "RecursiveCallExecuteAsync":
                totals = await RecursiveCallExecuteAsync(ai, loopCount);

                break;

            case "GetSettingsSpeedTest":
                totals = await GetSettingsSpeedTest(ai, loopCount);

                break;
            }

            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("@Result", totals)
                   .Update());
        }
Exemple #3
0
        public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp)
        {
            DateTime date      = (DateTime)dp["@Date"];
            string   branchID  = (string)dp["@BranchID"];
            string   dealType  = (string)dp["@DealType"];
            int      confirmed = (int)dp["@Confirmed"];
            string   batch     = (string)dp["@Batch"];

            var ctx = ai.GetContext();
            var cs  = ctx.Services
                      .GetRequiredService <IConfiguration>()
                      .GetSection($"connectionStrings:{ctx.ConnectionName}").Get <ConnectInfo>();

            string[] filials   = DealValuesCalculate.GetParamListData(ai, "@BranchID", branchID, "0");
            string[] dealTypes = DealValuesCalculate.GetParamListData(ai, "@DealType", dealType, "Все");

            var pipe = ctx.Services
                       .GetRequiredService <PipeQueue>();
            StringBuilder sb = new StringBuilder();

            foreach (var filial in filials)
            {
                foreach (var dtype in dealTypes)
                {
                    using (MdbContext mdb = new MdbContext(cs))
                    {
                        try
                        {
                            await mdb.ExecuteAsync($@"
							exec workdb..mib_msfo_Reserve_OperGen 
								@Date = '{date.ToString("yyyyMMdd")}'
								,@BranchID = {filial}
								,@DealType = '{dtype}'
								,@Confirmed = {confirmed}
								,@Batch = '{batch}'"                                );

                            string result = $"Success mib_msfo_Reserve_OperGen {date} filial={filial} deal type={dtype}";
                            pipe.Write(ctx, result);
                            sb.AppendLine(result);
                        }
                        catch (Exception ex)
                        {
                            string message = $"{LogLevels.Error} {ex.Message}\n{ex.StackTrace}";
                            pipe.Write(ctx, message);
                            sb.AppendLine(message);
                        }
                    }
                }
            }
            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("@Result", sb.ToString())
                   .Update());
        }
Exemple #4
0
        public DataPackage Invoke(ActionInfo ai, DataPackage dp)
        {
            var ctx = ai.GetContext();

            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("Result", ctx
                             .Services
                             .GetRequiredService <PipeQueue>()
                             .Read(ctx))
                   .Update());
        }
Exemple #5
0
        public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp)
        {
            GetParameters(ai, dp);
            var ctx = ai.GetContext();

            var r = ctx.CreateJMXFactory(_connectionName)
                    .SchemaFactory
                    .CreateJMXRepo();

            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("ObjectSchema", (await r.GetSchemaAsync(_objectName)).ToString())
                   .Update());
        }
Exemple #6
0
        public DataPackage Invoke(ActionInfo ai, DataPackage dp)
        {
            GetParameters(ai, dp);
            var ctx = ai.GetContext();

            var r = ctx.CreateJMXFactory(_connectionName)
                    .SchemaFactory
                    .CreateJMXRepo();

            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("ObjectSchema", (r.SaveSchema(_schemaSource)).ToString())
                   .Update());
        }
Exemple #7
0
        public DataPackage Invoke(ActionInfo ai, DataPackage dp)
        {
            string userName  = (string)dp["UserName"];
            string publicKey = (string)dp["PublicKey"];
            var    key       = ai.GetContext()
                               .Services
                               .GetRequiredService <ILoginProvider>()
                               .LoginRequest(userName, publicKey);

            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("LoginInfo", key)
                   .Update());
        }
Exemple #8
0
        public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp)
        {
            ActionContext ctx      = ai.GetContext();
            string        userName = (string)dp["UserName"];
            string        password = (string)dp["Password"];
            var           key      = await ctx
                                     .Services
                                     .GetService <ILoginProvider>()
                                     .LoginRequestAsync(userName, password);

            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("JwtToken", key)
                   .Update());
        }
Exemple #9
0
        public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp)
        {
            string userName     = (string)dp["UserName"];
            string sessionID    = (string)dp["SessionID"];
            string encryptedKey = (string)dp["EncryptedKey"];
            var    key          = await ai.GetContext()
                                  .Services
                                  .GetRequiredService <ILoginProvider>()
                                  .LogonAsync(userName, sessionID, encryptedKey);

            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("Ticket", key.SessionToken)
                   .Update());
        }
Exemple #10
0
        public DataPackage Invoke(ActionInfo ai, DataPackage dp)
        {
            ActionContext ctx          = ai.GetContext();
            string        userName     = (string)dp["UserName"];
            string        sessionID    = (string)dp["SessionID"];
            string        encryptedKey = (string)dp["EncryptedKey"];
            var           key          = ctx
                                         .Services
                                         .GetService <ILoginProvider>()
                                         .Logon(userName, sessionID, encryptedKey);

            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("Ticket", key)
                   .Update());
        }
Exemple #11
0
        public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp)
        {
            string objectName = (string)dp["@ObjectName"];

            long[] ids = ((string)dp["@IDs"])
                         .Split(new char[] { ',', ';' })
                         .Select(s => s.ToLongOrDefault())
                         .ToArray();

            var ctx = ai.GetContext();
            var cs  = ctx.Services
                      .GetRequiredService <IConfiguration>()
                      .GetSection($"connectionStrings:{ctx.ConnectionName}").Get <ConnectInfo>();

            var pipe = ctx.Services
                       .GetRequiredService <PipeQueue>();
            StringBuilder sb = new StringBuilder();

            foreach (long i in ids)
            {
                using (MdbContext mdb = new MdbContext(cs))
                {
                    try
                    {
                        string result = await mdb.ExecuteAsync <string>($@"
							select 'Session ID = ' + cast(@@SPID as varchar(10))
							+ ' User Name = ' + '{ctx.UserName}'
							+ ' Connection Name = ' + '{ctx.ConnectionName}'
							+ ' Param Value = ' + '{i}'"                            );

                        pipe.Write(ctx, result);
                        sb.AppendLine(result);
                    }
                    catch (Exception ex)
                    {
                        string message = $"{LogLevels.Error} {ex.Message}\n{ex.StackTrace}";
                    }
                }
            }
            return(ai.GetOutputParamTable()
                   .AddNew()
                   .SetValue("@Result", sb.ToString())
                   .Update());
        }