/// <summary> /// 返回URL的访问地址 /// </summary> /// <param name="uri">服务的地址或者IP</param> /// <param name="path">服务地址</param> /// <returns>address字符串</returns> private String GetWebRequestAddress(String uri, String path) { String address = String.Empty; if (!SIString.IsNullOrEmptyOrDBNull(uri) && !SIString.IsNullOrEmptyOrDBNull(path)) { if (uri.EndsWith(@"/")) { address = string.Format(@"{0}{1}", uri, path); } else { address = string.Format(@"{0}/{1}", uri, path); } } return(address); }
/// <summary> /// 初始化门店调用服务信息、门店、POS信息 /// </summary> /// <returns></returns> public static long InitEnvironment() { try { //门店POS配置文件 String xmlpath = Application.StartupPath + @"\" + Gattr.ApplicationXml; //流水号文件 Gattr.FlowNoFile = Application.StartupPath + @"\flowno.isf"; //是否启动双屏模块 //Gattr.IsDoubleModule = false; CheckSysInfo(); InitSysIni(); string[] nodePaths = new string[1]; nodePaths[0] = "//applicationConfig/BranchNo"; Dictionary <String, String> dic = XMLUtility.Instance.GetNodesText(xmlpath, nodePaths); LoggerHelper.Log("MsmkLogger", "开始检测是否需要更新配置信息", LogEnum.InitLog); if (dic == null || SIString.IsNullOrEmptyOrDBNull(dic[nodePaths[0]])) { LoggerHelper.Log("MsmkLogger", "更新配置信息开始Start", LogEnum.InitLog); FrmInitData frmInitData = new FrmInitData(); if (frmInitData.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { LoggerHelper.Log("MsmkLogger", "取消配置信息Cancel", LogEnum.InitLog); return(-1); } //if (frmInitData.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) LoggerHelper.Log("MsmkLogger", "更新配置信息完成End", LogEnum.InitLog); } //if (SIString.IsNullOrEmptyOrDBNull(dic[nodePaths[0]])) LoggerHelper.Log("MsmkLogger", "读取配置信息开始Start", LogEnum.InitLog); nodePaths = new string[3]; nodePaths[0] = "//applicationConfig/ServerUrl"; nodePaths[1] = "//applicationConfig/BranchNo"; nodePaths[2] = "//applicationConfig/PosId"; dic = XMLUtility.Instance.GetNodesText(xmlpath, nodePaths); //Gattr.HttpAddress = dic[nodePaths[0]]; Gattr.serverUrl = dic[nodePaths[0]]; Gattr.BranchNo = dic[nodePaths[1]]; Gattr.PosId = dic[nodePaths[2]]; string err = string.Empty; //获取二维码支付html Gattr.PayHtml = FileUtility.Instance.GetFileContent(Application.StartupPath + @"\pay.htm", ref err); LoggerHelper.Log("MsmkLogger", "读取配置信息完成End", LogEnum.InitLog); string errorMessage1 = string.Empty; if (!PosServericeBll.Instance.ValidatePos(Gattr.BranchNo, Gattr.PosId, ref errorMessage1)) { MessageBox.Show(errorMessage1, Gattr.AppTitle); return(-3); } //if (!ValidatePos(Gattr.BranchNo, Gattr.PosId)) //{ // return -3; //} bool isok = true; string errorMessage = string.Empty; Dictionary <string, object> _dicParameters = GetServiceParameter(); _dicParameters.Add("branch_no", Gattr.BranchNo); _dicParameters.Add("posid", Gattr.PosId); string result = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Getadurl", _dicParameters, ref isok, ref errorMessage); if (isok) { if (result != "-10" && result != "-20" && result != "404") { Gattr.adUrl = result; } } else { LoggerHelper.Log("MsmkLogger", "读取门店广告信息错误:" + errorMessage, LogEnum.InitLog); } //Gattr.adUrl } catch (Exception) { return(-2); } return(1); }