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();
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        protected void RadGridPublicationChannels_UpdateCommand(object source, GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;

            GridDropDownListColumnEditor trigger      = (GridDropDownListColumnEditor)(editedItem.EditManager.GetColumnEditor("_Trigger"));
            GridTextBoxColumnEditor      channelName  = (GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("ChannelName");
            GridNumericColumnEditor      pubDateMove  = (GridNumericColumnEditor)editedItem.EditManager.GetColumnEditor("PubDateMoveDays");
            GridNumericColumnEditor      releaseDelay = (GridNumericColumnEditor)editedItem.EditManager.GetColumnEditor("ReleaseDelay");
            GridCheckBoxColumnEditor     use          = (GridCheckBoxColumnEditor)(editedItem.EditManager.GetColumnEditor("Use"));

            if (trigger == null || use == null || channelName == null || pubDateMove == null)
            {
                RadGridPublicationChannels.Controls.Add(new LiteralControl("Unable to locate the ChannelName for updating."));
                e.Canceled = true;
                return;
            }

            int selectedChannelID = Utils.GetChannelID(channelName.Text);
            List <Models.PublicationChannel> pcList = (DataItem as Models.Publication).PublicationChannels;

            Models.PublicationChannel pc = pcList.FirstOrDefault(p => p.ChannelID == selectedChannelID);
            if (pc != null)
            {
                if (use.CheckBoxControl.Checked == false)
                {
                    pcList.Remove(pc);
                }
                pc.Trigger         = trigger.SelectedIndex;
                pc.PubDateMoveDays = Utils.StringToInt(pubDateMove.Text);
                pc.ReleaseDelay    = Utils.StringToInt(releaseDelay.Text);
            }
            else
            {
                Models.PublicationChannel pcNew = new Models.PublicationChannel()
                {
                    ChannelID       = selectedChannelID,
                    Trigger         = trigger.SelectedIndex,
                    PubDateMoveDays = Utils.StringToInt(pubDateMove.Text),
                    ReleaseDelay    = Utils.StringToInt(releaseDelay.Text)
                };
            }
        }