/// <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); }
/// <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); }