private PlugLocation TranslateToPlugLocation(IDataReader dataReader) { PlugLocation plugLoc = new PlugLocation(); TranslateToPlugLocation(dataReader, plugLoc); return(plugLoc); }
internal List <PlugLocation> InternalLoadByPlugId(int plugId) { RawSqlExecuteReaderAction readerAction = new RawSqlExecuteReaderAction(); readerAction.CommandText = _loadByPlugIdCommandText; readerAction.AddParameter("@PlugId", plugId, DbType.Int32); this.ExecuteCommand(readerAction); List <PlugLocation> plugLocList = new List <PlugLocation>(); IDataReader dataReader = readerAction.DataReader; try { int[] ordinals = GetPlugLocationFieldOrdinals(dataReader); while (dataReader.Read()) { PlugLocation res = new PlugLocation(); TranslateToPlugLocation(dataReader, res, ordinals[0], ordinals[1], ordinals[2], ordinals[3], ordinals[4]); plugLocList.Add(res); } } finally { dataReader.Close(); } return(plugLocList); }
void Delete(PlugLocation plugLoc) { using (PlugLocationFactory factory = PlugLocationFactory.GetInstance()) { factory.Context = this.FactoryContext; factory.InternalDelete(plugLoc); } }
protected void Delete(PlugLocation plugLoc) { RawSqlExecuteNonQueryAction deleteAction = new RawSqlExecuteNonQueryAction(); deleteAction.CommandText = _deleteCommandText; deleteAction.AddParameter("@PlugLocationId", plugLoc.PlugLocationId, DbType.Int32); this.ExecuteCommand(deleteAction); }
protected void TranslateToPlugLocation(IDataReader dataReader, PlugLocation plugLoc, int idIndex, int nameIndex, int descrIndex, int pathIndex, int plugIndex) { plugLoc.PlugLocationId = dataReader.GetInt32(idIndex); plugLoc.PlugLocationName = dataReader.GetString(nameIndex); if (!dataReader.IsDBNull(descrIndex)) { plugLoc.PlugLocationDescription = dataReader.GetString(descrIndex); } plugLoc.PlugLocationPath = dataReader.GetString(pathIndex); plugLoc.PlugId = dataReader.GetInt32(plugIndex); }
protected void Insert(PlugLocation plugLoc) { RawSqlInsertAction insertAction = new RawSqlInsertAction(); insertAction.CommandText = _insertCommandText; insertAction.AddParameter("@PlugLocationName", plugLoc.PlugLocationName, DbType.String); insertAction.AddParameter("@PlugLocationDescription", plugLoc.PlugLocationDescription, DbType.String); insertAction.AddParameter("@PlugLocationPath", plugLoc.PlugLocationPath, DbType.String); insertAction.AddParameter("@PlugId", plugLoc.PlugId, DbType.Int32); this.ExecuteCommand(insertAction); plugLoc.PlugLocationId = insertAction.InsertedIdentity; }
protected void Update(PlugLocation plugLoc) { RawSqlExecuteNonQueryAction updateAction = new RawSqlExecuteNonQueryAction(); updateAction.CommandText = _updateCommandText; updateAction.AddParameter("@PlugLocationId", plugLoc.PlugLocationId, DbType.Int32); updateAction.AddParameter("@PlugLocationName", plugLoc.PlugLocationName, DbType.String); updateAction.AddParameter("@PlugLocationDescription", plugLoc.PlugLocationDescription, DbType.String); updateAction.AddParameter("@PlugLocationPath", plugLoc.PlugLocationPath, DbType.String); updateAction.AddParameter("@PlugId", plugLoc.PlugId, DbType.Int32); this.ExecuteCommand(updateAction); }
internal PlugLocation InternalLoadByName(string plugLocName) { RawSqlExecuteReaderAction readerAction = new RawSqlExecuteReaderAction(); readerAction.CommandText = _loadByNameCommandText; readerAction.AddParameter("@PlugLocationName", plugLocName, DbType.String); PlugLocation plugLoc = null; this.ExecuteCommand(readerAction); try { readerAction.DataReader.Read(); plugLoc = TranslateToPlugLocation(readerAction.DataReader); } finally { readerAction.DataReader.Close(); } return(plugLoc); }
internal PlugLocation InternalLoadByPrimaryKey(int plugLocId) { RawSqlExecuteReaderAction readerAction = new RawSqlExecuteReaderAction(); readerAction.CommandText = _loadByIdCommandText; readerAction.AddParameter("@PlugLocationId", plugLocId, DbType.Int32); PlugLocation plugLoc = null; this.ExecuteCommand(readerAction); try { readerAction.DataReader.Read(); plugLoc = TranslateToPlugLocation(readerAction.DataReader); } finally { readerAction.DataReader.Close(); } return(plugLoc); }
public override void RegisterPlug(ITransactionContext context) { #region Installing Required Environments Console.WriteLine("Installing Kernel required environment"); PlugInFactory factoryPlug = PlugInFactory.GetInstance(); factoryPlug.Context = context as SqlTransactionContext; factoryPlug.InstallRequiredEnvironment(); Console.WriteLine("Installed PlugInFactory"); PlugLocationFactory factoryPlugLocation = PlugLocationFactory.GetInstance(); factoryPlugLocation.Context = context as SqlTransactionContext; factoryPlugLocation.InstallRequiredEnvironment(); Console.WriteLine("Installed PlugLocationFactory"); PlugFileFactory factoryPlugFile = PlugFileFactory.GetInstance(); factoryPlugFile.Context = context as SqlTransactionContext; factoryPlugFile.InstallRequiredEnvironment(); Console.WriteLine("Installed PlugFileFactory"); ClassDefinitionFactory factoryClassDefinition = ClassDefinitionFactory.GetInstance(); factoryClassDefinition.Context = context as SqlTransactionContext; factoryClassDefinition.InstallRequiredEnvironment(); Console.WriteLine("Installed ClassDefinitionFactory"); BindablePointDefinitionFactory factoryBindablePointDefinition = BindablePointDefinitionFactory.GetInstance(); factoryBindablePointDefinition.Context = context as SqlTransactionContext; factoryBindablePointDefinition.InstallRequiredEnvironment(); Console.WriteLine("Installed BindablePointDefinitionFactory"); BindablePointFactory factoryBindablePoint = BindablePointFactory.GetInstance(); factoryBindablePoint.Context = context as SqlTransactionContext; factoryBindablePoint.InstallRequiredEnvironment(); Console.WriteLine("Installed BindablePointFactory"); BindingFactory factoryBinding = BindingFactory.GetInstance(); factoryBinding.Context = context as SqlTransactionContext; factoryBinding.InstallRequiredEnvironment(); InstanceFactory factoryInstance = InstanceFactory.GetInstance(); factoryInstance.Context = context as SqlTransactionContext; factoryInstance.InstallRequiredEnvironment(); #endregion FileTransaction trans = new FileTransaction(); trans.BeginTransaction(); PlugIn plug = new PlugIn(); plug.PlugName = "Interlogic.Trainings.Plugs.Kernel"; plug.PlugVersion = "0.0.0.1"; plug.PlugFriendlyName = "RemoteAdmin Kernel"; plug.PlugDescription = "RemoteAdmin Kernel"; plug.Active = true; PlugLocation loc = new PlugLocation(); loc.PlugLocationName = "EXECUTABLE_DIR"; loc.PlugLocationPath = Path.Combine(InitialDir, @"bin"); loc.PlugLocationDescription = "Main executable directory"; plug.Locations.Add(loc); string EXEC_DIR = loc.PlugLocationPath; PlugFile file = new PlugFile(); file.PlugFileName = "Interlogic.Trainings.Plugs.Kernel.dll"; file.RelativeIncomingPath = @"..\..\..\Interlogic.Trainings.Plugs.Kernel\bin\Debug"; file.DestinationPath = "EXECUTABLE_DIR"; plug.Files.Add(file); trans.AddAction(new CopyFileAction(Path.Combine(file.RelativeIncomingPath, file.PlugFileName), Path.Combine(EXEC_DIR, file.PlugFileName), true)); file = new PlugFile(); file.PlugFileName = "Interlogic.Trainings.Plugs.Kernel.pdb"; file.RelativeIncomingPath = @"..\..\..\Interlogic.Trainings.Plugs.Kernel\bin\Debug"; file.DestinationPath = "EXECUTABLE_DIR"; plug.Files.Add(file); trans.AddAction(new CopyFileAction(Path.Combine(file.RelativeIncomingPath, file.PlugFileName), Path.Combine(EXEC_DIR, file.PlugFileName), true)); ClassDefinition classDef = new ClassDefinition(); classDef.Active = true; classDef.ClassDefinitionDescription = "IInstantiatable public interface"; classDef.ClassName = "Interlogic.Trainings.Plugs.Kernel.IInstantiatable"; classDef.FileName = "Interlogic.Trainings.Plugs.Kernel.dll"; plug.ClassDefinitions.Add(classDef); try { Console.WriteLine("Trying to execute file transactions"); trans.Execute(); trans.Commit(); Console.WriteLine("File transactions completed"); Console.WriteLine("KernelPlug database insertion"); PlugInController plugController = new PlugInController(context); plugController.InsertAll(plug); } catch (Exception e) { Console.WriteLine("Kernel installation failed! Rolling back"); trans.RollBack(); throw new Exception("Kernel Installation Process Failed!", e); } Console.WriteLine("KernelPlug succesfully installed!"); }
public DomainObject GetObjectByInstanceName(string instanceName) { if (this.NeedCaching(instanceName) && this.IsInCache(instanceName)) { return(this.GetFromCache(instanceName)); } Instance instance = GetBySystemName(instanceName); string className = null; int fileId = 0; using (ClassDefinitionFactory classFactory = ClassDefinitionFactory.GetInstance()) { classFactory.Context = this.FactoryContext; ClassDefinition definition = classFactory.InternalLoadByPrimaryKey(instance.ClassDefinitionId); fileId = definition.FileId; className = definition.ClassName; } string fileName = null; int fileLocationId = 0; using (PlugFileFactory fileFactory = PlugFileFactory.GetInstance()) { fileFactory.Context = this.FactoryContext; PlugFile file = fileFactory.InternalLoadByPrimaryKey(fileId); fileName = file.PlugFileName; fileLocationId = file.DestinationLocationId; } string path = null; using (PlugLocationFactory locationFactory = PlugLocationFactory.GetInstance()) { locationFactory.Context = this.FactoryContext; PlugLocation location = locationFactory.InternalLoadByPrimaryKey(fileLocationId); path = location.PlugLocationPath; } string filePath = Path.Combine(path, fileName); string assemblyName = Path.GetFileNameWithoutExtension(filePath); Type requiredType = null; Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in loadedAssemblies) { if (assembly.GetName().Name == assemblyName) { requiredType = assembly.GetType(className, false, false); if (requiredType != null) { break; } } } if (requiredType == null) { Assembly newDll = Assembly.LoadFrom(filePath); requiredType = newDll.GetType(className, false, false); } if (requiredType == null) { throw new ArgumentException(string.Format("Type '{0}' was not found.", className)); } DomainObject instanceObject = (DomainObject)Activator.CreateInstance(requiredType); IInstantiatable instantinable = instanceObject as IInstantiatable; if (instantinable != null) { instantinable.Setup(instance, this.FactoryContext); } if (NeedCaching(instanceName)) { SetToCache(instanceName, instanceObject); } return(instanceObject); }
internal void InternalUpdate(PlugLocation plugLoc) { this.Update(plugLoc); }
internal void InternalInsert(PlugLocation plugLoc) { Insert(plugLoc); }
protected void TranslateToPlugLocation(IDataReader dataReader, PlugLocation plugLoc) { int[] indexes = GetPlugLocationFieldOrdinals(dataReader); TranslateToPlugLocation(dataReader, plugLoc, indexes[0], indexes[1], indexes[2], indexes[3], indexes[4]); }
internal void InternalDelete(PlugLocation plugLoc) { this.Delete(plugLoc); }