/// <summary> /// 更新数据。必须传入Id /// </summary> public static BaseResult UpdateModule(TModule module) { try { if (module.id < 0) { return(new BaseResult(false, null, "参数错误!")); } var model = DB.Context.From <TModule>().Where(d => d.id == module.id).First(); if (model == null) { return(new BaseResult(false, null, "不存在要修改的数据!")); } model.name = module.name; model.path = module.path; model.autostart = module.autostart; model.delay = module.delay; model.startindex = module.startindex; model.arguments = module.arguments; var count = DB.Context.Update(model); return(new BaseResult(count > 0, model, count > 0 ? "" : "数据库受影响行数为0!", count)); } catch (Exception e) { return(new BaseResult(false, null, e.StackTrace)); } }
/// <summary> /// Driver routine to call the program script /// </summary> static void TestFileScript(string filename) { if (filename == null) { return; } // -------------- Read the contents from the file StreamReader sr = new StreamReader(filename); string programs2 = sr.ReadToEnd(); //---------------- Creates the Parser Object // With Program text as argument RDParser pars = null; pars = new RDParser(programs2); TModule p = null; p = pars.DoParse(); if (p == null) { Console.WriteLine("Parse Process Failed"); return; } // // Now that Parse is Successul... // Do a recursive interpretation...! // RUNTIME_CONTEXT f = new RUNTIME_CONTEXT(p); SYMBOL_INFO fp = p.Execute(f); }
public void Register <TModule>() where TModule : IModule, new() { var module = new TModule(); Register(module); }
private void DynamicRegister <TModule>() where TModule : IntrinsicsModuleBase, new() { var module = new TModule(); module.Initialize(Engine); module.InternalImport(); }
/// <summary> /// Driver routine to call the program script /// </summary> static void TestFileScript(string filename) { if (filename == null) { return; } // -------------- Read the contents from the file StreamReader sr = new StreamReader(filename); string programs2 = sr.ReadToEnd(); sr.Close(); sr.Dispose(); //---------------- Creates the Parser Object // With Program text as argument RDParser pars = null; pars = new RDParser(programs2); TModule p = null; p = pars.DoParse(); // // Now that Parse is Successul... // Create an Executable...! // if (p.CreateExecutable("First.exe")) { Console.WriteLine("Creation of Executable is successul"); return; } }
public virtual void AddModule <TModule>() where TModule : Module, new() { var otherModule = new TModule(); otherModule.Configure(this); }
private void Process_Exited(object sender, EventArgs e) { try { Process p = sender as Process; int moduleKey = processDic.FirstOrDefault(q => q.Value == p.Id).Key; TModule module = moduleList.FirstOrDefault(m => m.id == moduleKey); if (!p.HasExited) { p.Kill(); } p.Close(); p.Dispose(); //if (module != null) //{ // lock (processDic) // { // if (processDic.ContainsKey(module.id)) processDic.Remove(module.id); // } // module.state = (int)LightState.Off; //} } catch (ArgumentNullException) { MixLogHelper.Error(ClassName, "退出模块时,模块数据有误"); } catch (ArgumentOutOfRangeException) { MixLogHelper.Error(ClassName, "退出模块时,数据表索引超出范围"); } catch (Exception ex) { MixLogHelper.Error(ClassName, ex.StackTrace); } }
public int InsertModule(TModule module) { string sql = string.Format("insert into moduleinfo (name, path, autostart, delay, state, startindex, arguments) values ('{0}', '{1}', {2}, {3}, {4}, {5}, '{6}')", new object[] { module.name, module.path, module.autostart, module.delay, -1, module.startindex, module.arguments }); SQLiteCommand command = new SQLiteCommand(sql, sqliteConn); return(command.ExecuteNonQuery()); }
public IContainerBuilder RegisterModule <TModule>() where TModule : IModule, new() { var module = new TModule(); module.Load(_services); return(this); }
protected IMessagingConfigurationListener Subscribe <TModule>() where TModule : IIntegrationModule, new() { var module = new TModule(); var listener = new MessagingConfigurationListener(); _listeners.Add(module, listener); return(listener); }
/// <summary> /// 更新模块信息 /// </summary> /// <param name="id"></param> /// <param name="module"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="FormatException"/> public int UpdateModule(int id, TModule module) { string sql = string.Format("update moduleinfo set name='{0}', path='{1}', autostart={2}, delay={3}, startindex={4}, arguments='{5}' where id={6}", new object[] { module.name, module.path, module.autostart, module.delay, module.startindex, module.arguments, id }); SQLiteCommand command = new SQLiteCommand(sql, sqliteConn); return(command.ExecuteNonQuery()); }
public void LoadModule <TModule>() where TModule : class, INinjectModule, new() { var module = new TModule(); if (!Kernel.HasModule(module.Name) && !IsModuleDisabled(typeof(TModule))) { Kernel.Load(module); } }
public void RegisterModule <TModule>() where TModule : IModule { IServiceContainer moduleContainer = new ServiceContainer(); _ = moduleContainer.RegisterInstance <IRegistrar>(this); _ = moduleContainer.Register <TModule>(); TModule module = moduleContainer.GetInstance <TModule>(); module.Initialize(this); }
public void Create(TModule TModule, string user = "") { _tmoduleRepository.Insert(TModule); _applicationTraceService.create(new ApplicationTrace { utilisateur = user, action = Parametres.Action.Creation.ToString(), description = "Création d'un type d'un type de module", }); }
public void Update(TModule TModule, string user = "") { _tmoduleRepository.Update(TModule); _applicationTraceService.create(new ApplicationTrace { utilisateur = user, action = Parametres.Action.Modification.ToString(), description = String.Format("Mise à jour d'un type d'un type de module tmodule_id = {0}", TModule.id), }); }
private void dgvMix_SelectionChanged(object sender, EventArgs e) { if (dgvMix.SelectedRows.Count > 0) { TModule module = dgvMix.SelectedRows[0].DataBoundItem as TModule; textBoxName.Text = module.name; textBoxLocation.Text = module.path; checkBoxAutoStart.Checked = module.autostart != 0; textBoxDelay.Text = module.delay.ToString(); textBoxArguments.Text = module.arguments; } }
public void RegisterModule <TModule>() where TModule : class, IModule, new() { if (_modules.ContainsKey(typeof(TModule))) { return; } var module = new TModule(); module.Init(this); _modules.Add(typeof(TModule), module); }
public BioEngine AddModule <TModule>() where TModule : IBioEngineModule, new() { if (typeof(TModule).GetTypeInfo().ImplementedInterfaces .Any(i => i.Name.StartsWith("IBioEngineModule") && i.IsGenericType)) { throw new Exception($"Module {typeof(TModule)} is implementing IBioEngineModule<TConfig>. It must be added using AddModule<TModule, TModuleConfig> method."); } var module = new TModule(); ConfigureModule(module); _modules.Add(module); return(this); }
public ChainBuilder AddModule <TModule>() where TModule : IModule, new() { var module = new TModule(); if (_module == null) { _module = module; return(this); } SetLastSuccessor(_module, module); return(this); }
private int type; //0是查看,1是更新,2是添加 public FormModule(Form form, int type, TModule module = null) { InitializeComponent(); NewModule = module ?? new TModule(); BackColor = form.BackColor; if (form is UserForm && (form as UserForm).BackBrush != null) { BackBrush = (form as UserForm).BackBrush; BackAngle = (form as UserForm).BackAngle; } this.type = type; InitModuleType(cbBoxType); InitData(module); }
/// <summary>获取某个模块的实例(唯一入口)</summary> public static TModule GetModule <TModule>() where TModule : Module, new() { Type moduleType = typeof(TModule); Module module = null; if (!modulesDic.TryGetValue(moduleType, out module)) { if (!moduleType.Name.EndsWith("Module")) { throw new CoreException(string.Format("[Core.GetModule]The module named {0} is not end with \"Module\" ", moduleType.Name)); } module = new TModule(); modulesDic.Add(moduleType, module); } return(module as TModule); }
private void InitData(TModule module) { //0是查看,1是更新,2是添加 switch (type) { case 0: Text = "查询模块信息"; cbBoxType.Enabled = false; textBoxName.ReadOnly = true; checkBoxAutoStart.Enabled = false; textBoxDelay.ReadOnly = true; textBoxArguments.ReadOnly = true; lblFile.Enabled = false; break; case 1: Text = "更新模块信息"; cbBoxType.Enabled = true; textBoxName.ReadOnly = false; checkBoxAutoStart.Enabled = true; textBoxDelay.ReadOnly = false; textBoxArguments.ReadOnly = false; lblFile.Enabled = true; break; case 2: Text = "添加模块信息"; cbBoxType.Enabled = true; textBoxName.ReadOnly = false; checkBoxAutoStart.Enabled = true; textBoxDelay.ReadOnly = false; textBoxArguments.ReadOnly = false; lblFile.Enabled = true; break; } if (type != 2) { textBoxName.Text = module.name; textBoxLocation.Text = module.path; checkBoxAutoStart.Checked = module.autostart != 0; textBoxDelay.Text = module.delay.ToString(); textBoxArguments.Text = module.arguments; cbBoxType.SelectedValue = module.temtype; } }
public TModule Module <TModule>() where TModule : ITestModule, new() { var moduleType = typeof(TModule); lock (_modules) { if (!_modules.ContainsKey(moduleType)) { Logger.LogDebug("Init test module [{0}]", moduleType.FullName); var newModule = new TModule(); newModule.Setup(this); _modules[moduleType] = newModule; } } return((TModule)_modules[moduleType]); }
/// <summary> /// Print the data that is shown in a grid /// </summary> /// <param name="AParentForm">The parent form (since a modal dialog is called)</param> /// <param name="APrintApplication">The print application to use - either Word or Excel</param> /// <param name="APreviewOnly">True if preview, False to print without preview</param> /// <param name="AModule">The module that is making the call</param> /// <param name="ATitleText">Title for the page</param> /// <param name="AGrid">A grid displaying data</param> /// <param name="ATableColumnOrder">Zero-based table column order that matches the grid columns</param> public static void SelectAndPrintGridFields(Form AParentForm, TStandardFormPrint.TPrintUsing APrintApplication, bool APreviewOnly, TModule AModule, string ATitleText, TSgrdDataGrid AGrid, int[] ATableColumnOrder) { TFrmSelectPrintFields SelectPrintFields = new TFrmSelectPrintFields(AParentForm, "SelectPrintFields"); SelectPrintFields.InitData(ATableColumnOrder, AGrid, APreviewOnly); SelectPrintFields.ShowDialog(); if (SelectPrintFields.DialogResult == DialogResult.OK) { TStandardFormPrint.PrintGrid(APrintApplication, APreviewOnly, ATitleText, AGrid, SelectPrintFields.GetColumnOrder(), SelectPrintFields.GetColumnID()); } }
/// <summary> /// 新增数据。 /// </summary> public static BaseResult InsertModule(TModule module) { try { if (string.IsNullOrWhiteSpace(module.path)) { return(new BaseResult(false, null, "参数错误!")); } if (string.IsNullOrWhiteSpace(module.name)) { module.name = System.IO.Path.GetFileNameWithoutExtension(module.path); } module.state = -1; var count = DB.Context.Insert(module); return(new BaseResult(count > 0, module, count > 0 ? "" : "数据库受影响行数为0!", count)); } catch (Exception e) { return(new BaseResult(false, null, e.StackTrace)); } }
public static Assembly WeaveAssembly <TModule, TContainer>() where TModule : new() { var projectPath = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\..\..\AssemblyToProcess\AssemblyToProcess.csproj")); var assemblyPath = Path.Combine(Path.GetDirectoryName(projectPath), @"bin\Debug\AssemblyToProcess.dll"); #if (!DEBUG) assemblyPath = assemblyPath.Replace("Debug", "Release"); addinBinPath = springBinPath.Replace("Debug", "Release"); #endif var newAssembly = assemblyPath.Replace(".dll", "2.dll"); File.Copy(assemblyPath, newAssembly, true); var moduleDefinition = ModuleDefinition.ReadModule(newAssembly); dynamic weavingTask = new TModule(); weavingTask.ModuleDefinition = moduleDefinition; weavingTask.Execute(); moduleDefinition.Write(newAssembly); return(Assembly.LoadFile(newAssembly)); }
/// <summary> /// 根据除id和state外的字段进行查询 /// </summary> /// <param name="module"></param> /// <returns></returns> public static BaseResult QureyModule(TModule module) { try { var where = new Where(); #region 模糊查询 if (!string.IsNullOrWhiteSpace(module.name)) { where.And(TModule._.name == module.name); } if (!string.IsNullOrWhiteSpace(module.path)) { where.And(TModule._.path == module.path); } if (!string.IsNullOrWhiteSpace(module.arguments)) { where.And(TModule._.arguments == module.arguments); } if (module.autostart > -2) { where.And(TModule._.autostart == module.autostart); } if (module.delay > -2) { where.And(TModule._.delay == module.delay); } if (module.startindex > -2) { where.And(TModule._.startindex == module.startindex); } #endregion var fs = DB.Context.From <TModule>().Where(where); return(new BaseResult(fs.Count() > 0, fs.ToList(), fs.Count() > 0 ? "" : "数据库受影响行数为0!", fs.Count())); } catch (Exception e) { return(new BaseResult(false, null, e.StackTrace)); } }
private void DelModule() { try { if (dgvMix.SelectedRows.Count > 0) { TModule module = moduleList[dgvMix.SelectedRows[0].Index]; DialogResult result = MessageBox.Show(this, "确定要删除该模块:" + module.name + "?", "温馨提示", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { var databaseResult = TModuleLogic.DeletModule(module.id); if (databaseResult.IsSuccess) { ShowToolTip("删除成功", 2000); } else { ShowToolTip("删除失败", 2000); } if (processDic.ContainsKey(module.id)) { StopModule(module); } moduleList.RemoveAt(dgvMix.SelectedRows[0].Index); lblError.Visible = false; } } else { ShowToolTip("未选中模块", 2000); //MessageBox.Show("未选中模块"); } } catch (Exception e) { MixLogHelper.Error(ClassName, "删除模块异常", e.StackTrace); } }
/// <summary> /// /// </summary> /// <param name="mod"></param> /// <param name="func"></param> /// <returns></returns> private string ConcatFormals(TModule mod, string func) { Procedure p = mod.Find(func); ArrayList arr = p.FORMALS; string fstr = func + "("; int i = 0; foreach (SYMBOL_INFO smb in arr) { if (i < arr.Count - 1) { fstr += smb.SymbolName + ","; } else { fstr += smb.SymbolName; } i++; } fstr += ")"; return(fstr); }
/// <summary> /// Generate the JavaScript for the Eligibility rules... /// </summary> /// <param name="slang_text"></param> /// <returns></returns> public bool GenerateJSRuleEligible(string slang_text) { //---------------- Creates the Parser Object // With Program text as argument RDParser pars = null; pars = new RDParser(slang_text); _eligible_rules = pars.DoParse(); if (_eligible_rules == null) { Console.WriteLine("Parse Process Failed while processing Eligibility rules"); return(false); } // // Now that Parse is Successul... // Generate JavaScript // RUNTIME_CONTEXT f = new RUNTIME_CONTEXT(_eligible_rules); SYMBOL_INFO fp = _eligible_rules.GenerateJS(f, null); return(true); }
public TCable(TModule src, TModule dest, int index, GraphControl c) { Src = src; Dest = dest; Index = index; var pa = new Point(Src.HitRect.Right,Src.HitRect.Top + IOPinY); var pb = new Point(Dest.HitRect.Left,(index>0)?(Dest.HitRect.Top + ParamY + ParamPinY + ParamH * (Index - 1)):(Dest.HitRect.Top + IOPinY)); Layout(pa, pb, Src.HitRect.Top, Src.HitRect.Bottom, Dest.HitRect.Top, Dest.HitRect.Bottom); Pen = Src.Mod.Definition.OutChannels > 1 ? c.CableStereo : c.CableMono; HitRect = RectFromPoints(Points, 2); }
public TCable(TModule src, Point b, GraphControl c) { Src = src; var pa = new Point(Src.HitRect.Right, Src.HitRect.Top + IOPinY); Layout(pa, b, Src.HitRect.Top, Src.HitRect.Bottom, 0, 0); HitRect = RectFromPoints(Points, 2); }
public TCable(Point a, TModule dest, int index, GraphControl c) { Dest = dest; Index = index; var pb = new Point(Dest.HitRect.Left, (index > 0) ? (Dest.HitRect.Top + ParamY + ParamPinY + ParamH * (Index - 1)) : (Dest.HitRect.Top + IOPinY)); Layout(a, pb, 0, 0, Dest.HitRect.Top, Dest.HitRect.Bottom); HitRect = RectFromPoints(Points, 2); }
public TPin(TModule mod, bool output, int index, GraphControl c) { Module = mod; IsOutput = output; Index = index; if (output) { HitRect = new Rectangle(mod.HitRect.Right - 2, mod.HitRect.Top + IOPinY - 4, 7, 7); Brush = mod.Mod.Definition.OutChannels > 1 ? c.ModPinStereo : c.ModPinMono; } else if (Index>0) { HitRect = new Rectangle(mod.HitRect.Left - 4, mod.HitRect.Top + ParamY + (index - 1) * ParamH + ParamPinY - 2, 5, 5); Brush = c.ModPinMono; } else { HitRect = new Rectangle(mod.HitRect.Left - 5, mod.HitRect.Top + IOPinY - 4, 7, 7); Brush = mod.Mod.Definition.InChannels > 1 ? c.ModPinStereo : c.ModPinMono; } }