/// <summary> /// 更新邮寄方式 /// </summary> internal static void UpdatePostTypes() { try { var systemSetting = GetSystemSetting(); using (var db = new OrderSortingDBEntities()) { var now = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); var loginCount = db.LoginLog.Count(ll => ll.LoginTime > now); if (loginCount > 0) { return; } //获取OA的全部邮寄方式 DataTable dt = null; if (systemSetting.InterfaceType == InterfaceType.SigleFlyt) { var content = API_Helper.GetPostListBySingleFlyt(); if (content != null && content.Count > 1) { foreach (var row in content) { Posttypes post = new Posttypes(); post.PostID = row.Id; post.CnPostName = row.Type; post.EnPostCode = row.Id; db.Posttypes.AddOrUpdate(post); } db.SaveChangesAsync(); } } else { dt = API_Helper.GetPostList(); if (dt != null && dt.Rows.Count > 1) { foreach (DataRow row in dt.Rows) { Posttypes post = new Posttypes(); post.PostID = row["id"].ToString(); post.CnPostName = row["type"].ToString(); post.EnPostCode = row["entype"].ToString(); db.Posttypes.AddOrUpdate(post); } db.SaveChangesAsync(); } } } } catch (Exception) { throw; } }