示例#1
0
        private void BuildButtons(StartLight light)
        {
            foreach (Statement statement in light.ScriptsList)
            {
                Button tempBtn  = new Button();
                Button tempBtn2 = new Button();
                tempBtn.Content = statement.Label;
                tempBtn.Name    = "exec_" + statement.Identity;
                tempBtn.ToolTip = statement.Description;
                switch (statement.OperationType.ToLowerInvariant())
                {
                case "ssh":
                    if (statement.ServerName.ToSafeString() != "")
                    {
                        tempBtn.Click += new RoutedEventHandler((e, o) =>
                                                                Behaviours.ExecScriptWithLog()(
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])],
                                                                    txtTailPars.Text,
                                                                    execBar,
                                                                    txtBox,
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].ServerName,
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].ServerUser,
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].ServerPassword));
                    }
                    else
                    {
                        tempBtn.Click += new RoutedEventHandler((e, o) =>
                                                                Behaviours.ExecScriptWithLog()(
                                                                    light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])],
                                                                    txtTailPars.Text,
                                                                    execBar,
                                                                    txtBox,
                                                                    light.ServerName,
                                                                    light.ServerUser,
                                                                    light.ServerPassword));
                    }
                    break;

                case "localosstatement":
                    tempBtn.Click += new RoutedEventHandler((e, o) =>
                                                            Behaviours.StartProcess()(statement, txtTailPars.Text, txtBox, this.execBar));
                    break;

                default:
                    break;
                }

                btnMain.Children.Add(tempBtn);

                tempBtn2.Content = "script";
                tempBtn2.Name    = "script_" + statement.Identity;
                tempBtn2.Click  += new RoutedEventHandler(
                    (e, o) => MessageBox.Show(light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].ScriptToLaunch + " " + light.ScriptsList[Convert.ToInt16(tempBtn.Name.Split('_')[1])].Parameters + txtTailPars.Text)

                    );
                btnMainScripts.Children.Add(tempBtn2);
            }
        }
示例#2
0
        private void btnGenTemplate_Click(object sender, RoutedEventArgs e)
        {
            StartLight light = new StartLight(new List <Statement> {
                new Statement
                {
                    Identity       = "0",
                    Description    = "descrizione primo comando",
                    Label          = "label primo comando",
                    ScriptToLaunch = "path completo dello script o primo comando",
                    ServerName     = "clio",
                    ServerUser     = "******",
                    ServerPassword = "******"
                },
                new Statement
                {
                    Identity       = "1",
                    Description    = "descrizione secondo comando",
                    Label          = "label secondo comando",
                    ScriptToLaunch = "path completo dello script o secondo comando",
                    ServerName     = "clio",
                    ServerUser     = "******",
                    ServerPassword = "******"
                },
                new Statement
                {
                    Identity       = "2",
                    Description    = "descrizione terzo comando",
                    Label          = "label terzo comando",
                    ScriptToLaunch = "path completo dello script o terzo comando",
                    ServerName     = "clio",
                    ServerUser     = "******",
                    ServerPassword = "******"
                }
            });

            light.ServerName     = "server Name";
            light.ServerPassword = "******";
            light.ServerUser     = "******";

            String JsonTemplate = JsonConvert.SerializeObject(light);

            var myWindow = new ShowJsonTemplate();

            myWindow.txtArea.Text = JsonTemplate;
            myWindow.Show();

            /*WebClient client = new WebClient();
             * Stream stream = client.OpenRead("http://openlibrary.org/api/get?key=/b/OL1001932M");
             * StreamReader reader = new StreamReader(stream);
             *
             * List<dynamic> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(reader.Read().ToString());*/
        }
示例#3
0
        public MainWindow()
        {
            InitializeComponent();

            if (File.Exists("config.json"))
            {
                File.Decrypt("config.json");
                StartLight light = new StartLight(new List <Statement> {
                });
                light = JsonConvert.DeserializeObject <StartLight>(File.ReadAllText("config.json"));
                //File.Encrypt("config.json");
                BuildButtons(light);
            }
        }
 // Use this for initialization
 void Start()
 {
     GetNeighbors();
     startLight = (StartLight)UnityEngine.Random.Range(0, 2);
     StartCoroutine(StartLightTimer());
 }