protected override void OnPrimaryKeyChangedComplete(Exception error) { if (error != null) { RTOut.WriteError(error); throw error; } dgvPlugin.Rows.Clear(); List <string> pluginUrls = new List <string>(); foreach (XElement each in Plugin.Elements("Module")) { pluginUrls.Add(each.ElementText("ModuleUrl")); } pluginUrls.Sort(); List <PluginGridRow> rows = new List <PluginGridRow>(); foreach (string each in pluginUrls) { rows.Add(new PluginGridRow(each)); } dgvPlugin.DataSource = new BindingList <PluginGridRow>(rows); }
protected override void OnPrimaryKeyChangedComplete(Exception error) { if (error != null) { RTOut.WriteError(error); throw error; } XElement target = PackagesData.XPathSelectElement("Package[TargetType='Guest' and RefTagID='0']"); tabGuest.Tag = CreateGadgetPackageRecord(target); target = PackagesData.XPathSelectElement("Package[TargetType='Teacher' and RefTagID='0']"); tabTeacher.Tag = CreateGadgetPackageRecord(target); target = PackagesData.XPathSelectElement("Package[TargetType='Student' and RefTagID='0']"); tabStudent.Tag = CreateGadgetPackageRecord(target); target = PackagesData.XPathSelectElement("Package[TargetType='Parent' and RefTagID='0']"); tabParent.Tag = CreateGadgetPackageRecord(target); target = PackagesData.XPathSelectElement("Package[TargetType='Administrator' and RefTagID='0']"); tabAdmin.Tag = CreateGadgetPackageRecord(target); foreach (SuperTabItem item in tabs.Tabs) { item.Visible = !(item.Tag == null); } tabs.RecalcLayout(); PuplateTabData(tabs.SelectedTab); }
private void btnDelete_Click(object sender, EventArgs e) { try { DialogResult dr = MessageBox.Show("確定要刪除選擇的 UDS?", "Campus", MessageBoxButtons.YesNo); if (dr == DialogResult.No) { return; } XElement req = new XElement("Request"); foreach (DataGridViewRow row in dgvUDS.SelectedRows) { string name = row.Cells["chName"].Value + ""; req.Add(new XElement("ContractName", name)); } if (req.Elements().Count() > 0) { ConnectionHelper conn = ConnectionHelper.GetConnection(PrimaryKey); conn.CallService("UDSManagerService.DeleteContracts", new Envelope(new XHelper(req))); OnPrimaryKeyChanged(EventArgs.Empty); MessageBox.Show("UDS Contract 已刪除!"); } } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); } }
protected override void OnPrimaryKeyChangedComplete(Exception error) { if (error != null) { RTOut.WriteError(error); throw error; } dgvUDS.Rows.Clear(); List <string> udsNames = new List <string>(); foreach (XElement each in UDS.Elements("Contract")) { udsNames.Add(each.AttributeText("Name")); } udsNames.Sort(); foreach (string each in udsNames) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgvUDS, each); dgvUDS.Rows.Add(row); } }
private void btnInstall_Click(object sender, EventArgs e) { try { InputBox box = new InputBox(); if (box.ShowDialog() != DialogResult.OK) { return; } string url = box.InputString; XElement req = new XElement("Request", new XElement("Module", new XElement("Field", new XElement("ModuleUrl", url), new XElement("Type", "FiscaAEModule"), new XElement("Memo", "集中安裝"), new XElement("Config", new XElement("Content", new XElement("VersionOption", "Stable")))))); ConnectionHelper conn = ConnectionHelper.GetConnection(PrimaryKey); conn.CallService("InsertDesktopModule", new Envelope(new XStringHolder(req))); MessageBox.Show("安裝完成。"); OnPrimaryKeyChanged(EventArgs.Empty); } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (dgvPlugin.SelectedRows.Count <= 0) { return; } DialogResult dr = MessageBox.Show("確定要刪除選擇的項目?", "Campus", MessageBoxButtons.YesNo); if (dr == DialogResult.No) { return; } PluginGridRow pg = dgvPlugin.SelectedRows[0].DataBoundItem as PluginGridRow; XElement req = new XElement("Request", new XElement("Module", new XElement("Condition", new XElement("ModuleUrl", pg.Url)))); ConnectionHelper conn = ConnectionHelper.GetConnection(PrimaryKey); conn.CallService("DeleteDesktopModule", new Envelope(new XHelper(req))); OnPrimaryKeyChanged(EventArgs.Empty); MessageBox.Show("項目已刪除!"); } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); } }
private void btnInstall_Click(object sender, EventArgs e) { try { InputBox box = new InputBox(); if (box.ShowDialog() != DialogResult.OK) { return; } string url = box.InputString; XElement req = new XElement("Request", new XElement("URL", url)); ConnectionHelper conn = ConnectionHelper.GetConnection(PrimaryKey); conn.CallService("UDMService.ForceRegistry", new Envelope(new XStringHolder(req))); MessageBox.Show("註冊 UDM 完成。"); OnPrimaryKeyChanged(EventArgs.Empty); } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); } }
private void buttonItem1_Click(object sender, EventArgs e) { if (dgvUDM.SelectedRows.Count < 0) { return; } DataGridViewRow row = dgvUDM.SelectedRows[0]; UDMGridRow udmrow = (row.DataBoundItem as UDMGridRow); XElement req = new XElement("Request", new XElement("ModuleName", udmrow.Name)); try { ConnectionHelper conn = ConnectionHelper.GetConnection(PrimaryKey); conn.CallService("UDMService.UpdateModule", new Envelope(new XStringHolder(req))); MessageBox.Show("更新完成。"); OnPrimaryKeyChanged(EventArgs.Empty); } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); } }
private void btnDelete_Click(object sender, EventArgs e) { try { if (dgvUDM.SelectedRows.Count <= 0) { return; } DialogResult dr = MessageBox.Show("如果 UDM 包含 UDT 會一同刪除!您確定?", "Campus", MessageBoxButtons.YesNo); if (dr == DialogResult.No) { return; } DataGridViewRow row = dgvUDM.SelectedRows[0]; string name = (row.DataBoundItem as UDMGridRow).Name; XElement req = new XElement("Request", new XElement("ModuleName", name)); ConnectionHelper conn = ConnectionHelper.GetConnection(PrimaryKey); conn.CallService("UDMService.RemoveModule", new Envelope(new XStringHolder(req))); MessageBox.Show("刪除 UDM 完成。"); OnPrimaryKeyChanged(EventArgs.Empty); } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); } }
private void CallTransferInWS() { TransferInRecord record = Record; try { string contract = "StudentTransferHsinchuSpecial"; string service = "SyncTransferIn"; SecurityToken token = (DSAServices.DefaultDataSource.SecurityToken as SessionToken).OriginToken; Connection conn = DSAServices.DefaultDataSource.AsContract(contract, token); XElement econtent = XElement.Parse(record.ModifiedContent); FISCA.DSAClient.XmlHelper req = new FISCA.DSAClient.XmlHelper("<Request/>"); req.AddElement(".", "TargetSchool", GetSchoolCode()); req.AddElement(".", "Writer", string.Format("{0}:{1}", DSAServices.AccessPoint, DSAServices.UserAccount)); req.AddElement(".", "StudentID", econtent.XPathSelectElement("Student").ElementText("IDNumber")); req.AddElement(".", "StudentNumber", SRecord.StudentNumber); req.AddElement(".", "Grade", SRecord.Class.GradeYear + ""); req.AddElement(".", "ClassName", SRecord.Class.Name.Substring(1)); RTOut.WriteLine(req.XmlString); RTOut.WriteLine(conn.SendRequest(service, new Envelope(req)).XmlString); } catch (Exception ex) { RTOut.WriteError(ex); } }
protected override void OnInitializeAsync() { try { Conn = new Connection(); Conn.Connect(LogApplication, LogContract, "logquery", "logquery1234"); } catch (Exception ex) { RTOut.WriteError(ex); } }
private void UDTTableDefContent_Load(object sender, EventArgs e) { try { ConnectionHelper ch = ConnectionHelper.GetConnection(UID); XElement tn = new XElement("Request"); tn.Add(new XElement("TableName", TableName)); Envelope rsp = ch.CallService("UDTService.DDL.GetTableInfo", new Envelope(new XHelper(tn))); XElement rspxml = XElement.Parse(rsp.BodyContent.XmlString); editor.Text = rspxml.ToString(); } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); } }
private void btnInstall_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false; dialog.Filter = "Contract 定議 (*.csml;*.cml)|*.csml;*.cml"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { ConnectionHelper conn = ConnectionHelper.GetConnection(PrimaryKey); XElement udsdef = XElement.Load(dialog.FileName); if (dialog.FileName.EndsWith(".csml", StringComparison.InvariantCultureIgnoreCase)) { conn.CallService("UDSManagerService.ImportContracts", new Envelope(new XStringHolder(udsdef.ToString()))); } else if (dialog.FileName.EndsWith(".cml", StringComparison.InvariantCultureIgnoreCase)) { conn.CallService("UDSManagerService.ImportContract", new Envelope(new XStringHolder(udsdef.ToString()))); } else { throw new ArgumentException("不支援的格式!"); } MessageBox.Show("安裝/更新 UDS 完成。"); OnPrimaryKeyChanged(EventArgs.Empty); } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); } } }
protected override void OnPrimaryKeyChangedComplete(Exception error) { if (error != null) { RTOut.WriteError(error); throw error; } dgvUDM.Rows.Clear(); List <UDMGridRow> udms = new List <UDMGridRow>(); foreach (XElement each in UDM.Elements("Module")) { udms.Add(new UDMGridRow(each)); } udms.Sort((x, y) => { return(x.Name.CompareTo(y.Name)); }); dgvUDM.DataSource = new BindingList <UDMGridRow>(udms); }
private void Field_PreloadVariable(object sender, PreloadVariableEventArgs e) { if (IsDataLoading) { IsPaddingTask = true; return; } if (IsReloading) { return; } if (CacheProvider != null) { CurrentCache = CacheProvider; } else { CurrentCache = new DynamicCache(); } IsDataLoading = true; Task task = Task.Factory.StartNew(() => { if (CurrentCache.GetOutOfDate(e.Keys, FieldName)) {//如果不是在最新狀態就呼叫 GetDataAsync 讀取資料,並更新到 Cache 中。 if (e.Keys.Count() <= 0) { return; //如果沒有資料就不執行。 } IEnumerable <Value> values = GetDataAsync(e.Keys); HashSet <string> resultSet = new HashSet <string>(); foreach (Value v in values) { CurrentCache.FillProperty(v.Id, FieldName, v.Val); resultSet.Add(v.Id); } HashSet <string> clearSet = new HashSet <string>(e.Keys); clearSet.ExceptWith(resultSet); //將沒有回傳的 Id 值清空。 foreach (string id in clearSet) { CurrentCache.FillProperty(id, FieldName, string.Empty); } } }, new CancellationToken(), TaskCreationOptions.PreferFairness, TaskScheduler.Default); task.ContinueWith((x) => { IsDataLoading = false; if (IsPaddingTask) { IsPaddingTask = false; Field.Reload(); return; } if (x.Exception != null) { RTOut.WriteError(x.Exception); } else { IsReloading = true; Field.Reload(); IsReloading = false; } CurrentCache = null; }, UISyncContext); }
protected override ContinueDirection?OnNextButtonClick() { try { string stuId = "0"; if (SRecord != null) { stuId = SRecord.ID; } errors.SetError(txtIDNumber, ""); if (IsIDNumberExists(stuId, txtIDNumber.Text)) { errors.SetError(txtIDNumber, "身分證號重覆!"); return(null); } errors.SetError(cboStudentNumber, ""); if (IsStudentNumberExists(stuId, cboStudentNumber.Text)) { errors.SetError(cboStudentNumber, "學號重覆!"); return(null); } errors.SetError(txtClass, ""); if (string.IsNullOrWhiteSpace(txtClass.Text)) { errors.SetError(txtClass, "班級必填!"); return(null); } //將資料寫回 XmlData。 XElement student = XmlData.Element("Student"); student.Element("Name").Value = txtName.Text; student.Element("IDNumber").Value = txtIDNumber.Text; student.Element("Birthdate").Value = dtBirthday.Text; student.Element("Gender").Value = cboGender.Text; XElement paddress = XmlData .Element("StudentComplete") .Element("PermanentAddress") .Element("AddressList"); if (paddress != null) { paddress = paddress.Element("Address"); if (paddress.Element("ZipCode") == null) { paddress.Add(new XElement("ZipCode", txtZipCode.Text)); } else { paddress.Element("ZipCode").Value = txtZipCode.Text; } if (paddress.Element("County") == null) { paddress.Add(new XElement("County", cmbCounty.Text)); } else { paddress.Element("County").Value = cmbCounty.Text; } if (paddress.Element("Town") == null) { paddress.Add(new XElement("Town", cmbTown.Text)); } else { paddress.Element("Town").Value = cmbTown.Text; } if (paddress.Element("District") == null) { paddress.Add(new XElement("District", txtDistrict.Text)); } else { paddress.Element("District").Value = txtDistrict.Text; } if (paddress.Element("Area") == null) { paddress.Add(new XElement("Area", txtArea.Text)); } else { paddress.Element("Area").Value = txtArea.Text; } if (paddress.Element("DetailAddress") == null) { paddress.Add(new XElement("DetailAddress", txtDetail.Text)); } else { paddress.Element("DetailAddress").Value = txtDetail.Text; } } else { paddress = new XElement("Address"); paddress.Add(new XElement("ZipCode", txtZipCode.Text)); paddress.Add(new XElement("County", cmbCounty.Text)); paddress.Add(new XElement("Town", cmbTown.Text)); paddress.Add(new XElement("District", txtDistrict.Text)); paddress.Add(new XElement("Area", txtArea.Text)); paddress.Add(new XElement("DetailAddress", txtDetail.Text)); XmlData .Element("StudentComplete") .Element("PermanentAddress").Add(new XElement("AddressList", paddress)); } //<StudentComplete Processor="StudentComplete"> // <PermanentAddress> // <AddressList> // <Address> // <ZipCode>310</ZipCode> // <County>新竹縣</County> // <Town>竹東鎮</Town> // <District /> // <Area /> // <DetailAddress>北岸19號</DetailAddress> // </Address> // </AddressList> // </PermanentAddress> // </StudentComplete> if (SRecord != null) { UpdateData(SRecord); K12.Data.Student.Update(SRecord); ARecord = K12.Data.Address.SelectByStudentID(SRecord.ID); #region 更新學生地址 ARecord.Permanent.ZipCode = txtZipCode.Text; ARecord.Permanent.County = cmbCounty.Text; ARecord.Permanent.Town = cmbTown.Text; ARecord.Permanent.District = txtDistrict.Text; ARecord.Permanent.Area = txtArea.Text; ARecord.Permanent.Detail = txtDetail.Text; K12.Data.Address.Update(ARecord); ARecord = K12.Data.Address.SelectByStudentID(ARecord.RefStudentID); #endregion student.SetAttributeValue("ID", SRecord.ID); //將 Xml 上標示新增的學生編號。 Arguments[Consts.StudentID] = SRecord.ID; } else { SRecord = new StudentRecord(); UpdateData(SRecord); string newid = K12.Data.Student.Insert(SRecord); ////新竹市的國中,需要多呼叫數位學生證資料同步的 Service。 ////新增的狀態下才呼叫,以免重覆呼叫。 //if (Program.CurrentMode == Program.Hsinchu) // CallTransferInWS(); #region 更新學生地址 ARecord = K12.Data.Address.SelectByStudentID(newid); ARecord.RefStudentID = newid; ARecord.Permanent.ZipCode = txtZipCode.Text; ARecord.Permanent.County = cmbCounty.Text; ARecord.Permanent.Town = cmbTown.Text; ARecord.Permanent.District = txtDistrict.Text; ARecord.Permanent.Area = txtArea.Text; ARecord.Permanent.Detail = txtDetail.Text; K12.Data.Address.Update(ARecord); ARecord = K12.Data.Address.SelectByStudentID(ARecord.RefStudentID); #endregion FISCA.Features.Invoke("StudentSyncAllBackground"); student.SetAttributeValue("ID", newid); //將 Xml 上標示新增的學生編號。 Arguments[Consts.StudentID] = newid; } //將最新狀況寫回資料庫中。 Record.ModifiedContent = XmlData.ToString(); Record.RefStudentID = Arguments[Consts.StudentID] + ""; Record.Save(); // 新增至班級學生變更 UDT_ClassSpecial StudSpec = UDTTransfer.AddClassSpecStudent(SRecord.ID, "", SRecord.RefClassID, "", txtClass.Text, txtClass.Text, "", ""); // 傳送至局端 string errMsg = Utility.SendData("自動轉入", SRecord.IDNumber, SRecord.StudentNumber, SRecord.Name, cboGender.Text, txtOClass.Text, cboSeatNo.Text, txtClass.Text, "", "", SRecord.ID, SRecord.RefClassID, StudSpec.ClassComment); if (errMsg != "") { FISCA.Presentation.Controls.MsgBox.Show(errMsg); } //設定所有 Processor 的學生編號。 foreach (TransferProcessor tp in TransferProcessor.Processors) { tp.SetStudentId(Arguments[Consts.StudentID] + ""); } //註冊一個事件引發模組 EventHandler eh = FISCA.InteractionService.PublishEvent("KH_StudentTransferStudentBriefItem"); eh(this, EventArgs.Empty); return(ContinueDirection.Next); } catch (Exception ex) { RTOut.WriteError(ex); MessageBox.Show(ex.Message); return(null); } }
/// <summary> /// 載入表單 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void StudentBrief_Load(object sender, EventArgs e) { try { Record = Arguments[Consts.TransferInRecord] as TransferInRecord; XmlData = Arguments[Consts.XmlData] as XElement; dynamic briefSection = (DynamicXmlObject)XmlData.Element("Student"); //取得地址資料 dynamic permanentAddress = GetAddressData(); //<PermanentAddress> // <AddressList> // <Address> // <ZipCode>303</ZipCode> // <County>新竹縣</County> // <Town>湖口鄉</Town> // <District /> // <Area /> // <DetailAddress>嶺尾8號</DetailAddress> // </Address> // </AddressList> //</PermanentAddress> string urAction = briefSection["@UpdateRecordAction"]; if (!string.IsNullOrWhiteSpace(urAction)) { Arguments[Consts.UpdateRecordAction] = Enum.Parse(typeof(ContinueDirection), urAction); } SelectStudentAddressRecord(briefSection); if (SRecord != null) { if (!string.IsNullOrWhiteSpace(SRecord.RefClassID)) { CRecord = SRecord.Class; } FillStudentNumberLast(SRecord.StudentNumber); } else { FillStudentNumberLast(string.Empty); } if (SRecord == null) { SingleMode(); } else { FromOriginData(); } NextButtonEnabled = false; ClassRunning.IsRunning = true; ClassRunning.Visible = true; Task task = Task.Factory.StartNew(() => { LoadClassRowSource(); TownList = K12.Data.Town.SelectAll(); CountyList = K12.Data.Town.SelectCountyList(); }, new CancellationToken(), TaskCreationOptions.None, TaskScheduler.Default); task.ContinueWith(x => { if (x.IsFaulted) { RTOut.WriteError(x.Exception); MessageBox.Show(x.Exception.Message); NextButtonEnabled = false; } SuspenSelectedValueChanged = true; cmbTown.DataSource = TownList.Select(y => y.Area).ToList(); cmbCounty.DataSource = CountyList; FromTransferData(briefSection, permanentAddress); //cboClass.DataSource = ClassRowSource; //cboClass.ValueMember = "ID"; //cboClass.DisplayMember = "Name"; SuspenSelectedValueChanged = false; cboGradeYear.Text = ""; List <string> grList = Utility.GetGradeYearList(); cboGradeYear.Items.AddRange(grList.ToArray()); if (SRecord != null) { cboSeatNo.Text = SRecord.SeatNo + ""; cboStudentNumber.Text = SRecord.StudentNumber; //if (CRecord != null) // cboClass.SelectedIndex = cboClass.FindStringExact(CRecord.Name); } // 如果學生是同校轉出又轉入,回到原班 if (CRecord != null) { // 2018/8/29 穎驊因應 高雄專案 [08-02][02]轉入學生編班 修正規則, // 如果學生本為同校生,則會有有選項,讓使用者選擇是否要回原班級,或是依照局端規則,優先提供轉入班級 List <KH_HighConcernCalc.ClassStudent> grClassList = Utility.GetClassNameFirst_List("" + CRecord.GradeYear); string msgString = ""; msgString = @"本轉入生在本學校發現其原本班級:" + CRecord.Name + "(編班人數:" + grClassList.Find(c => c.ClassID == CRecord.ID).ClassStudentCount + ")" + "請問是否轉入原班級?" + "\r\n" + "若選擇為否,則會依局端系統規則優先轉入班級:" + grClassList[0].ClassName + "(編班人數:" + grClassList[0].ClassStudentCount + ")"; if (FISCA.Presentation.Controls.MsgBox.Show(msgString, "提醒!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { txtClass.Text = CRecord.Name; } else { txtClass.Text = grClassList[0].ClassName; } } txtClass.ReadOnly = true; ClassRunning.IsRunning = false; ClassRunning.Visible = false; NextButtonEnabled = true; }, TaskScheduler.FromCurrentSynchronizationContext()); } catch (Exception ex) { MessageBox.Show(ex.Message); RTOut.WriteError(ex); WizardResult = ContinueDirection.Cancel; Close(); } }