/// <summary> /// 保存查询条件 /// </summary> private void SaveQueryCondition() { Neusoft.FrameWork.Xml.XML xml = new Neusoft.FrameWork.Xml.XML(); XmlDocument doc = new XmlDocument(); XmlElement root = xml.CreateRootElement(doc, "SETTING", "1.0"); for (int i = 0; i < this._CurConditionCount; i++) { //添加查询条件节点 ucCondition condition = (ucCondition)this.pnlConditionGroup.Controls[i]; XmlElement xmlCondition = xml.AddXmlNode(doc, root, "Condition", ""); xml.AddNodeAttibute(xmlCondition, "Tree", condition.Field); xml.AddNodeAttibute(xmlCondition, "CompareOperator", condition.CompareOperator); xml.AddNodeAttibute(xmlCondition, "CompareContext1", condition.CompareContext1); xml.AddNodeAttibute(xmlCondition, "RelationOperator", condition.RelationOperator); xml.AddNodeAttibute(xmlCondition, "CompareContext2", condition.CompareContext2); } if (Neusoft.HISFC.BizProcess.Factory.Function.IntegrateManager.SetQueryCondition(this.FindForm().Name, doc.OuterXml, false) == -1) { MessageBox.Show(Neusoft.HISFC.BizProcess.Factory.Function.IntegrateManager.Err); } // else // { // MessageBox.Show("条件模板保存成功!"); // } // // doc.Save(Application.StartupPath + "\\" + this._QueryConditionFileName); }
public static void SaveColumnProperty(FarPoint.Win.Spread.SheetView fv, string FileName) { string path; try { path = FileName.Substring(0, FileName.LastIndexOf(@"\")); if (System.IO.Directory.Exists(path) == false) { System.IO.Directory.CreateDirectory(path); } } catch { } Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML(); XmlDocument doc = new XmlDocument(); XmlElement root; root = myXml.CreateRootElement(doc, "Setting", "1.0"); for (int i = 0; i < fv.Columns.Count; i++) { XmlElement e = myXml.AddXmlNode(doc, root, "Column", ""); myXml.AddNodeAttibute(e, "displayname", fv.Columns[i].Label); myXml.AddNodeAttibute(e, "width", fv.Columns[i].Width.ToString()); myXml.AddNodeAttibute(e, "visible", fv.Columns[i].Visible.ToString()); if (fv.Columns[i].Locked) { myXml.AddNodeAttibute(e, "enable", "false"); } else { myXml.AddNodeAttibute(e, "enable", "true"); } if (fv.Columns[i].CellType != null) { myXml.AddNodeAttibute(e, "type", fv.Columns[i].CellType.ToString()); } else { myXml.AddNodeAttibute(e, "type", ""); } myXml.AddNodeAttibute(e, "sort", fv.Columns[i].AllowAutoSort.ToString()); try { myXml.AddNodeAttibute(e, "tag", fv.Columns[i].Tag.ToString()); } catch { } } try { StreamWriter sr = new StreamWriter(FileName, false, System.Text.Encoding.Default); string cleandown = doc.OuterXml; sr.Write(cleandown); sr.Close(); //doc.Save(FileName); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("无法保存!" + ex.Message); } }
/// <summary> /// 创建和更新配置文件 /// </summary> /// <param name="filePath">配置文件路径</param> /// <returns>false创建失败 true创建成功</returns> public bool CreateXml(string filePath) { Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML(); XmlDocument doc = new XmlDocument(); XmlElement root; root = myXml.CreateRootElement(doc, "Setting", "1.0"); string tempWindowName = this.fpSpead1_Sheet1.Cells[0, 5].Text; string currWindowName = string.Empty; XmlElement secondNode = null; for (int i = 0; i < this.fpSpead1_Sheet1.RowCount; i++) { currWindowName = this.fpSpead1_Sheet1.Cells[i, 5].Text; if (i == 0) { secondNode = myXml.AddXmlNode(doc, root, tempWindowName, string.Empty); } else if (tempWindowName != currWindowName) { secondNode = myXml.AddXmlNode(doc, root, currWindowName, string.Empty); } XmlElement e = myXml.AddXmlNode(doc, secondNode, "Column", string.Empty); myXml.AddNodeAttibute(e, "opCode", this.fpSpead1_Sheet1.Cells[i, 0].Text); myXml.AddNodeAttibute(e, "opName", this.fpSpead1_Sheet1.Cells[i, 1].Text); myXml.AddNodeAttibute(e, "opKey", this.fpSpead1_Sheet1.Cells[i, 2].Text); string opKeyHash = string.Empty, cuKeyHash = string.Empty; if (this.fpSpead1_Sheet1.Cells[i, 2].Text != string.Empty) { opKeyHash = this.fpSpead1_Sheet1.Cells[i, 2].Tag.ToString(); } myXml.AddNodeAttibute(e, "opKeyHash", opKeyHash); myXml.AddNodeAttibute(e, "cuKey", this.fpSpead1_Sheet1.Cells[i, 3].Text); if (this.fpSpead1_Sheet1.Cells[i, 3].Text != string.Empty) { cuKeyHash = this.fpSpead1_Sheet1.Cells[i, 3].Tag.ToString(); } myXml.AddNodeAttibute(e, "cuKeyHash", cuKeyHash); myXml.AddNodeAttibute(e, "hash", this.fpSpead1_Sheet1.Cells[i, 4].Text); tempWindowName = currWindowName; } try { StreamWriter sr = new StreamWriter(filePath, false, System.Text.Encoding.Default); string cleandown = doc.OuterXml; sr.Write(cleandown); sr.Close(); } catch (Exception ex) { MessageBox.Show("无法保存!" + ex.Message); } return(true); }
protected string _SaveCondition() { Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML(); XmlDocument doc = new XmlDocument(); XmlElement eRoot = myXml.CreateRootElement(doc, "setting"); for (int i = 0; i < 20; i++) { XmlElement eRow = null; eRow = myXml.AddXmlNode(doc, eRoot, "row", ""); for (int j = 0; j < 4; j++) { Control c = this.getControl(j, i) as Control; if (c == null) { break; } myXml.AddXmlNode(doc, eRow, "column", c.Text); } } return(doc.OuterXml); }
/// <summary> /// 获得连接串 /// </summary> /// <returns></returns> public string GetConnectString() { string dbInstance = ""; string DataBaseName = ""; string userName = ""; string password = ""; string connString = ""; if (!System.IO.File.Exists(profileName)) { Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML(); XmlDocument doc = new XmlDocument(); XmlElement root; root = myXml.CreateRootElement(doc, "SqlServerConnectForHis4.0", "1.0"); XmlElement dbName = myXml.AddXmlNode(doc, root, "设置", ""); myXml.AddNodeAttibute(dbName, "数据库实例名", ""); myXml.AddNodeAttibute(dbName, "数据库名", ""); myXml.AddNodeAttibute(dbName, "用户名", ""); myXml.AddNodeAttibute(dbName, "密码", ""); try { StreamWriter sr = new StreamWriter(profileName, false, System.Text.Encoding.Default); string cleandown = doc.OuterXml; sr.Write(cleandown); sr.Close(); } catch (Exception ex) { this.Err = "创建医保连接服务配置出错!" + ex.Message; this.ErrCode = "-1"; this.WriteErr(); return(""); } return(""); } else { XmlDocument doc = new XmlDocument(); try { StreamReader sr = new StreamReader(profileName, System.Text.Encoding.Default); string cleandown = sr.ReadToEnd(); doc.LoadXml(cleandown); sr.Close(); } catch { return(""); } XmlNode node = doc.SelectSingleNode("//设置"); try { dbInstance = node.Attributes["数据库实例名"].Value.ToString(); DataBaseName = node.Attributes["数据库名"].Value.ToString(); userName = node.Attributes["用户名"].Value.ToString(); password = node.Attributes["密码"].Value.ToString(); } catch { return(""); } connString = "packet size=4096;user id=" + userName + ";data source=" + dbInstance + ";pers" + "ist security info=True;initial catalog=" + DataBaseName + ";password=" + password; } return(connString); }
/// <summary> /// 从对象生成Xml /// </summary> /// <param name="setting"></param> public string GetXmlFromNurseSheetSetting(Neusoft.HISFC.Models.EPR.NurseSheetSetting setting) { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); Neusoft.FrameWork.Xml.XML xml = new Neusoft.FrameWork.Xml.XML(); XmlElement root = xml.CreateRootElement(doc, "Setting"); ////Help //XmlElement elmHelp = xml.AddXmlNode(doc, root, "Help", ""); //xml.AddNodeAttibute(elmHelp, "IsUseHelp", setting.IsUseHelp.ToString()); //if (setting.Help != null && setting.Help.Length > 0) //{ // xml.AddNodeAttibute(elmHelp, "Text", string.Join("\n", setting.Help)); //} //Print System.Xml.XmlElement elmPrint = xml.AddXmlNode(doc, root, "Print", ""); //xml.AddNodeAttibute(elmPrint, "PrintType", setting.PrintType.ToString()); //xml.AddNodeAttibute(elmPrint, "Page", setting.Page); //xml.AddNodeAttibute(elmPrint, "LandScape", setting.LandSacpe.ToString()); //xml.AddNodeAttibute(elmPrint, "StartX", setting.StartX.ToString()); //xml.AddNodeAttibute(elmPrint, "StartY", setting.StartY.ToString()); //xml.AddNodeAttibute(elmPrint, "RowHeight", setting.RowHeight.ToString()); //xml.AddNodeAttibute(elmPrint, "RowCount1", setting.RowCount1.ToString()); //xml.AddNodeAttibute(elmPrint, "RowCount2", setting.RowCount2.ToString()); //xml.AddNodeAttibute(elmPrint, "CaptionRowCount", setting.CaptionRowCount.ToString()); //if (setting.BackImage != null) //{ // string fileName = Neusoft.NFC.Interface.Classes.Function.GetTempFileName() + ".bmp"; // setting.BackImage.Save(fileName); // System.IO.FileStream stream = new System.IO.FileStream(fileName, System.IO.FileMode.Open); // byte[] byteimg = new byte[stream.Length]; // stream.Read(byteimg, 0, (int)stream.Length); // stream.Close(); // System.Text.UnicodeEncoding encoding = new UnicodeEncoding(); // string strImg = Convert.ToBase64String(byteimg); // encoding.GetString(byteimg); // xml.AddXmlCDataNode(doc, elmPrint, "BackGroundImage", strImg); //} System.Xml.XmlElement elmColumns = xml.AddXmlNode(doc, root, "Columns", ""); //Columns if (setting.Columns != null && setting.Columns.Length > 0) { for (int i = 0; i < setting.Columns.Length; i++) { System.Xml.XmlElement elmColumn = xml.AddXmlNode(doc, elmColumns, "Column", ""); xml.AddNodeAttibute(elmColumn, "Caption", setting.Columns[i].Caption); xml.AddNodeAttibute(elmColumn, "Style", setting.Columns[i].Style.ToString()); //xml.AddNodeAttibute(elmColumn, "WordCount", setting.Columns[i].WordCount.ToString()); xml.AddNodeAttibute(elmColumn, "IsDescription", setting.Columns[i].IsDescription.ToString()); xml.AddNodeAttibute(elmColumn, "IsUseHelp", setting.Columns[i].IsUseHelp.ToString()); if (setting.Columns[i].Help != null) { xml.AddNodeAttibute(elmColumn, "Help", string.Join("\n", setting.Columns[i].Help)); } xml.AddNodeAttibute(elmColumn, "Width", setting.Columns[i].Width.ToString()); xml.AddNodeAttibute(elmColumn, "Left", setting.Columns[i].Left.ToString()); if (setting.Columns[i].Items != null && setting.Columns[i].Items.Length > 0) { for (int j = 0; j < setting.Columns[i].Items.Length; j++) { System.Xml.XmlElement elemItem = xml.AddXmlNode(doc, elmColumn, "Item", setting.Columns[i].Items[j]); } } } } return(doc.OuterXml); }
/// <summary> /// 保存操作员最后一次选择的操作类型、目标单位写入配置文件 /// </summary> /// <returns>成功返回1 失败返回-1</returns> public int SavePriv() { try { if (this.filePath == "") { return(1); } Neusoft.FrameWork.Xml.XML myXml = new Neusoft.FrameWork.Xml.XML(); System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); System.Xml.XmlElement root; if (System.IO.File.Exists(Application.StartupPath + this.filePath)) { //文件已存在 doc.Load(Application.StartupPath + this.filePath); root = (System.Xml.XmlElement)doc.SelectSingleNode("Setting"); } else { //文件不存在 //设置根结点 root = myXml.CreateRootElement(doc, "Setting", "1.0"); } System.Xml.XmlNode deptNode = doc.SelectSingleNode("/Setting/DeptInfo[@DeptID = '" + this.deptInfo.ID + "']"); if (deptNode != null) //存在科室节点 { System.Xml.XmlNode operNode = doc.SelectSingleNode("/Setting/DeptInfo[@DeptID = '" + this.deptInfo.ID + "']/OperInfo[@OperID = '" + this.operInfo.ID + "']"); if (operNode != null) //存在操作员节点 { //保存入库类型 operNode.ChildNodes[0].Attributes["ID"].Value = this.PrivType.ID; operNode.ChildNodes[0].Attributes["Name"].Value = this.privType.Name; //保存目标科室 operNode.ChildNodes[1].Attributes["ID"].Value = this.targetDept.ID; operNode.ChildNodes[1].Attributes["Name"].Value = this.targetDept.Name; //保存领送人 operNode.ChildNodes[2].Attributes["ID"].Value = this.targetPerson.ID; operNode.ChildNodes[2].Attributes["Name"].Value = this.targetPerson.Name; } else //不存在操作员节点 { #region 添加操作员节点 //在该科室内未找到该操作员历史信息 添加该操作员信息 System.Xml.XmlElement xmlNewOper = doc.CreateElement("OperInfo"); xmlNewOper.SetAttribute("OperID", this.operInfo.ID); //添加入库类型子节点 并赋值 System.Xml.XmlElement xmlPriv = doc.CreateElement("PrivType"); xmlPriv.SetAttribute("ID", this.privType.ID); xmlPriv.SetAttribute("Name", this.privType.Name); xmlNewOper.AppendChild(xmlPriv); //添加供货单位子节点 并赋值 System.Xml.XmlElement xmlOffer = doc.CreateElement("TargetDept"); xmlOffer.SetAttribute("ID", this.targetDept.ID); xmlOffer.SetAttribute("Name", this.targetDept.Name); xmlNewOper.AppendChild(xmlOffer); //添加领送人子节点 并赋值 System.Xml.XmlElement xmlPerson = doc.CreateElement("TargetPerson"); xmlPerson.SetAttribute("ID", this.targetPerson.ID); xmlPerson.SetAttribute("Name", this.targetPerson.Name); xmlNewOper.AppendChild(xmlPerson); //设置关联 ((System.Xml.XmlElement)deptNode).AppendChild(xmlNewOper); #endregion } } else { #region 添加科室节点 //该科室未找到 添加该科室、该操作员的配置信息 本次入库类型 供货单位 System.Xml.XmlElement xmlNewDept = doc.CreateElement("DeptInfo"); xmlNewDept.SetAttribute("DeptID", this.deptInfo.ID); //添加该操作员信息 System.Xml.XmlElement xmlNewOper1 = doc.CreateElement("OperInfo"); xmlNewOper1.SetAttribute("OperID", this.operInfo.ID); //添加入库类型子节点 并赋值 System.Xml.XmlElement xmlPriv1 = doc.CreateElement("PrivType"); xmlPriv1.SetAttribute("ID", this.privType.ID); xmlPriv1.SetAttribute("Name", this.privType.Name); //添加供货单位子节点 并赋值 System.Xml.XmlElement xmlOffer1 = doc.CreateElement("TargetDept"); xmlOffer1.SetAttribute("ID", this.targetDept.ID); xmlOffer1.SetAttribute("Name", this.targetDept.Name); //添加领送人子节点 并赋值 System.Xml.XmlElement xmlPerson = doc.CreateElement("TargetPerson"); xmlPerson.SetAttribute("ID", this.targetPerson.ID); xmlPerson.SetAttribute("Name", this.targetPerson.Name); xmlNewOper1.AppendChild(xmlPriv1); xmlNewOper1.AppendChild(xmlOffer1); xmlNewOper1.AppendChild(xmlPerson); xmlNewDept.AppendChild(xmlNewOper1); root.AppendChild(xmlNewDept); #endregion } doc.Save(Application.StartupPath + this.filePath); return(1); } catch (Exception ex) { MessageBox.Show(ex.Message); return(-1); } }