public static TOWList buildTOWList(string strSuffixCountryLangCode, string strSuffixCode, JobList jl, string strCluster) { //first we create a TOWlist TOWList tl = new TOWList(); //now we get each row from the underlying tables... //mrm string strTmpLang = strLangCode; // string strTmpSuffix = strSuffixCode; // if (strTmpLang == "EN"){strTmpLang ="";} // else{strTmpLang = "_"+strTmpLang;}; // if (strTmpSuffix=="CA") {strTmpSuffix ="Canada";}; // DataTable dt = CCLib.Cache.GetCachedDataTableWithNoExpire("ClusterCodes_"+ strCluster + "_" + strTmpLang, "select clustercode as code, clustename"+strTmpLang+" as title from clustercodes where clustertype='"+strCluster+"'"); DataTable dt = CCLib.Cache.GetCachedDataTableWithNoExpire("ClusterCodes_"+strSuffixCode+"_"+strCluster, "select clustercode as code, clustename" + strSuffixCode + " as title from clustercodes where clustertype='" + strCluster + "'"); foreach (DataRow rt in dt.Rows) { TOWItem ti = new TOWItem(); ti.Title = rt["title"].ToString(); ti.Code = rt["code"].ToString(); tl.Add(ti); }; //now we get the cluster vs job list //mrm DataTable dtCluster = CCLib.Cache.GetCachedDataTable("Cluster" + strSuffixCode + "_" + strLangCode, "select * from Clusters" + strSuffixCode + "_" + strLangCode + "_View"); DataTable dtCluster = CCLib.Cache.GetCachedDataTable("Cluster" + strSuffixCountryLangCode, "select * from Clusters" + strSuffixCountryLangCode + "_View"); DataRow[] drsClusterCodes; // string strClusterType = "CCClusters";//mrm remove not used foreach (JobItem ji in jl) { string strSQL="OccNumber=" + ji.JobRef.ToString(); drsClusterCodes = dtCluster.Select(strSQL); //now we find the matching clusters if (drsClusterCodes.Length >0) { //mrm string strFoundCode = drsClusterCodes[0][strClusterType].ToString(); string strFoundCode = drsClusterCodes[0][strCluster].ToString(); List<TOWItem> tltmp = tl.FindAll(delegate(TOWItem towitem){return(strFoundCode.IndexOf(towitem.Code)>=0);}); foreach(TOWItem tOWItem in tltmp) { tOWItem.Score = tOWItem.Score + (jl.Count - ji.Rank)+1; }; }; //yuk!! sequential search - need to check for better way } //sort the list by score tl.Sort(delegate(TOWItem x, TOWItem y) { return Comparer.Default.Compare(y.Score, x.Score); }); if (tl.Count >2) { tl.RemoveRange(2, tl.Count - 2); }; for (int i = 0; i < tl.Count; i++) { if (tl[i].Score < 83) { tl.Remove(tl[i]); i = i - 1; }; }; return(tl); }
public static TOWList buildTOWList(string strSuffixCountryLangCode, string strSuffixCode, string strCluster) { //first we create a TOWlist TOWList tl = new TOWList(); //now we get each row from the underlying tables... //mrm string strTmpLang = strLangCode; // string strTmpSuffix = strSuffixCode; // if (strTmpLang == "EN") { strTmpLang = ""; } // else { strTmpLang = "_" + strTmpLang; }; // if (strTmpSuffix == "CA") { strTmpSuffix = "Canada"; }; // DataTable dt = CCLib.Cache.GetCachedDataTableWithNoExpire("ClusterCodes_"+strCluster+ "_" + strTmpLang, "select clustercode as code, clustename" + strTmpLang + " as title from clustercodes where clustertype='"+strCluster+"'"); DataTable dt = CCLib.Cache.GetCachedDataTableWithNoExpire("ClusterCodes_" + strSuffixCode + "_" + strCluster, "select clustercode as code, clustename" + strSuffixCode + " as title from clustercodes where clustertype='" + strCluster + "'"); foreach (DataRow rt in dt.Rows) { TOWItem ti = new TOWItem(); ti.Title = rt["title"].ToString(); ti.Code = rt["code"].ToString(); tl.Add(ti); }; return (tl); }