private static void ExecuteTasks(string sql)
        {
            MultiTaskingRunner runner = new MultiTaskingRunner();

            List<XElement> rsps = new List<XElement>();

            foreach (string uid in Program.MainPanel.SelectedSource)
            {
                string name = Program.GlobalSchoolCache[uid].Title;
                ConnectionHelper ch = ConnectionHelper.GetConnection(uid);
                runner.AddTask(string.Format("{0}({1})", name, uid), (x) =>
                {
                    XElement req = new XElement("Request",
                        new XElement("SQL", sql));

                    Envelope rsp = ch.CallService("UDTService.DML.Query", new Envelope(new XStringHolder(req)));

                    lock (rsps)
                    {
                        XElement r = XElement.Parse(rsp.BodyContent.XmlString);
                        r.SetAttributeValue("UID", ((object[])x)[0].ToString());
                        rsps.Add(r);
                    }
                }, new object[] { uid, ch }, new CancellationTokenSource());
            }

            runner.ExecuteTasks();

            ExportToExcel(rsps);
        }
示例#2
0
        private void btnCheckUpdate_Click(object sender, EventArgs e)
        {
            IEnumerable<UDMGridRow> udms = GetSelectedUDM();

            MultiTaskingRunner runner = new MultiTaskingRunner();

            foreach (UDMGridRow udm in udms)
            {
                runner.AddTask(udm.Name, x =>
                {
                    UDMGridRow s = x as UDMGridRow;
                    CheckUDMNewVersion(s);
                }, udm, new System.Threading.CancellationTokenSource());
            }

            runner.AllTaskCompleted += delegate
            {
            };

            runner.ExecuteTasks();
        }
示例#3
0
        private void Search(Action<List<string>, string, object> patternMatcher)
        {
            MultiTaskingRunner runner = new MultiTaskingRunner();
            List<string> matchs = new List<string>();
            string pattern = txtPattern.Text;

            foreach (string uid in Program.MainPanel.SelectedSource)
            {
                string name = Program.GlobalSchoolCache[uid].Title;
                ConnectionHelper ch = ConnectionHelper.GetConnection(uid);
                runner.AddTask(string.Format("{0}({1})", name, uid), (x) =>
                {
                    patternMatcher(matchs, pattern, x);
                }, new object[] { uid, ch }, new CancellationTokenSource());
            }

            runner.ExecuteTasks();
            Program.MainPanel.AddToTemp(matchs);
            DialogResult = DialogResult.OK;
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (dgvModules.SelectedRows.Count <= 0)
                return;

            DialogResult dr = MessageBox.Show("確定要刪除選擇的模組?", "ischool", MessageBoxButtons.YesNo);
            if (dr == System.Windows.Forms.DialogResult.No)
                return;

            MultiTaskingRunner runner = new MultiTaskingRunner();
            ModuleRow mr = dgvModules.SelectedRows[0].DataBoundItem as ModuleRow;
            string modUrl = mr.Url;

            foreach (ConnectionHelper conn in Connections)
            {
                string name = Program.GlobalSchoolCache[conn.UID].Title;
                runner.AddTask(string.Format("{0}({1})", name, conn.UID), (x) =>
                {
                    object[] obj = x as object[];
                    ConnectionHelper c = obj[0] as ConnectionHelper;
                    string xurl = (string)obj[1];
                    RemoveDesktopModule(c, xurl);
                }, new object[] { conn, modUrl }, new System.Threading.CancellationTokenSource());
            }
            runner.ExecuteTasks();

            try
            {
                InitConnections();
                LoadAllModuleConfig();
                GroupByToDataGrid();
            }
            catch { Close(); } //爆了就關吧。
        }
        private void LoadAllModuleConfig()
        {
            MultiTaskingRunner runner = new MultiTaskingRunner();

            ModuleConfigs = new Dictionary<string, ModulesOfSchool>();
            foreach (ConnectionHelper conn in Connections)
            {
                string name = Program.GlobalSchoolCache[conn.UID].Title;
                runner.AddTask(string.Format("{0}({1})", name, conn.UID), (x) =>
                {
                    LoadModuleConfig(x as ConnectionHelper);
                }, conn, new System.Threading.CancellationTokenSource());
            }
            runner.ExecuteTasks();
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            MultiTaskingRunner runner = new MultiTaskingRunner();

            InputBox box = new InputBox();
            box.ShowDialog();

            string modUrl = box.InputString;
            foreach (ConnectionHelper conn in Connections)
            {
                string name = Program.GlobalSchoolCache[conn.UID].Title;
                runner.AddTask(string.Format("{0}({1})", name, conn.UID), (x) =>
                {
                    object[] obj = x as object[];
                    ConnectionHelper c = obj[0] as ConnectionHelper;
                    string xurl = (string)obj[1];
                    AddDesktopModule(c, xurl);
                }, new object[] { conn, modUrl }, new System.Threading.CancellationTokenSource());
            }
            runner.ExecuteTasks();

            try
            {
                InitConnections();
                LoadAllModuleConfig();
                GroupByToDataGrid();
            }
            catch { Close(); } //爆了就關吧。
        }