public HttpResponseMessage RmUserToGr([FromBody] MKV9984[] values) { results <MKV9999> rel = new results <MKV9999>(); DB db = new DB(); foreach (MKV9984 val in values) { result <MKV9999> tm = new result <MKV9999>(); MKV9984 check = (from kjkj in db.MKV9984 where kjkj.MKV9999_ID == val.MKV9999_ID && kjkj.MKV9983_ID == val.MKV9983_ID select kjkj).FirstOrDefault(); if (check == null) { } else { db.MKV9984.Remove(check); try { db.SaveChanges(); tm.set("OK", db.MKV9999.SingleOrDefault(p => p.MKV9999_ID == val.MKV9999_ID), "Thành công"); } catch (Exception d) { tm.set("ERR", db.MKV9999.SingleOrDefault(p => p.MKV9999_ID == val.MKV9999_ID), "Thất bại: " + d.Message); } } rel.add(tm); } return((rel.ToHttpResponseMessage())); }
public HttpResponseMessage delete([FromBody] KTX0010[] values) { DB db = new DB(); results <KTX0010> list = new results <KTX0010>(); foreach (var value in values) { result <KTX0010> rel = new result <KTX0010>(); var check = db.KTX0010.SingleOrDefault(p => p.KTX0010_ID == value.KTX0010_ID); if (check != null) { try { db.KTX0010.Remove(check); db.SaveChanges(); rel.set("OK", value, "Thành công"); } catch (Exception rr) { rel.set("ERR", value, "Thất bại: " + rr.Message); } } else { rel.set("ERR", value, "Không thấy dữ liệu bản ghi."); } list.add(rel); } return(list.ToHttpResponseMessage()); }
private static results checkRow(int[] row) { results result = results.UNKNOWN; int first = row[0]; if (row.All(s => int.Equals(first, s))) { if (first == 1) { result = results.X; } if (first == 2) { result = results.O; } } if (row.Contains(1) && row.Contains(2)) { result = results.Draw; } if (row.Count(s => s == 0) > 0) { result = results.EmptySpots; } return(result); }
public HttpResponseMessage Deletes([FromBody] DX0011[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0011.SingleOrDefault(p => p.DX0011_ID == val.DX0011_ID); if (check != null) { db.DX0011.Remove(check); try { db.SaveChanges(); rel.set("DELETE", getDX0011(check)); } catch (Exception s) { rel.set("ERR", getDX0011(check), s.Message); } } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage add([FromBody] KTX0010[] values) { DB db = new DB(); results <KTX0010> list = new results <KTX0010>(); foreach (var value in values) { result <KTX0010> rel = new result <KTX0010>(); KTX0010 t = value; var check = db.KTX0010.FirstOrDefault(p => p.WH0007_ID == t.WH0007_ID && p.WH0007_ID != null); if (check == null) { try { var kkk = db.KTX0010.Add(t); db.SaveChanges(); rel.set("OK", t, "Thành công"); } catch (Exception rr) { rel.set("ERR", t, "Thất bại: " + rr.Message); } } else { rel.set("ERR", t, "Thất bại: Mặt hàng này đã tồn tại trên hệ thống."); } list.add(rel); } return(list.ToHttpResponseMessage()); }
public HttpResponseMessage add([FromBody] A0028[] values) { using (DB db = new DB()) { results <A0028> list = new results <A0028>(); values.ToList().ForEach(value => { result <A0028> rel = new result <A0028>(); var check = db.A0028.SingleOrDefault(p => p.A0028_ID == value.A0028_ID); if (check == null) { var c = db.A0028.Select(p => p.sophieu).Max(); value.sophieu = (c == null ? 0 : c) + 1; db.A0028.Add(value); try { db.SaveChanges(); rel.set("OK", value); } catch (Exception d) { rel.set("ERR", value, "Thất bại: " + d.Message); } } else { rel.set("EXIST", value, "Lỗi: Đã tồn tại"); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage updatenguoiphongvan([FromBody] A0028E[] value) { using (DB db = new DB()) { results <Exception> list = new results <Exception>(); value.ToList().ForEach(val => { result <Exception> rel = new result <Exception>(); var check = db.A0028E.Where(p => p.A0028_ID == val.A0028_ID && p.MKV9999_ID == val.MKV9999_ID); if (check == null) { db.A0028E.Add(new A0028E() { A0028E_ID = val.A0028E_ID, MKV9999_ID = val.MKV9999_ID }); } try { db.SaveChanges(); rel.set("OK", null); } catch (Exception j) { rel.set("OK", j); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
// GET api/values/5 public List <results> Get(int id) { MySqlConnection conn = WebApiConfig.conn(); string query = $"Select username, password FROM all_users WHERE id='{id}'"; MySqlCommand selectByIdQuery = new MySqlCommand(query, conn); var results = new List <results>(); try { conn.Open(); } catch (MySql.Data.MySqlClient.MySqlException ex) { results user = new results(null, null, ex.ToString()); results.Add(user); return(results); } MySqlDataReader fetch_query = selectByIdQuery.ExecuteReader(); if (fetch_query.Read()) { results user = new results( fetch_query["username"].ToString(), fetch_query["password"].ToString(), null ); results.Add(user); } return(results); }
public HttpResponseMessage approval([FromBody] KTX0020[] values) { results <KTX0020> rel = new results <KTX0020>(); using (DB db = new DB()) { foreach (var k in values) { result <KTX0020> re = new result <KTX0020>(); var check = db.KTX0020.SingleOrDefault(p => p.KTX0020_ID == k.KTX0020_ID); if (check != null) { check.trangthai = true; check.hotenbengiao = k.hotenbengiao; check.ngayduyetdon = DateTime.Now; check.ngaycohieuluc = DateTime.Now; try { db.SaveChanges(); k.ngayduyetdon = DateTime.Now; k.ngaycohieuluc = DateTime.Now; k.trangthai = true; re.set("OK", k, "Thành công"); } catch (Exception fd) { re.set("ERR", k, "Thất bại: " + fd.Message); } } rel.add(re); } return(rel.ToHttpResponseMessage()); } }
public results saveEnquiry(enquiryModel enquryParams) { using (DAL db = new DAL()) { results results = new results(); try { SqlCommand cmd = new SqlCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "sp_SaveEnquiry"; cmd.Parameters.AddWithValue("@fullname", enquryParams.fullname); cmd.Parameters.AddWithValue("@email", enquryParams.email); cmd.Parameters.AddWithValue("@contactNumber", enquryParams.contactNumber); cmd.Parameters.AddWithValue("@queryMessage", enquryParams.queryMessage); DataSet ds = db.ReturnDataset(cmd); results.flag = Convert.ToBoolean(ds.Tables[0].Rows[0]["Flag"]); results.msg = Convert.ToString(ds.Tables[0].Rows[0]["msg"]); return(results); } catch (Exception) { throw; } } }
private void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e) { App.log($"Query status check @ {e.SignalTime} | Runtime : {runtime()} | Max RunTime : {App.queryMaxRunTime}"); if (state == states.Running) { if (runtime() > App.queryMaxRunTime) { App.log($"need to cancel query.| Runtime : {runtime()} | Max RunTime : {App.queryMaxRunTime} "); Timing timing = new Timing(this.db); cmd.Cancel(); timing.stop(); timing.log("Cancelling Query"); state = states.Done; result = results.Stopped; timer.Stop(); throw new TimeoutException($"SQL Query exceeded maximum allowed runtime. | Runtime : {runtime()} | Max RunTime : {App.queryMaxRunTime} "); // I should save/log this efffort and allow a retry - now while in memory? // or leave the scheduler retry } else { timer.Start(); // schedule another run } } else { App.log($@"This query should have stopped. Will stop {errorMsg} {sql}"); timer.Stop(); } }
private static results runner(Graph g, string outputFile, Algorithm a) { Visualizer v = new Visualizer(); int i = 0; a.start(g); var start = Process.GetCurrentProcess().TotalProcessorTime; var stopwatch = Stopwatch.StartNew(); while (!a.step(g)) { i++; if (outputFile != null) { string s = String.Format("{0}.{1}", outputFile, i); v.Visualize(g, s); } } stopwatch.Stop(); var stop = Process.GetCurrentProcess().TotalProcessorTime; if (outputFile != null) { v.Visualize(g, outputFile, 1024, 1024); } results r = new results(); r.iterations = i + 1; r.runtime = stopwatch.ElapsedMilliseconds;//(stop - start).TotalMilliseconds; r.stats = GraphStatistics.From(g); r.graph = g; return(r); }
public HttpResponseMessage add([FromBody] DX0001[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0001.Where(p => p.A0028_ID == val.A0028_ID).FirstOrDefault(); if (check == null) { db.DX0001.Add(val); try { db.SaveChanges(); rel.set("OK", getDX0001(val)); } catch (Exception f) { rel.set("ERR", getDX0001(val), f.Message); } } else { rel.set("EXIST", getDX0001(check)); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage Getall([FromBody] RM0015A[] values) { using (DB db = new DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.RM0015A.SingleOrDefault(p => p.RM0015A_ID == val.RM0015A_ID); if (check != null) { check.ghiChu = val.ghiChu; check.trangThai = val.trangThai; try { db.SaveChanges(); rel.set("OK", GetRM0015A.Get(new GetRM0015A.filter() { id = check.RM0015A_ID }), "Thành công."); } catch (Exception fd) { rel.set("ERR", null, "Thất bại: " + fd.Message); } } else { rel.set("NaN", null, "Không thấy dữ liệu."); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
void ChkCFG(parameters paras, out results rets) { rets = new results(); //result rst = new result(); //rst.name = "NumOfVars"; //rst.value = hartDev.Vars.Count; //rets.Add(rst); if (DPDev.asLocalDevCfgList[0].strWK_State == "WAIT_CFG") { DPDev.ChkCFG(); //生成SET_PRM报文中数据 CFRAME_PARSE_NODE cFrameParse = new CFRAME_PARSE_NODE(); if (DPDev.diagDevice(0, ref cFrameParse)) { string slaveState = DPDev.parseSlaveStateByDiag(cFrameParse.aucData, cFrameParse.ucDataLen); if (slaveState == "DATA_EXCHANGE") { rets.response = rspCode.positive; } } else { rets.response = rspCode.negitive; } } else { rets.response = rspCode.negitive; } }
void WriteVariable(parameters paras, out results rets) { rets = new results(); result rst = new result(); ThreadUpdate tusend = new ThreadUpdate(); if (paras.Count != 1) { rets.response = rspCode.negitive; rets.resDesc = "More than 1 variable to read."; saveLogfile(rets.resDesc); } else { CDDLBase ddb = new CDDLBase(); if (hartDev.getItembyName((string)paras[0].value, ref ddb)) { if (ddb.GetType() == typeof(CDDLVar)) { CDDLVar vartowrite = (CDDLVar)ddb; hCcommandDescriptor pCmdDesc = vartowrite.getWrCmdList().ElementAt(0); CDDLCmd pCmd = hartDev.Cmds.getCmdByNumber(pCmdDesc.cmdNumber); if (hartDev.pCmdDispatch.SendCmd(pCmd, pCmdDesc.transNumb, null, logSw) == Common.SUCCESS) { saveLogfile("Command {0}, transaction {1} sent.", pCmdDesc.cmdNumber, pCmdDesc.transNumb); returncode creply = hartDev.parentform.ReData(null); hartDev.parentform.setThread(tusend); tusend.ucTranNumSent = (byte)pCmdDesc.transNumb; tusend.ucCmdSent = (byte)pCmdDesc.cmdNumber; hartDev.parentform.procRcvData(creply, pCmdDesc.transNumb, pCmd.getCmdNumber(), pCmd.getOperation()); rets.response = (hartDev.parentform.getCmdRes() as results).response;//getCmdRes //rst.name = (string)paras[0].value; //rst.rtype = resultDataType.floatpoint; //rst.value = vartowrite.GetDispString(); rets.Add(rst); } else { rets.response = rspCode.negitive; rets.resDesc = String.Format("The Command {0}, transaction {1} cannot be sent.", pCmdDesc.cmdNumber, pCmdDesc.transNumb); saveLogfile(rets.resDesc); } } else { rets.response = rspCode.negitive; rets.resDesc = "The item is not a variable."; saveLogfile(rets.resDesc); } } else { rets.response = rspCode.negitive; rets.resDesc = "The variable name is not valid."; saveLogfile(rets.resDesc); } } }
public HttpResponseMessage update([FromBody] RM0009[] values) { using (DB db = new DB()) { results <RM0009> list = new results <RM0009>(); values.ToList().ForEach(value => { result <RM0009> rel = new result <RM0009>(); var check = db.RM0009.SingleOrDefault(p => p.RM0009_ID == value.RM0009_ID); if (check != null) { db.RM0009.Remove(check); try { db.SaveChanges(); rel.set("OK", value, "Thành công"); } catch (Exception l) { rel.set("ERR", value, "Thất bại:" + l.Message); } } else { rel.set("NaN", null, "Thành công"); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage Update([FromBody] KTX0031[] values) { using (var db = new DB()) { results <KTX0031> list = new results <KTX0031>(); foreach (var value in values) { result <KTX0031> rel = new result <KTX0031>(); var check = db.KTX0031.SingleOrDefault(p => p.KTX0031_ID == value.KTX0031_ID); if (check != null) { check.soluongtra = value.soluongtra; check.ngaytra = DateTime.Now; try { db.SaveChanges(); rel.set("OK", check, "Thành công."); } catch { rel.set("ERR", value, REST.ERR); } } else { rel.set("NaN", check, REST.NaN); } list.add(rel); } return(list.ToHttpResponseMessage()); } }
public IHttpActionResult PostRUsuario(RUsuario rsuario) { try { if (this.objDb.Get().Where(o => o.Usuario == rsuario.Usuario).Count() == 0) { var randomPass = HelperGeneral.RandomPass(); rsuario.Password = Utility.TripleDES(randomPass, true); var decypt = Utility.TripleDES(rsuario.Password, false); rsuario.CambioObligatorio = true; var obj = this.objDb.Add(rsuario); CreateLogEventos(CrearUsuario, rsuario); this.IEnviarEmail(rsuario, randomPass, ""); return(CreatedAtRoute("DefaultApi", new { id = rsuario.IdUsuario }, rsuario)); } else { results result = new results(); result.Message = "El usuario ya existe"; result.Ok = false; return(Ok(result)); } } catch (Exception ex) { return(Ok(HelperGeneral.exceptionError(ex))); } }
public IHttpActionResult PutRecordarContrasena(RecuperarPassword recuperarPassword) { try { if (this.objDb.Get(o => o.Usuario == recuperarPassword.Usuario).Count() > 0) { var rsuario = this.objDb.Get(o => o.Usuario == recuperarPassword.Usuario).FirstOrDefault(); rsuario.Estado = ((int)Estados.Activo).ToString(); rsuario.CambioObligatorio = true; var randomPass = HelperGeneral.RandomPass(); rsuario.Password = Utility.TripleDES(randomPass, true); UpdateTry(rsuario); rsuario.UsuarioLogueado = HelperGeneral.GetSession(); CreateLogEventos(OlvidaClave, rsuario); this.IEnviarEmail(rsuario, randomPass, "El administrador de Consulta ANI de Asocajas ha actualizado su contraseña, antes de poder acceder al sistema, es imprescindible cambiar la contraseña. Para ello acceda a la siguiente dirección:", "Recordar Contraseña"); return(CreatedAtRoute("DefaultApi", new { id = rsuario.IdUsuario }, rsuario)); } else { results result = new results(); result.Message = "El usuario no existe"; result.Ok = false; return(Ok(result)); } } catch (Exception ex) { return(Ok(HelperGeneral.exceptionError(ex))); } }
public HttpResponseMessage delete([FromBody] DX0070[] values) { using (QLDX_DB db = new QLDX_DB()) { results <object> list = new results <object>(); values.ToList().ForEach(val => { result <object> rel = new result <object>(); var check = db.DX0070.SingleOrDefault(p => p.DX0070_ID == val.DX0070_ID); if (check != null) { db.DX0070.Remove(check); try { db.SaveChanges(); rel.set("OK", getDX0070(val)); } catch (Exception d) { rel.set("ERR", val, d.Message); } } else { rel.set("NOT_EXIST", val); } list.add(rel); }); return(list.ToHttpResponseMessage()); } }
public IHttpActionResult GetExisteUser(string password) { try { string user = HelperGeneral.GetSession(); var obj = this.objDb.Get().Where(o => o.Usuario == user).ToList(); results result = new results(); if (obj.Count() > 0) { var linqEmails = Utility.TripleDES(obj.FirstOrDefault().Password, false); if (password != linqEmails) { result.Message = "La contraseña actual no es correcta."; result.Ok = false; } else { result.Message = ""; result.Ok = true; } } else { result.Message = "Su usuario no está registrado en el sistema."; result.Ok = false; } return(Ok(result)); } catch (Exception ex) { return(Ok(HelperGeneral.exceptionError(ex))); } }
public HttpResponseMessage Edit([FromBody] MKV9981[] value) { using (DB db = new DB()) { results <MKV9981> list = new results <MKV9981>(); foreach (var val in value) { result <MKV9981> rel = new result <MKV9981>(); var data = db.MKV9981.SingleOrDefault(p => p.MKV9981_ID == val.MKV9981_ID); if (data != null) { data.TENHANHDONG = val.TENHANHDONG; data.LINKMENU = val.LINKMENU; data.IMAGE = val.IMAGE; data.THUTU = val.THUTU; try { db.SaveChanges(); rel.set("OK", data, "Thành công"); } catch (Exception rr) { rel.set("ERR", data, "Thất bại: " + rr.Message); } } else { rel.set("ERR", val, "Thất bại: Không tìm thấy dữ liệu."); } list.add(rel); } return(list.ToHttpResponseMessage()); } }
public HttpResponseMessage Getall([FromBody] KTX0049[] values) { using (DB db = new DB()) { results <KTX0049> list = new results <KTX0049>(); values.ToList().ForEach(value => { result <KTX0049> rel = new result <KTX0049>(); var check = db.KTX0049.SingleOrDefault(ppp => ppp.User_ID == value.User_ID); if (check == null) { var k = db.Database.SqlQuery <object>(@"insert into ktx0049(User_ID,startdate,enddate,ghichu,trangthai) values ('" + value.User_ID + "','" + value.startdate + "','" + value.enddate + "',N'" + value.ghichu + "'," + (value.trangthai == true?1:0) + ");").ToList(); //if (k.FirstOrDefault() == 1) rel.set("OK", value); } else { if (value.startdate < check.startdate) { check.startdate = value.startdate; } if (value.enddate > check.enddate) { check.enddate = value.enddate; } check.ghichu = value.ghichu; check.trangthai = value.trangthai; rel.set("OK", value); } list.add(rel); }); db.SaveChanges(); return(list.ToHttpResponseMessage()); } }
public void Initialize() { exportModel = ServiceLocator.Current.GetInstance <MainViewModel>().export; rLastPeriod = ServiceLocator.Current.GetInstance <DashboardViewModel>().LastPeriod; productionList = exportModel.productionList; produceItemProductionList = new List <produceItemsItem>(); WorkplacesTimesNew = new ObservableCollection <WorkplaceTimeModel>(); workspaces = WorkspacesModel.GetInstance().GetWorkspaces(); produceItems = ProduceItemsModel.GetInstance().GetProduceItems(); produceItemProductionList = ProduceItemsModel.GetInstance().GetProduceItems(); workspaces.ForEach(w => { string description = w.label.de; var shift = 1; var model = new WorkplaceTimeModel(w.id, description, 0, 0, 0, 0, 0, shift, 0); WorkplacesTimesNew.Add(model); }); calcSetUpNew(); productionList.ForEach(i => calculateProductionTimeNew(i.article, i.quantity)); createMapOldTimeOrdersInWork(rLastPeriod); createMapOldWaitinglistWorkstations(rLastPeriod); oldSetUpTime(rLastPeriod, produceItems); calculate(); }
private void oldSetUpTime(results rLastPeriod, List <produceItemsItem> produceItems) { var itemsList = new List <int>(); rLastPeriod.waitinglistworkstations?.ToList().ForEach(wait => { wait.waitinglist?.ToList().ForEach(waitList => { itemsList.Add(waitList.item); }); }); itemsList.ForEach(item => { produceItems.ForEach(produce => { if (item == produce.id) { produce.timePerWorkplace.ToList().ForEach(work => { WorkplacesTimesNew.ToList().ForEach(workNew => { if (workNew.Id == work.id) { workNew.SetUpOld += work.setUpTime; } }); }); } }); }); }
public IHttpActionResult Putresults(int id, results results) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != results.resultID) { return(BadRequest()); } db.Entry(results).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!resultsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void ShowSSISandROCspecifics(results r, DataTable jobs, DataTable steps, string filename, string loc, subresult sr) { foreach (DataRow drStep in steps.Rows) { if (parseSSISjob(drStep["command"].ToString()).ToUpper() == filename.ToUpper()) { foreach (DataRow drJob in jobs.Rows) { if ((drStep["subsystem"].ToString() == "SSIS") && (drJob["job_id"].ToString() == drStep["job_id"].ToString())) { sr.SA = drJob["name"].ToString(); sr.jobid = drJob["job_id"].ToString(); sr.stepid = drStep["step_id"].ToString(); foreach (DataRow drROC in dtProdROC.Rows) { if ((r.prod.SA != null) && (drROC["JobName"].ToString().ToUpper() == r.prod.SA.ToUpper())) { r.ROCProdJob = drROC["Description"].ToString(); } } foreach (DataRow drROC in dtTestROC.Rows) { if ((r.test.SA != null) && (drROC["JobName"].ToString().ToUpper() == r.test.SA.ToUpper())) { r.ROCTestJob = drROC["Description"].ToString(); } } } } } } dgSearchResults.ItemsSource = resultList; }
public HttpResponseMessage add([FromBody] KTX0001[] values) { if (values == null) { return(null); } DB db = new DB(); results <KTX0001> list = new results <KTX0001>(); foreach (var value in values) { result <KTX0001> rel = new result <KTX0001>(); var checkgiuong = db.KTX0001.FirstOrDefault(p => p.ten == value.ten && p.type == 4); if (checkgiuong == null) { KTX0001 t = value; try { var kkk = db.KTX0001.Add(t); db.SaveChanges(); for (int i = 0; i < t.slot; i++) { db.KTX0002.Add(new KTX0002() { ghichu = "Giường trống", KTX0001_ID = t.KTX0001_ID, ten = "GA-" /*+ t.ten.Replace("", "")*/ + t.ten + "-G0" + (i + 1), thutu = i, trangthai = false }); } db.SaveChanges(); if (t.type == 4) { var arrtaisan = db.KTX0010.Where(p => p.loai == 1).Select(p => new { p.KTX0010_ID, p.soluongmacdinh }).ToList(); arrtaisan.ForEach(val => { var g = new KTX0011() { KTX0001_ID = t.KTX0001_ID, KTX0010_ID = val.KTX0010_ID, soluong = val.soluongmacdinh }; db.KTX0011.Add(g); //t.KTX0011.Add(g); }); try { db.SaveChanges(); } catch { } } rel.set("OK", t, "Thành công"); } catch (Exception rr) { rel.set("ERR", t, "Thất bại: " + rr.Message); } } else { rel.set("ERR", value, "Thất bại: Phòng có mã " + value.ten + " đã tồn tại, xin nhập tên khác."); } list.add(rel); } return(list.ToHttpResponseMessage()); }
internal static void getSubGroups(results Results, List <Grouped> Groups, Grouped Parent, int Depth, params string[] Grouped) { var subrow = Results.result.row; var parent = Parent; while (parent != null) { subrow = subrow.Where(w => w.AnyAttr.LookupValue(parent.Name) == parent.Value).ToList(); parent = parent.Parent; } foreach (var row in subrow) { var name = Grouped[0]; var val = row.AnyAttr.LookupValue(name); if (!Groups.Any(a => a.Name.Equals(name) && a.Value.Equals(val))) { //string subval = null; var isEqual = true; Schema.Grouped g; Groups.Add(g = new Schema.Grouped() { Depth = Depth, Name = name, Value = val, Parent = Parent // TODO: is this correct parent? }); // Exhaust Grouped to last item - then add rows // Group1>Group2>Group3 // Group2>Group3 // Group3 // row // row ... if (Grouped.Length == 1) { if (g.Row == null) { g.Row = new List <row>(); } g.Row.Add(row); } } } // drill down for each group if (Grouped.Length > 1) { Depth++; foreach (var group in Groups) { group.Groups = new List <Schema.Grouped>(); getSubGroups(Results, group.Groups, group, Depth, Grouped.Skip(1).ToArray()); } } }