public TabConsoleControl() { InitializeComponent(); scrabl = new ScrablerCore(); rep = new ScriptRepo(Path.GetDirectoryName(Application.ExecutablePath)); tabControl1.TabPages.Clear(); // this.consoleBox1.Dispose(); this.toolStripNewTab_Click(null, null); }
public void ExecuteCommand(string Cmd) { try { Allias allias = new Allias(); Cmd = allias.ReplaceAllias(Cmd); if (Cmd != null) { string[] files = Directory.GetFiles(Program.ScriptsFolder);; if (Cmd.Contains(run) == true) { if ((Cmd.Contains(run) == true) && (Cmd.Contains(script) == true)) { string tscrpt = Cmd.Substring(Cmd.LastIndexOf(script) + script.Length + 1); //string[] files; //MessageBox.Show(Program.ScriptsFolder + "\\" + tscrpt); //files = Directory.GetFiles(Program.ScriptsFolder ); Executescript(this.SearchList(files, tscrpt)); // MessageBox.Show(this.SearchList(files,tscrpt)); /*else if ((files!=null)&&(files.Length >0)&&(File.Exists(files[0])==true)) * { * Executescript(files[0]); * * // MessageBox.Show(tscrpt); * }*/ } } else if (Cmd.Contains(stop) == true) { if ((Cmd.Contains(stop) == true) && (Cmd.Contains(script) == true)) { string tname, tscript2; DataSet set; ScrablerCore tscrabl = new ScrablerCore(); string tscrpt = Cmd.Substring(Cmd.LastIndexOf(script) + script.Length + 1); //this.SearchList(files,tscrpt) // files = Directory.GetFiles(Program.ScriptsFolder); tscript2 = this.SearchList(files, tscrpt); tname = Path.GetFileName(tscript2); // ScrablerCore.AssemblyCol.Remove(ScrablerCore.AssemblyCol.GetItem(tname)); ScrablerCore.AssemblyCol.Remove(ScrablerCore.AssemblyCol.GetItem(tname)); } } else if (Cmd.Contains(Core.code) == true) { Program.Console.CommandBox.Multiline = true; Program.Console.CommandBox.ScrollBars = ScrollBars.Both; string tcode; tcode = Cmd.Substring(Cmd.LastIndexOf(code) + code.Length); ScrablerCore.cp.ReferencedAssemblies.Add(Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")) + "\\Scrabler.dll"); ScrablerCore.cp.ReferencedAssemblies.Add(Application.ExecutablePath); scarabler.Eval(tcode); // } else if (Cmd.Contains(Core.exit) == true) { Application.Exit(); } else if (Cmd.Contains(Core.listscripts) == true) { this.ShowList(files); } else if (Cmd.Contains(Core.loadedscripts) == true) { int i = 0; Program.Console.WriteLine("Loaded Scripts: \n"); for (i = 0; i < ScrablerCore.AssemblyCol.Count; i++) { Type[] t = ScrablerCore.AssemblyCol.GetItem(i).GetTypes(); // foreach (Type d in t) { Program.Console.WriteLine("NameSapce: " + t[0].Namespace); } } } else if (Cmd.Contains(Core.addAllias) == true) { //string tmp = Cmd.Substring(Cmd.LastIndexOf(Core.addAllias) + addAllias.Length + 1); // string[] tmpar = tmp.Split(','); // MessageBox.Show(tmp); AddAllias adallias = new AddAllias(); adallias.Show(); //allias.LoadAlliaces(); } else if (Cmd.Contains(Core.showAllias) == true) { allias.ShowAllias(); } ///ScrablerCore.AssemblyCol } } catch (Exception ex) { Program.errorreporting(ex); } }
/// <summary> /// this method will install the given script to the script folder /// and copy the dll neede by the sript to the needed folder /// </summary> /// <param name="script_Archfilename">the full path of the script </param> /// <param name="installfolder_scriptanddll">the path that /// script and dll wll be installed</param> public void Install(string script_Archfilename, string installfolder_scriptanddll) { try { ScriptInfo scrinf = null; ScrablerCore core = new ScrablerCore(); DataSet set = new DataSet(); hydrobaseADO ad = new hydrobaseADO(); string tscrfilename = null, str; string[] files; if ((script_Archfilename != null) && (installfolder_scriptanddll != null) && (File.Exists(script_Archfilename) == true) && (Directory.Exists(installfolder_scriptanddll) == true)) { if (Directory.Exists(installfolder_scriptanddll + "\\" + ScrablerCore.ScriptsFolderDLL) != true) { Directory.CreateDirectory(installfolder_scriptanddll + "\\" + ScrablerCore.ScriptsFolderDLL); } FastZip ziphandler = new FastZip(); FileInfo fileinf = new FileInfo(script_Archfilename); ziphandler.ExtractZip(script_Archfilename, SDKBase.UsersTempDirectory + "\\" + fileinf.Name, "scrf"); files = Directory.GetFiles(SDKBase.UsersTempDirectory + "\\" + fileinf.Name); ad.AttachDataBaseinDataSet(set, files[0]); // MessageBox.Show(files[0]); scrinf = core.GetScriptInfo(set); core.SetReferences(set, installfolder_scriptanddll + "\\" + ScrablerCore.ScriptsFolderDLL + "\\" + scrinf.Title, files[0]); File.Copy(files[0], installfolder_scriptanddll + "\\" + ScrablerCore.ScriptsFolder + "\\" + files[0].Substring(files[0].LastIndexOf("\\") + 1)); str = files[0]; tscrfilename = files[0]; File.Delete(files[0]); ziphandler.ExtractZip(script_Archfilename, SDKBase.UsersTempDirectory + "\\" + fileinf.Name, "dll"); files = null; files = Directory.GetFiles(SDKBase.UsersTempDirectory + "\\" + fileinf.Name); foreach (string file in files) { FileInfo dllinf = new FileInfo(file); this.CopyDll(file, installfolder_scriptanddll + "\\" + ScrablerCore.ScriptsFolderDLL + "\\" + scrinf.Title + "\\" + dllinf.Name); //MessageBox.Show("hi6"); } core.SetReferences(set, installfolder_scriptanddll + "\\" + ScrablerCore.ScriptsFolderDLL + "\\" + scrinf.Title, tscrfilename); } FileInfo fileinf2 = new FileInfo(script_Archfilename); string [] tfile = Directory.GetFiles(SDKBase.UsersTempDirectory + "\\" + fileinf2.Name); foreach (string file in tfile) { File.Delete(file); } Directory.Delete(SDKBase.UsersTempDirectory + "\\" + fileinf2.Name); } catch (Exception e) { Program.Bugtracking(e); } }