public static void DisposeCustomProfile() { try { if (_instanceFromOtherAssembly != null) { _instanceFromOtherAssembly.Dispose(); } if (_worker != null) { if (_worker.IsAlive) { _worker.Abort(); } } } catch (Exception exception) { Logging.WriteError("DisposeCustomProfile(): " + exception); } finally { _instanceFromOtherAssembly = null; _assembly = null; _obj = null; } }
public static List <ProfileColumn> GetColumns() { ICustomProfile dal = Factory <ICustomProfile> .Create("CustomProfile"); List <ProfileColumn> cols = dal.GetColumns(); foreach (ProfileColumn col in cols) { if (!String.IsNullOrEmpty(col.DefaultValue)) { col.DefaultValue = col.DefaultValue.Replace("(", "").Replace(")", ""); } if (col.Precision == "-1") { col.Precision = "Max"; } } return(cols); }
public static bool DropColumn(string column) { ICustomProfile dal = Factory <ICustomProfile> .Create("CustomProfile"); return(dal.DropColumn(column)); }
public static bool AddColumn(ProfileColumn column) { ICustomProfile dal = Factory <ICustomProfile> .Create("CustomProfile"); return(dal.AddColumn(column)); }
public static void LoadCustomProfile(string pathToCustomProfileFile, bool settingOnly = false, bool resetSettings = false, bool cSharpFile = true) { try { _pathToCustomProfileFile = pathToCustomProfileFile; if (_instanceFromOtherAssembly != null) { _instanceFromOtherAssembly.Dispose(); } _instanceFromOtherAssembly = null; _assembly = null; _obj = null; if (cSharpFile) { CodeDomProvider cc = new CSharpCodeProvider(); CompilerParameters cp = new CompilerParameters(); IEnumerable <string> assemblies = AppDomain.CurrentDomain .GetAssemblies() .Where( a => !a.IsDynamic && !a.CodeBase.Contains( (Process.GetCurrentProcess().ProcessName + ".exe"))) .Select(a => a.Location); cp.ReferencedAssemblies.AddRange(assemblies.ToArray()); StreamReader sr = File.OpenText(pathToCustomProfileFile); string toCompile = sr.ReadToEnd(); CompilerResults cr = cc.CompileAssemblyFromSource(cp, toCompile); if (cr.Errors.HasErrors) { String text = cr.Errors.Cast <CompilerError>().Aggregate("Compilator Error :\n", (current, err) => current + (err + "\n")); Logging.WriteError(text); MessageBox.Show(text); return; } _assembly = cr.CompiledAssembly; _obj = _assembly.CreateInstance("Main", true); _threadName = "CustomProfile CS"; } else { _assembly = Assembly.LoadFrom(_pathToCustomProfileFile); _obj = _assembly.CreateInstance("Main", false); _threadName = "CustomProfile DLL"; } if (_obj == null || _assembly == null) { return; } _instanceFromOtherAssembly = _obj as ICustomProfile; if (_instanceFromOtherAssembly != null) { if (settingOnly) { if (resetSettings) { _instanceFromOtherAssembly.ResetConfiguration(); } else { _instanceFromOtherAssembly.ShowConfiguration(); } _instanceFromOtherAssembly.Dispose(); return; } _worker = new Thread(_instanceFromOtherAssembly.Initialize) { IsBackground = true, Name = _threadName }; _worker.Start(); } else { Logging.WriteError("Custom Profile Loading error."); } } catch (Exception exception) { Logging.WriteError("LoadCustomProfile(string _pathToCustomProfileFile): " + exception); } }