Esempio n. 1
0
        private void run_upload()
        {
            if (textSystemName.Text == "")
            {
                return;
            }
            //手動同步
            //收集所有 gridview 的內容
            //組合成 json 加密後,上傳到伺服器
            Dictionary <string, object> output = new Dictionary <string, object>();

            setStatusBar("同步開始...", 0);
            logError("同步開始...");
            output["NAME"] = textSystemName.Text;
            setStatusBar("同步開始...取得系統資訊", 20);
            cSystem.init(this);
            cHdd.init(this);
            cEvents.init(this);
            cFirewall.init(this);
            cRunningProgram.init(this);
            cSystemService.init(this);
            cSchedule.init(this);
            cIis.init(this);
            cInstalledSoftware.init(this);
            Thread.Sleep(3000);
            while (
                cSystem.is_running == true ||
                cHdd.is_running == true ||
                cEvents.is_running == true ||
                cRunningProgram.is_running == true ||
                cSystemService.is_running == true ||
                cFirewall.is_running == true ||
                cSchedule.is_running == true ||
                cIis.is_running == true ||
                cInstalledSoftware.is_running == true
                )
            {
                Thread.Sleep(1000);
                setStatusBar("等待資料完成...", 0);
            }

            //setStatusBar("同步開始...取得硬碟資訊", 40);
            try
            {
                //output["SYSTEM_INFO"] = my.gridViewToDataTable(system_grid);
                output["SYSTEM_INFO"] = cSystem.dt;
            }
            catch { }
            try
            {
                //output["SYSTEM_SERVICE_INFO"] = my.gridViewToDataTable(system_service_grid);
                output["SYSTEM_SERVICE_INFO"] = cSystemService.dt;
            }
            catch { }
            try
            {
                //output["HDD_INFO"] = my.gridViewToDataTable(hdd_grid);
                output["HDD_INFO"] = cHdd.dt;
            }
            catch { }
            try
            {
                //output["FIREWALL_INFO"] = my.gridViewToDataTable(firewall_grid);
                output["FIREWALL_INFO"] = cFirewall.dt;
            }
            catch { }
            try
            {
                //output["EVENTS_INFO"] = my.gridViewToDataTable(events_grid);
                output["EVENTS_INFO"] = cEvents.dt;
            }
            catch { }
            try
            {
                //output["TASK_INFO"] = my.gridViewToDataTable(running_program_grid);
                output["TASK_INFO"] = cRunningProgram.dt;
            }
            catch { }
            try
            {
                //output["SCHEDULE_INFO"] = my.gridViewToDataTable(schedule_grid);
                output["SCHEDULE_INFO"] = cSchedule.dt;
            }
            catch { }
            try
            {
                //output["IIS_INFO"] = my.gridViewToDataTable(iis_grid);
                output["IIS_INFO"] = cIis.dt;
            }
            catch { }

            try
            {
                //output["IIS_INFO"] = my.gridViewToDataTable(iis_grid);
                output["INSTALLED_SOFTWARE_INFO"] = cInstalledSoftware.dt;
            }
            catch { }

            //logError(my.json_encode_formated(output));
            string URL = my.getSystemKey("REPORT_URL") + "?mode=updateStatus";
            ConcurrentDictionary <string, string> o = new ConcurrentDictionary <string, string>();

            o["data"] = my.base64_encode(my.Zip(my.json_encode(output)));
            output    = null;
            try
            {
                string data = my.b2s(my.file_get_contents_post(URL, o));
                if (data != "")
                {
                    logError(data);
                }
            }
            catch (Exception ex)
            {
                logError(ex.Message + "\r\n" + ex.StackTrace);
            }
            o = null;
        }