internal Root Create(esSettings settings) { Root esMeta = new Root(settings); if (!esMeta.Connect(settings.Driver, settings.ConnectionString)) { throw new Exception("Unable to Connect to Database: " + settings.Driver); } esMeta.Language = "C#"; //#if !TRIAL // Licensing licensing = new Licensing(); // licensing.ReplaceMeLater("developer", esMeta.esPlugIn.esVersion, "Serial_Number", "Serial_Number2", "Interop.ADODBX.dll", GetProxySettings(userSettings)); //#else // Licensing licensing = new Licensing(); // string id = licensing.getUniqueID("C"); // int result = licensing.ValidateLicense("trial", "b69e3783-9f56-47a7-82e0-6eee6d0779bf", System.Environment.MachineName, id, "2019.1.0725.0", GetProxySettings(userSettings)); // if (1 != result) // { // result = licensing.RegisterLicense("trial", "b69e3783-9f56-47a7-82e0-6eee6d0779bf", System.Environment.MachineName, id, "2019.1.0725.0", GetProxySettings(userSettings)); // } // if (result != 1) // { // throw new Exception("Trial Expired"); // } //#endif return(esMeta); }
private void ConvertProject(string fileNameAndFilePath, esSettings settings) { esProject2010 project2010 = new esProject2010(); project2010.Load(fileNameAndFilePath, settings); ConvertProjectNodeSettings(project2010.RootNode); esProject project = new esProject(); // Manually copy root node of tree into new project project.RootNode = new esProjectNode(); project.RootNode.Name = project2010.RootNode.Name; project.RootNode.IsFolder = project2010.RootNode.IsFolder; project.RootNode.Children = project2010.RootNode.Children; project.RootNode.Settings = project2010.RootNode.Settings; FileInfo fileInfo = new FileInfo(fileNameAndFilePath); string backup = fileInfo.Name.Replace(fileInfo.Extension, ""); backup += "_original" + fileInfo.Extension; backup = fileInfo.DirectoryName + "\\" + backup; File.Copy(fileNameAndFilePath, backup, true); // Now Save it in our new format project.Save(fileNameAndFilePath, settings); }
static internal Root Create(esSettings settings) { Root esMeta = new Root(settings); if (!esMeta.Connect(settings.Driver, settings.ConnectionString)) { throw new Exception("Unable to Connect to Database"); } esMeta.Language = "C#"; return(esMeta); }
internal static ProxySettings GetProxySettings(esSettings settings) { ProxySettings proxy = new ProxySettings(); proxy.UseProxy = settings.LicenseProxyEnable; if (proxy.UseProxy) { proxy.Url = settings.LicenseProxyUrl; proxy.UserName = settings.LicenseProxyUserName; proxy.Password = settings.LicenseProxyPassword; proxy.DomainName = settings.LicenseProxyDomainName; } return(proxy); }
public void Save(string fileNameAndFilePath, esSettings mainSettings) { projectFilePath = fileNameAndFilePath; userSettings = mainSettings; XmlTextWriter writer = new XmlTextWriter(fileNameAndFilePath, System.Text.Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("EntitySpacesProject"); writer.WriteAttributeString("Version", "2012.1.0930.0"); Save(this.RootNode, writer); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); }
public void LoadTemplates(ContextMenuStrip templateMenu, ContextMenuStrip subTemplateMenu, esSettings settings) { try { this.Settings = settings; if (this.TreeViewNodeSorter == null) { this.TreeViewNodeSorter = new NodeSorter(); InitializeComponent(); Template.SetTemplateCachePath(esSettings.TemplateCachePath); Template.SetCompilerAssemblyPath(Settings.CompilerAssemblyPath); } this.Nodes.Clear(); rootNode = this.Nodes.Add("Templates"); rootNode.ImageIndex = 2; rootNode.SelectedImageIndex = 2; rootNode.ContextMenuStrip = this.folderMenu; this.currentUIControls.Clear(); this.coll.Clear(); string[] files = Directory.GetFiles(Settings.TemplatePath, "*.est", SearchOption.AllDirectories); foreach (string file in files) { Template template = new Template(); TemplateHeader header = null; string[] nspace = null; try { // If this doesn't meet the criteria skip it and move on to the next file template.Parse(file); header = template.Header; if (header.Namespace == string.Empty) { continue; } nspace = header.Namespace.Split('.'); if (nspace == null || nspace.Length == 0) { continue; } } catch { continue; } // Okay, we have a valid template with a namespace ... TreeNode node = rootNode; TreeNode[] temp = null; // This foreach loop adds all of the folder entries based on // the namespace foreach (string entry in nspace) { temp = node.Nodes.Find(entry, true); if (temp == null || temp.Length == 0) { node = node.Nodes.Add(entry); node.Name = entry; } else { node = temp[0]; } node.ImageIndex = 2; node.SelectedImageIndex = 2; node.ContextMenuStrip = this.folderMenu; } // Now we add the final node, with the template icon and stash the Template // in the node's "Tag" property for later use when they execute it. node = node.Nodes.Add(template.Header.Title); node.Tag = template; node.ToolTipText = header.Description + " : " + header.Author + " (" + header.Version + ")" + Environment.NewLine; if (header.IsSubTemplate) { node.ImageIndex = 0; node.SelectedImageIndex = 0; node.ContextMenuStrip = subTemplateMenu; } else { node.ImageIndex = 1; node.SelectedImageIndex = 1; node.ContextMenuStrip = templateMenu; } } // Now, let's sort it so it all makes sense ... this.Sort(); } catch { } }
public void Load(string fileNameAndFilePath, esSettings mainSettings) { userSettings = mainSettings; string version = GetFileVersion(fileNameAndFilePath); if (version != null && version.Substring(0, 4) != "2011" && version.Substring(0, 4) != "2012") { // Convert the old project file in place ConvertProject(fileNameAndFilePath, mainSettings); } RootNode = null; Dictionary <int, esProjectNode> parents = new Dictionary <int, esProjectNode>(); using (XmlTextReader reader = new XmlTextReader(fileNameAndFilePath)) { projectFilePath = fileNameAndFilePath; reader.WhitespaceHandling = WhitespaceHandling.None; esProjectNode currentNode = null; reader.Read(); reader.Read(); if (reader.Name != "EntitySpacesProject") { throw new Exception("Invalid Project File: '" + fileNameAndFilePath + "'"); } reader.Read(); currentNode = new esProjectNode(); currentNode.Name = reader.GetAttribute("Name"); RootNode = currentNode; parents[reader.Depth] = currentNode; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case "Folder": currentNode = new esProjectNode(); currentNode.Name = reader.GetAttribute("Name"); parents[reader.Depth - 1].Children.Add(currentNode); parents[reader.Depth] = currentNode; break; case "RecordedTemplate": currentNode = new esProjectNode(); currentNode.Name = reader.GetAttribute("Name"); currentNode.IsFolder = false; int depth = reader.Depth; // <Template> reader.Read(); currentNode.Template = new Template(); // Path fixup to the template string path = reader.GetAttribute("Path"); path = path.Replace("{fixup}", userSettings.TemplatePath); path = path.Replace("\\\\", "\\"); currentNode.Template.Parse(path); // <Input> reader.Read(); XmlReader input = reader.ReadSubtree(); input.Read(); currentNode.Input = new Hashtable(); while (input.Read()) { string type = input.GetAttribute("Type"); string key = input.GetAttribute("Key"); string value = input.GetAttribute("Value"); if (key == "OutputPath") { value = FixupTheFixup(this.projectFilePath, value); } switch (type) { case "(null)": currentNode.Input[key] = null; break; case "System.String": currentNode.Input[key] = value; break; case "System.Char": currentNode.Input[key] = Convert.ToChar(value); break; case "System.DateTime": currentNode.Input[key] = Convert.ToDateTime(value); break; case "System.Decimal": currentNode.Input[key] = Convert.ToDecimal(value); break; case "System.Double": currentNode.Input[key] = Convert.ToDouble(value); break; case "System.Boolean": currentNode.Input[key] = Convert.ToBoolean(value); break; case "System.Int16": currentNode.Input[key] = Convert.ToInt16(value); break; case "System.Int32": currentNode.Input[key] = Convert.ToInt32(value); break; case "System.Int64": currentNode.Input[key] = Convert.ToInt64(value); break; case "System.Collections.ArrayList": ArrayList list = new ArrayList(); string[] items = value.Split(','); foreach (string item in items) { list.Add(item); } currentNode.Input[key] = list; break; } } // <Settings> reader.Read(); XmlReader settings = reader.ReadSubtree(); currentNode.Settings = new esSettings(); currentNode.Settings = esSettings.Load(settings); // Fixup Settings ... currentNode.Settings.TemplatePath = userSettings.TemplatePath; currentNode.Settings.OutputPath = userSettings.OutputPath; currentNode.Settings.UIAssemblyPath = userSettings.UIAssemblyPath; currentNode.Settings.CompilerAssemblyPath = userSettings.CompilerAssemblyPath; currentNode.Settings.LanguageMappingFile = userSettings.LanguageMappingFile; currentNode.Settings.UserMetadataFile = userSettings.UserMetadataFile; parents[depth - 1].Children.Add(currentNode); break; } } } } }
public void DisplayTemplateUI ( bool useCachedInput, Hashtable input, esSettings settings, Template template, OnTemplateExecute OnExecuteCallback, OnTemplateCancel OnCancelCallback ) { try { this.Template = template; TemplateDisplaySurface.MainWindow.OnTemplateExecuteCallback = OnExecuteCallback; TemplateDisplaySurface.MainWindow.OnTemplateCancelCallback = OnCancelCallback; TemplateDisplaySurface.MainWindow.CurrentTemplateDisplaySurface = this; if (template != null) { CurrentUIControls.Clear(); PopulateTemplateInfoCollection(); SortedList <int, esTemplateInfo> templateInfoCollection = coll.GetTemplateUI(template.Header.UserInterfaceID); if (templateInfoCollection == null || templateInfoCollection.Count == 0) { MainWindow.ShowError(new Exception("Template UI Assembly Cannot Be Located")); } this.esMeta = esMetaCreator.Create(settings); esMeta.Input["OutputPath"] = settings.OutputPath; if (useCachedInput) { if (CachedInput.ContainsKey(template.Header.UniqueID)) { Hashtable cachedInput = CachedInput[template.Header.UniqueID]; if (cachedInput != null) { foreach (string key in cachedInput.Keys) { esMeta.Input[key] = cachedInput[key]; } } } } if (input != null) { esMeta.Input = input; } MainWindow.tabControlTemplateUI.SuspendLayout(); foreach (esTemplateInfo info in templateInfoCollection.Values) { UserControl userControl = info.UserInterface.CreateInstance(esMeta, useCachedInput, MainWindow.ApplicationObject); CurrentUIControls.Add(info.TabOrder, userControl); TabPage page = new TabPage(info.TabTitle); page.Controls.Add(userControl); userControl.Dock = DockStyle.Fill; MainWindow.tabControlTemplateUI.TabPages.Add(page); MainWindow.ShowTemplateUIControl(); } MainWindow.tabControlTemplateUI.ResumeLayout(); if (CurrentUIControls.Count > 0) { MainWindow.ShowTemplateUIControl(); } } } catch (Exception ex) { MainWindow.ShowError(ex); } }
static int Main(string[] args) { #if !DEBUG SecurityTest securityTest = new SecurityTest(); if (!securityTest.IsAllSecurityOkay) { while (true) { } object o = null; o.ToString(); } #endif #if !DEBUG bool isAllSecurityOkay = securityTest.IsAllSecurityOkay; if (isAllSecurityOkay) { isAllSecurityOkay = securityTest.IsPublicTokenOkay; } if (!isAllSecurityOkay) { return(-1); } #endif List <Exception> errors = new List <Exception>(); bool silentMode = false; try { if (args == null || args.Length == 0 || args[0] == "/?") { Console.WriteLine(); Console.WriteLine("Usage: EntitySpaces.CommandLine {project file} {project node} /S"); Console.WriteLine(); Console.ReadKey(); return(0); } string projectName = null; string projectNode = null; #region Parse Arguments // I feel lazy, so I'm doing this the poor mans way if (args.Length == 1) { projectName = args[0]; } if (args.Length == 2) { projectName = args[0]; if (args[1] == "/s" || args[1] == "/S") { silentMode = true; } else { projectNode = args[1]; } } if (args.Length == 3) { projectName = args[0]; projectNode = args[1]; if (args[2] == "/s" || args[2] == "/S") { silentMode = true; } } #endregion Arguments if (projectName != null) { esSettings settings = esSettings.Load(); Template.SetTemplateCachePath(esSettings.TemplateCachePath); Template.SetCompilerAssemblyPath(settings.CompilerAssemblyPath); ProjectExecuter exe = new ProjectExecuter(projectName, settings); List <Exception> moreErrors = exe.ExecuteFromNode(projectNode); if (moreErrors.Count > 0) { errors.AddRange(moreErrors); } } } catch (Exception ex) { errors.Add(ex); } if (!silentMode && errors.Count > 0) { Console.WriteLine(); foreach (Exception ex in errors) { Console.WriteLine(ex.Message); Console.WriteLine(); } Console.ReadKey(); } return(errors.Count == 0 ? 0 : 1); }
public ProjectExecuter(string projectFile, esSettings mainSettings) { userSettings = mainSettings; project = new esProject(); project.Load(projectFile, userSettings); }