Exemplo n.º 1
0
        public Packet(LOG_INFO logInfo)
        {
            this.ArrivalTime = DateTime.Now;
            this.Protocol = (IpProtocol) logInfo.m_Protocol;
            this.ProcessName = logInfo.m_szProcessName;

            if (logInfo.m_EvtType == TDIFLT_EVENT_TYPE.TDI_EVT_SND
                || logInfo.m_EvtType == TDIFLT_EVENT_TYPE.TDI_EVT_SND_DGM)
            {
                this.PacketDirection = PacketDirection.Uploading;
            }
            else
            {
                this.PacketDirection = PacketDirection.Downloading;
            }

            if(this.PacketDirection == PacketDirection.Downloading)
            {
                this.SourceIpAddress = GetIpAddress(logInfo.m_RemoteAddress.m_Ip, logInfo.m_RemoteAddress.m_Port);
                this.DestinationIpAddress = GetIpAddress(logInfo.m_LocalAddress.m_Ip, logInfo.m_LocalAddress.m_Port);
            }
            else
            {
                this.SourceIpAddress = GetIpAddress(logInfo.m_LocalAddress.m_Ip, logInfo.m_LocalAddress.m_Port);
                this.DestinationIpAddress = GetIpAddress(logInfo.m_RemoteAddress.m_Ip, logInfo.m_RemoteAddress.m_Port);
            }

            this.Size = (int)logInfo.m_DataLength;
        }
Exemplo n.º 2
0
        public Packet(LOG_INFO logInfo)
        {
            this.ArrivalTime = DateTime.Now;
            this.Protocol    = (IpProtocol)logInfo.m_Protocol;
            this.ProcessName = logInfo.m_szProcessName;

            if (logInfo.m_EvtType == TDIFLT_EVENT_TYPE.TDI_EVT_SND ||
                logInfo.m_EvtType == TDIFLT_EVENT_TYPE.TDI_EVT_SND_DGM)
            {
                this.PacketDirection = PacketDirection.Uploading;
            }
            else
            {
                this.PacketDirection = PacketDirection.Downloading;
            }

            if (this.PacketDirection == PacketDirection.Downloading)
            {
                this.SourceIpAddress      = GetIpAddress(logInfo.m_RemoteAddress.m_Ip, logInfo.m_RemoteAddress.m_Port);
                this.DestinationIpAddress = GetIpAddress(logInfo.m_LocalAddress.m_Ip, logInfo.m_LocalAddress.m_Port);
            }
            else
            {
                this.SourceIpAddress      = GetIpAddress(logInfo.m_LocalAddress.m_Ip, logInfo.m_LocalAddress.m_Port);
                this.DestinationIpAddress = GetIpAddress(logInfo.m_RemoteAddress.m_Ip, logInfo.m_RemoteAddress.m_Port);
            }

            this.Size = (int)logInfo.m_DataLength;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置model值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="strContent"></param>
        /// <returns></returns>
        public T ParaSetModelValue <T>(T t, string strType, string strContent)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(strContent);

                PropertyInfo[] pps    = GetPropertyInfos(t.GetType());
                Type           target = t.GetType();

                XmlNode xn = doc.SelectSingleNode("//" + strType);

                XmlNodeList nodes = xn.ChildNodes;
                if (nodes.Count > 0)
                {
                    List <string> lstError = new List <string>();
                    foreach (XmlNode v in nodes)
                    {
                        try
                        {
                            PropertyInfo targetPP = target.GetProperty(v.Name);
                            object       objValue = v.InnerText;
                            if (objValue != null && string.IsNullOrEmpty(objValue.ToString()) == false)
                            {
                                targetPP.SetValue(t, SD_ChanageType(objValue, targetPP.PropertyType), null);
                            }
                        }
                        catch (Exception ee)
                        {
                            lstError.Add(" 项目:[" + v.Name + "], 值:[" + v.InnerText + "]转换失败.");
                            continue;
                        }
                    }

                    #region 日志记录
                    string   strCategory = Log.LogType.NetUpDown.ToString();
                    LOG_INFO logInfo     = new LOG_INFO();
                    logInfo.Category  = strCategory;
                    logInfo.HostName  = System.Net.Dns.GetHostName();
                    logInfo.IPAddress = Log.GetIPAddress(logInfo.HostName);
                    logInfo.LogTime   = DateTime.Now;
                    logInfo.FS_Infor  = strContent;
                    logInfo.JS_Infor  = "";
                    logInfo.Log_Infor = "2." + t.GetType().Name.ToString() + "xml转换成Model成功.";
                    string strErrorPart = "";
                    foreach (var v in lstError)
                    {
                        strErrorPart += v + ",";
                    }
                    if (string.IsNullOrEmpty(strErrorPart) == false)
                    {
                        logInfo.Log_Infor = logInfo.Log_Infor + "部分转换失败,失败参数为:" + strErrorPart;
                    }

                    logInfo.Name    = "上传下载";
                    logInfo.FunName = "ModelReflection.cs -> ParaSetModelValue";

                    Log.WriteLog(logInfo);
                    #endregion
                }
            }
            catch (Exception ex)
            {
                #region 日志记录
                string   strCategory = Log.LogType.NPFail.ToString();
                LOG_INFO logInfo     = new LOG_INFO();
                logInfo.Category  = strCategory;
                logInfo.HostName  = System.Net.Dns.GetHostName();
                logInfo.IPAddress = Log.GetIPAddress(logInfo.HostName);
                logInfo.LogTime   = DateTime.Now;
                logInfo.FS_Infor  = strContent;
                logInfo.JS_Infor  = "";
                logInfo.Log_Infor = "2." + t.GetType().Name.ToString() + "xml转换成Model失败,失败原因为:" + HttpUtility.UrlEncode(ex.Message);

                logInfo.Name    = "联网失败";
                logInfo.FunName = "ModelReflection.cs -> ParaSetModelValue";

                Log.WriteLog(logInfo);
                #endregion
            }
            return(t);
        }
Exemplo n.º 4
0
        public T ResultSetModelValueEx <T>(T t, string strType, string strContent)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(strContent);

                PropertyInfo[] pps    = GetPropertyInfos(t.GetType());
                Type           target = t.GetType();

                var property = t.GetType().GetProperty("PropertyName");


                XmlNode xn = doc.SelectSingleNode("//" + strType);

                bool        bResult = false;
                XmlNodeList nodes   = xn.ChildNodes;
                if (nodes.Count > 0)
                {
                    //XmlNodeList subs = nodes[0].ChildNodes;
                    foreach (XmlNode v in nodes)
                    {
                        foreach (var vSX in pps)
                        {
                            if (vSX.Name == v.Name)
                            {
                                PropertyInfo targetPP = target.GetProperty(vSX.Name);
                                object       objValue = HttpUtility.UrlDecode(v.InnerText);

                                targetPP.SetValue(t, SD_ChanageType(objValue, targetPP.PropertyType), null);

                                if (v.Name == "code" && v.InnerText == "1")
                                {
                                    bResult = true;
                                    break;
                                }
                            }
                        }
                    }
                }

                if (bResult)
                {
                    XmlNode xn_Result = doc.SelectSingleNode("//vehispara");

                    if (xn_Result != null)
                    {
                        XmlNodeList nodes_Result = xn_Result.ChildNodes;
                        if (nodes_Result.Count > 0)
                        {
                            List <string> lstError = new List <string>();
                            foreach (XmlNode v in nodes_Result)
                            {
                                try
                                {
                                    foreach (var vSX in pps)
                                    {
                                        if (vSX.Name == v.Name)
                                        {
                                            PropertyInfo targetPP = target.GetProperty(v.Name);
                                            object       objValue = HttpUtility.UrlDecode(v.InnerText);

                                            if (objValue != null && string.IsNullOrEmpty(objValue.ToString()) == false)
                                            {
                                                targetPP.SetValue(t, SD_ChanageType(objValue, targetPP.PropertyType), null);
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    lstError.Add("项目:[" + v.Name + "], 值:[" + v.InnerText + "]转换失败.");
                                    continue;
                                }
                            }

                            #region 日志记录
                            string   strCategory = Log.LogType.NetUpDown.ToString();
                            LOG_INFO logInfo     = new LOG_INFO();
                            logInfo.Category  = strCategory;
                            logInfo.HostName  = "";
                            logInfo.IPAddress = "";
                            logInfo.LogTime   = DateTime.Now;
                            logInfo.FS_Infor  = "";
                            logInfo.JS_Infor  = "";
                            logInfo.Log_Infor = strType;
                            foreach (var v in lstError)
                            {
                                logInfo.Log_Infor = logInfo.Log_Infor + v;
                            }

                            logInfo.Name    = "上传下载";
                            logInfo.FunName = "ModelReflection.cs -> ResultSetModelValue";

                            Log.WriteLog(logInfo);
                            #endregion
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                #region 日志记录
                string   strCategory = Log.LogType.NPFail.ToString();
                LOG_INFO logInfo     = new LOG_INFO();
                logInfo.Category  = strCategory;
                logInfo.HostName  = "";
                logInfo.IPAddress = "";
                logInfo.LogTime   = DateTime.Now;
                logInfo.FS_Infor  = "";
                logInfo.JS_Infor  = "";
                logInfo.Log_Infor = ex.Message;
                logInfo.Name      = "上传下载";
                logInfo.FunName   = "ModelReflection.cs -> ResultSetModelValue";

                Log.WriteLog(logInfo);
                #endregion
            }
            return(t);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 参数实体转换成XML
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="strType"></param>
        /// <returns></returns>
        public string ParaModelToXML <T>(T t, string strType)
        {
            string strRet = "";

            try
            {
                strRet  = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
                strRet += "<root>";
                strRet += "<" + strType + ">";

                List <PropertyInfo> lstParent   = new List <PropertyInfo>();
                List <PropertyInfo> lstChildren = new List <PropertyInfo>();
                GetClassName(t, ref lstParent, ref lstChildren);

                foreach (var v in lstChildren)
                {
                    object objValue = v.GetValue(t, null);
                    if (objValue == null || string.IsNullOrEmpty(objValue.ToString()))
                    {
                        strRet += "<" + v.Name + "></" + v.Name + ">";
                    }
                    else
                    {
                        //处理传入参数是否是DateTime类型,如果是,转换成yyyy-MM-dd格式
                        DateTime dateTemp;
                        string   strValue;
                        if (IsDateTime(objValue.ToString()))
                        {
                            dateTemp = Convert.ToDateTime(objValue.ToString());
                            strValue = dateTemp.ToString("yyyy-MM-dd HH:mm:ss");
                        }
                        else
                        {
                            strValue = objValue.ToString();
                        }

#if RZLD
                        //日照兰大这边,18C58多个开始时间,发送给联网公司时,去掉kssj
                        if (typeof(T).Name == "Vehicle_18C58_Para" && v.Name == "kssj")
                        {
                            continue;
                        }
#endif
                        if (typeof(T).Name == "Vehicle_18C52_Para" && v.Name == "jclsh")
                        {
                            continue;
                        }

                        if (typeof(T).Name == "Vehicle_18C66_Para" && v.Name == "jclsh")
                        {
                            continue;
                        }

                        strRet += "<" + v.Name + ">" + strValue + "</" + v.Name + ">";
                    }
                }

                strRet += "</" + strType + ">";
                strRet += "</root>";

                #region 日志记录
                string   strCategory = Log.LogType.NetUpDown.ToString();
                LOG_INFO logInfo     = new LOG_INFO();
                logInfo.Category  = strCategory;
                logInfo.HostName  = System.Net.Dns.GetHostName();
                logInfo.IPAddress = Log.GetIPAddress(logInfo.HostName);
                logInfo.LogTime   = DateTime.Now;
                logInfo.FS_Infor  = strRet;
                logInfo.JS_Infor  = "";
                logInfo.Log_Infor = "3. 18C82 将Model转换成XML成功";
                logInfo.Name      = "上传下载";
                logInfo.FunName   = "ModelReflection.cs -> ParaModelToXML()";

                Log.WriteLog(logInfo);
                #endregion
            }
            catch (Exception ex)
            {
                #region 日志记录
                string   strCategory = Log.LogType.NPFail.ToString();
                LOG_INFO logInfo     = new LOG_INFO();
                logInfo.Category  = strCategory;
                logInfo.HostName  = System.Net.Dns.GetHostName();
                logInfo.IPAddress = Log.GetIPAddress(logInfo.HostName);
                logInfo.LogTime   = DateTime.Now;
                logInfo.FS_Infor  = strRet;
                logInfo.JS_Infor  = "";
                logInfo.Log_Infor = "3. 18C82 将Model转换成XML失败,失败原因:" + HttpUtility.UrlEncode(ex.Message);
                logInfo.Name      = "转换失败";
                logInfo.FunName   = "ModelReflection.cs -> ParaModelToXML()";

                Log.WriteLog(logInfo);
                #endregion
            }
            return(strRet);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 设置model值,仅适用与18C62
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="strContent"></param>
        /// <returns></returns>
        public Vehicle_18C62_Para ParaSetModelValue_18C62(Vehicle_18C62_Para m_Para, string strType, string strContent)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(strContent);

                PropertyInfo[] pps    = GetPropertyInfos(m_Para.GetType());
                Type           target = m_Para.GetType();

                XmlNode xn = doc.SelectSingleNode("//" + strType);

                XmlNodeList nodes = xn.ChildNodes;
                if (nodes.Count > 0)
                {
                    List <string> lstError = new List <string>();
                    foreach (XmlNode v in nodes)
                    {
                        try
                        {
                            if (v.Name == "rgjyjgs" || v.Name == "yqsbjyjgs")
                            {
                                ParaSetModelValue_18C62_Sub(ref m_Para, xn, v.Name);
                            }

                            PropertyInfo targetPP = target.GetProperty(v.Name);
                            object       objValue = v.InnerText;
                            if (objValue != null && string.IsNullOrEmpty(objValue.ToString()) == false)
                            {
                                targetPP.SetValue(m_Para, SD_ChanageType(objValue, targetPP.PropertyType), null);
                            }
                        }
                        catch (Exception ee)
                        {
                            lstError.Add(" 项目:[" + v.Name + "], 值:[" + v.InnerText + "]转换失败.");
                            continue;
                        }
                    }

                    #region 日志记录
                    string   strCategory = Log.LogType.NetUpDown.ToString();
                    LOG_INFO logInfo     = new LOG_INFO();
                    logInfo.Category  = strCategory;
                    logInfo.HostName  = System.Net.Dns.GetHostName();
                    logInfo.IPAddress = Log.GetIPAddress(logInfo.HostName);
                    logInfo.LogTime   = DateTime.Now;
                    logInfo.FS_Infor  = strContent;
                    logInfo.JS_Infor  = "";
                    logInfo.Log_Infor = m_Para.GetType().Name.ToString();
                    foreach (var v in lstError)
                    {
                        logInfo.Log_Infor = logInfo.Log_Infor + v;
                    }

                    logInfo.Name    = "上传下载";
                    logInfo.FunName = "ModelReflection.cs -> ParaSetModelValue";

                    Log.WriteLog(logInfo);
                    #endregion
                }
            }
            catch (Exception ex)
            {
            }
            return(m_Para);
        }
Exemplo n.º 7
0
        public Vehicle_18C50_Result Read_18C50(Vehicle_18C50_Para para)
        {
            Vehicle_18C50_Result m_Vehicle_18C50_Result = new Vehicle_18C50_Result();

            try
            {
                //ModelToXML
                AJ_ModelToXML modelToXml     = new AJ_ModelToXML();
                string        strQueryXmlDoc = modelToXml.ModelToXml("18C50", para);

                #region 填充联网公司接口
                string strResult = "";
#if RZLD
                var client = new VehicleForNetWebService.DataService.DataServicePortTypeClient();
#elif BJXY
                var client = new VehicleForNetWebService.TmriOutAccess.TmriOutAccessSoapClient();
#endif
                client.Open();
                client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, TimeOut);
                strResult = client.queryObjectOut(para.xtlb, para.jkxlh, para.jkid, strQueryXmlDoc);
                if (client.State != System.ServiceModel.CommunicationState.Closed || client.State != System.ServiceModel.CommunicationState.Closing)
                {
                    client.Close();
                }
                #endregion

                AJ_XMLToModel xmlToModel = new AJ_XMLToModel();
                m_Vehicle_18C50_Result = (Vehicle_18C50_Result)xmlToModel.Result_XmlToModel("18C50", strResult);

                #region 日志记录
                string   strCategory = Log.LogType.NetUpDown.ToString();
                LOG_INFO logInfo     = new LOG_INFO();
                logInfo.Category  = strCategory;
                logInfo.HostName  = System.Net.Dns.GetHostName();
                logInfo.IPAddress = System.Net.Dns.GetHostAddresses(logInfo.HostName).GetValue(1).ToString();
                logInfo.LogTime   = DateTime.Now;
                logInfo.FS_Infor  = strQueryXmlDoc;
                logInfo.JS_Infor  = strResult;
                logInfo.Log_Infor = "18C50";
                logInfo.Name      = "上传下载";
                logInfo.FunName   = "AJ_Read_WebServices.cs -> Read_18C50";

                Log.WriteLog(logInfo);
                #endregion
            }
            catch (Exception ex)
            {
                #region 日志记录
                string   strCategory = Log.LogType.NetFail.ToString();
                LOG_INFO logInfo     = new LOG_INFO();
                logInfo.Category  = strCategory;
                logInfo.HostName  = System.Net.Dns.GetHostName();
                logInfo.IPAddress = System.Net.Dns.GetHostAddresses(logInfo.HostName).GetValue(1).ToString();
                logInfo.LogTime   = DateTime.Now;
                logInfo.FS_Infor  = "";
                logInfo.JS_Infor  = "";
                logInfo.Log_Infor = "18C50:" + ex.Message;
                logInfo.Name      = "上传下载";
                logInfo.FunName   = "AJ_Read_WebServices.cs -> Read_18C50";

                Log.WriteLog(logInfo);
                #endregion
            }

            return(m_Vehicle_18C50_Result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 查詢外廓尺寸測量結果
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public Vehicle_18W06_Result Read_18W06(Vehicle_18W06_Para para)
        {
            Vehicle_18W06_Result _RESULT_18W06 = new Vehicle_18W06_Result();

            try
            {
                AJ_ModelToXML model2XML    = new AJ_ModelToXML();
                string        _QueryXMLDoc = model2XML.ModelToXml("18W06", para);

                string strResult = "";

                var client = new VehicleForNetWebService.ctwkService.JcxlwServerSoapClient();

                client.Open();
                client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, TimeOut);
                strResult = client.queryObjectOut(para.xtlb, para.jkxlh, para.jkid, _QueryXMLDoc);
                if (client.State != System.ServiceModel.CommunicationState.Closed || client.State != System.ServiceModel.CommunicationState.Closing)
                {
                    client.Close();
                }

                AJ_XMLToModel xmlToModel = new AJ_XMLToModel();
                _RESULT_18W06 = (Vehicle_18W06_Result)xmlToModel.Result_XmlToModel("18W06", strResult);

                #region 联网日志记录
                NETLOG_INFO log = new NETLOG_INFO();
                log.LWLSH    = para.lsh;
                log.JYXM     = "DC";
                log.LWType   = "AJ";
                log.SendInfo = _QueryXMLDoc;
                log.RevcInfo = strResult;
                log.JKName   = para.jkid;
                if (_RESULT_18W06 == null || string.IsNullOrEmpty(_RESULT_18W06.code))
                {
                    log.IsSuc = "0";
                }
                else
                {
                    log.IsSuc = _RESULT_18W06.code;
                }
                log.LogTime = DateTime.Now;

                bool b = LogHelper.Log.WriteJKLog(log);
                #endregion
            }
            catch (Exception ex)
            {
                string   strCategory = Log.LogType.NetFail.ToString();
                LOG_INFO logInfo     = new LOG_INFO();
                logInfo.Category  = strCategory;
                logInfo.HostName  = System.Net.Dns.GetHostName();
                logInfo.IPAddress = System.Net.Dns.GetHostAddresses(logInfo.HostName).GetValue(1).ToString();
                logInfo.LogTime   = DateTime.Now;
                logInfo.FS_Infor  = "";
                logInfo.JS_Infor  = "";
                logInfo.Log_Infor = "18X03->" + ex.Message;
                logInfo.Name      = "上传下载";
                logInfo.FunName   = "AJ_Read_WebServices.cs -> Read_18W06";

                Log.WriteLog(logInfo);
            }

            return(_RESULT_18W06);
        }
Exemplo n.º 9
0
        public Vehicle_18X03_Result Read_18X03(Vehicle_18X03_Para para)
        {
            Vehicle_18X03_Result m_Vehicle_18X03_Result = new Vehicle_18X03_Result();

            try
            {
                //ModelToXML
                AJ_ModelToXML modelToXml     = new AJ_ModelToXML();
                string        strQueryXmlDoc = modelToXml.ModelToXml("18X03", para);

                #region 填充联网公司接口
                string strResult = "";
#if RZLD
                var client = new VehicleForNetWebService.DataService.DataServicePortTypeClient();
#elif BJXY
                var client = new VehicleForNetWebService.TmriOutAccess.TmriOutAccessSoapClient();
#endif
                client.Open();
                client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, TimeOut);
                strResult = client.queryObjectOut(para.xtlb, para.jkxlh, para.jkid, strQueryXmlDoc);
                if (client.State != System.ServiceModel.CommunicationState.Closed || client.State != System.ServiceModel.CommunicationState.Closing)
                {
                    client.Close();
                }
                #endregion

                AJ_XMLToModel xmlToModel = new AJ_XMLToModel();
                m_Vehicle_18X03_Result = (Vehicle_18X03_Result)xmlToModel.Result_XmlToModel("18X03", strResult);

                #region 联网日志记录
                NETLOG_INFO log = new NETLOG_INFO();
                log.LWLSH    = para.jylsh;
                log.JYXM     = "DC";
                log.LWType   = "AJ";
                log.SendInfo = strQueryXmlDoc;
                log.RevcInfo = strResult;
                log.JKName   = para.jkid;
                if (m_Vehicle_18X03_Result == null || string.IsNullOrEmpty(m_Vehicle_18X03_Result.code))
                {
                    log.IsSuc = "0";
                }
                else
                {
                    log.IsSuc = m_Vehicle_18X03_Result.code;
                }
                log.LogTime = DateTime.Now;

                bool b = LogHelper.Log.WriteJKLog(log);
                #endregion
            }
            catch (Exception ex)
            {
                string   strCategory = Log.LogType.NetFail.ToString();
                LOG_INFO logInfo     = new LOG_INFO();
                logInfo.Category  = strCategory;
                logInfo.HostName  = System.Net.Dns.GetHostName();
                logInfo.IPAddress = System.Net.Dns.GetHostAddresses(logInfo.HostName).GetValue(1).ToString();
                logInfo.LogTime   = DateTime.Now;
                logInfo.FS_Infor  = "";
                logInfo.JS_Infor  = "";
                logInfo.Log_Infor = "18X03->" + ex.Message;
                logInfo.Name      = "上传下载";
                logInfo.FunName   = "AJ_Read_WebServices.cs -> Read_18X03";

                Log.WriteLog(logInfo);
            }

            return(m_Vehicle_18X03_Result);
        }