Ejemplo n.º 1
0
        static void PromptParametersAndDeploy()
        {
            try
            {
                ConsoleUtils.WriteHeader("MarketplaceDeployConsole started");
                Console.WriteLine("Select a plugin to deploy");

                SavedDeployments SavedDeployments = Properties.Settings.Default.SavedDeployments ?? new SavedDeployments();

                // Clear out invalid paths
                SavedDeployments.PluginParams.RemoveAll(Params => !Directory.Exists(Params.PluginPath));

                Properties.Settings.Default.SavedDeployments = SavedDeployments;
                Properties.Settings.Default.Save();

                // Build menu

                EasyConsole.Menu Menu = new EasyConsole.Menu();

                foreach (DeployParams Params in SavedDeployments.PluginParams)
                {
                    string PluginName  = DeployUtils.FindPluginName(Params.PluginPath);
                    string ProjectName = DeployUtils.FindHostProjectName(Params.PluginPath);
                    Menu.Add(ProjectName + "/" + PluginName, () =>
                    {
                        // Selected existing plugin
                        DeployParams UseParams = Params;

                        ConsoleUtils.WriteHeader("Deploying " + DeployUtils.FindPluginName(Params.PluginPath));

                        Console.WriteLine("Last used parameters were");
                        Console.WriteLine();
                        Console.WriteLine(UseParams.PrintParameters());
                        Console.WriteLine();

                        bool Reuse = ConsoleUtils.PromptBool("Use these again?", true);

                        if (!Reuse)
                        {
                            UseParams = PromptParams(UseParams);
                        }

                        SaveParams(Params);
                        Deploy.RunDeployment(Params);
                    });
                }

                Menu.Add("New", () =>
                {
                    string SelectDirectoryPrompt = "Select plugin directory within its example/host project";
                    Console.WriteLine(SelectDirectoryPrompt);
                    FolderBrowserDialog Dialog = new FolderBrowserDialog();
                    Dialog.Description         = SelectDirectoryPrompt;
                    Dialog.SelectedPath        = Properties.Settings.Default.PluginPath;

                    if (Dialog.ShowDialog() == DialogResult.OK)
                    {
                        DeployParams Params = new DeployParams();
                        Params.PluginPath   = Dialog.SelectedPath;
                        Properties.Settings.Default.PluginPath = Dialog.SelectedPath;
                        Properties.Settings.Default.Save();

                        ConsoleUtils.WriteHeader("Deploying " + DeployUtils.FindPluginName(Params.PluginPath));

                        Params = PromptParams(Params);

                        SaveParams(Params);
                        Deploy.RunDeployment(Params);
                    }
                });

                Menu.Display();
            }
            catch (Exception Ex)
            {
                ConsoleUtils.WriteHeader("Encountered exception");

                Console.WriteLine(Ex.GetType());
                Console.WriteLine(Ex.Message);
                Console.WriteLine(Ex.StackTrace);
                Console.WriteLine(Ex.ToString());
            }
        }
Ejemplo n.º 2
0
            public bool Show()
            {
                bool Result = false;
                int  tNum   = -1;


                // Instance of widgets
                // Label lblInfo = new Label();
                // Button btnConnect = new Button();
                // Button btnRefresh = new Button();
                // ListViewGroup listViewGroup = new ListViewGroup("Consoles", HorizontalAlignment.Left);
                // ListView listView = new ListView();
                // Form formList = new Form();

                // Create our button connect
                // btnConnect.Location = new Point(12, 254);
                // btnConnect.Name = "btnConnect";
                // btnConnect.Size = new Size(198, 23);
                // btnConnect.TabIndex = 1;
                // btnConnect.Text = strTraduction("btnConnect");
                // btnConnect.UseVisualStyleBackColor = true;
                // btnConnect.Enabled = false;
                // btnConnect.Click += (sender, e) =>
                // {
                //     if(tNum > -1)
                //     {
                //         if (Api.ConnectTarget(data[tNum].Ip))
                //         {
                //             Api.setTargetName(data[tNum].Name);
                //             Result = true;
                //         }
                //         else Result = false;
                //         formList.Close();
                //     }
                //     else
                //         MessageBox.Show(strTraduction("errorSelect"), strTraduction("errorSelectTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                // };

                // Create our button refresh
                // btnRefresh.Location = new Point(216, 254);
                // btnRefresh.Name = "btnRefresh";
                // btnRefresh.Size = new Size(86, 23);
                // btnRefresh.TabIndex = 1;
                // btnRefresh.Text = strTraduction("btnRefresh");
                // btnRefresh.UseVisualStyleBackColor = true;
                // btnRefresh.Click += (sender, e) =>
                // {
                //     tNum = -1;
                //     listView.Clear();
                //     lblInfo.Text = strTraduction("selectGrid");
                //     btnConnect.Enabled = false;
                //     data = Api.CCAPI.GetConsoleList();
                //     int sizeD = data.Count();
                //     for (int i = 0; i < sizeD; i++)
                //     {
                //         ListViewItem item = new ListViewItem(" " + data[i].Name + " - " + data[i].Ip);
                //         item.ImageIndex = 0;
                //         listView.Items.Add(item);
                //     }
                // };

                // Create our list view
                // listView.Font = new Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                // listViewGroup.Header = "Consoles";
                // listViewGroup.Name = "consoleGroup";
                // listView.Groups.AddRange(new ListViewGroup[] {listViewGroup});
                // listView.HideSelection = false;
                // listView.Location = new Point(12, 12);
                // listView.MultiSelect = false;
                // listView.Name = "ConsoleList";
                // listView.ShowGroups = false;
                // listView.Size = new Size(290, 215);
                // listView.TabIndex = 0;
                // listView.UseCompatibleStateImageBehavior = false;
                // listView.View = View.List;
                // listView.ItemSelectionChanged += (sender, e) =>
                // {
                //     tNum = e.ItemIndex;
                //     btnConnect.Enabled = true;
                //     string Name, Ip = "?";
                //     if (data[tNum].Name.Length > 18)
                //         Name = data[tNum].Name.Substring(0, 17) + "...";
                //     else Name = data[tNum].Name;
                //     if (data[tNum].Ip.Length > 16)
                //         Ip = data[tNum].Name.Substring(0, 16) + "...";
                //     else Ip = data[tNum].Ip;
                //     lblInfo.Text = strTraduction("selectedLbl") + " " + Name + " / " + Ip;
                // };

                // Create our label
                // lblInfo.AutoSize = true;
                // lblInfo.Location = new Point(12, 234);
                // lblInfo.Name = "lblInfo";
                // lblInfo.Size = new Size(158, 13);
                // lblInfo.TabIndex = 3;
                // lblInfo.Text = strTraduction("selectGrid");

                // Create our form
                // formList.MinimizeBox = false;
                // formList.MaximizeBox = false;
                // formList.ClientSize = new Size(314, 285);
                // formList.AutoScaleDimensions = new SizeF(6F, 13F);
                // formList.AutoScaleMode = AutoScaleMode.Font;
                // formList.FormBorderStyle = FormBorderStyle.FixedSingle;
                // formList.StartPosition = FormStartPosition.CenterScreen;
                // formList.Text = strTraduction("formTitle");
                // formList.Controls.Add(listView);
                // formList.Controls.Add(lblInfo);
                // formList.Controls.Add(btnConnect);
                // formList.Controls.Add(btnRefresh);

                // Start to update our list
                // ImageList imgL = new ImageList();
                // imgL.Images.Add(Resources.ps3);
                // listView.SmallImageList = imgL;
                // int sizeData = data.Count();

                // for (int i = 0; i < sizeData; i++)
                // {
                //     ListViewItem item = new ListViewItem(" " + data[i].Name + " - " + data[i].Ip);
                //     item.ImageIndex = 0;
                //     listView.Items.Add(item);
                // }

                data = Api.CCAPI.GetConsoleList();

                var menu = new EasyConsole.Menu();

                data.ForEach(
                    console => menu.Add(" " + console.Name + " - " + console.Ip, () =>
                {
                    if (Api.ConnectTarget(console.Ip))
                    {
                        Api.setTargetName(console.Name);
                        Result = true;
                    }
                })
                    );
                menu.Display();

                // If there are more than 0 targets we show the form
                // Else we inform the user to create a console.
                // if (sizeData > 0)
                //     formList.ShowDialog();
                // else
                // {
                //     Result = false;
                //     formList.Close();
                //     throw new Exception(strTraduction("noConsole"));
                //     //MessageBox.Show(), strTraduction("noConsoleTitle"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                // }

                return(Result);
            }