예제 #1
0
파일: Report.cs 프로젝트: 0anion0/IBN
        public static XmlDocument GetDocumentXMLReport(IBNReportTemplate repTemp, string _lang, string _timeoffset)
        {
            QDocument objD = new QDocument();
            QMaker qMaker = new QMaker(objD);
            qMaker.Language = _lang;
            qMaker.TimeOffset = _timeoffset;

            #region Fields
            foreach (FieldInfo fi in repTemp.Fields)
            {
                qMaker.Fields.Add(objD.Fields[fi.Name]);
            }
            #endregion

            #region GroupFields
            foreach (FieldInfo fi1 in repTemp.Groups)
            {
                qMaker.Groups.Add(objD.Fields[fi1.Name]);
            }
            #endregion

            #region Filters
            if (!Security.IsUserInGroup(InternalSecureGroups.PowerProjectManager) &&
                !Security.IsUserInGroup(InternalSecureGroups.ExecutiveManager))
            {
                qMaker.PrevSqlQuery.Add(String.Format("DECLARE @DocumentIdTable TABLE(Id INT) " +
                    "INSERT INTO @DocumentIdTable " +
                    "SELECT DISTINCT TD.DocumentId As Id FROM DOCUMENTS AS TD " +
                    "WHERE TD.DocumentId IN (SELECT DocumentId FROM DOCUMENT_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["DocId"], "(SELECT Id FROM @DocumentIdTable)", SimpleFilterType.In));
            }

            foreach (FilterInfo fti in repTemp.Filters)
            {
                QField qField = objD.Fields[fti.FieldName];
                QDictionary qDic = objD.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(objD.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(objD.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Equal));
                                        break;
                                    case "1":
                                        qMaker.Filters.Add(new SimpleFilterCondition(objD.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Great));
                                        break;
                                    case "2":
                                        qMaker.Filters.Add(new SimpleFilterCondition(objD.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Less));
                                        break;
                                    case "3":
                                        qMaker.Filters.Add(new IntervalFilterCondition(objD.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(objD.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(objD.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(objD.Fields[fti.FieldName], "CONVERT(datetime,'" + DateTime.Parse(fti.Values[1]).ToString("yyyy-MM-dd") + "',120)", SimpleFilterType.GreatOrEqual));
                                }
                                else
                                {
                                    qMaker.Filters.Add(new IntervalFilterCondition(objD.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(objD.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;
        }
예제 #2
0
파일: Report.cs 프로젝트: 0anion0/IBN
        public static XmlDocument GetIncidentXMLReport(IBNReportTemplate repTemp, string _lang, string _timeoffset)
        {
            QIncident objI = new QIncident();

            QMaker qMaker = new QMaker(objI);
            qMaker.Language = _lang;
            qMaker.TimeOffset = _timeoffset;

            #region Fields
            foreach (FieldInfo fi in repTemp.Fields)
            {
                qMaker.Fields.Add(objI.Fields[fi.Name]);
            }
            #endregion

            #region GroupFields
            foreach (FieldInfo fi1 in repTemp.Groups)
            {
                qMaker.Groups.Add(objI.Fields[fi1.Name]);
            }
            #endregion

            #region Filters
            bool PrjFilterExist = false;
            foreach (FilterInfo fti in repTemp.Filters)
            {
                if (fti.FieldName == "IncProjectId")
                    PrjFilterExist = true;
                QField qField = objI.Fields[fti.FieldName];
                QDictionary qDic = objI.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(objI.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(objI.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Equal));
                                        break;
                                    case "1":
                                        qMaker.Filters.Add(new SimpleFilterCondition(objI.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Great));
                                        break;
                                    case "2":
                                        qMaker.Filters.Add(new SimpleFilterCondition(objI.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Less));
                                        break;
                                    case "3":
                                        qMaker.Filters.Add(new IntervalFilterCondition(objI.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(objI.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(objI.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(objI.Fields[fti.FieldName], "CONVERT(datetime,'" + DateTime.Parse(fti.Values[1]).ToString("yyyy-MM-dd") + "', 120)", SimpleFilterType.GreatOrEqual));
                                }
                                else
                                {
                                    qMaker.Filters.Add(new IntervalFilterCondition(objI.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(objI.Fields[fti.FieldName], GetApString(fti.Values[0]), SimpleFilterType.Like));
                            }
                            break;
                    }
                }
            }
            if (!PrjFilterExist &&
                    !(Security.IsUserInGroup(InternalSecureGroups.PowerProjectManager) || Security.IsUserInGroup(InternalSecureGroups.ExecutiveManager)))
            {
                ArrayList alPrj = new ArrayList();
                using (IDataReader reader = Project.GetListProjects())
                {
                    while (reader.Read())
                        alPrj.Add(((int)reader["ProjectId"]).ToString());
                }
                alPrj.Add("NULL");
                string[] _str = new string[alPrj.Count];
                int i = 0;
                foreach (string s in alPrj)
                    _str[i++] = s;
                qMaker.Filters.Add(new SimpleFilterCondition(objI.Fields["IncProjectId"], _str, SimpleFilterType.Equal));
            }
            #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;
        }
예제 #3
0
파일: Report.cs 프로젝트: 0anion0/IBN
        public static XmlDocument GetUsersXMLReport(IBNReportTemplate repTemp, string _lang, string _timeoffset)
        {
            QDirectory objD = new QDirectory();
            QMaker qMaker = new QMaker(objD);
            qMaker.Language = _lang;
            qMaker.TimeOffset = _timeoffset;

            #region Fields
            foreach (FieldInfo fi in repTemp.Fields)
            {
                qMaker.Fields.Add(objD.Fields[fi.Name]);
            }
            #endregion

            #region GroupFields
            foreach (FieldInfo fi1 in repTemp.Groups)
            {
                qMaker.Groups.Add(objD.Fields[fi1.Name]);
            }
            #endregion

            #region Filters
            foreach (FilterInfo fti in repTemp.Filters)
            {
                QField qField = objD.Fields[fti.FieldName];
                QDictionary qDic = objD.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(objD.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(objD.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Equal));
                                        break;
                                    case "1":
                                        qMaker.Filters.Add(new SimpleFilterCondition(objD.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Great));
                                        break;
                                    case "2":
                                        qMaker.Filters.Add(new SimpleFilterCondition(objD.Fields[fti.FieldName], fti.Values[1].ToString(), SimpleFilterType.Less));
                                        break;
                                    case "3":
                                        qMaker.Filters.Add(new IntervalFilterCondition(objD.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(objD.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(objD.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(objD.Fields[fti.FieldName], "CONVERT(datetime,'" + DateTime.Parse(fti.Values[1]).ToString("yyyy-MM-dd") + "',120)", SimpleFilterType.GreatOrEqual));
                                }
                                else
                                {
                                    qMaker.Filters.Add(new IntervalFilterCondition(objD.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(objD.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;
        }