protected void repCnlsByView_ItemCommand(object source, RepeaterCommandEventArgs e) { // добавление выбранного канала в список if (e.CommandName == "AddCnl") { int cnlNum = int.Parse((string)e.CommandArgument); if (!selCnlSet.Contains(cnlNum)) { int viewID = int.Parse(ddlView.SelectedValue); CnlViewPair pair = new CnlViewPair(cnlNum, viewID); pair.FillInfo(appData.DataAccess.GetCnlProps(cnlNum), null); selCnls.Add(pair); ViewState.Add("SelCnls", selCnls); btnSubmit.Enabled = true; bool warnWasVisible = pnlPerfWarn.Visible; pnlPerfWarn.Visible = selCnls.Count > ChartUtils.NormalChartCnt; if (pnlPerfWarn.Visible != warnWasVisible) { ChartUtils.AddUpdateModalHeightScript(this); } } Label lblCnlAdded = (Label)e.Item.FindControl("lblCnlAdded"); lblCnlAdded.Visible = true; } }
/// <summary> /// Получить список пар канал/представление по ид. представления /// </summary> public static List <CnlViewPair> GetCnlViewPairsByView( int viewID, DataAccess dataAccess, ViewCache viewCache, UserViews userViews) { BaseView view = null; if (viewID > 0) { Type viewType = userViews.GetViewType(viewID); view = viewCache.GetView(viewType, viewID); } if (view == null) { return(null); } else { List <CnlViewPair> cnlsByView = new List <CnlViewPair>(); foreach (int cnlNum in view.CnlList) { CnlViewPair pair = new CnlViewPair(cnlNum, 0); pair.FillInfo(dataAccess.GetCnlProps(cnlNum), null); cnlsByView.Add(pair); } return(cnlsByView); } }
protected void btnApplyAddedCnls_Click(object sender, EventArgs e) { // добавление каналов if (hidAddedCnlNums.Value != "") { int[] addedCnls = WebUtils.QueryParamToIntArray(hidAddedCnlNums.Value); int[] addedViewIDs = WebUtils.QueryParamToIntArray(hidAddedViewIDs.Value); ChartUtils.CheckArrays(addedCnls, addedViewIDs); HashSet <int> selCnlSet = ChartUtils.GetCnlSet(selCnls); for (int i = 0, cnt = addedCnls.Length; i < cnt; i++) { int cnlNum = addedCnls[i]; if (!selCnlSet.Contains(cnlNum)) { CnlViewPair pair = new CnlViewPair(cnlNum, addedViewIDs[i]); pair.FillInfo(appData.DataAccess.GetCnlProps(cnlNum), userData.UserViews); selCnls.Add(pair); } } ViewState.Add("SelCnls", selCnls); ShowSelCnls(); hidAddedCnlNums.Value = ""; hidAddedViewIDs.Value = ""; } }
/// <summary> /// Получить выбранные каналы и соответствующие им представления из списка /// </summary> public static void GetSelection(this List <CnlViewPair> cnlViewPairs, out string cnlNums, out string viewIDs) { StringBuilder sbCnlNums = new StringBuilder(); StringBuilder sbViewIDs = new StringBuilder(); for (int i = 0, lastInd = cnlViewPairs.Count - 1; i <= lastInd; i++) { CnlViewPair pair = cnlViewPairs[i]; sbCnlNums.Append(pair.CnlNum); sbViewIDs.Append(pair.ViewID); if (i < lastInd) { sbCnlNums.Append(","); sbViewIDs.Append(","); } } cnlNums = sbCnlNums.ToString(); viewIDs = sbViewIDs.ToString(); }