public static AspectResultSet buildAspectResultSet(string strCountry, JobList jl, AspectResultSet arsAnswered) { DataTable dtAspects = CCLib.Cache.GetCachedDataTableWithNoExpire("ASPECT_DETIALS_" + strCountry, "select * from tblaspects" + strCountry); bool[] baInclude = new bool[MaxNoOfAspects]; foreach (JobItem ji in jl) //go through each job in the list { DataRow[] drsAspects = dtAspects.Select("OccNumber=" + ji.JobRef); if (drsAspects.Length > 0) { //make sure we find the job in the aspects table for (int intSection = 1; intSection <= 3; intSection++)//check the core, secondary, other { string strAspectList=""; switch (intSection) { case 1: strAspectList = drsAspects[0]["Central"].ToString(); break; case 2: strAspectList = drsAspects[0]["Secondary"].ToString(); break; case 3: strAspectList = drsAspects[0]["Other"].ToString(); break; }; //check which aspects they should of answered for (int i = 0; i < strAspectList.Length; i = i + 3) { baInclude[Convert.ToInt16(strAspectList.Substring(i, 3).ToString())] = true; //set a flag for each aspect }; }; }; }; AspectResultSet ars = new AspectResultSet(); for (int i = 1; i < MaxNoOfAspects; i++) // go through our list of flags { //if the flags say they shold of answered it if (baInclude[i] == true) { //if the client hasn't already answered them AspectResult aspectResult = arsAnswered.Find(delegate(AspectResult ar) { return ar.AspectRef == i; } ); if (aspectResult == null) //if it's not in the list of aspects the client has answered { AspectResult ar = new AspectResult(); ar.AspectRef = i; ars.Add(ar); } else if (aspectResult.AspectResponse < 1)// or it's in the list but it has no response { AspectResult ar = new AspectResult(); ar.AspectRef = i; ars.Add(ar); } }; }; return (ars); }
public static AspectResultSet buildAspectResultSet(string strLangCode, AspectResultSet arsAnswered) { //build unanswered aspects AspectResultSet ds = new AspectResultSet(); DataTable dtAspects = CCLib.Cache.GetCachedDataTableWithNoExpire("QU_ALL_ASPECT_IDS_" + strLangCode, "Select QuestionID from tblquestions" + strLangCode + " order by questionid"); foreach (DataRow rt in dtAspects.Rows) { AspectResult aspectResult = arsAnswered.Find(delegate(AspectResult ar) { return ar.AspectRef == Convert.ToInt16(rt["QuestionID"].ToString()); } ); if (aspectResult == null) //if it's not in the list of aspects the client has answered { AspectResult ar = new AspectResult(); ar.AspectRef = Convert.ToInt16(rt["QuestionID"].ToString()); ar.AspectResponse = -1; ds.Add(ar); } else if (aspectResult.AspectResponse < 1)// or it's in the list but it has no response { AspectResult ar = new AspectResult(); ar.AspectRef = Convert.ToInt16(rt["QuestionID"].ToString()); ar.AspectResponse = -1; ds.Add(ar); } }; return (ds); }