protected void btn_Delete_Click(object sender, EventArgs e) { if (ddl_UserAD.SelectedValue == "-1") { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('请选择用户!');</script>"); return; } int a = XmlSource.DeleteUserConfig(ddl_UserAD.SelectedItem.Text); if (a == -1) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存失败!');</script>"); } else if (a == 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存成功!');</script>"); #region 用户下拉列表 InitDropDownList(); try { ddl_UserAD.SelectedItem.Selected = false; } catch { } finally { ddl_UserAD.Items.FindByValue("-1").Selected = true; BindData(""); } #endregion } }
///-------------------------------------------------------------------------------- /// <summary>This method is used to copy/paste a new item.</summary> /// /// <param name="copyItem">The item to copy/paste.</param> /// <param name="savePaste">Flag to determine whether to save the results of the paste.</param> ///-------------------------------------------------------------------------------- public XmlSourceViewModel PasteXmlSource(XmlSourceViewModel copyItem, bool savePaste = true) { XmlSource newItem = new XmlSource(); newItem.ReverseInstance = new XmlSource(); newItem.TransformDataFromObject(copyItem.XmlSource, null, false); newItem.SpecificationSourceID = Guid.NewGuid(); newItem.IsAutoUpdated = false; newItem.Solution = Solution; newItem.Solution = Solution; XmlSourceViewModel newView = new XmlSourceViewModel(newItem, Solution); newView.ResetModified(true); AddXmlSource(newView); // paste children if (savePaste == true) { Solution.XmlSourceList.Add(newItem); newView.OnUpdated(this, null); Solution.ResetModified(true); } return(newView); }
public void SourceWithDifferentNames() { //Arrange TwoColumnsTableFixture dest2Columns = new TwoColumnsTableFixture("XmlSource2ColsDynamic"); RowTransformation <ExpandoObject> trans = new RowTransformation <ExpandoObject>( row => { dynamic r = row as ExpandoObject; r.Col1 = r.Column1; r.Col2 = r.Column2; return(r); }); DbDestination <ExpandoObject> dest = new DbDestination <ExpandoObject>("XmlSource2ColsDynamic", Connection); //Act XmlSource <ExpandoObject> source = new XmlSource <ExpandoObject>("res/XmlSource/TwoColumnsElementDifferentNames.xml", ResourceType.File) { ElementName = "MySimpleRow" }; var link1 = source.LinkTo(trans); var link2 = link1.source.LinkTo(dest); using (link1.link) using (link2.link) { source.Execute(); dest.Wait(); //Assert dest2Columns.AssertTestData(); } }
public void Catalog_InitializeTest() { Catalog c = new Catalog(); string outputFile = "catalog.xml"; c.AddNew("Apple", 0.75M, DateTime.MinValue, new DateTime(2001, 12, 31, 23, 59, 59)); c.AddNew("Apple", 0.75M, new DateTime(2002, 01, 01), null); c.AddNew("Banana", 1.0M, DateTime.MinValue, null); c.AddNew("Orange Juice", 1.1M, DateTime.MinValue, new DateTime(1983, 06, 09, 23, 59, 59)); c.AddNew("Orange Juice", 2.0M, new DateTime(1983, 06, 10), null); c.AddNew("Pineapple", 5.0M, DateTime.MinValue, null); c.AddNew("Pen", 0.99M, DateTime.MinValue, null); XmlSource.Save(c, outputFile); Catalog c2 = XmlSource.Load(typeof(Catalog), outputFile) as Catalog; Assert.IsTrue(c2 != null, "Catalog was not rehydrated successfully"); Assert.IsTrue(c2.Count == c.Count, "Catalog items serialized and rehydrated are not the same count"); Assert.IsTrue(c2.Count > 0, "No objects were rehydrated"); // if (System.IO.File.Exists(outputFile)) // System.IO.File.Delete(outputFile); }
/// <summary> /// 拒绝 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void button_shenpi_no_Click(object sender, ImageClickEventArgs e) { CARDataBLL dataBll = new CARDataBLL(FactoryID); CARLogBLL logbll = new CARLogBLL(FactoryID); DataInfo datainfo = new DataInfo(); datainfo = dataBll.GetByKey(did); datainfo.status = 14;//拒绝 dataBll.UpdateData(datainfo); LogInfo loginfo = new LogInfo(); if (ApprovalTable.Rows.Count > 0) { loginfo = logbll.GetByKey(int.Parse(ApprovalTable.Rows[0]["rkey"].ToString())); loginfo.sp_end_date = DateTime.Now; loginfo.sp_content = SP_Content.Text; loginfo.status = 2; logbll.UpdateData(loginfo); } string sp_user = datainfo.nowuser; string subject = "8D form,未通过审批。"; string url = System.Configuration.ConfigurationManager.AppSettings["url"].ToString(); string body = url; XmlSource.SendEmail(sp_user, subject, body); Response.Write("<script language='javaScript'>alert('操作成功');window.opener = null;window.close();</script>");//无提示关闭页面 button_shenpi_yes.Enabled = false; button_shenpi_no.Enabled = false; }
public void CheckVerticesCount_XmlGenerated() { var path = @"../../../testGraph.xml"; var graph = XmlSource.GetGraphFromXml(path); Assert.AreEqual(graph.Vertices.Count, 6); }
public void ProductCollection_AddProductsPPAPTest() { ProductCollection products = new ProductCollection(); products.AddNew("Pen"); products.AddNew("Pineapple"); products.AddNew("Apple"); products.AddNew("Pen"); Assert.IsTrue(products.Count == 4); System.Collections.Generic.List <Product> prods = new System.Collections.Generic.List <Product>(); prods.GroupBy(x => x.Name); var results = products.GroupBy(x => x.Name) .Select(x => new { Name = x.Key, Count = x.Count() }); XmlSource.Save(products, "OrderPPAP.xml"); /* Debugger results: * Apple: 3 * Banana: 1 */ //TODO: figure out the syntax to access the count groupings. // debugger shows it properly but adding to the watch window results in an error. }
///-------------------------------------------------------------------------------- /// <summary>This method refreshes the view model.</summary> /// /// <param name="refreshChildren">Flag indicating whether children should be refreshed.</param> ///-------------------------------------------------------------------------------- public void Refresh(bool refreshChildren, int refreshLevel = 0) { if (refreshChildren == true || refreshLevel > 0) { } #region protected #endregion protected HasErrors = !XmlSource.IsValid; HasCustomizations = XmlSource.IsAutoUpdated == false || XmlSource.IsEmptyMetadata(XmlSource.ForwardInstance) == false || ChildrenHaveAnyCustomizations(); if (HasCustomizations == false && XmlSource.ReverseInstance != null) { // remove customizations if solely due to child customizations no longer present XmlSource.IsAutoUpdated = true; XmlSource.SpecSourceName = XmlSource.ReverseInstance.SpecSourceName; XmlSource.ResetModified(XmlSource.ReverseInstance.IsModified); XmlSource.ResetLoaded(XmlSource.ReverseInstance.IsLoaded); if (!XmlSource.IsIdenticalMetadata(XmlSource.ReverseInstance)) { HasCustomizations = true; XmlSource.IsAutoUpdated = false; } } if (HasCustomizations == false) { // clear customizations XmlSource.ForwardInstance = null; XmlSource.ReverseInstance = null; XmlSource.IsAutoUpdated = true; } OnPropertyChanged("Items"); OnPropertyChanged("HasCustomizations"); OnPropertyChanged("HasErrors"); }
protected void sendApproval_Click(object sender, ImageClickEventArgs e) { if (ApprovalTable.Rows.Count < 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('未设置审批流程或审批人少于两个!');</script>"); return; } #region 保存 int sn_ptr = Writedata(2); if (sn_ptr == -1) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存失败!');</script>"); return; } if (Writelog(sn_ptr) == -1) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存失败!');</script>"); return; } #endregion #region 邮件提示 CARDataBLL dataBll = new CARDataBLL(CurrentFactoryID); string sp_user = ApprovalTable.Rows[0][2].ToString(); string subject = "8D Form 有新的审批。"; string url = System.Configuration.ConfigurationManager.AppSettings["url"].ToString(); string body = url; XmlSource.SendEmail(sp_user, subject, body); #endregion Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('发送成功!');</script>"); ibtn_Save.Enabled = false; sendApproval.Enabled = false; }
/// <summary> /// 拒绝 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void button_shenpi_no_Click(object sender, ImageClickEventArgs e) { QSMBLL qsmbll = new QSMBLL(FactoryID); CARLogBLL logbll = new CARLogBLL(FactoryID); qsminfo.STATUS = 14; qsmbll.Update(qsminfo); LogInfo loginfo = new LogInfo(); if (ApprovalTable.Rows.Count > 0) { loginfo = logbll.GetByKey(int.Parse(ApprovalTable.Rows[0]["rkey"].ToString())); loginfo.sp_end_date = DateTime.Now; loginfo.sp_content = SP_Content.Text; loginfo.status = 2; logbll.UpdateData(loginfo); } string sp_user = qsminfo.ENT_USER; string subject = "客户投诉单,未通过审批。"; string url = System.Configuration.ConfigurationManager.AppSettings["url"].ToString(); string body = url; XmlSource.SendEmail(sp_user, subject, body); Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('提交成功!');window.opener = null;window.close();</script>"); button_shenpi_yes.Enabled = false; button_shenpi_no.Enabled = false; }
public void XmlSourceGetAllRowsTest() { var source = new XmlSource("./TestFiles/Test1.xml", new RuntimeContext(CancellationToken.None, null, null)); var rows = source.Rows.ToArray(); Assert.AreEqual(22, rows.Length); }
/// <summary> /// 审批通过 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void button_shenpi_yes_Click(object sender, ImageClickEventArgs e) { SABLL saBLL = new SABLL(FactoryID); CARLogBLL logbll = new CARLogBLL(FactoryID); LogInfo loginfo = new LogInfo(); #region data if (SP_Step == SP_Total_Step) { saInfo.STATUS = 1; saInfo.CLOSE_DATE = DateTime.Now; } saBLL.Update(saInfo); #endregion #region log if (ApprovalTable.Rows.Count >= 1) { loginfo = logbll.GetByKey(int.Parse(ApprovalTable.Rows[0]["rkey"].ToString())); loginfo.sp_end_date = DateTime.Now; loginfo.sp_content = SP_Content.Text; loginfo.status = 1; logbll.UpdateData(loginfo); if (ApprovalTable.Rows.Count >= 2) { loginfo = logbll.GetByKey(int.Parse(ApprovalTable.Rows[1]["rkey"].ToString())); loginfo.sp_start_date = DateTime.Now; logbll.UpdateData(loginfo); } } #endregion #region mail string sp_user = ""; string subject = ""; string body = ""; if (ApprovalTable.Rows.Count == 1) { if (SP_Step == SP_Total_Step) { sp_user = saInfo.ENT_USER; subject = "不良品确认单,审批通过。"; string url = System.Configuration.ConfigurationManager.AppSettings["url"].ToString(); body = url; } else { sp_user = ApprovalTable.Rows[1]["sp_user"].ToString(); subject = "有新的不良品确认单,请审批。"; string url = System.Configuration.ConfigurationManager.AppSettings["url"].ToString(); body = url; } XmlSource.SendEmail(sp_user, subject, body); } #endregion Response.Write("<script language='javaScript'>alert('操作成功');window.opener = null;window.close();</script>");//无提示关闭页面 button_shenpi_yes.Enabled = false; button_shenpi_no.Enabled = false; }
/// <summary>Write an asset instance to disk.</summary> /// <param name="asset">The asset value.</param> /// <param name="toPathWithoutExtension">The absolute path to the export file, without the file extension.</param> /// <param name="relativePath">The relative path within the content folder.</param> /// <param name="platform">The operating system running the unpacker.</param> /// <param name="error">An error phrase indicating why writing to disk failed (if applicable).</param> /// <returns>Returns whether writing to disk completed successfully.</returns> public override bool TryWriteFile(object asset, string toPathWithoutExtension, string relativePath, Platform platform, out string error) { XmlSource value = (XmlSource)asset; File.WriteAllText($"{toPathWithoutExtension}.fnt", value.Source); error = null; return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FactoryID = String.IsNullOrEmpty(Request.QueryString["FID"]) ? 98 : int.Parse(Request.QueryString["FID"]); did = String.IsNullOrEmpty(Request.QueryString["did"]) ? 0 : int.Parse(Request.QueryString["did"]); type = String.IsNullOrEmpty(Request.QueryString["type"]) ? "view" : Request.QueryString["type"]; try { this.UserAD = CurrentUser.UserADAcount; } catch { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户AD丢失!');</script>"); Response.End(); } CARDataBLL dataBll = new CARDataBLL(FactoryID); dataInfo = dataBll.GetByKey(did); if (dataInfo.op_type != 3) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('非法访问!');</script>"); Response.End(); } if (type == "view") { if (!HasRight(XmlSource.GetRightIndex("VIEW")) || !HasRight(XmlSource.GetRightIndex("JIAOZHENG"))) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('您没有查看此页面的权限!');</script>"); Response.End(); } div_sp.Visible = false; Info_Content.AutoConfigure = CuteEditor.AutoConfigure.None; Info_Content.ActiveTab = CuteEditor.TabType.View; Info_Content.ShowBottomBar = false; Interim_Action.AutoConfigure = CuteEditor.AutoConfigure.None; Interim_Action.ActiveTab = CuteEditor.TabType.View; Interim_Action.ShowBottomBar = false; IPCA.AutoConfigure = CuteEditor.AutoConfigure.None; IPCA.ActiveTab = CuteEditor.TabType.View; IPCA.ShowBottomBar = false; CONF_Content.AutoConfigure = CuteEditor.AutoConfigure.None; CONF_Content.ActiveTab = CuteEditor.TabType.View; CONF_Content.ShowBottomBar = false; InitPage(dataInfo); } else if (type == "approval") { if (dataInfo.status == 0 || dataInfo.status == 1 || dataInfo.status == 14) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('此单未在审批中!');</script>"); Response.End(); } Check(); InitPage(dataInfo); } } }
public XmlSource ReadXmlIfExists(string filePath) { var file = TryGetFileInfo(filePath); if (!file.Exists) { return(XmlSource.NonExisting(filePath)); } using (var stream = file.OpenRead()) { return(new XmlSource(file.FullName, XDocument.Load(stream))); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Date_Start.Text = DateTime.Now.AddDays(-10).ToShortDateString(); Date_End.Text = DateTime.Now.ToShortDateString(); if (!HasRight(XmlSource.GetRightIndex("SA")) || !HasRight(XmlSource.GetRightIndex("VIEW"))) { Response.Write("<script>alert('你没有权限进入此页面!');</script>"); Response.End(); } } }
protected void btn_Submit_Click(object sender, EventArgs e) { string userAD; if (tb_UserAD.Visible == true) { if (tb_UserAD.Text.Trim() == "" || !tb_UserAD.Text.ToLower().StartsWith("founderpcb\\")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('域帐号格式有误!');</script>"); return; } userAD = tb_UserAD.Text.Trim(); } else { if (ddl_UserAD.SelectedValue == "-1") { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('请选择用户!');</script>"); return; } userAD = ddl_UserAD.SelectedItem.Text; } int count = int.Parse(((HiddenField)GridView1.Rows[GridView1.Rows.Count - 1].Cells[2].FindControl("hdf_Index")).Value); StringBuilder config = new StringBuilder(); for (int i = 1; i <= count + 1; i++) { config.Append("0"); } for (int j = 0; j < GridView1.Rows.Count; j++) { CheckBox cb = (CheckBox)GridView1.Rows[j].Cells[1].FindControl("ckb_Right"); if (cb.Checked) { config.Remove(int.Parse(((HiddenField)GridView1.Rows[j].Cells[2].FindControl("hdf_Index")).Value), 1); config.Insert(int.Parse(((HiddenField)GridView1.Rows[j].Cells[2].FindControl("hdf_Index")).Value), "1"); } } int a = XmlSource.SetUserConfig(userAD, config.ToString()); if (a == -1) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存失败!');</script>"); } else if (a == 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存成功!');</script>"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!HasRight(XmlSource.GetRightIndex("SA")) || !HasRight(XmlSource.GetRightIndex("VIEW"))) { Response.Clear(); Response.Write("<script>alert('你没有权限进入此页面!');</script>"); Response.End(); } InitWebElement(); BindData(); } }
///-------------------------------------------------------------------------------- /// <summary>This method loads an item of XmlSource into the view model.</summary> /// /// <param name="xmlSource">The XmlSource to load.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadXmlSource(XmlSource xmlSource, bool loadChildren = true) { // attach the XmlSource XmlSource = xmlSource; ItemID = XmlSource.SpecificationSourceID; Items.Clear(); if (loadChildren == true) { #region protected #endregion protected Refresh(false); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FactoryID = String.IsNullOrEmpty(Request.QueryString["FID"]) ? 98 : int.Parse(Request.QueryString["FID"]); did = String.IsNullOrEmpty(Request.QueryString["did"]) ? 0 : int.Parse(Request.QueryString["did"]); type = String.IsNullOrEmpty(Request.QueryString["type"]) ? "view" : Request.QueryString["type"]; try { this.UserAD = CurrentUser.UserADAcount; } catch { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('用户AD丢失!');</script>"); Response.End(); } QSMBLL qsmbll = new QSMBLL(FactoryID); qsminfo = qsmbll.getQSMInfoByrkey(did); if (type == "view") { if (!HasRight(XmlSource.GetRightIndex("VIEW")) || !HasRight(XmlSource.GetRightIndex("QSM"))) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('您没有查看此页面的权限!');</script>"); Response.End(); } div_sp.Visible = false; CAR_Content.AutoConfigure = CuteEditor.AutoConfigure.None; CAR_Content.ActiveTab = CuteEditor.TabType.View; CAR_Content.ShowBottomBar = false; Info_Content.AutoConfigure = CuteEditor.AutoConfigure.None; Info_Content.ActiveTab = CuteEditor.TabType.View; Info_Content.ShowBottomBar = false; CONF_Content.AutoConfigure = CuteEditor.AutoConfigure.None; CONF_Content.ActiveTab = CuteEditor.TabType.View; CONF_Content.ShowBottomBar = false; InitPage(qsminfo); } else if (type == "approval") { if (qsminfo.STATUS == 0 || qsminfo.STATUS == 1 || qsminfo.STATUS == 14) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('此单未在审批中!');</script>"); Response.End(); } Check(); InitPage(qsminfo); } } }
public void Is_FindedPath_Shortest_Xml() { var path = @"../../../testGraph.xml"; var graph = XmlSource.GetGraphFromXml(path); IVertex <string> kyiv; graph.Vertices.TryGetValue(new Vertex <string>() { Data = "Kyiv" }, out kyiv); //TODO: Write hashset Find or something like this IVertex <string> tokyo; graph.Vertices.TryGetValue(new Vertex <string>() { Data = "Tokyo" }, out tokyo); IVertex <string> lviv; graph.Vertices.TryGetValue(new Vertex <string>() { Data = "Lviv" }, out lviv); IEdge <string> kl; graph.Edges.TryGetValue(new Edge <string>() { StartNode = kyiv, EndNode = lviv, Distance = 3 }, out kl); IEdge <string> lt; graph.Edges.TryGetValue(new Edge <string>() { StartNode = lviv, EndNode = tokyo, Distance = 1 }, out lt); var expPath = new List <IEdge <string> >() { kl, lt }; var actualPath = graph.FindShortestPath(kyiv, tokyo).ToList(); CollectionAssert.AreEqual(expPath, actualPath); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!HasRight(XmlSource.GetRightIndex("VIEW"))) { Response.Write("<script>alert('你没有权限进入此页面!');</script>"); Response.End(); return; } did = String.IsNullOrEmpty(Request.QueryString["did"]) ? 0 : int.Parse(Request.QueryString["did"]); type = string.IsNullOrEmpty(Request.QueryString["type"]) ? "" : Request.QueryString["type"].ToString(); BindData(); } }
public void XmlOnlyAttributes() { //Arrange TwoColumnsTableFixture dest2Columns = new TwoColumnsTableFixture("XmlSource2ColsAttribute"); DbDestination <MyAttributeRow> dest = new DbDestination <MyAttributeRow>(Connection, "XmlSource2ColsAttribute"); //Actt XmlSource <MyAttributeRow> source = new XmlSource <MyAttributeRow>("res/XmlSource/TwoColumnsOnlyAttributes.xml", ResourceType.File); source.LinkTo(dest); source.Execute(); dest.Wait(); //Assert dest2Columns.AssertTestData(); }
/// <summary> /// Initializes a new instance of the <see cref="XmlConfigurationSource"/> class. /// </summary> /// <param name="filename">The full path to the document.</param> public XmlConfigurationSource(string filename) { if (filename == null) { throw new ArgumentNullException(nameof(filename)); } path = new FileInfo(filename); source = XmlSource.File; sync = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); if (!path.Exists) { throw new FileNotFoundException($"Cannot resolve an XML configuration source at path '{filename}'"); } }
/// <summary> /// Initializes a new instance of the <see cref="XmlConfigurationSource"/> class. /// </summary> /// <param name="src">The source.</param> public XmlConfigurationSource(Stream src) { if (src == null) { throw new ArgumentNullException(nameof(src)); } if (!src.CanRead) { throw new IOException("Cannot read content from the provided stream"); } source = XmlSource.Stream; stream = src; streamPosition = src.Position; sync = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); }
public void WithoutErrorLinking() { //Arrange MemoryDestination <MySimpleRow> dest = new MemoryDestination <MySimpleRow>(); //Act XmlSource <MySimpleRow> source = new XmlSource <MySimpleRow>("res/XmlSource/TwoColumnsErrorLinking.xml", ResourceType.File); //Assert Assert.Throws <System.InvalidOperationException>(() => { source.LinkTo(dest); source.Execute(); dest.Wait(); }); }
protected void BindData(string userAD) { string config = XmlSource.GetUserConfig(userAD); InitTable(); for (int i = 1; i <= config.Length - 1; i++) { DataRow[] rows = tb.Select("index=" + i.ToString()); foreach (DataRow row in rows) { row["hasRight"] = config.Substring(i, 1); } } GridView1.DataSource = tb; GridView1.DataBind(); }
///-------------------------------------------------------------------------------- /// <summary>This method sets the default values.</summary> ///-------------------------------------------------------------------------------- protected override void OnSetDefaults() { if (XmlSource.ReverseInstance != null) { EditXmlSource.TransformDataFromObject(XmlSource.ReverseInstance, null, false); } else if (XmlSource.IsAutoUpdated == true) { EditXmlSource.TransformDataFromObject(XmlSource, null, false); } else { XmlSource newXmlSource = new XmlSource(); newXmlSource.SpecificationSourceID = EditXmlSource.SpecificationSourceID; EditXmlSource.TransformDataFromObject(newXmlSource, null, false); } EditXmlSource.ResetModified(true); }
public void XmlDataSource_SerializeCollectionTest1() { string outputFile = @".\products.xml"; IProductCollection products = new kiosk.Model.ProductCollection(); products.AddNew("Apple"); products.AddNew("Banana"); products.AddNew("Apple"); products.AddNew("Apple"); XmlSource.Save(products, outputFile); Assert.IsTrue(System.IO.File.Exists(outputFile)); //Cleanup System.IO.File.Delete(outputFile); }
private void CreateDataSources() { _dataSources.Clear(); if (checkBoxSqlServer.Checked) { var sqlSource = new SqlSource(textBoxSqlServer.Text); if (!sqlSource.TestConnection()) { MessageBox.Show("Could not connect to database. Please check the connection string.", "Error"); } else { _dataSources.Add(sqlSource); } } if (checkBoxCsvFile.Checked) { var csvSource = new CsvSource(textBoxCsvFile.Text); if (!csvSource.TestConnection()) { MessageBox.Show("Could not find the CSV file. Please check the path to the file.", "Error"); } else { _dataSources.Add(csvSource); } } if (checkBoxXmlFile.Checked) { var xmlSource = new XmlSource(textBoxXmlFile.Text); if (!xmlSource.TestConnection()) { MessageBox.Show("Could not find the XML file. Please check the path to the file.", "Error"); } else { _dataSources.Add(xmlSource); } } }