public IntroMetaData LoadMenu(INodePluginContext pc) { var roleList = pc.ProcessingContext.InputModel.SecurityModel.Roles; var name = pc.ProcessingContext.InputModel.SecurityModel.UserName; string command = string.Empty; IntroMetaDataDto metaData = new IntroMetaDataDto(); using (SqliteConnection connection = new SqliteConnection(_ConnectionString)) { connection.Open(); if (roleList.Contains("administrator") || roleList.Contains("manager")) { command = _QueryBuilder.GetMenuQuery(true); } else { command = _QueryBuilder.GetMenuQuery(false); } SqliteCommand readMetaDataCommand = new SqliteCommand { Connection = connection, CommandText = command }; readMetaDataCommand.Parameters.Add(new SqliteParameter("name", name)); using (SqliteDataReader reader = readMetaDataCommand.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { IntroSection sec = new IntroSection { Caption = reader.GetString(reader.GetOrdinal("scaption")), ImagePath = reader.GetString(reader.GetOrdinal("img")), Id = reader.GetString(reader.GetOrdinal("sid")), OrderIdx = int.Parse(reader.GetString(reader.GetOrdinal("sord"))) }; IntroItem it = new IntroItem { Caption = reader.GetString(reader.GetOrdinal("itcaption")), Id = reader.GetString(reader.GetOrdinal("itid")), Description = reader.GetString(reader.GetOrdinal("desc")), OrderIdx = int.Parse(reader.GetString(reader.GetOrdinal("itord"))), Sources = null, LaunchSpec = null }; metaData.AddSection(sec).IntroItems.Add(it); } } } } IntroMetaData introMetaData = new IntroMetaData(metaData.Sections); if (introMetaData.Sections.Count == 0) { throw new Exception("Configuration failure."); } return(introMetaData); }
private IIntroContentProvider GetContentProvider(INodePluginContext pluginContext) { KraftGlobalConfigurationSettings kraftGlobalConfigurationSettings = pluginContext.PluginServiceManager.GetService <KraftGlobalConfigurationSettings>(typeof(KraftGlobalConfigurationSettings)); string moduleRoot = Path.Combine(kraftGlobalConfigurationSettings.GeneralSettings.ModulesRootFolder(pluginContext.ProcessingContext.InputModel.Module), pluginContext.ProcessingContext.InputModel.Module); string connectionString = pluginContext.OwnContextScoped.CustomSettings["ConnectionString"].Replace("@moduleroot@", moduleRoot); return(new BindKraftIntroDbManager(connectionString)); }
public static string LocationInfo(this INodePluginContext ctx, string plugin) { string module = ctx.ProcessingContext.InputModel.Module; string nodepath = ctx.ProcessingContext.InputModel.Nodepath; string nodeset = ctx.ProcessingContext.InputModel.NodeSet; string currentNode = ctx.CurrentNode.NodeKey; string action = ctx.Action; string operation = ctx.Operation; return($"Location: {module}:{nodeset}/{nodepath} ({currentNode}|{action}|{operation}) {plugin ?? ""}"); }
public override void Execute(INodePluginContext p) { object results = null; if (p.Action == ACTION_READ) { var readctx = p as INodePluginReadContext; results = Read(readctx); if (results is Dictionary <string, object> ) { readctx.Results.Add(results as Dictionary <string, object>); } else if (results is IEnumerable <Dictionary <string, object> > ) { foreach (var result in results as IEnumerable <Dictionary <string, object> > ) { readctx.Results.Add(result); } } else { throw new Exception("Unexpected type returned by ExecuteRead"); } } else if (p.Action == ACTION_WRITE) { var writectx = p as INodePluginWriteContext; results = Write(writectx); if (results is Dictionary <string, object> ) { UpdateRow(results as Dictionary <string, object>, writectx); } else if (results is IEnumerable <Dictionary <string, object> > ) { foreach (var result in results as IEnumerable <Dictionary <string, object> > ) { UpdateRow(result, writectx); } } else { throw new Exception("Unexpected type returned by ExecuteRead"); } } else { throw new Exception("Unknown action: " + (p.Action ?? "null")); } }
public void Execute(IEnumerable <CustomPlugin> customPlugins, INodePluginContext p) { foreach (CustomPlugin customPlugin in customPlugins) { // localResult = null; if (customPlugin != null) { INodePlugin plugin = p.CustomPluginAccessor.LoadPlugin(customPlugin.CustomPluginName); // Here the customplugin's context is attached // the dataloader's context is attached in the iterator p.OwnContextScoped = p.CustomPluginAccessor.GetPluginsSynchronizeContextScoped(customPlugin.CustomPluginName, plugin).Result; plugin?.Execute(p); } } }
public override void Execute(INodePluginContext p) { if (p.Action == ACTION_READ) { ExecuteRead(p as INodePluginReadContext); } else if (p.Action == ACTION_WRITE) { ExecuteWrite(p as INodePluginWriteContext); } else { throw new Exception("Unknown action: " + (p.Action ?? "null")); } }
public IntroItem LoadIntroItem(INodePluginContext pc) { IntroItem currentItem = new IntroItem(); string exampleId = pc.Evaluate("exampleName").Value?.ToString()?.Replace("'", string.Empty) ?? string.Empty; using (SqliteConnection connection = new SqliteConnection(_ConnectionString)) { connection.Open(); SqliteCommand readIntroItemCommand = new SqliteCommand { Connection = connection, CommandText = _QueryBuilder.GetExampleByIdQuery() }; readIntroItemCommand.Parameters.Add(new SqliteParameter("ExampleId", exampleId)); int id = -1; using (SqliteDataReader reader = readIntroItemCommand.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { id = int.Parse(reader.GetString(reader.GetOrdinal("Id"))); currentItem.Caption = reader.GetString(reader.GetOrdinal("Caption")); currentItem.Description = reader.GetString(reader.GetOrdinal("Description")); currentItem.Id = reader.GetString(reader.GetOrdinal("Name")); currentItem.OrderIdx = int.Parse(reader.GetString(reader.GetOrdinal("OrderIdx"))); currentItem.Author = reader.GetString(reader.GetOrdinal("Author")); currentItem.Sources = new Sources(); currentItem.LaunchSpec = null; } } } if (id == -1) { throw new Exception("Can not find the required example. Check the database"); } SqliteCommand readIntroItemSourcesCommand = new SqliteCommand { Connection = connection, CommandText = _QueryBuilder.GetExampleSourceFilesQuery() }; readIntroItemSourcesCommand.Parameters.Add(new SqliteParameter("Id", id)); using (SqliteDataReader reader = readIntroItemSourcesCommand.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { SourceEntry se = new SourceEntry { Content = reader.GetString(reader.GetOrdinal("Content")), Type = (ESourceType)int.Parse(reader.GetString(reader.GetOrdinal("Type"))), EntryName = reader.GetString(reader.GetOrdinal("EntryName")) }; currentItem.Sources.Entries.Add(se); } } } } if (currentItem.Sources.Entries.Count == 0) { throw new Exception("Can not find the source section for this example in the database"); } return(currentItem); }
public List <IntroItem> LoadDeletedIntroItem(INodePluginContext pc) { return(null); //throw new NotImplementedException(); }
protected ScopeContext Scope(INodePluginContext p) { return(p.OwnContextScoped as ScopeContext); }
public abstract void Execute(INodePluginContext p);