private void BuildPublicationChannelTable() { List <Models.PublicationChannel> specificPubChannels = new List <Models.PublicationChannel>(); if (Publication != null) { specificPubChannels = Publication.PublicationChannels; } List <Models.PublicationChannelAll> allPubChannels = new List <Models.PublicationChannelAll>(); DataProviders.DBaccess db = new DataProviders.DBaccess(); string errmsg = ""; if (Session["ChannelList"] == null) { List <Models.Channel> channels = new List <Models.Channel>(); db.GetChannelList(ref channels, out errmsg); Session["ChannelList"] = channels; } try { List <Models.Channel> channelList = (List <Models.Channel>)HttpContext.Current.Session["ChannelList"]; foreach (Models.Channel channel in channelList) { bool use = false; int trigger = (int)Models.PushTrigger.None; int pubDateMoveDays = 0; int releaseDelay = 0; bool sendPlan = false; Models.PublicationChannel sc = specificPubChannels.FirstOrDefault(p => p.ChannelID == channel.ChannelID); if (sc != null) { use = true; trigger = sc.Trigger; pubDateMoveDays = sc.PubDateMoveDays; releaseDelay = sc.ReleaseDelay; sendPlan = sc.SendPlan; } allPubChannels.Add(new Models.PublicationChannelAll() { ChannelName = channel.Name, Use = use, Trigger = trigger, PubDateMoveDays = pubDateMoveDays, ReleaseDelay = releaseDelay, ChannelID = channel.ChannelID, SendPlan = sendPlan }); } } catch { } GridViewPublicationChannels.DataSource = allPubChannels; GridViewPublicationChannels.DataBind(); }
protected void RadGridPublicationChannels_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { List <Models.PublicationChannel> specificPubChannels = new List <Models.PublicationChannel>(); if (DataItem != null && (DataItem is Models.Publication)) { specificPubChannels = (DataItem as Models.Publication).PublicationChannels; } List <Models.PublicationChannelAll> allPubChannels = new List <Models.PublicationChannelAll>(); DataProviders.DBaccess db = new DataProviders.DBaccess(); string errmsg = ""; if (Session["ChannelList"] == null) { List <Models.Channel> channels = new List <Models.Channel>(); db.GetChannelList(ref channels, out errmsg); Session["ChannelList"] = channels; } try { List <Models.Channel> channelList = (List <Models.Channel>)HttpContext.Current.Session["ChannelList"]; foreach (Models.Channel channel in channelList) { bool use = false; int trigger = (int)Models.PushTrigger.None; int pubDateMoveDays = 0; int releaseDelay = 0; Models.PublicationChannel sc = specificPubChannels.FirstOrDefault(p => p.ChannelID == channel.ChannelID); if (sc != null) { use = true; trigger = sc.Trigger; pubDateMoveDays = sc.PubDateMoveDays; releaseDelay = sc.ReleaseDelay; } allPubChannels.Add(new Models.PublicationChannelAll() { ChannelName = channel.Name, Use = use, Trigger = trigger, PubDateMoveDays = pubDateMoveDays, ReleaseDelay = releaseDelay }); } } catch { } RadGridPublicationChannels.DataSource = allPubChannels; }