$('#partial').html('<div id="loaderModalConnection" class="loader-centerd-screen mx-auto text-center"></div>');
public async Task<ActionResult> Grid(int tableOrFamillyId, string tableOrFamillyName, bool isTable)
{
if (!SessionHelper.IsExisting())
{
HomeController.SessionExpired = true;
return null;//RedirectToAction("index", "Home");
}
int idLang = SessionHelper.IdLangSession();
DataTable table = new DataTable("table");
List<Column> cols = new List<Column>();
DataSet setTable = new DataSet();
using (var client = new HttpClient())
{
ViewBag.Title = tableOrFamillyName;
SessionHelper.Set("tableOrFamillyName", tableOrFamillyName);
ViewBag.tableOrFamillyId = tableOrFamillyId;
ViewBag.isTable = isTable;
ViewBag.UserInfoContentList = SessionHelper.Get<string>("nameUser");
ViewBag.UserProjectNameContentList = SessionHelper.Get<string>("nameProject");
ViewBag.MenuContentList = SessionHelper.Get<List<MenuModel>>("menu");
ViewBag.VersionBuild = Constants.versionBuild;
client.BaseAddress = new Uri(ConfigurationManager.AppSettings["BaseUrl"]);
// récupération des colonnes
var resColConf = await client.GetAsync(String.Format("{0}?tableId={1}&isTable={2}&login={3}&idLang={4}&projectId={5}", Constants.RouteApiColumnsConf, tableOrFamillyId, isTable, SessionHelper.Get<string>("userLogin"), idLang, SessionHelper.Get<int>("idProject")));
if (resColConf.IsSuccessStatusCode)
{
GridOperation gridOperation = new GridOperation();
dynamic resultAnonyme = await gridOperation.ConstuctColumnGrid(resColConf, tableOrFamillyId);
table = resultAnonyme.table;
cols = resultAnonyme.cols;
}
else
{
ViewBag.MessageError = JsonConvert.DeserializeObject<Dictionary<string, string>>(resColConf.Content.ReadAsStringAsync().Result)["Message"];
}
// récupération des éléments
JObject json = new JObject
{
["tableId"] = tableOrFamillyId,
["isTable"] = isTable,
["idLang"] = idLang,
["login"] = SessionHelper.Get<string>("userLogin"),
["projectID"] = SessionHelper.Get<int>("idProject")
};
var resElem = await client.PostAsJsonAsync(Constants.RouteApiGetElem, json);
if (resElem.IsSuccessStatusCode)
{
setTable = JsonConvert.DeserializeObject<DataSet>(resElem.Content.ReadAsStringAsync().Result);
table = setTable.Tables[0];
}
else
{
ViewBag.MessageError = JsonConvert.DeserializeObject<Dictionary<string, string>>(resElem.Content.ReadAsStringAsync().Result)["Message"];
}
ViewBag.cols = cols;
ViewBag.DataSource = table;
if (Request.Cookies[Constants.CoockiesNamePageSize + "-" + SessionHelper.Get<string>("nameSchema")] == null)
{
// Initialisation du pageSize de la grid et stockage dans les coockies
ViewBag.pageSize = 10;
Response.Cookies[Constants.CoockiesNamePageSize + "-" + SessionHelper.Get<string>("nameSchema")].Value = "10";
Response.Cookies[Constants.CoockiesNamePageSize + "-" + SessionHelper.Get<string>("nameSchema")].Expires = DateTime.Now.AddDays(365);
}
else
{
// Récupération dans les coockies du pageSize de la grid
ViewBag.pageSize = Convert.ToInt32(Server.HtmlEncode(Request.Cookies[Constants.CoockiesNamePageSize + "-" + SessionHelper.Get<string>("nameSchema")].Value));
}
TableSource = table;
SessionHelper.Set("table", table);
// récupération du nombre d'utilisateur connectés
var resOnlineUsers = await client.GetAsync(String.Format("{0}?project={1}", Constants.RouteApiGetOnlineUsers, SessionHelper.Get<string>("nameSchema")));
if (resOnlineUsers.IsSuccessStatusCode)
{
var nbrUser = JsonConvert.DeserializeObject<int>(resOnlineUsers.Content.ReadAsStringAsync().Result);
ViewBag.OnlineUsers = String.Format(Resources.Resources.allUsersOnlineString, nbrUser);
}
UserController userController = new UserController();
Object jsonPermissions = await userController.GetPermissions(0);
ViewBag.Permissions = jsonPermissions;
}
return PartialView("grid");
}