public void Insert(int index, SortInfo field) { if (field == null) { throw new ArgumentNullException(); } this.InnerList.Insert(index, field); }
public void Add(SortInfo field) { if (field == null) { throw new ArgumentNullException(); } this.InnerList.Add(field); }
private void ShowStep(int step) { for (int i = 0; i <= _stepCount; i++) ((Panel)_steps[i]).Visible = false; ((Panel)_steps[step - 1]).Visible = true; if (step == 1 && Elem.Value == "NULL") { pastStep.Value = "1"; ResultXML.Value = ""; ViewState["FiltersTable"] = null; ViewState["SortFields"] = null; if (_pc["Cust_Rep_valMode"].ToString() == "Both") { ddTemplates.DataSource = Report.GetReportTemplate(); ddTemplates.DataValueField = "TemplateId"; ddTemplates.DataTextField = "Name"; ddTemplates.DataBind(); if (ddTemplates.Items.Count == 0) fsChoice.Visible = false; } } #region Step 2 - Fields if ((step == 2 && Elem.Value == "NULL") || (step == 1 && Elem.Value != "NULL")) { if (valMode.Value == "Both1" && ddTemplates.SelectedItem != null) { int reportTemplateId = int.Parse(ddTemplates.SelectedValue); Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "<script language='javascript'>" + "try {window.opener.top.frames['right'].location.href='../Reports/TemplateEdit.aspx?Generate=1&TemplateId=" + reportTemplateId.ToString() + "';}" + "catch (e){}window.close();</script>"); } lbAvailableFields.Items.Clear(); BindItemCollections(lbAvailableFields.Items, rbReportItem.SelectedItem.Value, 0); lbSelectedFields.Items.Clear(); string sFields = iFields.Value; ArrayList alFields = new ArrayList(); while (sFields.Length > 0) { alFields.Add(sFields.Substring(0, sFields.IndexOf(","))); sFields = sFields.Remove(0, sFields.IndexOf(",") + 1); } foreach (string i in alFields) { ListItem lItm = lbAvailableFields.Items.FindByValue(i); if (lItm != null) { lbAvailableFields.Items.Remove(lItm); lbSelectedFields.Items.Add(lItm); } } pastStep.Value = "2"; } #endregion #region Step 3 - Grouping if ((step == 3 && Elem.Value == "NULL") || (step == 2 && Elem.Value != "NULL")) { if (pastStep.Value == "2") { ddGroup1.Items.Clear(); ddGroup2.Items.Clear(); ddGroup1.Items.Add(new ListItem(" " + LocRM.GetString("tNotSet"), "01")); ddGroup2.Items.Add(new ListItem(" " + LocRM.GetString("tNotSet"), "02")); BindItemCollections(ddGroup1.Items, rbReportItem.SelectedItem.Value, 1); BindItemCollections(ddGroup2.Items, rbReportItem.SelectedItem.Value, 1); string sFields = iFields.Value; ArrayList alFields = new ArrayList(); while (sFields.Length > 0) { alFields.Add(sFields.Substring(0, sFields.IndexOf(","))); sFields = sFields.Remove(0, sFields.IndexOf(",") + 1); } foreach (string i in alFields) { ListItem lItm1 = ddGroup1.Items.FindByValue(i); if (lItm1 != null) ddGroup1.Items.Remove(lItm1); ListItem lItm2 = ddGroup2.Items.FindByValue(i); if (lItm2 != null) ddGroup2.Items.Remove(lItm2); } string sGroups = iGroups.Value; ArrayList alGroups = new ArrayList(); while (sGroups.Length > 0) { alGroups.Add(sGroups.Substring(0, sGroups.IndexOf(","))); sGroups = sGroups.Remove(0, sGroups.IndexOf(",") + 1); } foreach (string i in alGroups) { if (ddGroup1.SelectedItem.Value == "01") { ListItem lItm1 = ddGroup1.Items.FindByValue(i); if (lItm1 != null) { ddGroup1.SelectedItem.Selected = false; lItm1.Selected = true; } continue; } else { ListItem lItm2 = ddGroup2.Items.FindByValue(i); if (lItm2 != null) { ddGroup2.SelectedItem.Selected = false; lItm2.Selected = true; } } } } pastStep.Value = "3"; pastCommand.Value = ""; } #endregion #region Step 4 - Filtering if ((step == 4 && Elem.Value == "NULL") || (step == 3 && Elem.Value != "NULL")) { iGroups.Value = ""; if (ddGroup1.SelectedItem.Value != "01") iGroups.Value += ddGroup1.SelectedItem.Value + ","; if (ddGroup2.SelectedItem.Value != "02") iGroups.Value += ddGroup2.SelectedItem.Value + ","; DataTable dtFilters = new DataTable(); if (ViewState["FiltersTable"] == null || !(ViewState["FiltersTable"] is DataTable)) { dtFilters.Columns.Add(new DataColumn("IsChecked", typeof(bool))); dtFilters.Columns.Add(new DataColumn("FieldName", typeof(string))); dtFilters.Columns.Add(new DataColumn("FriendlyName", typeof(string))); DataRow dr; if (_qItem != null) { foreach (QField fd in _qItem.Fields) if ((fd.UsingType & QFieldUsingType.Filter) == QFieldUsingType.Filter) { dr = dtFilters.NewRow(); dr["IsChecked"] = false; dr["FieldName"] = fd.Name; dr["FriendlyName"] = fd.FriendlyName; dtFilters.Rows.Add(dr); } ViewState["FiltersTable"] = dtFilters; } } else dtFilters = (DataTable)ViewState["FiltersTable"]; DataView dvFilters = dtFilters.DefaultView; dvFilters.Sort = "FriendlyName"; dlFilterFields.DataSource = dvFilters; dlFilterFields.DataBind(); dlFilterFields.SelectedIndex = 0; LinkButton lb = (LinkButton)dlFilterFields.Items[0].FindControl("lbField"); if (lb != null) BindFilter(lb.CommandName); pastStep.Value = "4"; } #endregion #region Step 5 - SortStep if ((step == 5 && Elem.Value == "NULL") || (step == 4 && Elem.Value != "NULL")) { BindFilter(""); btnAdd.Text = LocRM.GetString("tAdd"); if (ViewState["SortFields"] == null || !(ViewState["SortFields"] is DataTable)) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Field", typeof(string))); dt.Columns.Add(new DataColumn("FieldText", typeof(string))); dt.Columns.Add(new DataColumn("SortDirect", typeof(int))); //1 - asc, 0 - desc ViewState["SortFields"] = dt; } BindFields(); BindDGFields(); pastStep.Value = "5"; } #endregion #region Step 6 - Settings if ((step == 6 && Elem.Value == "NULL") || (step == 5 && Elem.Value != "NULL")) { switch (rbReportItem.SelectedItem.Value) { case "0": //Incident lblReportName.Text = LocRM.GetString("tIncRep"); break; case "1": //Project lblReportName.Text = LocRM.GetString("tPrjRep"); break; case "2": //ToDo`s lblReportName.Text = LocRM.GetString("tTdRep"); break; case "3": //Calendar Entries lblReportName.Text = LocRM.GetString("tCalEntrRep"); break; case "4": //Documents lblReportName.Text = LocRM.GetString("tAstRep"); break; case "5": //Users lblReportName.Text = LocRM.GetString("tUsrRep"); break; case "6": //Tasks lblReportName.Text = LocRM.GetString("tTkRep"); break; case "7": //Portfolios lblReportName.Text = LocRM.GetString("tPrjGrpRep"); break; default: break; } lblReportName.Text += " " + DateTime.Now.ToString("yyyy-MM-dd HH:mm"); if (iGroups.Value.Length > 1) trRadioGroup.Visible = true; else trRadioGroup.Visible = false; if (rblGrouptype.SelectedIndex == 1) imgType.ImageUrl = "~/layouts/images/pp1.gif"; else imgType.ImageUrl = "~/layouts/images/pp2.gif"; if (_pc["Cust_Rep_valMode"].ToString() != "Temp") { trTemplateSetsRow.Visible = false; } IBNReportTemplate repTemp = null; if (ResultXML.Value != "") { repTemp = IBNReportTemplate.Load(ResultXML.Value); } if (repTemp == null) repTemp = new IBNReportTemplate(); #region Report Fields string sFields = iFields.Value; repTemp.Fields.Clear(); while (sFields.Length > 0) { string sF = sFields.Substring(0, sFields.IndexOf(",")); sFields = sFields.Remove(0, sFields.IndexOf(",") + 1); repTemp.Fields.Add(new FieldInfo(sF, _qItem.Fields[sF].DataType.ToString())); } #endregion #region Report Group Fields string sGroups = iGroups.Value; repTemp.Groups.Clear(); while (sGroups.Length > 0) { string sG = sGroups.Substring(0, sGroups.IndexOf(",")); sGroups = sGroups.Remove(0, sGroups.IndexOf(",") + 1); repTemp.Groups.Add(new FieldInfo(sG, _qItem.Fields[sG].DataType.ToString())); } #endregion #region SortFields DataTable dt = (DataTable)ViewState["SortFields"]; repTemp.Sorting.Clear(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { SortInfo si = new SortInfo(); string sS = dr["Field"].ToString(); si.FieldName = sS; si.DataType = _qItem.Fields[sS].DataType.ToString(); if (dr["SortDirect"].ToString() == "0") si.SortDirection = Mediachase.IBN.Business.Reports.SortDirection.DESC; else si.SortDirection = Mediachase.IBN.Business.Reports.SortDirection.ASC; repTemp.Sorting.Add(si); } } #endregion ResultXML.Value = repTemp.CreateXMLTemplate().InnerXml; pastStep.Value = "6"; } #endregion #region Step 7 - Preview if ((step == 7 && Elem.Value == "NULL") || (step == 6 && Elem.Value != "NULL")) { IBNReportTemplate repTemp = null; if (ResultXML.Value != "") { repTemp = IBNReportTemplate.Load(ResultXML.Value); } if (repTemp == null) repTemp = new IBNReportTemplate(); string sFilter = MakeFilterText(repTemp); #region Report Fields lblFields.Text = ""; foreach (FieldInfo fi in repTemp.Fields) lblFields.Text += _qItem.Fields[fi.Name].FriendlyName + "<br>"; #endregion #region Report Group Fields lblGroupFields.Text = ""; foreach (FieldInfo fi in repTemp.Groups) lblGroupFields.Text += _qItem.Fields[fi.Name].FriendlyName + "<br>"; #endregion #region SortFields DataTable dt = (DataTable)ViewState["SortFields"]; lblSortFields.Text = ""; if (dt.Rows.Count > 0) foreach (DataRow dr in dt.Rows) lblSortFields.Text += dr["FieldText"].ToString() + " - " + GetSortDirect((int)dr["SortDirect"]) + "<br>"; #endregion txtReportTitle.Text = lblReportName.Text; //ResultXML.Value = repTemp.CreateXMLTemplate().InnerXml; if (!cbShowEmptyItems.Checked) sFilter += " " + LocRM.GetString("tDontShowEmptyGroupItem"); lblFilter.Text = sFilter; pastStep.Value = "7"; } #endregion #region Step 8 - Save & Redirect if ((step == 8 && Elem.Value == "NULL") || (step == 7 && Elem.Value != "NULL")) { IBNReportTemplate reportTemp = null; if (ResultXML.Value != "") { reportTemp = IBNReportTemplate.Load(ResultXML.Value); } if (reportTemp == null) reportTemp = new IBNReportTemplate(); reportTemp.Version = IbnConst.VersionMajorDotMinor; reportTemp.Author = Security.CurrentUser.DisplayName; reportTemp.Created = UserDateTime.UserNow; reportTemp.Name = lblReportName.Text; if (reportTemp.Groups.Count > 0 && !cbShowEmptyItems.Checked) reportTemp.ShowEmptyGroup = false; else reportTemp.ShowEmptyGroup = true; if (rblGrouptype.SelectedIndex == 0) reportTemp.ViewType = "0"; //Old else reportTemp.ViewType = "1"; //New XmlDocument doc = new XmlDocument(); switch (rbReportItem.SelectedValue) { case "0": //Incident reportTemp.ObjectName = "Incident"; doc = Report.GetIncidentXMLReport(reportTemp, Security.CurrentUser.LanguageId.ToString(), Security.CurrentUser.TimeZoneId.ToString()); break; case "1": //Project reportTemp.ObjectName = "Project"; doc = Report.GetProjectXMLReport(reportTemp, Security.CurrentUser.LanguageId.ToString(), Security.CurrentUser.TimeZoneId.ToString()); break; case "2": //ToDo`s reportTemp.ObjectName = "ToDo"; doc = Report.GetToDoXMLReport(reportTemp, Security.CurrentUser.LanguageId.ToString(), Security.CurrentUser.TimeZoneId.ToString()); break; case "3": //Calendar Entries reportTemp.ObjectName = "Event"; doc = Report.GetCalendarEntryXMLReport(reportTemp, Security.CurrentUser.LanguageId.ToString(), Security.CurrentUser.TimeZoneId.ToString()); break; case "4": //Documents reportTemp.ObjectName = "Document"; doc = Report.GetDocumentXMLReport(reportTemp, Security.CurrentUser.LanguageId.ToString(), Security.CurrentUser.TimeZoneId.ToString()); break; case "5": //Users reportTemp.ObjectName = "Directory"; doc = Report.GetUsersXMLReport(reportTemp, Security.CurrentUser.LanguageId.ToString(), Security.CurrentUser.TimeZoneId.ToString()); break; case "6": // Tasks reportTemp.ObjectName = "Task"; doc = Report.GetTaskXMLReport(reportTemp, Security.CurrentUser.LanguageId.ToString(), Security.CurrentUser.TimeZoneId.ToString()); break; case "7": // Portfolios reportTemp.ObjectName = "Portfolio"; doc = Report.GetPortfolioXMLReport(reportTemp, Security.CurrentUser.LanguageId.ToString(), Security.CurrentUser.TimeZoneId.ToString()); break; } bool isTemporary = false; int iReportTemplateId = Report.CreateReportTemplate(txtReportTitle.Text, reportTemp.CreateXMLTemplate().InnerXml, !cbOnlyForMe.Checked, isTemporary); pastStep.Value = "7"; Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "<script language='javascript'>" + string.Format("try {{window.opener.top.frames['right'].location.href='{0}';}}", this.ResolveUrl("~/Apps/ReportManagement/Pages/UserReport.aspx")) + "catch (e){}window.close();</script>"); } #endregion }
public int IndexOf(SortInfo field) { return(this.InnerList.IndexOf(field)); }
public void Insert(int index, SortInfo field) { if(field==null) throw new ArgumentNullException(); this.InnerList.Insert(index,field); }
public int IndexOf(SortInfo field) { return this.InnerList.IndexOf(field); }
public void Add(SortInfo field) { if(field==null) throw new ArgumentNullException(); this.InnerList.Add(field); }
protected void btnSave_ServerClick(object sender, System.EventArgs e) { XmlDocument temp = new XmlDocument(); bool isGlobal = true; using (IDataReader reader = Report.GetReportTemplate(TemplateId)) { if (reader.Read()) { // O.R. [2009-06-05]: If report name contains "&" then we got the exception //temp.InnerXml = HttpUtility.HtmlDecode(reader["TemplateXML"].ToString()); temp.InnerXml = reader["TemplateXML"].ToString(); isGlobal = (bool)reader["IsGlobal"]; } } IBNReportTemplate repTemplate = new IBNReportTemplate(temp); QObject qItem = GetQObject(repTemplate); switch (Tab) { case "Fields": string sFields = iFields.Value; ArrayList alFields = new ArrayList(); while (sFields.Length > 0) { alFields.Add(sFields.Substring(0, sFields.IndexOf(","))); sFields = sFields.Remove(0, sFields.IndexOf(",") + 1); } repTemplate.Fields.Clear(); foreach (string s in alFields) { repTemplate.Fields.Add(new FieldInfo(s, qItem.Fields[s].DataType.ToString())); if (repTemplate.Groups[s] != null) repTemplate.Groups.RemoveAt(repTemplate.Groups.IndexOf(repTemplate.Groups[s])); } ArrayList alSort = new ArrayList(); foreach (SortInfo si in repTemplate.Sorting) alSort.Add(si.FieldName); foreach (string s in alSort) { if (repTemplate.Fields[s] == null) repTemplate.Sorting.RemoveAt(repTemplate.Sorting.IndexOf(repTemplate.Sorting[s])); } break; case "Groups": repTemplate.Groups.Clear(); if (ddGroup1.SelectedItem.Value != "01") repTemplate.Groups.Add(new FieldInfo(ddGroup1.SelectedItem.Value, qItem.Fields[ddGroup1.SelectedItem.Value].DataType.ToString())); if (ddGroup2.SelectedItem.Value != "02") repTemplate.Groups.Add(new FieldInfo(ddGroup2.SelectedItem.Value, qItem.Fields[ddGroup2.SelectedItem.Value].DataType.ToString())); break; case "Filters": if (!generate) { BindFilter(""); IBNReportTemplate repTemp = IBNReportTemplate.Load(ResultXML.Value); if (repTemp != null) { repTemplate.Filters.Clear(); foreach (FilterInfo fi in repTemp.Filters) repTemplate.Filters.Add(fi); } } else { foreach (HtmlTableRow row in tblFiltersValues.Rows) { HtmlTableCell cell = row.Cells[0]; IFilterControl ctrl = (IFilterControl)cell.Controls[0]; string FieldName = ctrl.FilterField; FilterInfo flt = new FilterInfo(); flt.FieldName = FieldName; flt.DataType = repTemplate.Filters[FieldName].DataType; repTemplate.Filters.RemoveAt(repTemplate.Filters.IndexOf(repTemplate.Filters[FieldName])); object curValue = null; switch (ctrl.FilterType) { case "Dictionary": curValue = ctrl.Value; if (curValue != null) { foreach (string _s in (string[])curValue) flt.Values.Add(_s); } break; case "DateTime": curValue = ctrl.Value; if (curValue != null) { flt.Values.Add(((DateFilterValue)curValue).TypeValue); flt.Values.Add(((DateFilterValue)curValue).FirstValue); flt.Values.Add(((DateFilterValue)curValue).SecondValue); } break; case "Int": curValue = ctrl.Value; if (curValue != null) { flt.Values.Add(((IntFilterValue)curValue).TypeValue); flt.Values.Add(((IntFilterValue)curValue).FirstValue); flt.Values.Add(((IntFilterValue)curValue).SecondValue); } break; case "String": curValue = ctrl.Value; if (curValue != null) flt.Values.Add(curValue.ToString()); break; case "Time": curValue = ctrl.Value; if (curValue != null) { flt.Values.Add(((TimeFilterValue)curValue).TypeValue); flt.Values.Add(((TimeFilterValue)curValue).FirstValue); flt.Values.Add(((TimeFilterValue)curValue).SecondValue); } break; default: break; } repTemplate.Filters.Add(flt); } } break; case "Sorts": DataTable dt = (DataTable)ViewState["SortFields"]; repTemplate.Sorting.Clear(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { SortInfo si = new SortInfo(); string sS = dr["Field"].ToString(); si.FieldName = sS; si.DataType = qItem.Fields[sS].DataType.ToString(); if (dr["SortDirect"].ToString() == "0") si.SortDirection = Mediachase.IBN.Business.Reports.SortDirection.DESC; else si.SortDirection = Mediachase.IBN.Business.Reports.SortDirection.ASC; repTemplate.Sorting.Add(si); } } break; default: break; } if (!generate) { Report.UpdateReportTemplate(TemplateId, repName.Text, repTemplate.CreateXMLTemplate().InnerXml, isGlobal, false); BindCurrentTab(); } else { XmlDocument doc = GetReportDoc(repTemplate); int iReportId = Report.CreateReportByTemplate(TemplateId, doc.InnerXml); Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "OpenWindow('../Reports/XMLReportOutput.aspx?ReportId=" + iReportId.ToString() + "',screen.width,screen.height,true);window.location.href='../Reports/ReportHistory.aspx?TemplateId=" + TemplateId.ToString() + "';", true); } }