Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
GetDataFromSQLGroups
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
public static string GetDataFromSQLGroups(clsGroupCallInput objInputData, clsGroupCallType callType) { var result = new List<dynamic>(); var resultTemp = new List<dynamic>(); List<ef.AppPagingDetails> objPagingDetails = null; List<Task> tasks = null; int iTotalRecords = 0; try { objPagingDetails = new List<ef.AppPagingDetails>(); if (!string.IsNullOrWhiteSpace(objInputData.sPagingDetails)) { objPagingDetails = JsonConvert.DeserializeObject<List<ef.AppPagingDetails>>(objInputData.sPagingDetails); } var groupList = GroupList.Groupdetail; tasks = new List<Task>(); if (groupList != null && groupList.Count > 0) { foreach (Vagaro.Web.Business.Groupdetail group in groupList) { int newPageIndex = 1; if (objInputData.pageIndex == 1) { objPagingDetails.Add(new ef.AppPagingDetails { sGroup = group.GroupValue, skipRecords = 0, isPast = objInputData.isPastApp }); } else { if (objPagingDetails.Any(x => x.sGroup == group.GroupValue && x.isPast == objInputData.isPastApp)) { newPageIndex = objPagingDetails.Where(x => x.sGroup == group.GroupValue && x.isPast == objInputData.isPastApp).FirstOrDefault().skipRecords; } } newPageIndex = ((newPageIndex == 0 ? 1 : newPageIndex) - 1); if (callType == clsGroupCallType.MyAccount_Appointment) { var task = Task.Factory.StartNew<List<dynamic>>((o) => { return GetAppointmentGroupWise(objInputData.userID, objInputData.isPastApp, newPageIndex, objInputData.pageSize, objInputData.LoadServiceClass, group.GroupValue, (objInputData.IsCallFromCheckIn ? objInputData.businessID : null), objInputData.IsCallFromCheckIn); }, 3); tasks.Add(task); if (task.Result != null && task.Result.Count > 0) { resultTemp.AddRange(task.Result); if (objInputData.pageIndex == 1) { iTotalRecords = iTotalRecords + task.Result[0].TotalPage; } } } else if (callType == clsGroupCallType.MyAccount_Product) { } } Task.WaitAll(tasks.ToArray()); } if (resultTemp.Count > 0) { if (callType == clsGroupCallType.MyAccount_Appointment) { if (objInputData.isPastApp) { result = resultTemp.OrderByDescending(obj => obj.StartTime).Take(objInputData.pageSize).ToList(); } else { result = resultTemp.OrderBy(obj => obj.StartTime).Take(objInputData.pageSize).ToList(); } } else if (callType == clsGroupCallType.MyAccount_Product) { } foreach (Vagaro.Web.Business.Groupdetail grp in groupList) { int totalCount = 0; var tmpObj = resultTemp.Where(o => o.sGroup == grp.GroupValue).Select(x => x).FirstOrDefault(); if (tmpObj != null) { totalCount = Convert.ToInt32(tmpObj.TotalPage); } if (result.Any(x => x.sGroup == grp.GroupValue)) { var objUpdate = objPagingDetails.Where(obj => obj.sGroup == grp.GroupValue && obj.isPast == objInputData.isPastApp).FirstOrDefault(); if (objUpdate != null) { //int intGroupWiseCount = result.Where(obj => obj.sGroup == grp.GroupValue).Count(); objUpdate.skipRecords = objUpdate.skipRecords + result.Where(obj => obj.sGroup == grp.GroupValue).Count(); if (objInputData.pageIndex == 1) { objUpdate.skipRecords += 1; objUpdate.totalRecords = iTotalRecords; } if (objUpdate.skipRecords > totalCount) { objUpdate.skipRecords = -1; } } else { objPagingDetails.Add(new ef.AppPagingDetails { sGroup = grp.GroupValue, skipRecords = result.Where(obj => obj.sGroup == grp.GroupValue).Count(), isPast = objInputData.isPastApp }); } } else if (resultTemp.Any(x => x.sGroup == grp.GroupValue)) { var objUpdate = objPagingDetails.Where(obj => obj.sGroup == grp.GroupValue && obj.isPast == objInputData.isPastApp).FirstOrDefault(); if (objInputData.pageIndex == 1 && objUpdate != null) { objUpdate.skipRecords += 1; objUpdate.totalRecords = iTotalRecords; } } else { var objUpdate = objPagingDetails.Where(obj => obj.sGroup == grp.GroupValue && obj.isPast == objInputData.isPastApp).FirstOrDefault(); if (objUpdate != null) objUpdate.skipRecords = -1; // objUpdate.skipRecords + (from obj in result where obj.Group == grp.GroupValue select obj).Count(); } } result[0].TotalPage = objPagingDetails.Where(obj => obj.isPast == objInputData.isPastApp).FirstOrDefault().totalRecords; // objPagingDetails.Where(obj => obj.isPast == isPastApp).FirstOrDefault().totalRecords; result[0].sPagingDetails = JsonConvert.SerializeObject(objPagingDetails); } //string test = JsonConvert.SerializeObject(objPagingDetails); groupList = null; //return result; return JsonConvert.SerializeObject(result); } catch (Exception ex) { ex.HandleException(Declaration.Platform.WebSite, 0, objInputData.userID, true); throw new Exception("Something went wrong. Please try again"); } finally { tasks = null; result = null; resultTemp = null; objPagingDetails = null; } }
Show compiler warnings
[
+
]
Show input
edit mode
|
history
|
discussion