private void Get_FXrate(Hss_XML_obj xbrl) { if (xbrl == null) { return; } Hss_XML_obj fx_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:ForeignExchangeConversionRateForADRPayment"); if (fx_xo == null) { return; } decimal val = Helper_XML.Get_decimal(fx_xo, 0); if (val == 0) { return; } string unitRef = fx_xo.Get_attr("unitRef"); if (unitRef == null) { unitRef = ""; } unitRef = unitRef.ToUpper().Trim(); int index_usd = unitRef.IndexOf("USD"); if (index_usd == 0) { this.FXrate_US_to_foreign = val; this.FXrate_foreign_to_US = 1m / val; } else { this.FXrate_foreign_to_US = val; this.FXrate_US_to_foreign = 1m / val; } }
/// <summary> /// 安装软件 /// 流程:解压 修改配置文件 /// 适用:数据库\服务\应用程序\网络站点 /// </summary> /// <param name="stnm"></param> /// <param name="tcode"></param> /// <param name="ip"></param> /// <returns></returns> protected bool Install(string stnm, string tcode, string ip) { try { //解压 report.Add("解压缩..."); FileInfo fi_zip = GetZipFile_FromSource(name); if (fi_zip == null) { return(false); } Helper_Zip.UnZip(fi_zip.FullName, dir_deploy.FullName, "", true); //获取具体软件部署目录 DirectoryInfo dir_soft = GetDir_FromDeploy(name); //修改配置文件 if (list_mx.Count > 0) { report.Add("修改配置文件..."); foreach (modify_xml mx in list_mx) { try { if (string.IsNullOrWhiteSpace(mx.innerText)) { Helper_XML.ModifyAttr_ByID(dir_soft.FullName + "\\" + mx.path, mx.id, mx.attr, mx.value.Replace("@TelexCode", tcode).Replace("@IP", ip), mx.encode); report.Add("【" + mx.path + "】id:" + mx.id + "的属性" + mx.attr + "置为" + mx.value.Replace("@TelexCode", tcode).Replace("@IP", ip), "成功"); } else { Helper_XML.ModifyText_ByID(dir_soft.FullName + "\\" + mx.path, mx.id, mx.innerText.Replace("@TelexCode", tcode).Replace("@IP", ip), mx.encode); report.Add("【" + mx.path + "】id:" + mx.id + "的InnerText置为" + mx.innerText.Replace("@TelexCode", tcode).Replace("@IP", ip), "成功"); } } catch (Exception ex) { report.Error(mx.path, ex); continue; } } } //获取新版本号 FileInfo exe_new = GetFile_FromDeploy(name); if (exe_new != null) { report.Add("新版本:" + Common_Handle.GetExeVersion(exe_new.FullName)); } return(true); } catch (Exception e) { report.Error(comment + "安装[解压+修改配置文件]异常", e); return(false); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Save_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { ribbonControl1.Focus(); XmlDocument newdoc = new XmlDocument(); XmlDeclaration dec = newdoc.CreateXmlDeclaration("1.0", "UTF-8", null); newdoc.AppendChild(dec); XmlElement root = newdoc.CreateElement("root"); newdoc.AppendChild(root); //单独添加模板ID(模板ID是不允许修改,所以单独添加) XmlElement TemplateIDconfig = newdoc.CreateElement("config"); TemplateIDconfig.SetAttribute("id", "Template_ID"); TemplateIDconfig.SetAttribute("name", "模板ID"); TemplateIDconfig.SetAttribute("value", TemplateID); root.AppendChild(TemplateIDconfig); foreach (Template_Node_config cn in List_config) { XmlElement config = newdoc.CreateElement("config"); config.SetAttribute("id", cn.id); config.SetAttribute("name", cn.name); config.SetAttribute("value", cn.value); root.AppendChild(config); } foreach (Template_Node_software sn in List_software) { XmlElement software = newdoc.CreateElement("software"); software.SetAttribute("type", sn.type); software.SetAttribute("comment", sn.comment); software.SetAttribute("zipname", sn.zipname); software.SetAttribute("exename", sn.exename); software.SetAttribute("srvname", sn.srvname); software.SetAttribute("start", sn.start); software.SetAttribute("update", sn.update.ToString().ToLower()); root.AppendChild(software); if (sn.List_configXML != null && sn.List_configXML.Count > 0) { foreach (Template_SubNode_configXML subxn in sn.List_configXML) { XmlElement configXML = newdoc.CreateElement("configXML"); configXML.SetAttribute("filepath", subxn.filepath); configXML.SetAttribute("id", subxn.id); configXML.SetAttribute("attr", subxn.attr); configXML.SetAttribute("value", subxn.value); configXML.SetAttribute("encode", subxn.encode); configXML.SetAttribute("comment", subxn.comment); if (!string.IsNullOrWhiteSpace(subxn.innertext)) { configXML.InnerText = subxn.innertext; } software.AppendChild(configXML); } } } foreach (Template_Node_del dn in List_del) { XmlElement del = newdoc.CreateElement("del"); del.SetAttribute("path", dn.path); root.AppendChild(del); } using (MySqlConnection mycon = new MySqlConnection(CommonSetting.Default.ConStr_Inspection)) { mycon.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = mycon; cmd.CommandText = "UPDATE t_template SET Content='" + newdoc.OuterXml.Replace("\\", "$") + "' WHERE ID='" + TemplateID + "'"; if (cmd.ExecuteNonQuery() > 0) { XtraMessageBox.Show(" 保存成功!\r\r\n【注:模板中所有“\\”会自动转移为“$”进行存储】", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } cmd.CommandText = "SELECT * FROM t_template WHERE id='" + TemplateID + "';"; MySqlDataReader mdr = cmd.ExecuteReader(); if (mdr.HasRows) { mdr.Read(); memoEdit_XML.Text = Helper_XML.FormatXml(mdr["Content"].ToString().Replace("$", "\\"), "max"); TemplateContent = memoEdit_XML.Text; LoadTab_RelevantInfo(); } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } }
private void LoadTab_EditTemplate() { try { np_Main.SelectedPage = np_Setting_ConfigNodes; List_config = new List <Template_Node_config>(); List_software = new List <Template_Node_software>(); List_del = new List <Template_Node_del>(); #region XML预览 memoEdit_XML.Text = Helper_XML.FormatXml(TemplateContent, "max").Replace("$", @"\"); #endregion #region 模板节点内容加载 //基础节点加载 XmlNodeList configlist = doc.GetElementsByTagName("config"); foreach (XmlNode n in configlist) { Template_Node_config cn = new Template_Node_config(); cn.id = n.Attributes["id"].Value; cn.value = n.Attributes["value"].Value; cn.name = n.Attributes["name"].Value; if (cn.id == "Template_ID") { continue; } List_config.Add(cn); } BS_config.DataSource = List_config; gc_configNodes.DataSource = BS_config; //软件节点加载 XmlNodeList softwarelist = doc.GetElementsByTagName("software"); foreach (XmlNode n in softwarelist) { Template_Node_software sn = new Template_Node_software(); sn.type = n.Attributes["type"] != null ? n.Attributes["type"].Value : ""; sn.comment = n.Attributes["comment"] != null ? n.Attributes["comment"].Value : ""; sn.srvname = n.Attributes["srvname"] != null ? n.Attributes["srvname"].Value : ""; sn.zipname = n.Attributes["zipname"] != null ? n.Attributes["zipname"].Value : ""; sn.exename = n.Attributes["exename"] != null ? n.Attributes["exename"].Value : ""; sn.start = n.Attributes["start"] != null ? n.Attributes["start"].Value : ""; sn.update = n.Attributes["update"] != null?Convert.ToBoolean(n.Attributes["update"].Value) : false; if (n.ChildNodes.Count > 0) { sn.List_configXML = new List <Template_SubNode_configXML>(); foreach (XmlNode sub in n.ChildNodes) { Template_SubNode_configXML subxn = new Template_SubNode_configXML(); subxn.id = sub.Attributes["id"] != null ? sub.Attributes["id"].Value : ""; subxn.attr = sub.Attributes["attr"] != null ? sub.Attributes["attr"].Value : ""; subxn.encode = sub.Attributes["encode"] != null ? sub.Attributes["encode"].Value : ""; subxn.filepath = sub.Attributes["filepath"] != null ? sub.Attributes["filepath"].Value : ""; subxn.value = sub.Attributes["value"] != null ? sub.Attributes["value"].Value : ""; subxn.comment = sub.Attributes["comment"] != null ? sub.Attributes["comment"].Value : ""; subxn.innertext = !string.IsNullOrWhiteSpace(sub.InnerText) ? sub.InnerText : ""; if (!string.IsNullOrWhiteSpace(subxn.id) && !string.IsNullOrWhiteSpace(subxn.filepath) && (!string.IsNullOrWhiteSpace(subxn.attr) || !string.IsNullOrWhiteSpace(subxn.innertext))) { sn.List_configXML.Add(subxn); } else { continue; } } } List_software.Add(sn); } //* //*层级关系的关键是要就LevelName 与 对象列表名称一致 //*其他的GridView只是作为模板,并不加载数据 BS_software.DataSource = List_software; gc_softwareNodes.DataSource = BS_software; //删除文件节点加载 XmlNodeList dellist = doc.GetElementsByTagName("del"); foreach (XmlNode n in dellist) { Template_Node_del dn = new Template_Node_del(); dn.path = n.Attributes["path"] != null ? n.Attributes["path"].Value : ""; List_del.Add(dn); } BS_del.DataSource = List_del; gc_delNodes.DataSource = BS_del; #endregion } catch (Exception ex) { XtraMessageBox.Show("模板缺少关键节点或属性:" + ex.Message, "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Get_Fees(Hss_XML_obj xbrl) { if (xbrl == null) { return; } else { this.fee_list.Clear(); } List <Hss_XML_obj> WithholdingTaxPercentage_xoList = xbrl.Get_obj_list(this.XBRL_rootName, "ca:WithholdingTaxPercentage"); foreach (Hss_XML_obj xo in WithholdingTaxPercentage_xoList) { FeeInfo fi = new FeeInfo(); this.fee_list.Add(fi); fi.WithholdingTaxPercentage = Helper_XML.Get_decimal(xo, 0); } List <Hss_XML_obj> PayoutAmount_xoList = xbrl.Get_obj_list(this.XBRL_rootName, "ca:PayoutAmount"); for (int i = 0; i < this.fee_list.Count; ++i) { if (i >= PayoutAmount_xoList.Count) { break; } else { this.fee_list[i].PayoutAmount = Helper_XML.Get_decimal(PayoutAmount_xoList[i], 0); } } List <Hss_XML_obj> TaxAmountWithheldFromPayout_xoList = xbrl.Get_obj_list(this.XBRL_rootName, "ca:TaxAmountWithheldFromPayout"); for (int i = 0; i < this.fee_list.Count; ++i) { if (i >= TaxAmountWithheldFromPayout_xoList.Count) { break; } else { this.fee_list[i].TaxAmountWithheldFromPayout = Helper_XML.Get_decimal(TaxAmountWithheldFromPayout_xoList[i], 0); } } List <Hss_XML_obj> TaxReliefFee_xoList = xbrl.Get_obj_list(this.XBRL_rootName, "ca:TaxReliefFee"); for (int i = 0; i < this.fee_list.Count; ++i) { if (i >= TaxReliefFee_xoList.Count) { break; } else { this.fee_list[i].TaxReliefFee = Helper_XML.Get_decimal(TaxReliefFee_xoList[i], 0); } } List <Hss_XML_obj> FeeRate_xoList = xbrl.Get_obj_list(this.XBRL_rootName, "ca:FeeRate"); for (int i = 0; i < this.fee_list.Count; ++i) { if (i >= FeeRate_xoList.Count) { break; } else { this.fee_list[i].FeeRate = Helper_XML.Get_decimal(FeeRate_xoList[i], 0); } } List <Hss_XML_obj> PayoutAmountNetOfTax_xoList = xbrl.Get_obj_list(this.XBRL_rootName, "ca:PayoutAmountNetOfTax"); for (int i = 0; i < this.fee_list.Count; ++i) { if (i >= PayoutAmountNetOfTax_xoList.Count) { break; } else { this.fee_list[i].PayoutAmountNetOfTax = Helper_XML.Get_decimal(PayoutAmountNetOfTax_xoList[i], 0); } } List <Hss_XML_obj> DepositaryServiceFee_xoList = xbrl.Get_obj_list(this.XBRL_rootName, "ca:DepositaryServiceFee"); for (int i = 0; i < this.fee_list.Count; ++i) { if (i >= DepositaryServiceFee_xoList.Count) { break; } else { this.fee_list[i].DepositaryServiceFee = Helper_XML.Get_decimal(DepositaryServiceFee_xoList[i], 0); } } }
private void Parse_all_values(Hss_XML_obj xbrl) { Hss_XML_obj country_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:UnderlyingSecurityIssuerCountryofIncorporation"); if (country_xo != null) { this.ISO2CntryCode = country_xo.value; } this.Get_CUSIP(xbrl); /*----------------------------------------------------------------------------------------------------------------------*/ Hss_XML_obj sponsered_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:DepositoryReceiptSponsorIndicator"); this.Sponsored = Helper_XML.Get_bool(sponsered_xo); Hss_XML_obj IsFirstFiler_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:FirstFilerFlag"); this.IsFirstFiler = Helper_XML.Get_bool(IsFirstFiler_xo); /*----------------------------------------------------------------------------------------------------------------------*/ Hss_XML_obj PayDate_ADR_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:PaymentDate"); this.PayDate_ADR = Helper_XML.Get_datetime(PayDate_ADR_xo, "yyyy-MM-dd", Utility.MinDate); Hss_XML_obj ExDate_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:OrdExDividendDate"); this.ExDate = Helper_XML.Get_datetime(ExDate_xo, "yyyy-MM-dd", Utility.MinDate); Hss_XML_obj PayDate_ORD_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:OrdPaymentDate"); this.PayDate_ORD = Helper_XML.Get_datetime(PayDate_ORD_xo, "yyyy-MM-dd", Utility.MinDate); Hss_XML_obj RecordDate_ADR_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:RecordDate"); this.RecordDate_ADR = Helper_XML.Get_datetime(RecordDate_ADR_xo, "yyyy-MM-dd", Utility.MinDate); Hss_XML_obj RecordDate_ORD_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:OrdRecordDate"); this.RecordDate_ORD = Helper_XML.Get_datetime(RecordDate_ORD_xo, "yyyy-MM-dd", Utility.MinDate); /*----------------------------------------------------------------------------------------------------------------------*/ Hss_XML_obj ratio_ADR_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:ADRBase"); Hss_XML_obj ratio_ORD_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:OrdinaryShare"); this.ADR_Ratio_ADR = Helper_XML.Get_decimal(ratio_ADR_xo, 0); this.ADR_Ratio_ORD = Helper_XML.Get_decimal(ratio_ORD_xo, 0); this.Get_FXrate(xbrl); Hss_XML_obj StatutoryRate_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:WithholdingTaxPercentage"); this.StatutoryRate = Helper_XML.Get_decimal(StatutoryRate_xo, 0); /*----------------------------------------------------------------------------------------------------------------------*/ Hss_XML_obj EventCompleteness_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:EventCompleteness"); if (EventCompleteness_xo != null) { this.EventCompleteness = EventCompleteness_xo.value; } Hss_XML_obj EventType_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:EventType"); if (EventType_xo != null) { this.EventType = EventType_xo.value; } Hss_XML_obj DivGrossAmount_ORD_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:OrdinaryGrossDividendPayoutRate"); this.DivGrossAmount_ORD = Helper_XML.Get_decimal(DivGrossAmount_ORD_xo, 0); if (DivGrossAmount_ORD_xo != null) { this.PaidCurrency_ORD = DivGrossAmount_ORD_xo.Get_attr("UnitRef"); } Hss_XML_obj TickerSymbol_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:TradingSymbol"); if (TickerSymbol_xo != null) { this.TickerSymbol = TickerSymbol_xo.value; } Hss_XML_obj issue_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:SecurityDescription"); if (issue_xo != null) { this.Issue = issue_xo.value; } /*----------------------------------------------------------------------------------------------------------------------*/ Hss_XML_obj depo_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:DepositaryName"); if (depo_xo != null) { this.depoName = depo_xo.value; } Hss_XML_obj sender_xo = xbrl.Get_obj(this.XBRL_rootName, "xbrli:context", "xbrli:entity", "xbrli:identifier"); if (sender_xo != null) { this.Sender = sender_xo.value; } /*----------------------------------------------------------------------------------------------------------------------*/ Hss_XML_obj xbrl_ref_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:UniqueUniversalEventIdentifier"); if (xbrl_ref_xo != null) { this.XBRL_ReferenceNumber = xbrl_ref_xo.value; } Hss_XML_obj annType_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:AnnouncementType"); if (annType_xo != null) { this.AnnouncementType = annType_xo.value; } Hss_XML_obj annID_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:AnnouncementIdentifier"); if (annID_xo != null) { this.AnnouncementIdentifier = annID_xo.value; } Hss_XML_obj annDate_xo = xbrl.Get_obj(this.XBRL_rootName, "ca:AnnouncementDate"); this.AnnouncementDate = Helper_XML.Get_datetime(annDate_xo, "yyyy-MM-dd", Utility.MinDate); /****************************************/ this.Get_Fees(xbrl); }