private void CreateNewScript(string name, string type) { if (string.IsNullOrEmpty(name)) return; if(_dbContext.UserScripts.Any(x => x.Name == name)) { _dialogService.ShowMessageAsync(this, "Script Already Exists", "A script with that name already exists."); return; } //If there are unsaved changes, prompt to save before making a new script HandleUnsavedChanges(); //test text for uniqueness var script = new UserScript(); script.Name = name; AddStandardAssemblies(script); script.Code = string.Format(type == "Order" ? OrderScriptBase : TradeScriptBase, name); _dbContext.UserScripts.Add(script); Scripts.Add(script); SelectedScript = script; Code = SelectedScript.Code; SaveScripts(); }
private void AddStandardAssemblies(UserScript script) { script.ReferencedAssemblies.Add("mscorlib.dll"); script.ReferencedAssemblies.Add("System.dll"); script.ReferencedAssemblies.Add("System.Collections.dll"); script.ReferencedAssemblies.Add("System.Core.dll"); string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; script.ReferencedAssemblies.Add(exePath); string entityModelDllPath = Path.Combine(Path.GetDirectoryName(exePath), "EntityModel.dll"); script.ReferencedAssemblies.Add(entityModelDllPath); string qpasCommonPath = Path.Combine(Path.GetDirectoryName(exePath), "QPAS.Common.dll"); script.ReferencedAssemblies.Add(qpasCommonPath); string nlogPath = Path.Combine(Path.GetDirectoryName(exePath), "NLog.dll"); script.ReferencedAssemblies.Add(nlogPath); }
private void OpenScript(UserScript script) { if (SelectedScript == script) return; HandleUnsavedChanges(); SelectedScript = script; Code = SelectedScript.Code; ChangedSinceLastSave = false; }