예제 #1
0
        public void Save(Socket socket, string json)
        {
            C_To_S_Data <object> obj = Utility.JsonHelper.JsonDeserialize <C_To_S_Data <object> >(json);

            Clazz.Config.XML_Org _org = SysConfig.orgConfig.GetOrgByOrgId(obj.OrgId);

            if (_org == null)
            {
                //将信息写入到日志文件中    orgid为***的污水厂不存在
                LogMg.AddError("OrgId:\"{0}\"不存在");
                //isSuccess = false;
            }
            else
            {
                try
                {
                    SWSDataContext  SWS     = new SWSDataContext(ServerSocketHelper.GetConnection(_org.DBName)); //建立一个分厂数据源提供程序实例
                    country_station station = SWS.country_station.SingleOrDefault(c => c.id == obj.StationId);
                    if (station == null)
                    {
                        LogMg.AddError("StationId: " + obj.StationId + " 不存在");
                    }
                    else
                    {
                        station.ip = obj.Data[0].ToString();     //保存客户端IP地址
                        SWS.SubmitChanges();
                    }
                }
                catch (Exception ex)
                {
                    LogMg.AddError(ex);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 根据电话号码找出站点名称
        /// </summary>
        /// <param name="tel"></param>
        /// <returns></returns>
        public static string GetStationNameByTel(string tel)
        {
            string stationName = string.Empty;

            Clazz.Config.XML_Station station = SysConfig.DTU_StationConfig.GetStationByTel(tel);
            if (station != null)
            {
                stationName = station.Name;
            }
            else
            {
                bool ExistStation = false;
                foreach (XML_Org item in SysConfig.orgConfig.Orgs)
                {
                    try
                    {
                        SWSDataContext  db = new SWSDataContext(ServerSocketHelper.GetConnection(item.DBName));
                        country_station s  = db.country_station.SingleOrDefault(c => c.jiankongyitiji_version == 2 && c.transfer_code == tel);
                        if (s != null)
                        {
                            ExistStation = true;
                            stationName  = s.name;
                        }
                    }
                    catch (Exception ex)
                    {
                        LogMg.AddError(ex);
                    }
                }
                if (ExistStation == false)
                {
                    stationName = "未知的客户端";
                }
            }
            return(stationName);
        }