public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp) { IServiceProvider services = ai.GetContext().Services; ILogger logger = services.GetRequiredService <ILogger>(); ISettingsProvider <VocabularySettingsProvider> settings = services.GetRequiredService <ISettingsProvider <VocabularySettingsProvider> >(); var rabbitConnectorOptions = await settings.GetSettings("CKSServiceSettings.RabbitConnectorOptions"); if ((string)dp[0] != "id") { throw new IndexOutOfRangeException("Required parameter name = 'id'"); } long id = dp[1].CastAs <long>(); StringBuilder b = new StringBuilder(); using (var _rpcClient = new RpcClient(rabbitConnectorOptions)) { await _rpcClient.Login(); var list = await _rpcClient.GetClientInfo(id); b.Append(list.ToString()); } return(new DataPackage("@Result.String.2048") .AddNew() .SetValue("@Result", b.ToString()) .Update()); }
public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp) { GetParameters(ai, dp); var ctx = ai.GetContext(); JMXFactory f = ctx.CreateJMXFactory(_connectionName); IJMXRepo repo = f.SchemaFactory.CreateJMXRepo(); using (SQLStatementWriter writer = f.CreateSQLStatementWriter()) { JMXSchema schema = await repo.GetSchemaAsync(_viewName); string body = writer.WriteSelectStatement( schema, _conditions.ToArray()) .ToString(); if (schema.DbObjectType == DbObjectTypes.Action) { ActionManager am = ctx.Services.GetRequiredService <ActionManager>(); return(await am.ExecuteAsync(am.GetActionInfo(body), dp)); } else { return(await f .GetMdbContext() .GetReaderAsync(body, CreateParameters(schema))); } } }
public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp) { IServiceProvider services = ai.GetContext().Services; ILogger logger = services.GetRequiredService <ILogger>(); ISettingsProvider <VocabularySettingsProvider> settings = services.GetRequiredService <ISettingsProvider <VocabularySettingsProvider> >(); var rabbitConnectorOptions = await settings.GetSettings("CKSServiceSettings.RabbitConnectorOptions"); dp.GoDataTop(); List <object> p = new List <object>(); for (; dp.Read();) { p.Add(dp[0]); p.Add(dp[1]); } StringBuilder b = new StringBuilder(); using (var _rpcClient = new RpcClient(rabbitConnectorOptions)) { await _rpcClient.Login(); var list = await _rpcClient.PerformClientSearch(p.ToArray()); b.Append(list.ToString()); } return(new DataPackage("@Result.String.2048") .AddNew() .SetValue("@Result", b.ToString()) .Update()); }
/// <summary> /// Name of object in format [SchemaName].[ObjectName] (as dbo.Accounts) /// </summary> public virtual bool HasPermission(ActionInfo actionInfo, string objectName) { var user = actionInfo.GetContext().Principal; return(IsAdmin(user) ? true : user.UserPermissions.Any(p => p.ActionID.Equals(actionInfo.ActionID, StringComparison.OrdinalIgnoreCase) && (actionInfo.IsStatic || objectName.Equals(p.ObjectName, StringComparison.OrdinalIgnoreCase)))); }
private void GetParameters(ActionInfo ai, DataPackage dp) { _connectionName = ai.GetContext() .Services .GetRequiredService <IConfiguration>()["appSettings:SysCatConnection"]; if (dp.Read()) { _objectName = (string)dp["ObjectName"]; } }
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()); }
public DataPackage Invoke(ActionInfo ai, DataPackage dp) { string userName = (string)dp.Headers["UserName"]; string sessionID = (string)dp.Headers["SessionID"]; string encryptedKey = (string)dp.Headers["EncryptedKey"]; ai.GetContext() .Services .GetRequiredService <ILoginProvider>() .Logout(userName, sessionID, encryptedKey); return(DataPackage.CreateOKPackage()); }
public DataPackage Invoke(ActionInfo ai, DataPackage dp) { var ctx = ai.GetContext(); return(ai.GetOutputParamTable() .AddNew() .SetValue("Result", ctx .Services .GetRequiredService <PipeQueue>() .Read(ctx)) .Update()); }
public static string GetAuthorizationExceptionsMessage(this ActionInfo ai, string objectName) { ActionContext ctx = ai.GetContext(); if (ctx != null) { return(Properties.Strings.S031_MetaStack_Core_SecurityAuthorizationExceptions_GetMessage_1 .ToFormat(ctx.UserName, ai.Name, objectName)); } return(Properties.Strings.S031_MetaStack_Core_SecurityAuthorizationExceptions_GetMessage_1 .ToFormat(Environment.UserName, ai.Name, objectName)); }
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()); }
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()); }
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()); }
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()); }
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()); }
private static async Task <string> GetSettingsSpeedTest(ActionInfo ai, int loopCount) { IServiceProvider services = ai.GetContext().Services; ISettingsProvider <VocabularySettingsProvider> settings = services.GetRequiredService <ISettingsProvider <VocabularySettingsProvider> >(); var start = DateTime.Now; JsonObject rabbitConnectorOptions = null; for (int i = 0; i < loopCount; i++) { rabbitConnectorOptions = JsonObject.Parse(await settings.GetSettings("CKSServiceSettings.RabbitConnectorOptions")); } return($"GetSettingsSpeedTest loop count = {loopCount}, total times = {(DateTime.Now - start).TotalMilliseconds}ms\n{rabbitConnectorOptions}"); }
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()); }
public async Task <DataPackage> InvokeAsync(ActionInfo ai, DataPackage dp) { IServiceProvider services = ai.GetContext().Services; string actionID = string.Empty;; if (dp.Read()) { actionID = (string)dp["ActionID"]; } IActionManager am = services.GetRequiredService <IActionManager>(); return(new DataPackage( new string[] { "ActionInfo" }, new object[] { (await am.GetActionInfoAsync(actionID))?.ToString() })); }
private void GetParameters(ActionInfo ai, DataPackage dp) { _connectionName = ai.GetContext().ConnectionName; _conditions = new List <JMXCondition>(); for (; dp.Read();) { string paramName = ((string)dp["ParamName"]).ToUpper(); switch (paramName) { case "_VIEWNAME": _viewName = (string)dp["ParamValue"]; break; case "_FILTER": _conditions.Add(new JMXCondition(JMXConditionTypes.Where, (string)dp["ParamValue"])); break; case "_SORT": _conditions.Add(new JMXCondition(JMXConditionTypes.OrderBy, (string)dp["ParamValue"])); break; case "_GROUP": _conditions.Add(new JMXCondition(JMXConditionTypes.GroupBy, (string)dp["ParamValue"])); break; case "_HAVING": _conditions.Add(new JMXCondition(JMXConditionTypes.Havind, (string)dp["ParamValue"])); break; case "_JOIN": _conditions.Add(new JMXCondition(JMXConditionTypes.Join, (string)dp["ParamValue"])); break; default: if (paramName[0] == '@') { _parameters.Add(dp["ParamName"]); _parameters.Add(dp["ParamValue"]); } //else // //!!! to resource // throw new ArgumentException("Ivalid parameter name for DB query"); break; } } }
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()); }
private static async Task <string> RecursiveCallExecuteAsync(ActionInfo ai, int loopCount) { if (loopCount > 0) { var am = ai.GetContext() .Services .GetRequiredService <IActionManager>(); var start = DateTime.Now; for (int i = 0; i < loopCount; i++) { await am.ExecuteAsync(ai, ai.GetInputParamTable() .AddNew() .SetValue("@ObjectName", "RecursiveCallExecuteAsync") .SetValue("@IDs", "0") .Update()); } return($"IActionManager.ExecuteAsync test loop count = {loopCount}, total times = {(DateTime.Now - start).TotalMilliseconds}ms"); } return(""); }