private void SetInfo(Foresight.DataAccess.SystemMsg data) { this.tdTitle.Value = data.Title; this.tdSortOrder.Value = data.SortOrder > 0 ? data.SortOrder.ToString() : ""; this.hdContent.Value = string.IsNullOrEmpty(data.ContentSummary) ? string.Empty : data.ContentSummary; this.tdIsTopShow.Value = data.IsTopShow ? "1" : "0"; var list = Foresight.DataAccess.SystemMsg_Company.GetSystemMsg_CompanyList(data.ID); var CompanyIDList = list.Select(p => p.CompanyID).ToList(); if (CompanyIDList.Count > 0) { this.hdCompanys.Value = JsonConvert.SerializeObject(CompanyIDList); var companylist = Foresight.DataAccess.Company.GetAllActiveCompanyList().Where(p => CompanyIDList.Contains(p.CompanyID)).ToArray(); this.tdCompanyNames.Value = string.Join(",", companylist.Select(p => p.CompanyName).ToArray()); } this.tdDisableNotify.Value = data.DisableNotify ? "1" : "0"; this.tdIsNotifyALL.Value = data.IsNotifyALL ? "1" : "0"; }
private void savesystemmsg(HttpContext context) { Foresight.DataAccess.SystemMsg msg = null; int ID = 0; int.TryParse(context.Request.Params["ID"], out ID); if (ID > 0) { msg = Foresight.DataAccess.SystemMsg.GetSystemMsg(ID); } if (msg == null) { msg = new Foresight.DataAccess.SystemMsg(); msg.AddTime = DateTime.Now; } msg.Title = getValue(context, "tdTitle"); msg.IsTopShow = getIntValue(context, "tdIsTopShow") == 1; msg.SortOrder = getIntValue(context, "tdSortOrder"); msg.ContentSummary = context.Request["HTMLContent"]; msg.DisableNotify = getIntValue(context, "tdDisableNotify") == 1; msg.IsNotifyALL = getIntValue(context, "tdIsNotifyALL") == 1; string CompanyIDs = context.Request["CompanyIDs"]; List <Foresight.DataAccess.SystemMsg_Company> msgcompany_list = new List <Foresight.DataAccess.SystemMsg_Company>(); List <int> CompanyIDList = new List <int>(); if (!string.IsNullOrEmpty(CompanyIDs)) { CompanyIDList = JsonConvert.DeserializeObject <List <int> >(CompanyIDs); } if (msg.IsNotifyALL) { CompanyIDList = Company.GetAllActiveCompanyList().Select(p => p.CompanyID).ToList(); } if (CompanyIDList.Count > 0) { if (msg.ID > 0) { var exist_list = Foresight.DataAccess.SystemMsg_Company.GetSystemMsg_CompanyList(msg.ID); foreach (var CompanyID in CompanyIDList) { var msgcompany = exist_list.FirstOrDefault(p => p.CompanyID == CompanyID); if (msgcompany == null) { msgcompany = new Foresight.DataAccess.SystemMsg_Company(); msgcompany.CompanyID = CompanyID; msgcompany.AddTime = DateTime.Now; } msgcompany_list.Add(msgcompany); } } else { foreach (var CompanyID in CompanyIDList) { var msgcompany = new Foresight.DataAccess.SystemMsg_Company(); msgcompany.CompanyID = CompanyID; msgcompany.AddTime = DateTime.Now; msgcompany_list.Add(msgcompany); } } } using (SqlHelper helper = new SqlHelper()) { try { helper.BeginTransaction(); msg.Save(helper); foreach (var item in msgcompany_list) { item.IsReading = false; item.SystemMsgID = msg.ID; item.Save(helper); } helper.Commit(); } catch (Exception ex) { LogHelper.WriteError(LogModule, "savesystemmsg", ex); helper.Rollback(); WebUtil.WriteJson(context, new { status = false }); return; } } WebUtil.WriteJson(context, new { status = true, ID = msg.ID }); }