/// <summary> /// 公告更新 /// </summary> /// <param name="note"></param> public static object UpdateNotice(Notification note) { Variant v = note.GetVariant(0); if (v == null) { return null; } string id = v.GetStringOrDefault("ID"); Notice model; if (NoticeAccess.Instance.GetNotice(id, out model)) { bool ischange = false; if (v.ContainsKey("Name") && model.Name != v.GetStringOrDefault("Name")) { model.Name = v.GetStringOrDefault("Name"); ischange = true; } if (v.ContainsKey("StartTime") && model.StartTime != v.GetUtcTimeOrDefault("StartTime")) { model.StartTime = v.GetUtcTimeOrDefault("StartTime"); ischange = true; } if (v.ContainsKey("EndTime") && model.EndTime != v.GetUtcTimeOrDefault("EndTime")) { model.EndTime = v.GetUtcTimeOrDefault("EndTime"); ischange = true; } if (v.ContainsKey("Sort") && model.Sort != v.GetIntOrDefault("Sort")) { model.Sort = v.GetIntOrDefault("Sort"); ischange = true; } if (v.ContainsKey("Content") && model.Content != v.GetStringOrDefault("Content")) { model.Content = v.GetStringOrDefault("Content"); ischange = true; } if (v.ContainsKey("Count") && model.Count != v.GetIntOrDefault("Count")) { model.Count = v.GetIntOrDefault("Count"); ischange = true; } if (v.ContainsKey("Rate") && model.Rate != v.GetIntOrDefault("Rate")) { model.Rate = v.GetIntOrDefault("Rate"); ischange = true; } if (v.ContainsKey("Status") && model.Status != v.GetIntOrDefault("Status")) { model.Status = v.GetIntOrDefault("Status"); ischange = true; } if (v.ContainsKey("Place") && model.Place != v.GetStringOrDefault("Place")) { model.Place = v.GetStringOrDefault("Place"); ischange = true; } if (v.ContainsKey("Cur") && model.Cur != v.GetIntOrDefault("Cur")) { model.Cur = v.GetIntOrDefault("Cur"); ischange = true; } if (ischange) { model.Save(); return true; } } return false; }
/// <summary> /// 公告 /// </summary> /// <param name="note"></param> public static object Notice(Notification note) { Variant v = note.GetVariant(0); if (v == null) { return null; } Notice model = new Entity.Notice(); model.ID = ObjectId.GenerateNewId().ToString(); model.Name = v.GetStringOrDefault("Name"); model.StartTime = v.GetUtcTimeOrDefault("StartTime"); model.EndTime = v.GetUtcTimeOrDefault("EndTime"); model.Sort = v.GetIntOrDefault("Sort"); model.Content = v.GetStringOrDefault("Content"); model.Count = v.GetIntOrDefault("Count"); model.Rate = v.GetIntOrDefault("Rate"); model.Status = v.GetIntOrDefault("Status"); model.Place = v.GetStringOrDefault("Place"); if (model.Save()) { NoticeAccess.Instance.AddNotice(model); return TipManager.GetMessage(GMReturn.Notice1); } return string.Empty; }