コード例 #1
0
        private void PopulateComboBox(DefaultSettings settings)
        {
            this.cboxLanguage.Items.Clear();

            // Populate the ComboBox
            dbRoot myMeta = new dbRoot();

            myMeta.LanguageMappingFileName = settings.LanguageMappingFile;
            myMeta.Language = settings.Language;

            string[] languages = myMeta.GetLanguageMappings(settings.DbDriver);

            if (null != languages)
            {
                for (int i = 0; i < languages.Length; i++)
                {
                    this.cboxLanguage.Items.Add(languages[i]);
                }

                this.cboxLanguage.SelectedItem = myMeta.Language;

                if (this.cboxLanguage.SelectedIndex == -1)
                {
                    // The default doesn't exist, set it to the first in the list
                    this.cboxLanguage.SelectedIndex = 0;
                }
            }
        }
コード例 #2
0
ファイル: MetaDataBrowser.cs プロジェクト: zhh007/MyGen
        private void MetaDataBrowser_Load(object sender, System.EventArgs e)
        {
            this.startupPath = Zeus.FileTools.RootFolder;

            DefaultSettings settings = DefaultSettings.Instance;

            this.Setup(settings);

            //if (this.mdi is MyGenerationMDI)
            //{
            MyGenerationMDI p = mdi as MyGenerationMDI;

            this.MetaData       = p.MetaPropertiesDockContent;
            this.UserData       = p.UserMetaDataDockContent;
            this.GlobalUserData = p.GlobalUserMetaDataDockContent;
            // }
            // else
            // {
            //    MDIParent p = mdi as MDIParent;
            //    this.MetaData = p.MetaDataWindow;
            //     this.UserData = p.UserMetaWindow;
            //     this.GlobalUserData = p.GlobalUserMetaWindow;
            // }
            MyTree.Scrollable = true;
        }
コード例 #3
0
ファイル: MetaDataBrowser.cs プロジェクト: zhh007/MyGen
        public void DefaultSettingsChanged(DefaultSettings settings)
        {
            bool doRefresh = false;

            try
            {
                if ((myMeta.DriverString != settings.DbDriver) ||
                    (myMeta.ConnectionString != settings.ConnectionString) ||
                    (myMeta.LanguageMappingFileName != settings.LanguageMappingFile) ||
                    (myMeta.Language != settings.Language) ||
                    (myMeta.DbTargetMappingFileName != settings.DbTargetMappingFile) ||
                    (myMeta.DbTarget != settings.DbTarget) ||
                    (myMeta.UserMetaDataFileName != settings.UserMetaDataFileName) ||
                    (myMeta.DomainOverride != settings.DomainOverride))
                {
                    doRefresh = true;
                }
            }
            catch
            {
                doRefresh = true;
            }

            if (doRefresh)
            {
                this.Setup(settings);
            }
        }
コード例 #4
0
        public void Execute()
        {
            Cursor.Current = Cursors.WaitCursor;

            TreeNode        node     = this.treeViewProject.SelectedNode;
            DefaultSettings settings = DefaultSettings.Instance;

            ProjectExecuteStatus log = new ProjectExecuteStatus();

            log.Show(this);

            if ((node is ModuleTreeNode) || (node is ProjectTreeNode))
            {
                ZeusModule module = node.Tag as ZeusModule;
                module.Execute(settings.ScriptTimeout, log);
            }
            else if (node is SavedObjectTreeNode)
            {
                SavedTemplateInput savedinput = node.Tag as SavedTemplateInput;
                savedinput.Execute(settings.ScriptTimeout, log);
            }

            log.Finished = true;
            log.BringToFront();
            log.Activate();

            Cursor.Current = Cursors.Default;
        }
コード例 #5
0
ファイル: TemplateBrowser.cs プロジェクト: zhh007/MyGen
        public void ProcessAlert(IMyGenContent sender, string command, params object[] args)
        {
            DefaultSettings settings = DefaultSettings.Instance;

            if (command == "UpdateDefaultSettings")
            {
                bool doRefresh = false;

                try
                {
                    if (this.treeBuilder.DefaultTemplatePath != settings.DefaultTemplateDirectory)
                    {
                        doRefresh = true;
                    }
                }
                catch
                {
                    doRefresh = true;
                }

                if (doRefresh)
                {
                    this.RefreshTree();
                }
            }
        }
コード例 #6
0
ファイル: DbTargetMappings.cs プロジェクト: zhh007/MyGen
        private void PopulateComboBox(DefaultSettings settings)
        {
            this.cboxDbTarget.Items.Clear();

            // Populate the ComboBox
            dbRoot myMeta = new dbRoot();

            myMeta.DbTargetMappingFileName = settings.DbTargetMappingFile;
            myMeta.DbTarget = settings.DbTarget;

            string[] targets = myMeta.GetDbTargetMappings(settings.DbDriver);

            if (null != targets)
            {
                for (int i = 0; i < targets.Length; i++)
                {
                    this.cboxDbTarget.Items.Add(targets[i]);
                }

                this.cboxDbTarget.SelectedItem = myMeta.DbTarget;

                if (this.cboxDbTarget.SelectedIndex == -1)
                {
                    // The default doesn't exist, set it to the first in the list
                    this.cboxDbTarget.SelectedIndex = 0;
                }
            }
        }
コード例 #7
0
ファイル: MetaDataBrowser.cs プロジェクト: zhh007/MyGen
        public void DefaultSettingsChanged(DefaultSettings settings)
        {
            bool doRefresh = false;

            if (!IsTreeBusy)
            {
                try
                {
                    if ((StaticMyMeta.DriverString != settings.DbDriver) ||
                        (StaticMyMeta.ConnectionString != settings.ConnectionString) ||
                        (StaticMyMeta.ShowDefaultDatabaseOnly != settings.ShowDefaultDatabaseOnly) ||
                        (StaticMyMeta.LanguageMappingFileName != settings.LanguageMappingFile) ||
                        (StaticMyMeta.Language != settings.Language) ||
                        (StaticMyMeta.DbTargetMappingFileName != settings.DbTargetMappingFile) ||
                        (StaticMyMeta.DbTarget != settings.DbTarget) ||
                        (StaticMyMeta.UserMetaDataFileName != settings.UserMetaDataFileName) ||
                        (StaticMyMeta.DomainOverride != settings.DomainOverride) ||
                        (!CompareUserDataDatabaseMappings(StaticMyMeta.UserDataDatabaseMappings, settings.DatabaseUserDataXmlMappings)))
                    {
                        doRefresh = true;
                    }
                }
                catch
                {
                    doRefresh = true;
                }
            }

            if (doRefresh)
            {
                this.SetupAsync();
            }
        }
コード例 #8
0
ファイル: ProjectBrowserControl.cs プロジェクト: zhh007/MyGen
        public void Execute()
        {
            this.Save();
            ZeusProject proj = this._rootNode.Project;

            Cursor.Current = Cursors.WaitCursor;

            TreeNode        node     = this.treeViewProject.SelectedNode;
            DefaultSettings settings = DefaultSettings.Instance;

            if (node is ProjectTreeNode)
            {
                OnExecutionStarted();
                ZeusProcessManager.ExecuteProject(proj.FilePath, ExecutionCallback);
            }
            else if (node is ModuleTreeNode)
            {
                ZeusModule module = node.Tag as ZeusModule;
                OnExecutionStarted();
                ZeusProcessManager.ExecuteModule(proj.FilePath, module.ProjectPath, ExecutionCallback);
                //module.Execute(settings.ScriptTimeout, log);
            }
            else if (node is SavedObjectTreeNode)
            {
                SavedTemplateInput savedinput = node.Tag as SavedTemplateInput;
                ZeusModule         module     = node.Parent.Tag as ZeusModule;
                OnExecutionStarted();
                ZeusProcessManager.ExecuteProjectItem(proj.FilePath, module.ProjectPath + "/" + savedinput.SavedObjectName, ExecutionCallback);
                //savedinput.Execute(settings.ScriptTimeout, log);
            }
        }
コード例 #9
0
ファイル: MetaDataBrowser.cs プロジェクト: zhh007/MyGen
        /*private void menuItemClose_Click(object sender, System.EventArgs e)
         * {
         *      this.Close();
         * }*/

        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            switch (e.Button.Tag as string)
            {
            case "refresh":

                if (this.IsUserDataDirty)
                {
                    DialogResult result = MessageBox.Show("The User Meta Data has been Modified, Do you wish to save the modifications?",
                                                          "User Meta Data", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                    if (result == DialogResult.Yes)
                    {
                        this.SaveUserMetaData();
                    }
                }

                DefaultSettings settings = DefaultSettings.Instance;
                this.Setup(settings);

                this.UserData.MetaBrowserRefresh();
                this.GlobalUserData.MetaBrowserRefresh();
                this.MetaData.MetaBrowserRefresh();
                break;
            }
        }
コード例 #10
0
ファイル: MetaDataBrowser.cs プロジェクト: zhh007/MyGen
        private void MetaDataBrowser_Load(object sender, System.EventArgs e)
        {
            this.startupPath = Zeus.FileTools.ApplicationPath;

            DefaultSettings settings = DefaultSettings.Instance;

            this.Setup();
        }
コード例 #11
0
        public void ExecuteTemplate(ZeusTemplate template)
        {
            Cursor.Current = Cursors.WaitCursor;

            DefaultSettings settings = DefaultSettings.Instance;

            IZeusContext    context       = new ZeusContext();
            IZeusGuiControl guiController = context.Gui;
            IZeusOutput     zout          = context.Output;

            settings.PopulateZeusContext(context);

            bool exceptionOccurred = false;
            bool result            = false;

            try
            {
                template.GuiSegment.ZeusScriptingEngine.ExecutionHelper.Timeout = settings.ScriptTimeout;
                template.GuiSegment.ZeusScriptingEngine.ExecutionHelper.SetShowGuiHandler(new ShowGUIEventHandler(DynamicGUI_Display));
                result = template.GuiSegment.Execute(context);
                template.GuiSegment.ZeusScriptingEngine.ExecutionHelper.Cleanup();

                if (result)
                {
                    template.BodySegment.ZeusScriptingEngine.ExecutionHelper.Timeout = settings.ScriptTimeout;
                    result = template.BodySegment.Execute(context);
                    template.BodySegment.ZeusScriptingEngine.ExecutionHelper.Cleanup();
                }
            }
            catch (Exception ex)
            {
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
                //formError.SetControlsFromException();
                //formError.ShowDialog(this);

                exceptionOccurred = true;
            }

            Cursor.Current = Cursors.Default;

            if (!exceptionOccurred && result)
            {
                if (settings.EnableClipboard)
                {
                    try
                    {
                        Clipboard.SetDataObject(zout.text, true);
                    }
                    catch
                    {
                        // HACK: For some reason, Clipboard.SetDataObject throws an error on some systems. I'm cathhing it and doing nothing for now.
                    }
                }

                MessageBox.Show("Successfully rendered Template: " + template.Title);
            }
        }
コード例 #12
0
        public void SaveInput(ZeusTemplate template)
        {
            bool overridden = false;

            if (ExecuteTemplateOverride != null)
            {
                overridden = ExecuteTemplateOverride(TemplateOperations.SaveInput, template, null, _guiHandler);
            }

            if (!overridden)
            {
                try
                {
                    DefaultSettings settings = DefaultSettings.Instance;

                    ZeusSimpleLog log     = new ZeusSimpleLog();
                    ZeusContext   context = new ZeusContext();
                    context.Log = log;

                    ZeusSavedInput collectedInput = new ZeusSavedInput();
                    collectedInput.InputData.TemplateUniqueID = template.UniqueID;
                    collectedInput.InputData.TemplatePath     = template.FilePath + template.FileName;

                    settings.PopulateZeusContext(context);
                    template.Collect(context, settings.ScriptTimeout, collectedInput.InputData.InputItems);

                    if (log.HasExceptions)
                    {
                        throw log.Exceptions[0];
                    }
                    else
                    {
                        SaveFileDialog saveFileDialog = new SaveFileDialog();
                        saveFileDialog.Filter           = "Zues Input Files (*.zinp)|*.zinp";
                        saveFileDialog.FilterIndex      = 0;
                        saveFileDialog.RestoreDirectory = true;
                        if (saveFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            Cursor.Current = Cursors.WaitCursor;

                            collectedInput.FilePath = saveFileDialog.FileName;
                            collectedInput.Save();
                        }
                    }

                    MessageBox.Show(this, "Input collected and saved to file: \r\n" + collectedInput.FilePath);
                }
                catch (Exception ex)
                {
                    OnErrorsOccurred(ex);
                }

                Cursor.Current = Cursors.Default;
            }
        }
コード例 #13
0
ファイル: MetaDataBrowser.cs プロジェクト: zhh007/MyGen
        private void Setup(DefaultSettings settings)
        {
            string error = string.Empty;

            try
            {
                myMeta    = new dbRoot();
                this.Text = "MyMeta Browser (" + settings.DbDriver + ")";

                if (settings.DbDriver.ToUpper() != "NONE")
                {
#if !DEBUG
                    TestConnectionForm tcf = new TestConnectionForm(settings.DbDriver, settings.ConnectionString, true);
                    if (isFirstRun)
                    {
                        tcf.StartPosition = FormStartPosition.CenterScreen;
                        isFirstRun        = false;
                    }
                    tcf.ShowDialog(this.MdiParent);
                    if (TestConnectionForm.State == ConnectionTestState.Error)
                    {
                        if (TestConnectionForm.LastErrorMsg != null)
                        {
                            error = TestConnectionForm.LastErrorMsg;
                        }
                        else
                        {
                            error = "Connection Error...";
                        }
                    }
                    tcf = null;
#endif
                }

                if (error == string.Empty)
                {
                    myMeta.Connect(settings.DbDriver, settings.ConnectionString);
                    myMeta.LanguageMappingFileName = settings.LanguageMappingFile;
                    myMeta.Language = settings.Language;
                    myMeta.DbTargetMappingFileName = settings.DbTargetMappingFile;
                    myMeta.DbTarget             = settings.DbTarget;
                    myMeta.UserMetaDataFileName = settings.UserMetaDataFileName;

                    myMeta.DomainOverride = settings.DomainOverride;

                    myMeta.ShowSystemData = chkSystem.Checked;
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }

            this.InitializeTree(myMeta, error);
        }
コード例 #14
0
ファイル: DbTargetMappings.cs プロジェクト: zhh007/MyGen
        public void DefaultSettingsChanged(DefaultSettings settings)
        {
            PromptForSave(false);

            this.dbDriver = settings.DbDriver;

            PopulateComboBox(settings);
            PopulateGrid(this.dbDriver);

            MarkAsDirty(false);
        }
コード例 #15
0
ファイル: UserMetaData.cs プロジェクト: aqzou/MyGeneration
        public UserMetaData(IMyGenerationMDI mdi)
        {
            InitializeComponent();
            this.mdi = mdi;

            this.ShowHint = DockState.DockRight;

            DefaultSettings settings = DefaultSettings.Instance;

            this.UserMetaDataFileName = settings.UserMetaDataFileName;
        }
コード例 #16
0
ファイル: UserMetaData.cs プロジェクト: aqzou/MyGeneration
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            DefaultSettings settings = DefaultSettings.Instance;

            switch (e.Button.Tag as string)
            {
            case "save":

                _metaDataBrowser.SaveUserMetaData();
                break;
            }
        }
コード例 #17
0
        private void contextItemCacheSettings_Click(object sender, System.EventArgs e)
        {
            SortedProjectTreeNode node = this.treeViewProject.SelectedNode as SortedProjectTreeNode;

            if ((node is ModuleTreeNode) || (node is ProjectTreeNode))
            {
                ZeusModule      module   = node.Tag as ZeusModule;
                ZeusContext     context  = new ZeusContext();
                DefaultSettings settings = DefaultSettings.Instance;
                settings.PopulateZeusContext(context);
                module.SavedItems.Add(context.Input);
            }
        }
コード例 #18
0
        public void Show(DockPanel dockManager)
        {
            DefaultSettings settings = DefaultSettings.Instance;

            if (!System.IO.File.Exists(settings.LanguageMappingFile))
            {
                MessageBox.Show(this, "Language Mapping File does not exist at: " + settings.LanguageMappingFile + "\r\nPlease fix this in DefaultSettings.");
            }
            else
            {
                base.Show(dockManager);
            }
        }
コード例 #19
0
        private void SaveInput()
        {
            try
            {
                if (_collectInChildProcess)
                {
                    this.buttonCollectInput.Enabled = false;
                    this.Cursor = Cursors.WaitCursor;
                    ZeusProcessManager.RecordProjectItem(this._module.RootProject.FilePath, _module.ProjectPath + "/" + SavedObject.SavedObjectName, this.SelectedTemplate.Tag.ToString(), _executionCallback);
                }
                else
                {
                    //RecordProjectItem
                    ZeusTemplate    template = new ZeusTemplate(this.SelectedTemplate.Tag.ToString());
                    DefaultSettings settings = DefaultSettings.Instance;

                    ZeusSimpleLog log     = new ZeusSimpleLog();
                    ZeusContext   context = new ZeusContext();
                    context.Log = log;

                    SavedObject.TemplateUniqueID = template.UniqueID;
                    SavedObject.TemplatePath     = template.FilePath + template.FileName;

                    settings.PopulateZeusContext(context);
                    if (_module != null)
                    {
                        _module.PopulateZeusContext(context);
                        _module.OverrideSavedData(SavedObject.InputItems);
                    }

                    if (template.Collect(context, settings.ScriptTimeout, SavedObject.InputItems))
                    {
                        this._lastRecordedSelectedNode = this.SelectedTemplate;
                    }

                    if (log.HasExceptions)
                    {
                        throw log.Exceptions[0];
                    }
                }
            }
            catch (Exception ex)
            {
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
                //formError.SetControlsFromException();
                //formError.ShowDialog(this);
            }

            Cursor.Current = Cursors.Default;
        }
コード例 #20
0
        public void LoadTemplatesByFile()
        {
            if (_tree != null)
            {
                this._tree.Nodes.Clear();
                IdPathHash.Clear();

                if (_fsRootNode == null)
                {
                    DefaultSettings settings = DefaultSettings.Instance;

                    defaultTemplatePath = settings.DefaultTemplateDirectory;
                    string exePath = Directory.GetCurrentDirectory();

                    if (!Directory.Exists(defaultTemplatePath))
                    {
                        defaultTemplatePath = exePath;
                    }

                    // ArrayList templates = new ArrayList();
                    DirectoryInfo rootInfo = new DirectoryInfo(defaultTemplatePath);

                    _fsRootNode = new RootTreeNode("Zeus Templates by File");

#if RUN_AS_NON_ADMIN
                    SortedTreeNode item = new RootTreeNode("System");
                    _fsRootNode.Nodes.Add(item);
                    _buildChildren(item, rootInfo);
                    item.Expand();

                    string userTemplates = settings.UserTemplateDirectory;

                    if ((userTemplates != null) && (userTemplates != defaultTemplatePath))
                    {
                        rootInfo = new DirectoryInfo(userTemplates);

                        item = new RootTreeNode("User:" + Environment.UserName);
                        _fsRootNode.Nodes.Add(item);
                        _buildChildren(item, rootInfo);
                        item.Expand();
                    }
#else
                    _buildChildren(_fsRootNode, rootInfo);
#endif
                    _fsRootNode.Expand();
                }

                this._tree.Nodes.Add(_fsRootNode);
            }
        }
コード例 #21
0
        public void LoadTemplates(string selectedid)
        {
            DefaultSettings settings  = DefaultSettings.Instance;
            ArrayList       filenames = new ArrayList();

            filenames.Add(settings.DefaultTemplateDirectory);
            ArrayList        templatePaths = FileTools.GetFilenamesRecursive(filenames, this._extensions);
            ZeusTemplate     template;
            TemplateListItem item;

            this.listBoxTemplates.Items.Clear();

            foreach (string path in templatePaths)
            {
                try
                {
                    template = new ZeusTemplate(FileTools.ResolvePath(path));
                    string ns    = template.NamespacePathString.Trim();
                    string title = template.Title.Trim();
                    title = (title.Length > 0) ? title : "<unnamed>";

                    if (ns.Length > 0)
                    {
                        ns = template.NamespacePathString + "." + title;
                    }
                    else
                    {
                        ns = title;
                    }

                    item = new TemplateListItem(template.UniqueID, path, ns);

                    this.listBoxTemplates.Items.Add(item);
                    if (item.ID == selectedid)
                    {
                        this.listBoxTemplates.SelectedItem = item;
                    }
                }
                catch
                {
                    continue;
                }
            }

            if ((this.listBoxTemplates.SelectedItem == null) &&
                (this.listBoxTemplates.Items.Count > 0))
            {
                this.listBoxTemplates.SelectedIndex = 0;
            }
        }
コード例 #22
0
        public void ExecuteLoadedInput()
        {
            try
            {
                DefaultSettings settings = DefaultSettings.Instance;
                ZeusSimpleLog   log      = new ZeusSimpleLog();

                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter           = "Zues Input Files (*.zinp)|*.zinp";
                openFileDialog.FilterIndex      = 0;
                openFileDialog.RestoreDirectory = true;
                openFileDialog.Multiselect      = true;
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    Cursor.Current = Cursors.WaitCursor;

                    foreach (string filename in openFileDialog.FileNames)
                    {
                        ZeusSavedInput savedInput = new ZeusSavedInput(filename);
                        if (savedInput.Load())
                        {
                            ZeusContext context = new ZeusContext();
                            context.Input.AddItems(savedInput.InputData.InputItems);
                            context.Log = log;

                            ZeusTemplate template = new ZeusTemplate(savedInput.InputData.TemplatePath);
                            template.Execute(context, settings.ScriptTimeout, true);

                            if (log.HasExceptions)
                            {
                                throw log.Exceptions[0];
                            }
                        }
                    }

                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(this, "Selected files have been executed.");
                }
            }
            catch (Exception ex)
            {
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
                //formError.SetControlsFromException();
                //formError.ShowDialog(this);
            }

            Cursor.Current = Cursors.Default;
        }
コード例 #23
0
        public void ProcessAlert(IMyGenContent sender, string command, params object[] args)
        {
            if (command == "UpdateDefaultSettings")
            {
                DefaultSettings settings = DefaultSettings.Instance;
                PromptForSave(false);

                this.dbDriver = settings.DbDriver;

                PopulateComboBox(settings);
                PopulateGrid(this.dbDriver);

                MarkAsDirty(false);
            }
        }
コード例 #24
0
        public void ProcessAlert(IMyGenContent sender, string command, params object[] args)
        {
            if (command.Equals("UpdateDefaultSettings", StringComparison.CurrentCultureIgnoreCase))
            {
                DefaultSettings settings = DefaultSettings.Instance;
                PromptForSave(false);

                this.dbDriver = settings.DbDriver;

                PopulateComboBox(settings);
                PopulateGrid(this.dbDriver);

                MarkAsDirty(false);
            }
        }
コード例 #25
0
        static private XmlDocument GetXmlFromUrl(string url)
        {
            XmlDocument xmldoc = new XmlDocument();

            HttpWebRequest  request  = HttpWebRequest.Create(url) as HttpWebRequest;
            DefaultSettings settings = DefaultSettings.Instance;

            if (settings.UseProxyServer)
            {
                if (settings.ProxyAuthUsername != string.Empty)
                {
                    NetworkCredential creds = new NetworkCredential(settings.ProxyAuthUsername, settings.ProxyAuthPassword);
                    if (settings.ProxyAuthDomain != string.Empty)
                    {
                        creds.Domain = settings.ProxyAuthDomain;
                    }
                    request.Proxy = new WebProxy(settings.ProxyServerUri, true, null, creds);
                }

                else
                {
                    request.Proxy = new WebProxy(settings.ProxyServerUri, true, null);
                }
            }
            request.Timeout = 15 * 1000;

            try
            {
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
                    xmldoc.LoadXml(reader.ReadToEnd());
                    reader.Close();
                }
                else
                {
                    throw new Exception(response.StatusCode.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().Name + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
            }

            return(xmldoc);
        }
コード例 #26
0
        public void SaveInput(ZeusTemplate template)
        {
            try
            {
                DefaultSettings settings = DefaultSettings.Instance;

                ZeusSimpleLog log     = new ZeusSimpleLog();
                ZeusContext   context = new ZeusContext();
                context.Log = log;

                ZeusSavedInput collectedInput = new ZeusSavedInput();
                collectedInput.InputData.TemplateUniqueID = template.UniqueID;
                collectedInput.InputData.TemplatePath     = template.FilePath + template.FileName;

                settings.PopulateZeusContext(context);
                template.Collect(context, settings.ScriptTimeout, collectedInput.InputData.InputItems);

                if (log.HasExceptions)
                {
                    throw log.Exceptions[0];
                }
                else
                {
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
                    saveFileDialog.Filter           = "Zues Input Files (*.zinp)|*.zinp";
                    saveFileDialog.FilterIndex      = 0;
                    saveFileDialog.RestoreDirectory = true;
                    if (saveFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        collectedInput.FilePath = saveFileDialog.FileName;
                        collectedInput.Save();
                    }
                }

                MessageBox.Show(this, "Input collected and saved to file: \r\n" + collectedInput.FilePath);
            }
            catch (Exception ex)
            {
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
                //formError.SetControlsFromException();
                //formError.ShowDialog(this);
            }

            Cursor.Current = Cursors.Default;
        }
コード例 #27
0
        public void SendAlert(IMyGenContent sender, string command, params object[] args)
        {
            IMyGenContent         contentItem = null;
            DockContentCollection contents    = MainDockPanel.Contents;

            DefaultSettings settings = DefaultSettings.Instance;

            for (int i = 0; i < contents.Count; i++)
            {
                contentItem = contents[i] as IMyGenContent;

                if (contentItem != null)
                {
                    contentItem.ProcessAlert(sender, command, args);
                }
            }
        }
コード例 #28
0
ファイル: AddEditSavedObjectEx.cs プロジェクト: zhh007/MyGen
        private void SaveInput()
        {
            try
            {
                /*if (_lastRecordedSelectedIndex != this.listBoxTemplates.SelectedIndex)
                 * {
                 *      this.SavedObject.InputItems.Clear();
                 * }*/

                ZeusTemplate    template = new ZeusTemplate(this.SelectedTemplate.Path);
                DefaultSettings settings = DefaultSettings.Instance;

                ZeusSimpleLog log     = new ZeusSimpleLog();
                ZeusContext   context = new ZeusContext();
                context.Log = log;

                SavedObject.TemplateUniqueID = template.UniqueID;
                SavedObject.TemplatePath     = template.FilePath + template.FileName;

                settings.PopulateZeusContext(context);
                if (_module != null)
                {
                    _module.PopulateZeusContext(context);
                }

                if (template.Collect(context, settings.ScriptTimeout, SavedObject.InputItems))
                {
                    _lastRecordedSelectedIndex = this.listBoxTemplates.SelectedIndex;
                }

                if (log.HasExceptions)
                {
                    throw log.Exceptions[0];
                }
            }
            catch (Exception ex)
            {
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
//formError.SetControlsFromException();
//formError.ShowDialog(this);
            }

            Cursor.Current = Cursors.Default;
        }
コード例 #29
0
        static private byte[] GetBytesFromUrl(string url)
        {
            byte[] bytes = null;

            HttpWebRequest  request  = HttpWebRequest.Create(url) as HttpWebRequest;
            DefaultSettings settings = DefaultSettings.Instance;

            if (settings.UseProxyServer)
            {
                if (settings.ProxyAuthUsername != string.Empty)
                {
                    NetworkCredential creds = new NetworkCredential(settings.ProxyAuthUsername, settings.ProxyAuthPassword);
                    if (settings.ProxyAuthDomain != string.Empty)
                    {
                        creds.Domain = settings.ProxyAuthDomain;
                    }
                    request.Proxy = new WebProxy(settings.ProxyServerUri, true, null, creds);
                }
                else
                {
                    request.Proxy = new WebProxy(settings.ProxyServerUri, true, null);
                }
            }
            request.Timeout = 15 * 1000;

            HttpWebResponse response = request.GetResponse() as HttpWebResponse;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                BinaryReader reader = new BinaryReader(response.GetResponseStream());
                bytes = reader.ReadBytes(Convert.ToInt32(response.ContentLength));
                reader.Close();
                reader = null;
            }
            else
            {
                throw new Exception(response.StatusCode.ToString());
            }

            return(bytes);
        }
コード例 #30
0
        private void LanguageMappings_Load(object sender, System.EventArgs e)
        {
            this.col_From.TextBox.BorderStyle = BorderStyle.None;
            this.col_To.TextBox.BorderStyle   = BorderStyle.None;

            this.col_From.TextBox.Move += new System.EventHandler(this.ColorTextBox);
            this.col_To.TextBox.Move   += new System.EventHandler(this.ColorTextBox);

            DefaultSettings settings = DefaultSettings.Instance;

            this.dbDriver = settings.DbDriver;

            this.xml.Load(settings.LanguageMappingFile);

            PopulateComboBox(settings);
            PopulateGrid(this.dbDriver);

            MarkAsDirty(false);

            gridLayoutHelper = new GridLayoutHelper(XmlEditor, MyXmlStyle, new decimal[] { 0.50M, 0.50M }, new int[] { 100, 100 });
        }
コード例 #31
0
 public void Initialize(IMyGenerationMDI mdi)
 {
     this.mdi = mdi;
     settings = DefaultSettings.Instance;
 }
コード例 #32
0
		private void PopulateComboBox(DefaultSettings settings)
		{
			this.cboxLanguage.Items.Clear();

			// Populate the ComboBox
			dbRoot myMeta = new dbRoot();
			myMeta.LanguageMappingFileName	= settings.LanguageMappingFile;
			myMeta.Language					= settings.Language;

			string[] languages = myMeta.GetLanguageMappings(settings.DbDriver);

			if(null != languages)
			{
				for(int i = 0; i < languages.Length; i++)
				{
					this.cboxLanguage.Items.Add(languages[i]);
				}

				this.cboxLanguage.SelectedItem = myMeta.Language;

				if(this.cboxLanguage.SelectedIndex == -1)
				{
					// The default doesn't exist, set it to the first in the list
					this.cboxLanguage.SelectedIndex = 0;
				}
			}
		}
コード例 #33
0
		public void DefaultSettingsChanged(DefaultSettings settings)
		{
			bool doRefresh = false;

			try 
			{
				if ((myMeta.DriverString != settings.DbDriver) ||
					(myMeta.ConnectionString != settings.ConnectionString ) ||
					(myMeta.LanguageMappingFileName != settings.LanguageMappingFile ) ||
					(myMeta.Language != settings.Language ) ||
					(myMeta.DbTargetMappingFileName != settings.DbTargetMappingFile ) ||
					(myMeta.DbTarget != settings.DbTarget ) ||
					(myMeta.UserMetaDataFileName != settings.UserMetaDataFileName ) ||
					(myMeta.DomainOverride != settings.DomainOverride )) 
				{
					doRefresh = true;
				}
			}
			catch 
			{
				doRefresh = true;
			}
			
			if (doRefresh) this.Setup(settings);
		}
コード例 #34
0
        private void Setup(DefaultSettings settings)
		{
			string error = string.Empty;

			try
			{
				myMeta = new dbRoot();
				this.Text = "MyMeta Browser (" + settings.DbDriver + ")";

				if (settings.DbDriver.ToUpper() != "NONE")
                {
#if !DEBUG
                    TestConnectionForm tcf = new TestConnectionForm(settings.DbDriver, settings.ConnectionString, true);
					if (isFirstRun) 
					{
						tcf.StartPosition = FormStartPosition.CenterScreen;
						isFirstRun = false;
					}
					tcf.ShowDialog(this.MdiParent);
					if (TestConnectionForm.State == ConnectionTestState.Error) 
					{
						if (TestConnectionForm.LastErrorMsg != null)
							error = TestConnectionForm.LastErrorMsg;
						else 
							error = "Connection Error...";
					}
					tcf = null;
#endif
				}

				if (error == string.Empty) 
				{
					myMeta.Connect(settings.DbDriver, settings.ConnectionString);
					myMeta.LanguageMappingFileName	= settings.LanguageMappingFile;
					myMeta.Language					= settings.Language;
					myMeta.DbTargetMappingFileName	= settings.DbTargetMappingFile;
					myMeta.DbTarget					= settings.DbTarget;
					myMeta.UserMetaDataFileName		= settings.UserMetaDataFileName;

					myMeta.DomainOverride			= settings.DomainOverride;

					myMeta.ShowSystemData			= chkSystem.Checked;
				}
			}
			catch(Exception ex)
			{
				error = ex.Message;
			}

			this.InitializeTree(myMeta, error);
		}
コード例 #35
0
        public void DefaultSettingsChanged(DefaultSettings settings)
		{
			bool doRefresh = false;

            if (!IsTreeBusy)
            {
                try
                {
                    if ((StaticMyMeta.DriverString != settings.DbDriver) ||
                        (StaticMyMeta.ConnectionString != settings.ConnectionString) ||
                        (StaticMyMeta.ShowDefaultDatabaseOnly != settings.ShowDefaultDatabaseOnly) ||
                        (StaticMyMeta.LanguageMappingFileName != settings.LanguageMappingFile) ||
                        (StaticMyMeta.Language != settings.Language) ||
                        (StaticMyMeta.DbTargetMappingFileName != settings.DbTargetMappingFile) ||
                        (StaticMyMeta.DbTarget != settings.DbTarget) ||
                        (StaticMyMeta.UserMetaDataFileName != settings.UserMetaDataFileName) ||
                        (StaticMyMeta.DomainOverride != settings.DomainOverride) ||
                        (!CompareUserDataDatabaseMappings(StaticMyMeta.UserDataDatabaseMappings, settings.DatabaseUserDataXmlMappings)))
                    {
                        doRefresh = true;
                    }
                }
                catch
                {
                    doRefresh = true;
                }
            }

            if (doRefresh) this.SetupAsync();
		}
コード例 #36
0
		virtual public void DefaultSettingsChanged(DefaultSettings settings) {}
コード例 #37
0
		private void PopulateComboBox(DefaultSettings settings)
		{
			this.cboxDbTarget.Items.Clear();

			// Populate the ComboBox
			dbRoot myMeta = new dbRoot();
			myMeta.DbTargetMappingFileName	= settings.DbTargetMappingFile;
			myMeta.DbTarget					= settings.DbTarget;

			string[] targets = myMeta.GetDbTargetMappings(settings.DbDriver);

			if(null != targets)
			{
				for(int i = 0; i < targets.Length; i++)
				{
					this.cboxDbTarget.Items.Add(targets[i]);
				}

				this.cboxDbTarget.SelectedItem = myMeta.DbTarget;

				if(this.cboxDbTarget.SelectedIndex == -1)
				{
					// The default doesn't exist, set it to the first in the list
					this.cboxDbTarget.SelectedIndex = 0;
				}
			}
		}
コード例 #38
0
		public void DefaultSettingsChanged(DefaultSettings settings)
		{
			PromptForSave(false);

			this.dbDriver = settings.DbDriver;

			PopulateComboBox(settings);
			PopulateGrid(this.dbDriver);

			MarkAsDirty(false);
		}
コード例 #39
0
        public MyGenerationMDI(string startupPath, params string[] args)
        {
            this.startupPath = startupPath;

            // if the command line arguments contain a new location for the config file, set it.
            List<string> argsList = new List<string>();
            string lastArg = null;
            foreach (string arg in args)
            {
                if (lastArg == "-configfile")
                {
                    string file = Zeus.FileTools.MakeAbsolute(arg, FileTools.AssemblyPath);
                    if (File.Exists(file))
                    {
                        DefaultSettings.SettingsFileName = file;
                    }
                }
                else
                {
                    argsList.Add(arg);
                }
                lastArg = arg;
            }

            settings = DefaultSettings.Instance;

            //Any files that were locked when the TemplateLibrary downloaded and tried to replace them will be replaced now.
            ProcessReplacementFiles();

            InitializeComponent();

            startupFiles = argsList.ToArray();

            EditorManager.AddNewDocumentMenuItems(newFileDynamicToolStripMenuItem_Click,
                newToolStripMenuItem.DropDownItems,
                toolStripDropDownButtonNew.DropDownItems);

            ContentManager.AddNewContentMenuItems(openContentDynamicToolStripMenuItem_Click, this.pluginsToolStripMenuItem,
                this.toolStrip1);

            PluginManager.AddHelpMenuItems(chmToolStripMenuItem_Click, this.helpToolStripMenuItem, 2);

            this.RefreshRecentFiles();
        }
コード例 #40
0
		public void DefaultSettingsChanged(DefaultSettings settings)
		{
			//PromptForSave(false);
			//this.Clear();
        }
コード例 #41
0
        private void StartVersionCheck(DefaultSettings settings)
        {
            if (settings.CheckForNewBuild)
            {
                versionInfo = new VersionInfo();

                try
                {
                    asyncResult = versionInfo.BeginGetVersion(null, null);
                }
                catch
                {
                    webServiceError = true;
                }
            }
        }
コード例 #42
0
        private void FinishVersionCheck(DefaultSettings settings)
        {
            if (settings.CheckForNewBuild)
            {
                if (webServiceError == false)
                {
                    try
                    {
                        string newVersion = versionInfo.EndGetVersion(asyncResult);

                        Assembly asmblyMyGen = System.Reflection.Assembly.GetAssembly(typeof(NewAbout));
                        string thisVersion = asmblyMyGen.GetName().Version.ToString();

                        System.Version newVersionObject = new System.Version(newVersion);

                        if (newVersionObject > asmblyMyGen.GetName().Version)
                        {
                            this.Update();

                            UpdatesForm form = new UpdatesForm();
                            form.NewVersion = newVersion;
                            form.ThisVersion = thisVersion;
                            form.UpgradeText = versionInfo.GetUpdateText();
                            DialogResult result = form.ShowDialog();

                            if (result == DialogResult.OK)
                            {
                                DownloadLatestVersion();
                            }
                        }
                    }
                    catch { };
                }
            }

            this.asyncResult = null;
            this.versionInfo = null;
        }
コード例 #43
0
 public static void Refresh()
 {
     instance = null;
 }