//检测端口是否使用
public static bool VerifyListenerPort(int port)
{
bool inUse = false;
System.Net.NetworkInformation.IPGlobalProperties ipProperties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();
if (port > 65535) return true;// 超出范围
foreach (IPEndPoint endPoint in ipEndPoints)
{
if (endPoint.Port == port)
{
inUse = true;
break;
}
}
return inUse;
} public class rep_QueryACLReviewHistInfo
{
private int _result;
private string _errorDesc = "";
private long _histListNo;
private static int MAX_REVIEW_HIST_CNT = 100;
private ArrayWrapper<Typ_ACLReviewHistInfo> _histList = new ArrayWrapper<Typ_ACLReviewHistInfo>(MAX_REVIEW_HIST_CNT); public int result
{
get { return _result; }
set { _result = value; }
} public string errorDesc
{
get { return _errorDesc; }
set { _errorDesc = value; }
} public long histListNo
{
get { return _histListNo; }
set
{
if (value > MAX_REVIEW_HIST_CNT)
{
throw new Exception("histListNo must be less than MAX_REVIEW_HIST_CNT (100).");
}
_histListNo = value;
}
} public ArrayWrapper<Typ_ACLReviewHistInfo> histList
{
get { return _histList; }
}
}
public static bool rqst_QueryReviewHistInfo_to_XMLObject(rqst_QueryACLReviewHistInfo userData, ref string xmlStr, out string errDesc)
{
bool funcResult = false;
errDesc = "";
StringBuilder tmpStr = null;
StringWriter xmlWriter = null;
XmlTextWriter textWriter = null; try
{
tmpStr = new StringBuilder(xmlStr);
xmlWriter = new StringWriter();
textWriter = new XmlTextWriter(xmlWriter);
textWriter.WriteStartElement("msgBody");
textWriter.WriteElementString("instanceSysId", userData.instanceSysId);
textWriter.WriteElementString("reviewNo", userData.reviewNo.ToString()); textWriter.WriteEndElement();
xmlStr = tmpStr.Append(xmlWriter.ToString()).ToString();
funcResult = true;
}
catch (Exception e)
{
errDesc = e.Message;
funcResult = false;
}
finally
{
xmlWriter.Close();
textWriter.Close();
} return funcResult;
} public static bool rep_QueryReviewHistInfo_from_XMLObject(string xmlStr, ref rep_QueryACLReviewHistInfo userData, out string errDesc)
{
bool funcResult = false;
errDesc = "";
StringReader xmlReader = null;
XmlTextReader textReader = null;
Dictionary<string, bool> dicFlag = null;
bool OuterxmlFlag = false; try
{
xmlReader = new StringReader(xmlStr);
textReader = new XmlTextReader(xmlReader);
dicFlag = new Dictionary<string, bool>();
int histListIndex = 0; while (!textReader.EOF)
{
if (OuterxmlFlag == true)
{
OuterxmlFlag = false;
}
else
{
textReader.Read();
} dicFlag[textReader.Name] = true;
if (textReader.IsEmptyElement)
{
continue;
} if (textReader.NodeType == XmlNodeType.Element)
{
switch (textReader.Name)
{
case "result":
userData.result = int.Parse(textReader.ReadString());
break; case "errorDesc":
userData.errorDesc = textReader.ReadString();
break; case "histListNo":
userData.histListNo = int.Parse(textReader.ReadString());
break; case "histList":
string tempStr = textReader.ReadOuterXml();
OuterxmlFlag = true;
Typ_ACLReviewHistInfo temp_Typ_ACLReviewHistInfo = new Typ_ACLReviewHistInfo();
if (MsgTyp.Typ_ACLReviewHistInfo_from_XMLObject(tempStr, ref temp_Typ_ACLReviewHistInfo, out errDesc))
{
userData.histList[histListIndex] = temp_Typ_ACLReviewHistInfo;
histListIndex++;
}
else
{
return false;
}
break;
}
}
} if (!dicFlag.ContainsKey("result"))
{
errDesc = "rep_QueryACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'result' not found";
return funcResult;
} if (!dicFlag.ContainsKey("errorDesc"))
{
errDesc = "rep_QueryACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'errorDesc' not found";
return funcResult;
} if (!dicFlag.ContainsKey("histListNo"))
{
errDesc = "rep_QueryACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'histListNo' not found";
return funcResult;
} if (userData.histListNo > 0)
{
if (!dicFlag.ContainsKey("histList"))
{
errDesc = "rep_QueryACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'histList' not found";
return funcResult;
}
} funcResult = true;
}
catch (Exception e)
{
errDesc = e.Message;
funcResult = false;
}
finally
{
xmlReader.Close();
textReader.Close();
} return funcResult;
} public static bool Typ_ACLReviewHistInfo_from_XMLObject(string xmlStr, ref Typ_ACLReviewHistInfo userData, out string errDesc)
{
bool funcResult = false;
errDesc = "";
StringReader xmlReader = null;
XmlTextReader textReader = null;
Dictionary<string, bool> dicFlag = null; try
{
xmlReader = new StringReader(xmlStr);
textReader = new XmlTextReader(xmlReader);
dicFlag = new Dictionary<string, bool>(); while (!textReader.EOF)
{
textReader.Read(); dicFlag[textReader.Name] = true;
if (textReader.IsEmptyElement)
{
continue;
} if (textReader.NodeType == XmlNodeType.Element)
{
switch (textReader.Name)
{
case "userId":
userData.userId = textReader.ReadString();
break; case "activity":
userData.activity = textReader.ReadString();
break; case "txnTime":
userData.txnTime = textReader.ReadString();
break; case "txnComment":
userData.txnComment = textReader.ReadString();
break; case "costTime":
userData.costTime = textReader.ReadString();
break; case "choosedPathDesc":
userData.choosedPathDesc = textReader.ReadString();
break; case "reviewNo":
userData.reviewNo = textReader.ReadString();
break; case "stepSeq":
userData.stepSeq = textReader.ReadString();
break; case "stepName":
userData.stepName = textReader.ReadString();
break; case "txnSysId":
userData.txnSysId = textReader.ReadString();
break;
}
}
} if (!dicFlag.ContainsKey("userId"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'userId' not found";
return funcResult;
} if (!dicFlag.ContainsKey("activity"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'activity' not found";
return funcResult;
} if (!dicFlag.ContainsKey("txnTime"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'txnTime' not found";
return funcResult;
} if (!dicFlag.ContainsKey("txnComment"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'txnComment' not found";
return funcResult;
} if (!dicFlag.ContainsKey("costTime"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'costTime' not found";
return funcResult;
} if (!dicFlag.ContainsKey("choosedPathDesc"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'choosedPathDesc' not found";
return funcResult;
} if (!dicFlag.ContainsKey("reviewNo"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'reviewNo' not found";
return funcResult;
} if (!dicFlag.ContainsKey("stepSeq"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'stepSeq' not found";
return funcResult;
} if (!dicFlag.ContainsKey("stepName"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'stepName' not found";
return funcResult;
} if (!dicFlag.ContainsKey("txnSysId"))
{
errDesc = "Typ_ACLReviewHistInfo_from_XMLObject: Parse from XML failed,item 'txnSysId' not found";
return funcResult;
} funcResult = true;
}
catch (Exception e)
{
errDesc = e.Message;
funcResult = false;
}
finally
{
xmlReader.Close();
textReader.Close();
} return funcResult;
} public static void Typ_MsgHdr_to_XMLObject(Typ_MsgHdr userData, out string XmlMsgStr)
{
XmlMsgStr = ""; try
{
XElement MsgHeader = XElement.Parse(SFWUtility.SFW_MSG_HEADER);
MsgHeader.Element(SFWUtility.SFW_MSG_SRVADDR).Value = userData.SrvAddr;
MsgHeader.Element(SFWUtility.SFW_MSG_REQADDR).Value = userData.ReqAddr;
MsgHeader.Element(SFWUtility.SFW_MSG_MESSAGEOWNER).Value = userData.MsgOwner;
MsgHeader.Element(SFWUtility.SFW_MSG_SERVERMETHOD).Value = userData.SrvMethod;
MsgHeader.Element(SFWUtility.SFW_MSG_SERVERID).Value = userData.SrvId;
MsgHeader.Element(SFWUtility.SFW_MSG_TIMESTAMP).Value = userData.TimeStamp.ToString();
MsgHeader.Element(SFWUtility.SFW_MSG_TIMEOUT).Value = userData.Timeout.ToString();
MsgHeader.Element(SFWUtility.SFW_MSG_TRANSID).Value = userData.TransId.ToString();
MsgHeader.Element(SFWUtility.SFW_MSG_LOCALE).Value = userData.Locale;
MsgHeader.Element(SFWUtility.SFW_MSG_RETCODE).Value = ((int)userData.RetCode).ToString();
MsgHeader.Element(SFWUtility.SFW_MSG_RETMSG).Value = userData.RetMsg;
XmlMsgStr = MsgHeader.ToString(SaveOptions.DisableFormatting);
}
catch (Exception e)
{
Log.WriteLog(MethodBase.GetCurrentMethod().ReflectedType.ToString() + ": " + MethodBase.GetCurrentMethod().Name + ": " + e.Message);
}
} public static void Typ_MsgHdr_from_XMLObject(string XmlMsgStr, out Typ_MsgHdr userData)
{
userData = new Typ_MsgHdr(); try
{
XElement MsgHeader = XElement.Parse(XmlMsgStr);
userData.SrvAddr = MsgHeader.Element(SFWUtility.SFW_MSG_SRVADDR).Value;
userData.ReqAddr = MsgHeader.Element(SFWUtility.SFW_MSG_REQADDR).Value;
userData.MsgOwner = MsgHeader.Element(SFWUtility.SFW_MSG_MESSAGEOWNER).Value;
userData.SrvMethod = MsgHeader.Element(SFWUtility.SFW_MSG_SERVERMETHOD).Value;
userData.SrvId = MsgHeader.Element(SFWUtility.SFW_MSG_SERVERID).Value;
userData.TimeStamp = Convert.ToDateTime(MsgHeader.Element(SFWUtility.SFW_MSG_TIMEOUT).Value);
userData.Timeout = int.Parse(MsgHeader.Element(SFWUtility.SFW_MSG_TIMEOUT).Value);
userData.TransId = int.Parse(MsgHeader.Element(SFWUtility.SFW_MSG_TRANSID).Value);
userData.Locale = MsgHeader.Element(SFWUtility.SFW_MSG_LOCALE).Value;
userData.RetCode = int.Parse(MsgHeader.Element(SFWUtility.SFW_MSG_RETCODE).Value);
}
catch (Exception e)
{
Log.WriteLog(MethodBase.GetCurrentMethod().ReflectedType.ToString() + ": " + MethodBase.GetCurrentMethod().Name + ": " + e.Message);
}
}

  

Helper的更多相关文章

  1. [C#] 简单的 Helper 封装 -- RegularExpressionHelper

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  2. handlebars自定义helper的写法

    handlebars相对来讲算一个轻量级.高性能的模板引擎,因其简单.直观.不污染HTML的特性,我个人特别喜欢.另一方面,handlebars作为一个logicless的模板,不支持特别复杂的表达式 ...

  3. Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value '"*, Microsoft.AspNet.Mvc.TagHelpers"'

    project.json 配置: { "version": "1.0.0-*", "compilationOptions": { " ...

  4. VS2015突然报错————Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value 'Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper

    Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with ...

  5. JavaScript模板引擎artTemplate.js——template.helper()方法

    上一篇文章我们已经讲到了helper()方法,但是上面的例子只是一个参数的写法,如果是多个参数,写法就另有区别了. <div id="user_info"></d ...

  6. [ASP.NET MVC 小牛之路]13 - Helper Method

    我们平时编程写一些辅助类的时候习惯用“XxxHelper”来命名.同样,在 MVC 中用于生成 Html 元素的辅助类是 System.Web.Mvc 命名空间下的 HtmlHelper,习惯上我们把 ...

  7. asp.net MVC helper 和自定义函数@functions小结

    asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...

  8. C# random helper class

      项目中经常需要模拟些假数据,来做测试.这个随机生成数据的helper类就应用而生: using System; using System.Text; using System.Windows.Me ...

  9. @helper函数使用方法

    这个函数方法,我也是通过别人博客看到的,感觉不错和大家一起学习分享一下. 1.自定义函数方法,只在同一个view视图文件里调用 Controller public ActionResult Index ...

  10. Razor 中的@helper 与 @function 用法

    @helper : 可以有返回值,也可以没有返回值 @function :需要有返回值 可以将View中公共部分的代码抽取出来,变成一个独立的方法   公共部分 view        抽出的公共部分 ...

随机推荐

  1. 1.1开篇一:C语言编译器的选择---Dev C++

    返回总目录 目录: 1.Dev C++的下载&安装: 2.Dev C++的使用: 前言: 那么多编译器,为什么选择Dev C++?理由有下 理由一:Dev C++ 体积比较小,不占用太多的内存 ...

  2. vSphere ESXi 重新安装后的虚拟机恢复(转载)

    安装的 ESXi 的物理主机密码忘记,登录 不上了,需要重新安装 ESXi,安装后恢复原先物理主机上的 虚拟机的方法如下(VMFS分区完好): 关于 VMFS 分区: ESXi 的安装时会划分一个分区 ...

  3. [TJOI2018]教科书般的亵渎

    嘟嘟嘟 题面挺迷的,拿第一个样例说一下: 放第一次亵渎,对答案产生了\(\sum_{i = 1} ^ {10} i ^ {m + 1} - 5 ^ {m + 1}\)的贡献,第二次亵渎产生了\(\su ...

  4. pek (北大oj)3070

    思路:矩阵快速幂, 二分加速 #include<cstdio> #include<cstring> #define ll long long #define mod 10000 ...

  5. linux(centos 7)下安装elasticsearch - head插件(端口占用,防火墙关闭)

    本文章来自网络仅供个人学习记录之用 一:安装Git(如果未安装) 1, yum install git 2, git --version #查看版本 二:安装node(如果未安装) node安装 三: ...

  6. data函数参数

    date(format,timestamp); 参数 描述 format 必需.规定输出日期字符串的格式.可使用下列字符: d - 一个月中的第几天(从 01 到 31) D - 星期几的文本表示(用 ...

  7. centos断网调试

    保存命令 按ESC键 跳到命令模式,然后: :w 保存文件但不退出vi:w file 将修改另外保存到file中,不退出vi:w! 强制保存,不推出vi:wq 保存文件并退出vi:wq! 强制保存文件 ...

  8. k8s监控api调用

    k8s监控api调用 curl -s --cacert /etc/kubernetes/ssl/ca.pem -basic -u fengjian:fengjian --insecure -X GET ...

  9. go标准库的学习-database/sql

    参考:https://studygolang.com/pkgdoc 导入方式: import "database/sql" sql包提供了保证SQL或类SQL数据库的泛用接口. 使 ...

  10. ES5与ES6对比

    ES5与ES6对比 1. 模块引用 1.在ES5里,引入React包基本通过require进行,代码类似这样: // ES5 var React = require('react'); var { C ...