Exemple #1
0
 /// <summary>
 /// 创建新的 RouteData 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="groupID">GroupID 属性的初始值。</param>
 public static RouteData CreateRouteData(global::System.Int32 id, global::System.Int32 groupID)
 {
     RouteData routeData = new RouteData();
     routeData.ID = id;
     routeData.GroupID = groupID;
     return routeData;
 }
Exemple #2
0
 /// <summary>
 /// 用于向 RouteDatas EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToRouteDatas(RouteData routeData)
 {
     base.AddObject("RouteDatas", routeData);
 }
        public List<RouteDataResponseItem> ClientSubmitRouteDataToCenterrServer([FromBody]List<RouteDataRequestItem> routeDatas)
        {
            if (routeDatas == null)
            {
                throw new BadRequestException();
            }

            List<RouteData> dbItems = new List<RouteData>();

            IPRepository ipr = new IPRepository();

            foreach (var item in routeDatas)
            {
                if (item == null)
                {
                    continue;
                }

                RouteData dbItem = new RouteData();
                dbItem.GroupID = item.ParentUID;
                dbItem.T1 = item.T1;
                dbItem.T2 = item.T2;
                dbItem.T3 = item.T3;
                dbItem.RouteIP = item.RouteIP;
                dbItem.RouteDate = item.RouteDate;
                dbItem.SeqNoInGroup = item.SeqNo;
                dbItem.CreatedBy = Context.LoginName;
                dbItem.LastUpdatedBy = Context.LoginName;

                string ipBelongTo = "";
                if (!String.IsNullOrWhiteSpace(item.RouteIP))
                {
                    var ipEntity = ipr.RetriveIP(item.RouteIP);

                    if (ipEntity != null)
                    {
                        ipBelongTo = String.IsNullOrWhiteSpace(ipEntity.IPBelongTo) ? ipEntity.Country : ipEntity.IPBelongTo;
                        dbItem.IPBelongTo = ipBelongTo;
                        dbItem.IPBelongToProvince = ipEntity.Province;
                        dbItem.IPBelongToCity = ipEntity.City;
                    }
                }

                dbItems.Add(dbItem);
            }

            RouteDataRepository rdr = new RouteDataRepository();
            var resultDbItems = rdr.AddRoutDatas(dbItems);

            List<RouteDataResponseItem> result = new List<RouteDataResponseItem>();
            foreach (var item in resultDbItems)
            {
                RouteDataResponseItem rItem = new RouteDataResponseItem();
                rItem.ParentUID = item.GroupID;
                rItem.SeqNo = (item.SeqNoInGroup.HasValue ? item.SeqNoInGroup.Value : 0);
                rItem.RouteIP = item.RouteIP;
                rItem.IPBelongTo = item.IPBelongTo;
                rItem.IPBelongToProvince = item.IPBelongToProvince;
                rItem.IPBelongToCity = item.IPBelongToCity;
                result.Add(rItem);
            }

            return result;
        }