Esempio n. 1
0
        private List <TSS_Section> GetTreeView(List <TSS_Section> sec, List <TSS_Section> record)
        {
            TSS_SectionBL sb = new TSS_SectionBL();

            foreach (var s in sec)
            {
                var sec2 = record.Where(m => m.PSectionId == s.SectionId).ToList();// sb.ToList("By_SectionId", s.PSectionId.ToString()).ToList();
                if (sec2 != null)
                {
                    s.Sections.AddRange(sec2);
                    GetTreeView(sec2, record);
                }
            }

            return(sec);
        }
Esempio n. 2
0
        public TSS_SurveyDocument SurvayBySite(Int64 SiteSurveyId)
        {
            TSS_SurveyDocument sur = new TSS_SurveyDocument();
            TSS_SectionBL      sb  = new TSS_SectionBL();
            //----------------------------------------

            //var result = myList.GroupBy(test => test.id)
            //.Select(grp => grp.First())
            //.ToList();

            TSS_SectionDL sd = new TSS_SectionDL();
            DataTable     dt = sd.Get("By_SiteSurveyId", SiteSurveyId.ToString());

            if (dt.Rows.Count != 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    sur.SiteId     = int.Parse(dt.Rows[0]["SiteId"].ToString());
                    sur.SiteCode   = dt.Rows[0]["SiteCode"].ToString();
                    sur.WoRefId    = dt.Rows[0]["WoRefId"].ToString();
                    sur.Status     = dt.Rows[0]["Status"].ToString();
                    sur.ClientName = dt.Rows[0]["ClientName"].ToString();

                    sur.CityName = dt.Rows[0]["CityName"].ToString();
                    sur.Scope    = dt.Rows[0]["Scope"].ToString();

                    sur.Category    = dt.Rows[0]["Category"].ToString();
                    sur.SubCategory = dt.Rows[0]["SubCategory"].ToString();

                    sur.Latitude  = dt.Rows[0]["Latitude"].ToString();
                    sur.Longitude = dt.Rows[0]["Longitude"].ToString();

                    sur.SurveyId     = int.Parse(dt.Rows[0]["SurveyId"].ToString());
                    sur.SiteSurveyId = int.Parse(dt.Rows[0]["SiteSurveyId"].ToString());

                    sur.SurveyTitle = dt.Rows[0]["SurveyTitle"].ToString();
                    sur.Description = dt.Rows[0]["Sur Descp"].ToString();
                    break;
                }


                var temp = dt.AsEnumerable()
                           .GroupBy(r => new { Col1 = r["SiteSectionId"] })
                           .Select(g => g.OrderBy(r => r["SiteSectionId"]).First())
                           .CopyToDataTable();

                List <TSS_Section> sec = temp.ToList <TSS_Section>();
                TSS_QuestionBL     qb  = new TSS_QuestionBL();

                foreach (var q in sec)
                {
                    var que = qb.ToList("GET_QUESTION_BY_SECTION", q.SiteSectionId.ToString());
                    if (que != null)
                    {
                        q.Questions.AddRange(que);
                    }

                    TSS_ResponseBL    rb   = new TSS_ResponseBL();
                    RequiredActionsBL reqA = new RequiredActionsBL();

                    foreach (var r in que)
                    {
                        var resp = rb.ToList("GET_RESPONSE_BY_SITEQUESTION", r.QuestionId.ToString());
                        if (resp != null)
                        {
                            r.Responses.AddRange(resp);
                        }
                    }

                    foreach (var r in que)
                    {
                        var rAction = reqA.ToList("GET_REQACTION_BY_SITEQUESTION", r.QuestionId.ToString());
                        if (rAction != null)
                        {
                            r.ReqActions.AddRange(rAction);
                        }
                    }
                }

                sur.Sections = sec;


                //var temp = dt.AsEnumerable()
                //                  .GroupBy(r => new { Col1 = r["SiteSectionId"] })
                //                  .Select(g => g.OrderBy(r => r["SiteSectionId"]).First())
                //                  .CopyToDataTable();
                //List<TSS_Section> sec = temp.ToList<TSS_Section>();

                //foreach (var item in sec)
                //{
                //    dt.DefaultView.RowFilter = "SiteSectionId='" + item.SiteSectionId + "'";
                //    DataTable ques = (dt.DefaultView).ToTable();
                //    item.Questions = ques.ToList<TSS_Question>();

                //    foreach (var res in item.Questions)
                //    {
                //        dt.DefaultView.RowFilter = "QuestionId='" + res.QuestionId + "'";
                //        DataTable quesLogic = (dt.DefaultView).ToTable();
                //        res.QuestionLogics = quesLogic.ToList<TSS_QuestionLogic>();


                //        dt.DefaultView.RowFilter = "QuestionId='" + res.QuestionId + "'";
                //        DataTable response = (dt.DefaultView).ToTable();
                //        res.Responses = response.ToList<TSS_Response>();

                //        dt.DefaultView.RowFilter = "SiteQuestionId='" + res.QuestionId + "'";
                //        DataTable reqAction = (dt.DefaultView).ToTable();
                //        res.ReqActions = reqAction.ToList<RequiredActions>();
                //    }
                //}
                //sur.Sections = sec;

                //-------------------------------
            }
            return(sur);
        }