public static XmlDocument GetToDoXMLReport(IBNReportTemplate repTemp, string _lang, string _timeoffset) { QToDo objT = new QToDo(); QMaker qMaker = new QMaker(objT); qMaker.Language = _lang; qMaker.TimeOffset = _timeoffset; #region Fields foreach (FieldInfo fi in repTemp.Fields) { qMaker.Fields.Add(objT.Fields[fi.Name]); } #endregion #region GroupFields foreach (FieldInfo fi1 in repTemp.Groups) { qMaker.Groups.Add(objT.Fields[fi1.Name]); } #endregion #region Filters if (!Security.IsUserInGroup(InternalSecureGroups.PowerProjectManager) && !Security.IsUserInGroup(InternalSecureGroups.ExecutiveManager)) { qMaker.PrevSqlQuery.Add(String.Format( "DECLARE @ToDoIdTable TABLE(Id INT) " + "INSERT INTO @ToDoIdTable " + " SELECT DISTINCT TD.ToDoId As Id FROM TODO AS TD " + " WHERE TD.ToDoId IN (SELECT ToDoId FROM TODO_SECURITY_ALL WHERE PrincipalId = {0} AND (IsManager = 1 OR IsResource = 1))" + " OR TD.ProjectId IN (SELECT ProjectId FROM PROJECT_SECURITY_ALL WHERE PrincipalId = {0} AND (IsTeamMember = 1 OR IsSponsor = 1 OR IsStakeHolder = 1 OR IsManager = 1 OR IsExecutiveManager = 1))", Security.CurrentUser.UserID)); qMaker.Filters.Add(new SimpleFilterCondition(qMaker.OwnerObject.Fields["ToDoId"], "(SELECT Id FROM @ToDoIdTable)", SimpleFilterType.In)); } foreach (FilterInfo fti in repTemp.Filters) { QField qField = objT.Fields[fti.FieldName]; QDictionary qDic = objT.GetDictionary(qField); if (qDic != null) { if (fti.Values.Count > 0) { string[] _str = new string[fti.Values.Count]; int i = 0; foreach (string s in fti.Values) _str[i++] = s; qMaker.Filters.Add(new SimpleFilterCondition(objT.Fields[qDic.FieldId.Name], _str, SimpleFilterType.Equal)); } } else { switch (qField.DataType) { case DbType.Decimal: case DbType.Int32: case DbType.Time: if (fti.Values.Count > 0) { switch (fti.Values[0]) { case "0": qMaker.Filters.Add(new SimpleFilterCondition(objT.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Equal)); break; case "1": qMaker.Filters.Add(new SimpleFilterCondition(objT.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Great)); break; case "2": qMaker.Filters.Add(new SimpleFilterCondition(objT.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Less)); break; case "3": qMaker.Filters.Add(new IntervalFilterCondition(objT.Fields[fti.FieldName], fti.Values[1].ToString(), fti.Values[2].ToString())); break; } } break; case DbType.DateTime: case DbType.Date: if (fti.Values.Count > 0) { DateTime _Start = DateTime.MinValue; DateTime _Finish = DateTime.MaxValue; string sVal = fti.Values[0]; SetDates(sVal, out _Start, out _Finish); if (sVal != "9") { qMaker.Filters.Add(new IntervalFilterCondition(objT.Fields[fti.FieldName], "CONVERT(datetime,'" + _Start.ToString("yyyy-MM-dd") + "',120)", "CONVERT(datetime,'" + _Finish.ToString("yyyy-MM-dd") + "',120)")); } else if (DateTime.Parse(fti.Values[1]) == DateTime.MinValue) { qMaker.Filters.Add(new SimpleFilterCondition(objT.Fields[fti.FieldName], "CONVERT(datetime,'" + DateTime.Parse(fti.Values[2]).ToString("yyyy-MM-dd") + "',120)", SimpleFilterType.LessOrEqual)); } else if (DateTime.Parse(fti.Values[2]) >= DateTime.MaxValue.Date) { qMaker.Filters.Add(new SimpleFilterCondition(objT.Fields[fti.FieldName], "CONVERT(datetime,'" + DateTime.Parse(fti.Values[1]).ToString("yyyy-MM-dd") + "',120)", SimpleFilterType.GreatOrEqual)); } else { qMaker.Filters.Add(new IntervalFilterCondition(objT.Fields[fti.FieldName], "CONVERT(datetime,'" + DateTime.Parse(fti.Values[1]).ToString("yyyy-MM-dd") + "',120)", "CONVERT(datetime,'" + DateTime.Parse(fti.Values[2]).ToString("yyyy-MM-dd") + "',120)")); } } break; case DbType.String: if (fti.Values.Count > 0) { qMaker.Filters.Add(new SimpleFilterCondition(objT.Fields[fti.FieldName], GetApString(fti.Values[0]), SimpleFilterType.Like)); } break; } } } #endregion string sql = qMaker.Create(); XmlDocument doc = DBReport.GetXMLReport(sql); QMetaLoader.AddHeaderInformation(doc, qMaker); //QMetaLoader.AddSortInformation(doc, repTemp); //QMetaLoader.AddFilterInformation(doc, repTemp); AddTemplateInfo(doc, repTemp); ProcessResourceValues(doc); return doc; }
protected void Page_Load(object sender, System.EventArgs e) { UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/windows.css"); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/Theme.css"); UtilHelper.RegisterCssStyleSheet(Page, "~/Styles/IbnFramework/ibn.css"); UtilHelper.RegisterScript(Page, "~/Scripts/browser.js"); UtilHelper.RegisterScript(Page, "~/Scripts/buttons.js"); if (Request["Refresh"] != null && Request["Refresh"] == "1") Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), string.Format("try {{window.moveTo(0,0);window.resizeTo(screen.availWidth,screen.availHeight);window.opener.top.frames['right'].location.href='{0}';}}", this.ResolveUrl("~/Apps/ReportManagement/Pages/UserReport.aspx")) + "catch (e){}", true); if (!Page.IsPostBack) { if (Request["Mode"] != null && bool.Parse(Request["Mode"].ToString())) { int iTemplateId = -1; using (IDataReader reader = Report.GetReport(ReportId)) { if (reader.Read()) { iTemplateId = (int)reader["TemplateId"]; } } if (iTemplateId > 0) using (IDataReader rdr = Report.GetReportTemplate(iTemplateId)) { if (rdr.Read()) { txtTemplateTitle.Text = rdr["Name"].ToString(); } } // btnSaveVis.Visible = true; --[2006/01/17] btnSaveVis.Visible = false; } else btnSaveVis.Visible = false; } if (ReportId == -1) { return; } if (!Page.IsPostBack && (Request["Export"] == null || Request["Export"] != "2")) { byte[] bit_data = null; using (IDataReader reader_BLOB = Report.GetReportBinaryData(ReportId)) { if (reader_BLOB.Read()) { bit_data = (byte[])reader_BLOB["ReportData"]; } } XmlDocument doc = new XmlDocument(); doc.InnerXml = System.Text.Encoding.UTF8.GetString(bit_data); IBNReportTemplate repTemplate = null; using (IDataReader reader = Report.GetReport(ReportId)) { if (reader.Read()) { _header.ReportCreated = (DateTime)reader["ReportCreated"]; _header.ReportCreator = CommonHelper.GetUserStatusPureName((int)reader["ReportCreator"]); XmlDocument temp = new XmlDocument(); temp.InnerXml = "<IBNReportTemplate>" + doc.SelectSingleNode("Report/IBNReportTemplate").InnerXml + "</IBNReportTemplate>"; repTemplate = new IBNReportTemplate(temp); _header.Title = HttpUtility.HtmlDecode(repTemplate.Name); } } #region Filters QObject qItem = null; switch (repTemplate.ObjectName) { case "Incident": //Incident qItem = new QIncident(); break; case "Project": //Project qItem = new QProject(); break; case "ToDo": //ToDo`s qItem = new QToDo(); break; case "Event": //Calendar Entries qItem = new QCalendarEntries(); break; case "Document": //Documents qItem = new QDocument(); break; case "Directory": //Users qItem = new QDirectory(); break; case "Task": //Tasks qItem = new QTask(); break; case "Portfolio": //Portfolios qItem = new QPortfolio(); break; default: break; } _header.Filter = MakeFilterText(repTemplate, qItem); #endregion _header.BtnPrintVisible = false; bool ShowEmpty = repTemplate.ShowEmptyGroup; int GroupCount = repTemplate.Groups.Count; string ViewType = repTemplate.ViewType; string sPath = ""; if (GroupCount == 0) sPath = HttpRuntime.AppDomainAppPath + @"Reports\GroupWithout.xslt"; else if (GroupCount == 1 && ShowEmpty) { if (ViewType == "0") { sPath = HttpRuntime.AppDomainAppPath + @"Reports\GroupOne.xslt"; } else { sPath = HttpRuntime.AppDomainAppPath + @"Reports\GroupOneCollapse.xslt"; } } else if (GroupCount == 1 && !ShowEmpty) { if (ViewType == "0") { sPath = HttpRuntime.AppDomainAppPath + @"Reports\GroupOneNoEmpty.xslt"; } else { sPath = HttpRuntime.AppDomainAppPath + @"Reports\GroupOneNoEmptyCollapse.xslt"; } } else if (GroupCount == 2 && ShowEmpty) { if (ViewType == "0") { sPath = HttpRuntime.AppDomainAppPath + @"Reports\GroupTwo.xslt"; } else { sPath = HttpRuntime.AppDomainAppPath + @"Reports\GroupTwoCollapse.xslt"; } } else if (GroupCount == 2 && !ShowEmpty) { if (ViewType == "0") { sPath = HttpRuntime.AppDomainAppPath + @"Reports\GroupTwoNoEmpty.xslt"; } else { sPath = HttpRuntime.AppDomainAppPath + @"Reports\GroupTwoNoEmptyCollapse.xslt"; } } XslCompiledTransform _transform = new XslCompiledTransform(); XsltSettings set = new XsltSettings(true, true); _transform.Load(sPath, set, null); StringWriter sw = new StringWriter(); XmlTextWriter w = new XmlTextWriter(sw); _transform.Transform(doc, w); w.Close(); lblXML.Text = HttpUtility.HtmlDecode(sw.ToString()); } if (Request["Export"] != null && Request["Export"] == "2") { ExportXML(); } if (Request["Export"] != null && Request["Export"] == "1") { ExportExcel(); } btnSave.Text = LocRM.GetString("tSave"); btnSaveVis.Value = LocRM.GetString("tSaveAsTemplate"); btnExcel.Text = LocRM.GetString("Export"); btnXML.Text = LocRM.GetString("XMLExport"); lgdSaveTemplate.InnerText = LocRM.GetString("tSaveTemplate"); cbSaveResult.Text = LocRM.GetString("tSaveResult"); cbOnlyForMe.Text = LocRM.GetString("tOnlyForMe"); }
private QObject GetQObject(IBNReportTemplate repTemp) { QObject qItem = null; switch (repTemp.ObjectName) { case "Incident": //Incident qItem = new QIncident(); break; case "Project": //Project qItem = new QProject(); break; case "ToDo": //ToDo`s qItem = new QToDo(); break; case "Event": //Calendar Entries qItem = new QCalendarEntries(); break; case "Document": //Documents qItem = new QDocument(); break; case "Directory": //Users qItem = new QDirectory(); break; case "Task": //Tasks qItem = new QTask(); break; case "Portfolio": //Portfolios qItem = new QPortfolio(); break; default: break; } return qItem; }