Beispiel #1
0
        private void InitMetadata()
        {
            GinMetaData metadata    = GinMetaData.GetInstance();
            string      pluginsPath = Path.Combine(_ginRoot, "Plugins");

            metadata.Plugin(pluginsPath);
            GinSerializer.IncludeTypes(metadata.IncludedTypes);
        }
Beispiel #2
0
        private void InitMetadata()
        {
            string ginPath = ConfigurationManager.AppSettings["ROOT_PATH"];

            if (!Directory.Exists(ginPath))
            {
                Directory.CreateDirectory(ginPath);
            }
            string rootPath   = GetRootPath();
            string pluginPath = Path.Combine(rootPath, @"Plugins");

            _metaData = GinMetaData.GetInstance();
            _metaData.Plugin(pluginPath);
            GinSerializer.IncludeTypes(_metaData.IncludedTypes);
        }
Beispiel #3
0
        private CommandTreeNode IntermediateWithSequence(TreeNodeData currentNodeData)
        {
            CommandTreeNode sequenceCommandsTreeNode = null;
            GinMetaData     metaData = GinMetaData.GetInstance();
            ExternalCommand sequence = metaData.Commands.Where(c => c.Instance is CommandSequence).FirstOrDefault();

            if (sequence != null)
            {
                IEnumerable <CommandTreeNode> removedNodes = currentNodeData.Node.Childs;
                currentNodeData.Node.ClearChilds();
                CommandTreeNode sequenceTreeNode = AppendCommandAfter(currentNodeData.Node, sequence.Instance, null);
                sequenceCommandsTreeNode = sequenceTreeNode.Childs.FirstOrDefault();
                foreach (CommandTreeNode node in removedNodes)
                {
                    AppendCommandAfter(sequenceCommandsTreeNode, node.Data.Command, null);
                }
            }
            return(sequenceCommandsTreeNode);
        }
Beispiel #4
0
        private void InitMetadata()
        {
            _executionContext.Log.AddLogInformation("Вход в InitMetadata()");
            LogMessage("Загружаются метаданные...");
            string exePath    = GetExePath();
            string pluginPath = Path.Combine(exePath, @"Plugins");

            _executionContext.Log.AddLogInformation("exePath = <" + exePath + ">; pluginPath = <" + pluginPath + ">;");
            _executionContext.Log.AddLogInformation("Запрашиваем экземпляр метаданных");
            GinMetaData metaData = GinMetaData.GetInstance();

            _executionContext.Log.AddLogInformation("Получили экземпляр метаданных");
            _executionContext.Log.AddLogInformation("Команд - " + (metaData.Commands != null ? metaData.Commands.Count.ToString() : "0"));
            _executionContext.Log.AddLogInformation("Типов - " + (metaData.IncludedTypes != null ? metaData.IncludedTypes.Length.ToString() : "0"));
            _executionContext.Log.AddLogInformation("Загружаем плагины из папки <" + pluginPath + ">");
            metaData.Plugin(pluginPath);
            _executionContext.Log.AddLogInformation("Команд - " + (metaData.Commands != null ? metaData.Commands.Count.ToString() : "0"));
            _executionContext.Log.AddLogInformation("Типов - " + (metaData.IncludedTypes != null ? metaData.IncludedTypes.Length.ToString() : "0"));
            GinSerializer.IncludeTypes(metaData.IncludedTypes);
            _executionContext.Log.AddLogInformation("Загрузили типы в GinSerializer");
            LogMessage("Метаданные загружены");
            _executionContext.Log.AddLogInformation("Выход из InitMetadata()");
        }
Beispiel #5
0
        private void _tree_DragDrop(object sender, DragEventArgs e)
        {
            bool needRebuild = false;

            if (e.Data.GetDataPresent(typeof(ExternalCommand)))
            {
                ExternalCommand command = (ExternalCommand)e.Data.GetData(typeof(ExternalCommand));

                if (e.Effect == DragDropEffects.Move)
                {
                    if (_nodeWhereToDrop != null)
                    {
                        Command newInstance = command.Clone().Instance;
                        InsertCommandIntoTree((TreeNodeData)_nodeWhereToDrop.Tag, newInstance);
                        needRebuild = true;
                    }
                }
            }
            if (e.Data.GetDataPresent(typeof(TreeNodeData)))
            {
                TreeNodeData data = (TreeNodeData)e.Data.GetData(typeof(TreeNodeData));

                if (e.Effect == DragDropEffects.Move || e.Effect == DragDropEffects.Copy)
                {
                    if (_nodeWhereToDrop != null)
                    {
                        Command cmd = data.Command;
                        if (e.Effect == DragDropEffects.Copy)
                        {
                            cmd = data.Command.Copy();
                        }
                        ExternalCommand command         = new ExternalCommand(cmd);
                        TreeNodeData    dataWhereToDrop = (TreeNodeData)_nodeWhereToDrop.Tag;
                        if (data.Node.HasNested(dataWhereToDrop.Node))
                        {
                            return;
                        }
                        bool commandMoved = InsertCommandIntoTree(dataWhereToDrop, command.Instance);
                        needRebuild = commandMoved;
                        if (commandMoved && e.Effect == DragDropEffects.Move)
                        {
                            data.Node.Remove();
                        }
                    }
                }
            }
            if (e.Data.GetDataPresent("FileDrop"))
            {
                if (e.Effect == DragDropEffects.Move)
                {
                    if (_nodeWhereToDrop != null)
                    {
                        string[]        fileNames          = (string[])e.Data.GetData("FileDrop");
                        GinMetaData     metadata           = GinMetaData.GetInstance();
                        bool            applyToAllCommands = false;
                        ExternalCommand selectedCommand    = null;
                        int             lastIndex          = -1;
                        for (int i = 0; i < fileNames.Length; i++)
                        {
                            string            fileName = fileNames[i];
                            ExternalCommand[] commands = metadata.GetAssumedCommands(fileName);
                            if (commands.Length == 0)
                            {
                                return;
                            }
                            if (commands.Length == 1)
                            {
                                InsertCommandIntoTree((TreeNodeData)_nodeWhereToDrop.Tag, commands[0].Instance);
                                needRebuild = true;
                                return;
                            }
                            if (commands.Length > 1)
                            {
                                ChooseDroppedCommandForm form = new ChooseDroppedCommandForm();
                                form.InitDroppedCommands(commands);
                                if (form.ShowDialog() == DialogResult.OK)
                                {
                                    InsertCommandIntoTree((TreeNodeData)_nodeWhereToDrop.Tag, form.SelectedExternalCommand.Instance);
                                    needRebuild        = true;
                                    applyToAllCommands = form.ApplyToAllCommands;
                                    if (applyToAllCommands)
                                    {
                                        selectedCommand = form.SelectedExternalCommand;
                                        lastIndex       = i;
                                        break;
                                    }
                                }
                            }
                        }
                        if (applyToAllCommands)
                        {
                            for (int i = lastIndex + 1; i < fileNames.Length; i++)
                            {
                                string fileName = fileNames[i];
                                InsertCommandIntoTree((TreeNodeData)_nodeWhereToDrop.Tag, selectedCommand.Instance);
                                needRebuild = true;
                            }
                        }
                    }
                }
            }
            if (needRebuild)
            {
                ((TreeNodeData)_rootNode.Nodes[0].Tag).Node.Rebuild(true);
            }
        }
Beispiel #6
0
 private void InitMetadata()
 {
     string ginPath = ConfigurationManager.AppSettings["ROOT_PATH"];
     if (!Directory.Exists(ginPath))
     {
         Directory.CreateDirectory(ginPath);
     }
     string rootPath = GetRootPath();
     string pluginPath = Path.Combine(rootPath, @"Plugins");
     _metaData = GinMetaData.GetInstance();
     _metaData.Plugin(pluginPath);
     GinSerializer.IncludeTypes(_metaData.IncludedTypes);
 }