public Tease LoadTease(string scriptFileName) { Tease result = null; string fileContents = File.ReadAllText(scriptFileName); if (fileContents.StartsWith("<?xml")) { var xmldoc = new ConfigXmlDocument(); xmldoc.LoadXml(fileContents); if (xmldoc.DocumentElement != null) { if (xmldoc.DocumentElement.LocalName == "Tease") { // Current file format. if (xmldoc.DocumentElement.SelectSingleNode(String.Format("/Tease[@scriptVersion='{0}']", SupportedScriptVersion)) != null) { using (var reader = new StreamReader(scriptFileName)) { result = new XmlSerializer(typeof(Tease)).Deserialize(reader) as Tease; } } } } } if (result != null) { result.ScriptDirectory = new FileInfo(scriptFileName).DirectoryName; Environment.CurrentDirectory = result.ScriptDirectory; } return result; }
public Tease LoadTease(string scriptFileName) { Tease result = null; string fileContents = File.ReadAllText(scriptFileName); if (fileContents.StartsWith("<?xml")) { var xmldoc = new ConfigXmlDocument(); xmldoc.LoadXml(fileContents); if (xmldoc.DocumentElement != null) { if (xmldoc.DocumentElement.LocalName == "Tease") { // Current file format. if (xmldoc.DocumentElement.SelectSingleNode(String.Format("/Tease[@scriptVersion='{0}']", SupportedScriptVersion)) != null) { using (var reader = new StreamReader(scriptFileName)) { result = new XmlSerializer(typeof(Tease)).Deserialize(reader) as Tease; } } } if (xmldoc.DocumentElement.LocalName == "pages") { // Previous file format. var converter = new OldScriptConverter(fileContents); if (converter.CanConvert()) { result = converter.ConvertToTease(); var sourceFileName = new FileInfo(scriptFileName); var destFileName = sourceFileName.Name.BeforeLast(sourceFileName.Extension) + "-v0_0_5" + sourceFileName.Extension; string message = "The tease you selected is made for a previous version of this application. " + "Do you want to convert it to the current file format?\n" + "\n" + "Your old file will be renamed to " + destFileName; if (DialogResult.Yes == MessageBox.Show(message, "Save tease in new file format?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { File.Move(scriptFileName, Path.Combine(sourceFileName.DirectoryName, destFileName)); SaveTease(result, sourceFileName.FullName); } } } } } if (result != null) { result.ScriptDirectory = new FileInfo(scriptFileName).DirectoryName; Environment.CurrentDirectory = result.ScriptDirectory; } return result; }
public static XmlElement GetCfgXml() { var cfgXml = new ConfigXmlDocument(); try { cfgXml.Load(cfgFile); if(cfgXml.DocumentElement["version"].InnerText != nowVersion) { System.IO.File.Delete(cfgFile); throw new System.IO.FileNotFoundException(); } } catch(System.IO.FileNotFoundException) { cfgXml.LoadXml("<?xml version='1.0' encoding='utf-8' ?><gamecfg><version>" + nowVersion + "</version><GameRiver><isWhiteFirst>0</isWhiteFirst><player1><type>auto</type><name>匿名玩家</name><AIdt>1000</AIdt><server>false</server><port>8047</port><ip>192.168.1.101</ip></player1><player2><type>local</type><name>匿名玩家</name><AIdt>1000</AIdt><server>false</server><port>8047</port><ip>192.168.1.101</ip></player2></GameRiver></gamecfg>"); } return cfgXml.DocumentElement; }
/// <summary> /// Builds the configuration section XmlNode given an Xml string. /// </summary> /// <param name="xml">The XML string</param> /// <returns>The XmlNode of the document corresponding to the string.</returns> private static XmlNode BuildConfigurationSection(string xml) { ConfigXmlDocument doc = new ConfigXmlDocument(); doc.LoadXml(xml); return doc.DocumentElement; }
/// <summary> /// 出金操作--融宝支付 /// </summary> /// <param name="batchCurrnum">批次号50位长度,当日不能重复</param> /// <param name="batchAmount">金额精确到元 金额保留两位小数,逗号输入时用英文半角</param> /// <param name="number">序号可任意填写,不重复即可</param> /// <param name="card_no">持卡人银行账号</param> /// <param name="owner">持卡人银行保留姓名</param> /// <param name="bankName">持卡人开户银行</param> /// <param name="bankBranchName">持卡人开户分行没有可为空</param> /// <param name="bankBranch2Name">持卡人开户支行没有可为空</param> /// <param name="province">省</param> /// <param name="city">市</param> /// <param name="phone">手机号</param> /// <param name="cert_type">证件类型:'身份证';'户口簿';'护照';'军官证';'士兵证';'台胞证'</param> /// <param name="cert_no">证件号</param> /// <param name="order_no">商户订单号</param> /// <param name="body">备注</param> /// <param name="isPrivate">是否是私人账户(公/私)</param> /// <param name="currency">币种(暂时只知道人名币是CNY)</param> /// <param name="protocolNumber">用户协议号(不可重复)12位以内</param> private static RequestResult goldMoney(string batchCurrnum, string batchAmount, string number, string card_no, string owner, string bankName, string bankBranchName, string bankBranch2Name, string province, string city, string phone, string cert_type, string cert_no, string order_no, string body, string isPrivate, string currency, string protocolNumber) { RequestResult requesResult = new RequestResult(); //地址 string url = ConfigurationManager.AppSettings["dsfpay"].ToString(); //商户号 string batchBizid = ConfigurationManager.AppSettings["batchBizid"].ToString(); string key = ConfigurationManager.AppSettings["user_key"].ToString(); string signType = "MD5"; ; //签名方式 string _input_charset = "gbk";//编码 string batchBiztype = "00000";//提交批次类型 string batchDate = DateTime.Now.ToString("yyyyMMdd");//提交日期 string batchVersion = "00";//版本号 string batchCount = "1";//数量 #region MyRegion string batchContent = number + "," + card_no + "," + owner + "," + bankName + "," + bankBranchName + "," + bankBranch2Name + "," + isPrivate + "," + batchAmount + "," + currency + "," + province + "," + city + "," + phone + "," + cert_type + "," + cert_no + "," + protocolNumber + "," + order_no; string easypay_url = EasyPay.CreatPayUrlto( signType, batchBizid, _input_charset, batchBiztype, batchDate, batchVersion, batchCurrnum, batchContent, key ); string newEasypay_url = ""; string[] patten1 = easypay_url.Split('&'); for (int i = 0; i < patten1.Length; i++) { if (patten1[i].IndexOf("batchContent") == -1) { if (i == 0) { newEasypay_url += patten1[i]; } else { newEasypay_url += "&" + patten1[i]; } } else { newEasypay_url += "&batchContent=" + HttpUtility.UrlEncode( RSAEncryption( number + "," + card_no + "," + owner + "," + bankName + "," + bankBranchName + "," + bankBranch2Name + "," + isPrivate + "," + batchAmount + "," + currency + "," + province + "," + city + "," + phone + "," + cert_type + "," + cert_no + "," + protocolNumber + "," + order_no), System.Text.Encoding.Default); } } //post提交返回结果 string returnPayValue = PostDataGetHtml(newEasypay_url, url); ConfigXmlDocument xx = new ConfigXmlDocument(); xx.LoadXml(returnPayValue); string result = ""; XmlNodeList xxList = xx.GetElementsByTagName("Resp"); //取得节点名为Resp的XmlNode集合 foreach (XmlNode xxNode in xxList) { XmlNodeList childList = xxNode.ChildNodes; //取得Resp下的子节点集合 foreach (XmlNode xxNodes in childList) { result += xxNodes.InnerText + "|"; //返回的是Resp下的子节点的文字内容 } } string[] results = result.Split('|'); if (returnPayValue.IndexOf("fail") > -1) { requesResult.IsSuccess = false; requesResult.ErrMsg = results[1]; } else { requesResult.IsSuccess = true; requesResult.ErrMsg = "操作成功"; } return requesResult; #endregion }