/// <summary> /// 挂点文件上传 /// </summary> /// <param name="name"></param> public void CheckHangPointTemplate(string name) { TowerStrData tower = this.DataSource.Where(item => item.Name == name).SingleOrDefault(); OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.DefaultExt = ".xml"; // Required file extension fileDialog.Filter = "Text documents (.xml)|*.xml"; // Optional file extensions if (fileDialog.ShowDialog() == DialogResult.OK) { tower.HangPointName = Path.GetFileName(fileDialog.FileName); tower.HangPointFileExtension = Path.GetFileNameWithoutExtension(fileDialog.FileName) + "-" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + Path.GetExtension(fileDialog.FileName); UploadFile(tower, 2, fileDialog.FileName);//添加节点及负责相关文件 } }
protected void UpdateStruCalsParas(int index) { TowerSerial tower = TowerSerials[index]; string strucDirPath = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.StruCalsStr + "\\" + SequenceName; if (!Directory.Exists(strucDirPath)) { Directory.CreateDirectory(strucDirPath); } strucDirPath += "\\" + tower.TowerName; if (!Directory.Exists(strucDirPath)) { Directory.CreateDirectory(strucDirPath); } TowerStrData towerStr = GlobalInfo.GetInstance().GetLocalTowerStrByName(tower.TowerName); //复制结构计算的模板,结构计算的模板要从通用模板库里面复制 string struTempPathSce = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.DataBaseStr + "\\" + ConstVar.GeneralStruTemplateStr + "\\" + TowerTypeToString(tower.TowerType) + "\\" + towerStr.TempletName.Remove(0, 6) + ".dat"; string struTempPathDes = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.StruCalsStr + "\\" + SequenceName + "\\" + towerStr.Name + "\\" + ConstVar.StruCalsStr + "\\" + towerStr.TempletName.Remove(0, 6) + ".dat"; File.Copy(struTempPathSce, struTempPathDes); //复制应力计算模板文件,需要从TowerUploadFile下相应的塔文件里复制,一共需要复制三个文件:模板文件、data.ini、DataCh.ini string stressTempDirSce = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.DataBaseStr + "\\" + ConstVar.TowerUploadFileStr + "\\" + towerStr.Name + "[" + tower.TowerType.ToString() + "]\\"; string stressTempDirDes = ProjectUtils.GetInstance().ProjectPath + "\\" + ConstVar.StruCalsStr + "\\" + SequenceName + "\\" + towerStr.Name + "\\" + ConstVar.FullStressStr + "\\"; File.Copy(stressTempDirSce + towerStr.ModelFileExtension, stressTempDirDes + towerStr.ModelName); File.Copy(stressTempDirSce + ConstVar.SmartTowerIntFileName, stressTempDirDes + ConstVar.SmartTowerIntFileName); File.Copy(stressTempDirSce + ConstVar.SmartTowerIntCHFileName, stressTempDirDes + ConstVar.SmartTowerIntCHFileName); List <string> stressTempPathList = new List <string> { towerStr.ModelName, ConstVar.SmartTowerIntFileName, ConstVar.SmartTowerIntCHFileName }; //解码挂点参数 string hpSettingPath = stressTempDirSce + towerStr.HangPointFileExtension; List <HangingPointSettingParas> HPSettingsParas = XmlUtils.Deserializer <List <HangingPointSettingParas> >(hpSettingPath); ProjectUtils.GetInstance().NewStruCalsTower(towerStr.Name, SequenceName, ExcelPath, TowerTypeToString(tower.TowerType), ParaList[index].CommParas.Volt, struTempPathDes, stressTempPathList, HPSettingsParas); }
//更新塔序列参数 protected void UpdateTowerSerial(TowerSerial backTowerSerial, TowerSerial calsTowerSerial, out string waring) { TowerStrData towerStr = globalInst.GetLocalTowerStrByName(calsTowerSerial.TowerPattern); Appre = new ElecCalsTowerAppre() { UpSideInHei = towerStr.UpSideInHei, MidInHei = towerStr.MidInHei, DnSideInHei = towerStr.DnSideInHei, GrDHei = towerStr.GrDHei, UpSideJuHei = towerStr.UpSideJuHei, MidJuHei = towerStr.MidJuHei, DnSideJuHei = towerStr.DnSideJuHei, }; TowerElecCals tower = new TowerElecCals(); tower.SetPosInf(calsTowerSerial.TowerName, calsTowerSerial.TowerPattern, calsTowerSerial.CallItHigh, calsTowerSerial.TowerFootElevation, calsTowerSerial.BaseLevelDescent, TowerParas.RepStrIndLen, TowerParas.RepStrGrdLen, calsTowerSerial.TurningAngle); tower.SetFrontBackPosInf(calsTowerSerial.Span, calsTowerSerial.FrontPreSpan, backTowerSerial.Span, backTowerSerial.FrontPreSpan); waring = ""; }
/// <summary> /// 读取本地文件值 /// </summary> /// <param name="path"></param> /// <returns></returns> public static List <TowerStrData> ReadLoadFile(string path) { if (!File.Exists(path)) { return(new List <TowerStrData>()); } XmlDocument doc = new XmlDocument(); doc.Load(path); XmlNode rootNode = doc.GetElementsByTagName("Root")[0]; if (rootNode == null) { return(new List <TowerStrData>()); } List <TowerStrData> list = new List <TowerStrData>(); foreach (XmlNode node in rootNode.ChildNodes) { TowerStrData item = new TowerStrData(); if (node.Attributes["ID"] != null) { item.ID = Convert.ToInt32(node.Attributes["ID"].Value.ToString()); } if (node.Attributes["Name"] != null) { item.Name = node.Attributes["Name"].Value.ToString(); } if (node.Attributes["VoltageLevel"] != null) { item.VoltageLevel = Convert.ToInt32(node.Attributes["VoltageLevel"].Value.ToString()); } if (node.Attributes["Type"] != null) { item.Type = Convert.ToInt32(node.Attributes["Type"].Value.ToString()); } if (node.Attributes["TypeName"] != null) { item.TypeName = node.Attributes["TypeName"].Value.ToString(); } if (node.Attributes["CirNum"] != null) { item.CirNum = Convert.ToInt32(node.Attributes["CirNum"].Value.ToString()); } if (node.Attributes["CurType"] != null) { item.CurType = Convert.ToInt32(node.Attributes["CurType"].Value.ToString()); } if (node.Attributes["CalHeight"] != null) { item.CalHeight = Convert.ToInt32(node.Attributes["CalHeight"].Value.ToString()); } if (node.Attributes["MinHeight"] != null) { item.MinHeight = Convert.ToInt32(node.Attributes["MinHeight"].Value.ToString()); } if (node.Attributes["MaxHeight"] != null) { item.MaxHeight = Convert.ToInt32(node.Attributes["MaxHeight"].Value.ToString()); } if (node.Attributes["AllowedHorSpan"] != null) { item.AllowedHorSpan = Convert.ToInt32(node.Attributes["AllowedHorSpan"].Value.ToString()); } if (node.Attributes["OneSideMinHorSpan"] != null) { item.OneSideMinHorSpan = Convert.ToInt32(node.Attributes["OneSideMinHorSpan"].Value.ToString()); } if (node.Attributes["OneSideMaxHorSpan"] != null) { item.OneSideMaxHorSpan = Convert.ToInt32(node.Attributes["OneSideMaxHorSpan"].Value.ToString()); } if (node.Attributes["AllowedVerSpan"] != null) { item.AllowedVerSpan = Convert.ToInt32(node.Attributes["AllowedVerSpan"].Value.ToString()); } if (node.Attributes["OneSideMinVerSpan"] != null) { item.OneSideMinVerSpan = Convert.ToInt32(node.Attributes["OneSideMinVerSpan"].Value.ToString()); } if (node.Attributes["OneSideMaxVerSpan"] != null) { item.OneSideMaxVerSpan = Convert.ToInt32(node.Attributes["OneSideMaxVerSpan"].Value.ToString()); } if (node.Attributes["OneSideUpVerSpanMin"] != null) { item.OneSideUpVerSpanMin = Convert.ToInt32(node.Attributes["OneSideUpVerSpanMin"].Value.ToString()); } if (node.Attributes["OneSideUpVerSpanMax"] != null) { item.OneSideUpVerSpanMax = Convert.ToInt32(node.Attributes["OneSideUpVerSpanMax"].Value.ToString()); } if (node.Attributes["MinAngel"] != null) { item.MinAngel = Convert.ToInt32(node.Attributes["MinAngel"].Value.ToString()); } if (node.Attributes["MaxAngel"] != null) { item.MaxAngel = Convert.ToInt32(node.Attributes["MaxAngel"].Value.ToString()); } if (node.Attributes["DRepresentSpanMin"] != null) { item.DRepresentSpanMin = Convert.ToInt32(node.Attributes["DRepresentSpanMin"].Value.ToString()); } if (node.Attributes["DRepresentSpanMax"] != null) { item.DRepresentSpanMax = Convert.ToInt32(node.Attributes["DRepresentSpanMax"].Value.ToString()); } if (node.Attributes["StrHeightSer"] != null) { item.StrHeightSer = node.Attributes["StrHeightSer"].Value.ToString(); } if (node.Attributes["StrAllowHorSpan"] != null) { item.StrAllowHorSpan = node.Attributes["StrAllowHorSpan"].Value.ToString(); } if (node.Attributes["AngelToHorSpan"] != null) { item.AngelToHorSpan = Convert.ToInt32(node.Attributes["AngelToHorSpan"].Value.ToString()); } if (node.Attributes["MaxAngHorSpan"] != null) { item.MaxAngHorSpan = Convert.ToInt32(node.Attributes["MaxAngHorSpan"].Value.ToString()); } if (node.Attributes["UpSideInHei"] != null) { item.UpSideInHei = Convert.ToDouble(node.Attributes["UpSideInHei"].Value.ToString()); } if (node.Attributes["MidInHei"] != null) { item.MidInHei = Convert.ToDouble(node.Attributes["MidInHei"].Value.ToString()); } if (node.Attributes["DnSideInHei"] != null) { item.DnSideInHei = Convert.ToDouble(node.Attributes["DnSideInHei"].Value.ToString()); } if (node.Attributes["GrDHei"] != null) { item.GrDHei = Convert.ToDouble(node.Attributes["GrDHei"].Value.ToString()); } if (node.Attributes["UpSideJuHei"] != null) { item.UpSideJuHei = Convert.ToDouble(node.Attributes["UpSideJuHei"].Value.ToString()); } if (node.Attributes["MidJuHei"] != null) { item.MidJuHei = Convert.ToDouble(node.Attributes["MidJuHei"].Value.ToString()); } if (node.Attributes["DnSideJuHei"] != null) { item.DnSideJuHei = Convert.ToDouble(node.Attributes["DnSideJuHei"].Value.ToString()); } if (node.Attributes["TempletName"] != null)//结构计算模板 { item.TempletName = node.Attributes["TempletName"].Value.ToString(); } if (node.Attributes["ModelName"] != null)//结构计算模型 { item.ModelName = node.Attributes["ModelName"].Value.ToString(); } if (node.Attributes["ModelFileExtension"] != null)//结构计算模型 扩展名 年月日 { item.ModelFileExtension = node.Attributes["ModelFileExtension"].Value.ToString(); } if (node.Attributes["HangPointName"] != null)//挂点文件 { item.HangPointName = node.Attributes["HangPointName"].Value.ToString(); } if (node.Attributes["HangPointFileExtension"] != null)//挂点文件 扩展名 年月日 { item.HangPointFileExtension = node.Attributes["HangPointFileExtension"].Value.ToString(); } list.Add(item); } return(list); }
public static List <TowerStrCollection> Read(string path) { if (!File.Exists(path)) { return(new List <TowerStrCollection>()); } XmlDocument doc = new XmlDocument(); doc.Load(path); XmlNode rootNode = doc.GetElementsByTagName("Root")[0]; if (rootNode == null) { return(new List <TowerStrCollection>()); } List <TowerStrData> list = new List <TowerStrData>(); List <TowerStrCollection> collectionList = new List <TowerStrCollection>(); foreach (XmlNode colNode in rootNode.ChildNodes) { TowerStrCollection colItem = new TowerStrCollection() { Name = colNode.Attributes["Name"].Value.ToString(), Types = new List <TowerStrType>() }; foreach (XmlNode typeNode in colNode.ChildNodes) { TowerStrType typeItem = new TowerStrType() { Type = typeNode.Attributes["Type"].Value.ToString(), TowerStrs = new List <TowerStrData>() }; foreach (XmlNode node in typeNode.ChildNodes) { TowerStrData item = new TowerStrData(); if (node.Attributes["ID"] != null) { item.ID = Convert.ToInt32(node.Attributes["ID"].Value.ToString()); } if (node.Attributes["Name"] != null) { item.Name = node.Attributes["Name"].Value.ToString(); } if (node.Attributes["Type"] != null) { item.Type = int.Parse(node.Attributes["Type"].Value.ToString()); } if (node.Attributes["TypeName"] != null) { item.TypeName = node.Attributes["TypeName"].Value.ToString(); } if (node.Attributes["CirNum"] != null) { item.CirNum = Convert.ToInt32(node.Attributes["CirNum"].Value.ToString()); } if (node.Attributes["CurType"] != null) { item.CurType = Convert.ToInt32(node.Attributes["CurType"].Value.ToString()); } if (node.Attributes["CalHeight"] != null) { item.CalHeight = Convert.ToInt32(node.Attributes["CalHeight"].Value.ToString()); } if (node.Attributes["MinHeight"] != null) { item.MinHeight = Convert.ToInt32(node.Attributes["MinHeight"].Value.ToString()); } if (node.Attributes["MaxHeight"] != null) { item.MaxHeight = Convert.ToInt32(node.Attributes["MaxHeight"].Value.ToString()); } if (node.Attributes["AllowedHorSpan"] != null) { item.AllowedHorSpan = Convert.ToInt32(node.Attributes["AllowedHorSpan"].Value.ToString()); } if (node.Attributes["OneSideMinHorSpan"] != null) { item.OneSideMinHorSpan = Convert.ToInt32(node.Attributes["OneSideMinHorSpan"].Value.ToString()); } if (node.Attributes["OneSideMaxHorSpan"] != null) { item.OneSideMaxHorSpan = Convert.ToInt32(node.Attributes["OneSideMaxHorSpan"].Value.ToString()); } if (node.Attributes["AllowedVerSpan"] != null) { item.AllowedVerSpan = Convert.ToInt32(node.Attributes["AllowedVerSpan"].Value.ToString()); } if (node.Attributes["OneSideMinVerSpan"] != null) { item.OneSideMinVerSpan = Convert.ToInt32(node.Attributes["OneSideMinVerSpan"].Value.ToString()); } if (node.Attributes["OneSideMaxVerSpan"] != null) { item.OneSideMaxVerSpan = Convert.ToInt32(node.Attributes["OneSideMaxVerSpan"].Value.ToString()); } if (node.Attributes["OneSideUpVerSpanMin"] != null) { item.OneSideUpVerSpanMin = Convert.ToInt32(node.Attributes["OneSideUpVerSpanMin"].Value.ToString()); } if (node.Attributes["OneSideUpVerSpanMax"] != null) { item.OneSideUpVerSpanMax = Convert.ToInt32(node.Attributes["OneSideUpVerSpanMax"].Value.ToString()); } if (node.Attributes["MinAngel"] != null) { item.MinAngel = Convert.ToInt32(node.Attributes["MinAngel"].Value.ToString()); } if (node.Attributes["MaxAngel"] != null) { item.MaxAngel = Convert.ToInt32(node.Attributes["MaxAngel"].Value.ToString()); } if (node.Attributes["DRepresentSpanMin"] != null) { item.DRepresentSpanMin = Convert.ToInt32(node.Attributes["DRepresentSpanMin"].Value.ToString()); } if (node.Attributes["DRepresentSpanMax"] != null) { item.DRepresentSpanMax = Convert.ToInt32(node.Attributes["DRepresentSpanMax"].Value.ToString()); } if (node.Attributes["StrHeightSer"] != null) { item.StrHeightSer = node.Attributes["StrHeightSer"].Value.ToString(); } if (node.Attributes["StrAllowHorSpan"] != null) { item.StrAllowHorSpan = node.Attributes["StrAllowHorSpan"].Value.ToString(); } if (node.Attributes["AngelToHorSpan"] != null) { item.AngelToHorSpan = Convert.ToInt32(node.Attributes["AngelToHorSpan"].Value.ToString()); } if (node.Attributes["MaxAngHorSpan"] != null) { item.MaxAngHorSpan = Convert.ToInt32(node.Attributes["MaxAngHorSpan"].Value.ToString()); } typeItem.TowerStrs.Add(item); } colItem.Types.Add(typeItem); } collectionList.Add(colItem); } return(collectionList); }
/// <summary> /// 读取DBF源文件 /// </summary> /// <param name="dir">路径名</param> /// <returns></returns> public static List <TowerStrData> ReadImportFile(string sourcePath) { List <TowerStrData> towerStPraList = new List <TowerStrData>(); DataTable dataTable = DbfUtils.ReadDbf(sourcePath, ""); TowerStrData data = null; foreach (DataRow row in dataTable.Rows) { data = new TowerStrData(); data.Name = row["杆塔型号"].ToString().Split('-')[0]; data.Type = int.Parse(row["直线1耐张2"].ToString()); data.TypeName = int.Parse(row["直线1耐张2"].ToString()) == 1 ? "直线塔" : "转角塔"; data.VoltageLevel = row["电压等级"].ToString() == ""?0:double.Parse(row["电压等级"].ToString()); data.MaxAngel = row["最大转角"].ToString() == "" ? 0 : double.Parse(row["最大转角"].ToString()); data.MinHeight = row["呼高"].ToString() == "" ? 0 : double.Parse(row["呼高"].ToString()); //最小呼高 data.MaxHeight = row["呼高"].ToString() == "" ? 0 : double.Parse(row["呼高"].ToString()); //最大呼高 data.AllowedHorSpan = row["允许LH"].ToString() == "" ? 0 : double.Parse(row["允许LH"].ToString()); //设计水平档距 data.AllowedVerSpan = row["允许LV"].ToString() == "" ? 0 : double.Parse(row["允许LV"].ToString()); //最大垂直档距 data.StrHeightSer = row["呼高"].ToString(); //"直线塔呼高序列字符串" towerStPraList.Add(data); } var groups = towerStPraList.GroupBy(item => item.Name).ToList();//按塔型型号分组 towerStPraList = new List <TowerStrData>(); StringBuilder StrHeightSer = new StringBuilder(); //直线塔呼高序列字符串 StringBuilder StrAllowHorSpan = new StringBuilder(); //直线塔档距序列字符串 int index = 1, i = 0; foreach (var group in groups) { data = new TowerStrData(); data.ID = index; data.Name = group.Key; data.MaxHeight = group.Select(k => k.MaxHeight).Max(); data.MinHeight = group.Select(k => k.MinHeight).Min(); i = 0; foreach (TowerStrData item in group) { if (i == 0) { data.Type = item.Type; data.TypeName = item.TypeName; data.VoltageLevel = item.VoltageLevel; data.AllowedHorSpan = item.AllowedHorSpan; data.OneSideMinHorSpan = item.OneSideMinHorSpan; data.AllowedVerSpan = item.AllowedVerSpan; data.OneSideMaxVerSpan = item.OneSideMaxVerSpan; data.MaxAngel = item.MaxAngel; } StrHeightSer.Append(item.StrHeightSer + ","); StrAllowHorSpan.Append(item.AllowedHorSpan + ","); i++; } data.StrHeightSer = StrHeightSer.ToString().TrimEnd(','); data.StrAllowHorSpan = StrAllowHorSpan.ToString().TrimEnd(','); towerStPraList.Add(data); index++; } return(towerStPraList); }
//保存上传文件 /// <summary> /// 保存杆塔型号结构计算模型,挂点文件名称 /// </summary> /// <param name="tower">杆塔型号</param> /// <param name="type">1:结构计算模型 2:挂点文件</param> public void UploadFile(TowerStrData tower, int type, string uploadFilePath) { //加载xml文件 XmlDocument doc = new XmlDocument(); doc.Load(filePath); //获取到指定节点 XmlNodeList xmlNodeList = doc.GetElementsByTagName("Root")[0].ChildNodes; foreach (XmlNode xmlNode in xmlNodeList) { if (xmlNode.Attributes.GetNamedItem("Name").InnerXml == tower.Name && xmlNode.Attributes.GetNamedItem("Type").InnerXml == tower.Type.ToString()) { if (type == 1) //结构计算模型 { if (xmlNode.Attributes.GetNamedItem("ModelName") != null && xmlNode.Attributes.GetNamedItem("ModelName").InnerXml == tower.ModelName) //如果存在该节点,则修改 { xmlNode.Attributes.GetNamedItem("ModelName").InnerText = tower.ModelName; xmlNode.Attributes.GetNamedItem("ModelFileExtension").InnerText = tower.ModelFileExtension; } else//不存在则添加 { XmlAttribute xmlAttribute = doc.CreateAttribute("ModelName"); xmlAttribute.InnerText = tower.ModelName; xmlNode.Attributes.Append(xmlAttribute); XmlAttribute xmlAttribute1 = doc.CreateAttribute("ModelFileExtension"); xmlAttribute1.InnerText = tower.ModelFileExtension; xmlNode.Attributes.Append(xmlAttribute1); } } else//挂点文件 { if (xmlNode.Attributes.GetNamedItem("HangPointName") != null && xmlNode.Attributes.GetNamedItem("HangPointName").InnerXml == tower.HangPointName)//如果存在该节点,则修改 { xmlNode.Attributes.GetNamedItem("HangPointName").InnerXml = tower.HangPointName; xmlNode.Attributes.GetNamedItem("HangPointFileExtension").InnerText = tower.HangPointFileExtension; } else//不存在则添加 { XmlAttribute xmlAttribute = doc.CreateAttribute("HangPointName"); xmlAttribute.InnerText = tower.HangPointName; xmlNode.Attributes.Append(xmlAttribute); XmlAttribute xmlAttribute1 = doc.CreateAttribute("HangPointFileExtension"); xmlAttribute1.InnerText = tower.HangPointFileExtension; xmlNode.Attributes.Append(xmlAttribute1); } } break; } } //判断上传文件夹是否包含该 杆塔型号 文件夹,如果包含,直接保存到对应文件夹中,如不包含,穿件文件夹,并保存该上传文件 string uploadFolder = globalInfo.ProjectPath + @"\BaseData\TowerUploadFile\" + tower.Name + "[" + tower.Type + "]"; string sourceName = type == 1 ? (uploadFolder + @"\" + tower.ModelFileExtension) : (uploadFolder + @"\" + tower.HangPointFileExtension); if (File.Exists(uploadFolder)) { File.Copy(uploadFilePath, sourceName); } else { Directory.CreateDirectory(uploadFolder); File.Copy(uploadFilePath, sourceName); } doc.Save(filePath); }