public static Domain OpenDomainFile() { using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "解决方案文件|*.domain|所有文件|*.*"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { IFormatter formatter = new SoapFormatter(); using (Stream stream = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { try { Domain d = (Domain)formatter.Deserialize(stream); if (DomainManager.IsDomainExist(d.DomainGUID)) { d.NewDomainGUID(); } DomainManager.AddDomain(d); return(d); } catch (SerializationException e) { log.Error("反序列化失败: " + openFileDialog.FileName + "不是解决方案文件!", e); MessageBox.Show(openFileDialog.FileName + "不是解决方案文件!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(null); } catch (Exception e) { log.Error("未知错误: " + openFileDialog.FileName, e); MessageBox.Show(openFileDialog.FileName + "出现未知错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(null); } } } catch (System.IO.FileNotFoundException e) { log.Error("打开文件失败: " + openFileDialog.FileName, e); MessageBox.Show("打开文件失败: " + openFileDialog.FileName, "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(null); } } return(null); } }
private void DownloadTasks() { BaseVBAScriptTask bt = null; if (m_WaitingLocalTasks.Count <= m_SingerTransportation) { log.Debug("Start Download..."); List <IRemoteTask> ts = ConnectionManagerClient.TTMFeachTasks(m_SingerTransportation); if (ts != null && ts.Count > 0) { foreach (IRemoteTask t in ts) { bt = t as BaseVBAScriptTask; if (DomainManager.IsDomainNeedUpdated(bt.DomainGUID, bt.TimeStamp)) { Domain d = GetDomainFromServer(bt.DomainGUID); if (d != null) { DomainManager.AddDomain(d); log.Debug("Fetching A Domain for " + t.Name); } else { log.Debug("Weird DomainGUID With No Domian IN SERVER!:" + bt.DomainGUID); } } this.AddTask(t); log.Debug("Fetching one " + t.Name); } } else { log.Debug("No avaible remotetask for downloading..."); } } }