Exemple #1
0
        public void GetServersFromFile(ProgressBar pgb)
        {
            int max = 0;

            if (pgb != null)
            {
                max = pgb.Maximum;
            }

            servers = new List <Server>();
            servers.Add(new Server("All", "All"));
            TXTReader txtReader            = TXTReader.CreateInstance();
            Dictionary <string, int> pairs = txtReader.GetServerPortPair();

            if (pgb != null)
            {
                pgb.Invoke((MethodInvoker) delegate { pgb.Maximum = pairs.Count; });
            }
            foreach (string server in pairs.Keys)
            {
                servers.Add(new Server(txtReader.GetPortByServerName(server).ToString(), server));
                if (pgb != null)
                {
                    pgb.Invoke((MethodInvoker) delegate { pgb.PerformStep(); });
                }
            }
            updateDate = DateTime.Now;
            OnUpdated(EventArgs.Empty);

            if (pgb != null)
            {
                pgb.Invoke((MethodInvoker) delegate { pgb.Maximum = max; });
            }
        }
Exemple #2
0
        public TravelServer GetTravelServerFromXLSAndChangeProgressBar(string machineName, ProgressBar pgb)
        {
            int max = 0;

            if (pgb != null)
            {
                max = pgb.Maximum;
            }
            int i = 2;

            System.Array myvalues;
            TravelServer travelServer = new TravelServer(machineName);

            travelServer.Databases = new List <DatabaseItem>();
            TXTReader txtReader = TXTReader.CreateInstance();

            txtReader.GetServerPortPair();

            Microsoft.Office.Interop.Excel.Application ExcelObj = null;
            ExcelObj = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(file, Type.Missing, Type.Missing,
                                                                                          Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                                                          Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            Microsoft.Office.Interop.Excel.Sheets    sheets    = theWorkbook.Worksheets;
            Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets.get_Item(1);

            Microsoft.Office.Interop.Excel.Range range = worksheet.get_Range("A" + i.ToString(), "B" + i.ToString());
            if (pgb != null)
            {
                pgb.Invoke((MethodInvoker) delegate { pgb.Maximum = worksheet.Rows.Row; });
            }
            while (!range.Text.Equals(""))
            {
                myvalues = (System.Array)range.Cells.Value2;
                if (machineName.Equals("All") || myvalues.GetValue(1, 1).ToString().Equals(machineName))
                {
                    DatabaseItem databaseItem = new DatabaseItem(myvalues.GetValue(1, 2).ToString(),
                                                                 myvalues.GetValue(1, 2).ToString(), "PPE database", "CHC-APPWG01.idx.expedmz.com," +
                                                                 txtReader.GetPortByServerName(myvalues.GetValue(1, 1).ToString()).Value.ToString(),
                                                                 "Update8!", "expdev");
                    travelServer.Databases.Add(databaseItem);
                }
                i++;
                range = worksheet.get_Range("A" + i.ToString(), "B" + i.ToString());
                if (pgb != null)
                {
                    pgb.Invoke((MethodInvoker) delegate
                    {
                        pgb.PerformStep();
                        GlobalOperator.SetProgressBarText(pgb, "Reloading databases of " + machineName);
                    });
                }
            }

            theWorkbook.Close(Microsoft.Office.Interop.Excel.XlSaveAction.xlDoNotSaveChanges, Type.Missing, Type.Missing);
            ExcelObj.Quit();
            if (pgb != null)
            {
                pgb.Invoke((MethodInvoker) delegate { pgb.Maximum = max; });
            }
            return(travelServer);
        }