public static void WriteSettingJson(SettingObject setting) { fastJSON.JSONParameters parameters = new fastJSON.JSONParameters(); parameters.EnableAnonymousTypes = true; parameters.UseEscapedUnicode = false; var jsonStr = fastJSON.JSON.ToJSON(setting, parameters); System.IO.File.WriteAllText(Environment.CurrentDirectory + "\\setting.json", jsonStr); }
public static void WriteAppJson(List <AppFile> AppList) { fastJSON.JSONParameters parameters = new fastJSON.JSONParameters(); parameters.EnableAnonymousTypes = true; parameters.UseEscapedUnicode = false; var jsonStr = fastJSON.JSON.ToJSON(AppList, parameters); System.IO.File.WriteAllText(Environment.CurrentDirectory + "\\app.json", jsonStr); }
public static fastJSON.JSONParameters getDefaultParameters() { fastJSON.JSONParameters parameters = new fastJSON.JSONParameters(); parameters.UseExtensions = false; parameters.UsingGlobalTypes = false; parameters.EnableAnonymousTypes = false; parameters.SerializeNullValues = false; parameters.SerializeToLowerCamelCaseNames = true; return(parameters); }
public void AddParameter(string name, object parameter) { var paramJson = new fastJSON.JSONParameters { UsingGlobalTypes = false, EnableAnonymousTypes = true, UseExtensions = false }; Parameters.Add(name, fastJSON.JSON.Instance.ToJSON(parameter, paramJson)); }
/// <summary> /// Serializes an object to JSON /// </summary> /// <param name="Object">Object to be serialized</param> /// <param name="Options">Options for formatting the object</param> /// <returns>JSON representation of the object</returns> public static string Serialize(object Object, JsonSerializeOptions Options) { fastJSON.JSONParameters Params = new fastJSON.JSONParameters(); Params.EnableAnonymousTypes = true; string Text = fastJSON.JSON.Instance.ToJSON(Object, Params); if ((Options & JsonSerializeOptions.PrettyPrint) != 0) { Text = Format(Text); } return(Text); }
public JsonSerializer(bool pretty = false, bool preserveCase = false) { manager = new fastJSON.SerializationManager(); parameters = new fastJSON.JSONParameters { UseExtensions = false, UseFastGuid = false, NamingConvention = preserveCase ? fastJSON.NamingConvention.Default : fastJSON.NamingConvention.CamelCase }; this.pretty = pretty; }
void SaveToJsonFile(string jsonfile, object data) { fastJSON.JSONParameters param = new fastJSON.JSONParameters(); param.UseEscapedUnicode = false; string jsonString = fastJSON.JSON.ToJSON(data, param); if (m_BeautifyJson) { jsonString = fastJSON.JSON.Beautify(jsonString); } File.WriteAllText(jsonfile, jsonString); }
public static void InitAppJson(List <AppClassify> AppList) { fastJSON.JSONParameters parameters = new fastJSON.JSONParameters(); parameters.EnableAnonymousTypes = true; parameters.UseEscapedUnicode = false; var jsonStr = fastJSON.JSON.ToJSON(AppList, parameters); var fileName = Environment.CurrentDirectory + "\\app.json"; if (System.IO.File.Exists(fileName)) { System.IO.File.Delete(fileName + ".bak"); System.IO.File.Move(fileName, fileName + ".bak"); } System.IO.File.WriteAllText(fileName, jsonStr); }
/// <summary> /// опубликовать информация об обновлении книги /// </summary> /// <param name="authorUrl">урл автора</param> /// <param name="book">книга</param> /// <param name="authorName">имя автора</param> public void PublishMessageUpdatedBook(AuthorText book, string authorUrl, string authorName) { var paramJson = new fastJSON.JSONParameters { UsingGlobalTypes = false, EnableAnonymousTypes = true, UseExtensions = false }; var paramBJson = new fastBinaryJSON.BJSONParameters { UsingGlobalTypes = false, EnableAnonymousTypes = true, UseExtensions = false }; try { if (_settings.UseMessageBroker) { var transportBookInfo = new TransportBookInfo() { AuthorLink = authorUrl, AuthorName = authorName, Description = book.Description, Genres = book.Genres, Link = book.Link, Name = book.Name, SectionName = book.SectionName, Size = book.Size, UpdateDate = DateTime.Now.ToUniversalTime().Ticks }; var jsonTransportBookInfo = fastBinaryJSON.BJSON.Instance.ToBJSON(transportBookInfo, paramBJson);// fastJSON.JSON.Instance.ToJSON(transportBookInfo); var command = new SubscriptionMessageCommand() { JsonObjectBytes = jsonTransportBookInfo }; PublishMessageUpdatedBook(fastJSON.JSON.Instance.ToJSON(command, paramJson)); } } catch (Exception ex) { //_logger.Add("Остановлен сервис подписки на push-уведомления об обновлениях."); } }
/// <summary> /// Save configuration to file. /// </summary> public static void SaveToFile() { var fi = new FileInfo(FileName); if (!fi.Directory.Exists) { fi.Directory.Create(); } var p = new fastJSON.JSONParameters(); p.UseExtensions = false; string s = fastJSON.JSON.ToJSON(Config, p); var sw = new StreamWriter(FileName); sw.Write(fastJSON.JSON.Beautify(s)); sw.Close(); }
public string StreamBuilder(CommandList builderType) { string retValue = string.Empty; fastJSON.JSONParameters jsonParameters = new fastJSON.JSONParameters { UseExtensions = false }; communicationFrame.Clear(); try { switch (builderType) { case CommandList.RESP_OK: { communicationFrame.role = (int)RoleList.SERVER; communicationFrame.cmd = (int)CommandList.RESP_OK; communicationFrame.data_size = 1; communicationFrame.data.Add("Server"); break; } case CommandList.RESP_ERROR: { communicationFrame.role = (int)RoleList.SERVER; communicationFrame.cmd = (int)CommandList.RESP_ERROR; communicationFrame.data_size = 1; communicationFrame.data.Add("Server"); break; } } retValue = fastJSON.JSON.ToJSON(communicationFrame, jsonParameters); } catch (Exception) { }; return(retValue); }
public static T Deserialize <T>(string data, fastJSON.JSONParameters options = null) { return(default(T)); }
public string DataTableCSSPeopleList(int draw, int start, int length, string searchValue, string searchRegex, string order) { string result = String.Empty; Debug.WriteLine("DataTableController UserList draw:" + draw.ToString()); Debug.WriteLine("DataTableController UserList start:" + start.ToString()); Debug.WriteLine("DataTableController UserList searchValue:" + searchValue); Debug.WriteLine("DataTableController UserList searchRegex:" + searchRegex); Debug.WriteLine("DataTableController UserList order:" + order); // Lists all the Request parameters foreach (string s in Request.Params.Keys) { Debug.WriteLine(s.ToString() + ":" + Request.Params[s]); } try { // Initialize the DataTable response (later transformed to JSON) DataTableResult dtr = new DataTableResult() { draw = draw, recordsTotal = 1, recordsFiltered = 1, data = new List <string[]>(), error = String.Empty }; var sFirstN = Request.Params["columns[1][search][value]"]; var sLastN = Request.Params["columns[2][search][value]"]; var sloginId = Request.Params["columns[3][search][value]"]; var sEmail = Request.Params["columns[4][search][value]"]; // rename to avoid language/library conflicts int iniIndex = start; int noDsplyRecs = length; // Parse the parameters from DataTable request /* * if (!String.IsNullOrEmpty(json)) * { * var dResults = fastJSON.JSON.Parse(json); * } */ AuthenticationClient auth = new AuthenticationClient(); int entId = 8; int appId = 3; List <List <string> > usrs = auth.List_CSS_people_Users(SessionHelper.LoginStatus.UserID, entId, iniIndex, noDsplyRecs, sFirstN, sLastN, sloginId, sEmail); //* * * OT 2-23-16 explaination for Bug 13019, comment 21, first bullet //for users that do not have the "View users" permission, they can only see themselves in the limited users list //we do this by searching for the current user's loginId //this normally works, but in some cases there are multiple loginIds that contain the current user's loginId //Example: Login as nctest and you can also see NCTest1. //Final record stores total result set count. if (usrs.Count > 0) { dtr.recordsTotal = dtr.recordsFiltered = Convert.ToInt32(usrs[usrs.Count - 1][0]);//usrCount; usrs.RemoveAt(usrs.Count - 1); Debug.WriteLine("DataTableController usrs.Count:" + usrs.Count.ToString()); } else { dtr.recordsTotal = dtr.recordsFiltered = 0; Debug.WriteLine("DataTableController usrs.Count:" + 0); } dtr.data = (from u in usrs select u.ToArray()).ToList(); Debug.WriteLine("DataTableController UserList data populated."); // Output the JSON in DataTable format fastJSON.JSONParameters param = new fastJSON.JSONParameters(); param.EnableAnonymousTypes = true; result = fastJSON.JSON.ToJSON(dtr, param); Debug.WriteLine("DataTableController UserList result:" + result); } catch (Exception excptn) { Debug.WriteLine("DataTableController UserList exception:" + excptn.Message); result = excptn.Message + " - " + excptn.InnerException.Message; } return(result); }
/// <summary> /// Web Service to process requests from the Enrollment Site DataTable /// </summary> /// <param name="draw">Automatically posted by JQuery DataTables: count of the number of times this table has been drawn.</param> /// <param name="start">Automatically posted by JQuery DataTables: the starting index of the current result set.</param> /// <param name="length">Automatically posted by JQuery DataTables: the number of rows displayed by the table.</param> /// <param name="searchValue">Automatically posted by JQuery DataTables: </param> /// <param name="searchRegex">Automatically posted by JQuery DataTables: </param> /// <param name="order">Automatically posted by JQuery DataTables: </param> /// <returns>String formatted for JQuery DataTables.</returns> public string DataTableJurisdiction(int draw, int start, int length, string searchValue, string searchRegex, string order) { // Initialize the DataTable response (later transformed to JSON) DataTableResult dtr = new DataTableResult() { draw = draw, recordsTotal = 1, recordsFiltered = 1, data = new List <string[]>(), error = String.Empty }; var sJurisdiction = Request.Params["columns[1][search][value]"]; var sUnit = Request.Params["columns[2][search][value]"]; int iniIndex = start; int noDsplyRecs = length; int jurisdiction = -1; bool haveUnit = false; bool haveJurisdiction = false; if (int.TryParse(sJurisdiction, out jurisdiction)) { haveJurisdiction = true; } if (!string.IsNullOrEmpty(sUnit)) { haveUnit = true; } var context = DataContext.getUasDbContext(); var query = (from gr in context.uas_Group join e in context.uas_Group on gr.ParentGroupId equals e.GroupID into eg // left join uas_Group from elj in (from g in eg select new { g.GroupID, g.GroupName } ).DefaultIfEmpty() where gr.GroupTypeID == 194 && (haveJurisdiction == false || gr.GroupID == jurisdiction) && (haveUnit == false || elj.GroupName.StartsWith(sUnit)) orderby gr.GroupName let Unit = elj.GroupName select new { gr.GroupID, gr.GroupName, Unit }).ToList(); if (Request.Params["order[0][column]"] != null) { int orderColumnIndex = Convert.ToInt32(Request.Params["order[0][column]"]); bool descending = Request.Params["order[0][dir]"] == "desc"; query = query.OrderBy(row => GetJurisdictionSort(row, orderColumnIndex)).ToList(); if (descending) { query.Reverse(); } } var jurisdicions = query.Skip(iniIndex).Take(noDsplyRecs); dtr.recordsTotal = dtr.recordsFiltered = query.Count(); var data = from j in jurisdicions select new List <String> { "<a href=\"/AdapCa/EditJurisdiction?id=" + j.GroupID + "\"><i class=\"glyphicon glyphicon-edit\"></i></a>", j.GroupName, j.Unit }; dtr.data = (from s in data select s.ToArray()).ToList(); fastJSON.JSONParameters param = new fastJSON.JSONParameters(); param.EnableAnonymousTypes = true; var result = fastJSON.JSON.ToJSON(dtr, param); return(result); }
/// <summary> /// Web Service to process requests from the Enrollment Site DataTable /// </summary> /// <param name="draw">Automatically posted by JQuery DataTables: count of the number of times this table has been drawn.</param> /// <param name="start">Automatically posted by JQuery DataTables: the starting index of the current result set.</param> /// <param name="length">Automatically posted by JQuery DataTables: the number of rows displayed by the table.</param> /// <param name="searchValue">Automatically posted by JQuery DataTables: </param> /// <param name="searchRegex">Automatically posted by JQuery DataTables: </param> /// <param name="order">Automatically posted by JQuery DataTables: </param> /// <returns>String formatted for JQuery DataTables.</returns> public string DataTableEnrollmentSite(int draw, int start, int length, string searchValue, string searchRegex, string order) { // Initialize the DataTable response (later transformed to JSON) DataTableResult dtr = new DataTableResult() { draw = draw, recordsTotal = 1, recordsFiltered = 1, data = new List <string[]>(), error = String.Empty }; var sUnit = Request.Params["columns[1][search][value]"]; var sSiteName = Request.Params["columns[2][search][value]"]; int iniIndex = start; int noDsplyRecs = length; var context = DataContext.getUasDbContext(); IEnumerable <vEnrollmentSite> query = (from v in context.vEnrollmentSites where (string.IsNullOrEmpty(sUnit) || v.Jurisdiction.Contains(sUnit)) && (string.IsNullOrEmpty(sSiteName) || v.Enrollment_Site.Contains(sSiteName)) select v).ToList(); if (Request.Params["order[0][column]"] != null) { int orderColumnIndex = Convert.ToInt32(Request.Params["order[0][column]"]); bool descending = Request.Params["order[0][dir]"] == "desc"; query = query.OrderBy(row => GetEnrollmentSiteSort(row, orderColumnIndex)); if (descending) { query = query.Reverse(); } } else { query = query.OrderBy(x => x.Site__).ToList(); } var sites = query.Skip(iniIndex).Take(noDsplyRecs).ToList(); dtr.recordsTotal = dtr.recordsFiltered = query.Count(); var data = from v in sites select new List <string> { "<a href=\"/AdapCa/EditEnrollmentSite?id=" + v.GroupId + "\"><i class=\"glyphicon glyphicon-edit\"></i></a>", v.Jurisdiction, v.Site__, v.Restrictions, v.Enrollment_Site, v.Address, v.Telephone, v.Contact }; dtr.data = (from s in data select s.ToArray()).ToList(); fastJSON.JSONParameters param = new fastJSON.JSONParameters(); param.EnableAnonymousTypes = true; var result = fastJSON.JSON.ToJSON(dtr, param); return(result); }
/// <summary> /// Web Service to process requests from the ADAP Clinic Admin DataTable /// </summary> /// <param name="draw">Automatically posted by JQuery DataTables: count of the number of times this table has been drawn.</param> /// <param name="start">Automatically posted by JQuery DataTables: the starting index of the current result set.</param> /// <param name="length">Automatically posted by JQuery DataTables: the number of rows displayed by the table.</param> /// <param name="searchValue">Automatically posted by JQuery DataTables: </param> /// <param name="searchRegex">Automatically posted by JQuery DataTables: </param> /// <param name="order">Automatically posted by JQuery DataTables: </param> /// <returns>String formatted for JQuery DataTables.</returns> public string DataTableClinicList(int draw, int start, int length, string searchValue, string searchRegex, string order) { string result = String.Empty; Debug.WriteLine("Adap Controller ClinicList draw:" + draw.ToString()); Debug.WriteLine("Adap Controller ClinicList start:" + start.ToString()); Debug.WriteLine("Adap Controller ClinicList searchValue:" + searchValue); Debug.WriteLine("Adap Controller ClinicList searchRegex:" + searchRegex); Debug.WriteLine("Adap Controller ClinicList order:" + order); // Lists all the Request parameters foreach (string s in Request.Params.Keys) { Debug.WriteLine(s.ToString() + ":" + Request.Params[s]); } try { // Initialize the DataTable response (later transformed to JSON) DataTableResult dtr = new DataTableResult() { draw = draw, recordsTotal = 1, recordsFiltered = 1, data = new List <string[]>(), error = String.Empty }; // How to find Enterprise ID and Form ID? Values currently hardcoded to populate Data Table. //IQueryable<def_LookupMaster> query = formsRepo.GetLookupMaster(74); var sSort = Request.Params["columns[1][search][value]"]; var sTeam = Request.Params["columns[2][search][value]"]; int teamId = -1; if (!String.IsNullOrEmpty(sTeam) && !sTeam.Equals("-1")) { try { teamId = Convert.ToInt32(sTeam); } catch (Exception excptn) { Debug.WriteLine("Adap Controller ClinicList Integer Conversion:" + excptn.Message); } } // rename to avoid language/library conflicts int iniIndex = start; int noDsplyRecs = length; int entId = SessionHelper.LoginStatus.EnterpriseID; Debug.WriteLine("Adap Controller ClinicList SelectedEnterprise:" + entId.ToString()); IEnumerable <def_LookupDetail> detail = formsRepo.GetLookupMastersByLookupCode("ADAP_CLINIC").def_LookupDetail .Where(f => (teamId > -1) ? f.GroupID == teamId : true) .Where(f => (entId > 0) ? f.EnterpriseID == entId : true); if (String.IsNullOrEmpty(sSort) || sSort.Equals("false")) { detail = detail.OrderBy(f => f.displayOrder); } else { detail = detail.OrderBy(f => (f.def_LookupText.FirstOrDefault() != null) ? f.def_LookupText.FirstOrDefault().displayText : "zzzzz"); } IUasSql uasSql = new UasSql(); dtr.recordsTotal = dtr.recordsFiltered = detail.Count(); foreach (var d in detail.Skip(iniIndex).Take(noDsplyRecs)) { string[] data = new string[] { "<button type=\"button\" class=\"btn btn-primary btn-xs text-center\" onclick=\"window.location='/Adap/EditDetail?lookupDetailId=" + d.lookupDetailId.ToString() + "'\">Edit</button>", (formsRepo.GetLookupTextsByLookupDetail(d.lookupDetailId).FirstOrDefault() != null) ? formsRepo.GetLookupTextsByLookupDetail(d.lookupDetailId).FirstOrDefault().displayText : String.Empty, d.dataValue, (d.GroupID == null) ? "" : uasSql.getGroupName(d.GroupID.Value), d.displayOrder.ToString(), d.StatusFlag }; dtr.data.Add(data); } Debug.WriteLine("Adap Controller ClinicList data populated."); // Output the JSON in DataTable format fastJSON.JSONParameters param = new fastJSON.JSONParameters(); param.EnableAnonymousTypes = true; result = fastJSON.JSON.ToJSON(dtr, param); Debug.WriteLine("DataTable Clinic result:" + result); } catch (Exception excptn) { Debug.WriteLine("Adap Controller ClinicList exception:" + excptn.Message); result = excptn.Message + " - " + excptn.Message; } return(result); }
public static T Deserialize <T>(string data, fastJSON.JSONParameters options = null) { return(fastJSON.JSON.ToObject <T>(data, options ?? fastJSON.JSON.Parameters)); }
public static string Serialize <T>(T data, fastJSON.JSONParameters options = null) { return(fastJSON.JSON.ToJSON(data, options ?? fastJSON.JSON.Parameters)); }
public string DataTableTexts(int draw, int start, int length, string searchValue, string searchRegex, string order) { int detailId = 0; string result = String.Empty; Debug.WriteLine("Def3Maint Controller DataTableTexts draw:" + draw.ToString()); Debug.WriteLine("Def3Maint Controller DataTableTexts start:" + start.ToString()); Debug.WriteLine("Def3Maint Controller DataTableTexts searchValue:" + searchValue); Debug.WriteLine("Def3Maint Controller DataTableTexts searchRegex:" + searchRegex); Debug.WriteLine("Def3Maint Controller DataTableTexts order:" + order); try { string r = Request["detailId"]; if (!String.IsNullOrEmpty(r)) { detailId = Convert.ToInt32(r); } // Lists all the Request parameters foreach (string s in Request.Params.Keys) { Debug.WriteLine(s.ToString() + ":" + Request.Params[s]); } try { // Initialize the DataTable response (later transformed to JSON) DataTableResult dtr = new DataTableResult() { draw = draw, recordsTotal = 1, recordsFiltered = 1, data = new List <string[]>(), error = String.Empty }; // rename to avoid language/library conflicts int iniIndex = start; int noDsplyRecs = length; List <def_LookupText> query = formsRepo.GetLookupTextsByLookupDetail(detailId); List <def_BaseTypes> types = formsRepo.GetBaseTypes(); string basedropdown = String.Empty; foreach (def_Languages l in formsRepo.GetAllLanguages()) { basedropdown += "<option value=\"" + l.langId + "\">" + l.title + "</option>"; } dtr.recordsTotal = dtr.recordsFiltered = query.Count(); foreach (def_LookupText q in query.Skip(iniIndex).Take(noDsplyRecs).ToList()) { string dropdown = basedropdown; // Flag the appropriate html option as selected. string findText = "value=\"" + q.langId; int index = dropdown.IndexOf(findText); dropdown = dropdown.Insert(index - 1, " selected=\"selected\""); string[] data = new string[] { "<span id=\"language[" + q.lookupTextId + "]\">" + formsRepo.GetLanguageById(q.langId).title + "</span>" + "<span hidden=\"hidden\" id=\"languageSelectTd[" + q.lookupTextId + "]\">" + "<select name=\"selectdLanguage\" class=\"form-control\" id=\"selectLanguage[" + q.lookupTextId + "]\">" + dropdown + "</select>" + "</span>", "<span id=\"displayText[" + q.lookupTextId + "]\">" + q.displayText + "</span>", "<span id=\"editText[" + q.lookupTextId + "]\"><a href=\"#\" onclick=\"editText(" + q.lookupTextId + ")\">Edit</a></span>" + "<span hidden=\"hidden\" id=\"saveText[" + q.lookupTextId + "]\"><a href=\"#\" onclick=\"saveText(" + q.lookupTextId + ")\">Save</a></span>", "<span id=\"deleteText[" + q.lookupTextId + "]\"><a href=\"#\" onclick=\"deleteText(" + q.lookupTextId + ",'" + q.displayText + "')\">Delete</a></span>" + "<span hidden=\"hidden\" id=\"cancelText[" + q.lookupTextId + "]\"><a href=\"#\" onclick=\"cancelText(" + q.lookupTextId + ")\">Cancel</a></span>" }; dtr.data.Add(data); } Debug.WriteLine("Def3Maint Controller DataTableTexts data populated."); // Output the JSON in DataTable format fastJSON.JSONParameters param = new fastJSON.JSONParameters(); param.EnableAnonymousTypes = true; result = fastJSON.JSON.ToJSON(dtr, param); Debug.WriteLine("Def3Maint Controller DataTableTexts result:" + result); } catch (Exception excptn) { Debug.WriteLine("Def3Maint Controller DataTableTexts exception:" + excptn.Message); result = excptn.Message + " - " + excptn.Message; } } catch (FormatException excptn) { Debug.WriteLine("Def3Maint Controller DataTableTexts detailId format exception:" + excptn.Message); } return(result); }
public string DataTableDetails(int draw, int start, int length, string searchValue, string searchRegex, string order) { int masterId = 0; int ent = 0; int grp = 0; string result = String.Empty; Debug.WriteLine("Def3Maint Controller DataTableDetails draw:" + draw.ToString()); Debug.WriteLine("Def3Maint Controller DataTableDetails start:" + start.ToString()); Debug.WriteLine("Def3Maint Controller DataTableDetails searchValue:" + searchValue); Debug.WriteLine("Def3Maint Controller DataTableDetails searchRegex:" + searchRegex); Debug.WriteLine("Def3Maint Controller DataTableDetails order:" + order); try { string r = Request["masterId"]; if (!String.IsNullOrEmpty(r)) { masterId = Convert.ToInt32(r); } r = Request["entId"]; if (!String.IsNullOrEmpty(r)) { try { ent = Convert.ToInt32(r); } catch (FormatException excptn) { } } r = Request["grpId"]; if (!String.IsNullOrEmpty(r)) { try { grp = Convert.ToInt32(r); } catch (FormatException excptn) { } } // Lists all the Request parameters foreach (string s in Request.Params.Keys) { Debug.WriteLine(s.ToString() + ":" + Request.Params[s]); } try { // Initialize the DataTable response (later transformed to JSON) DataTableResult dtr = new DataTableResult() { draw = draw, recordsTotal = 1, recordsFiltered = 1, data = new List <string[]>(), error = String.Empty }; // rename to avoid language/library conflicts int iniIndex = start; int noDsplyRecs = length; int englishId = 0; foreach (def_Languages l in formsRepo.GetAllLanguages()) { if (l.title.Equals("English")) { englishId = l.langId; break; } } List <def_LookupDetail> query = formsRepo.GetLookupDetails(masterId, ent, grp); List <def_BaseTypes> types = formsRepo.GetBaseTypes(); dtr.recordsTotal = dtr.recordsFiltered = query.Count(); foreach (def_LookupDetail q in query.Skip(iniIndex).Take(noDsplyRecs).ToList()) { def_LookupText dl = formsRepo.GetLookupTextsByLookupDetailLanguage(q.lookupDetailId, englishId).FirstOrDefault(); string engText = (dl != null) ? dl.displayText : String.Empty; string[] data = new string[] { "<span id=\"dataValue[" + q.lookupDetailId + "]\">" + q.dataValue + "</span>", "<span id=\"order[" + q.lookupDetailId + "]\">" + q.displayOrder + "</span>", "<span id=\"english[" + q.lookupDetailId + "]\">" + engText + "</span>", "<span id=\"editDetail[" + q.lookupDetailId + "]\"><a href=\"#\" onclick=\"editDetail(" + q.lookupDetailId + ")\">Edit</a></span>" + "<span id=\"saveDetail[" + q.lookupDetailId + "]\" hidden=\"hidden\"><a href=\"#\" onclick=\"saveDetail(" + q.lookupDetailId + ")\">Save </a></span>", "<span id=\"textDetail[" + q.lookupDetailId + "]\"><a href=\"#\" onclick=\"textDetail(" + q.lookupDetailId + ", '" + q.dataValue + "')\">View Text </a></span>" + "<span id=\"cancelDetail[" + q.lookupDetailId + "]\" hidden=\"hidden\"><a href=\"#\" onclick=\"cancelDetail(" + q.lookupDetailId + ")\">Cancel </a></span>", "<span id=\"deleteDetail[" + q.lookupDetailId + "]\"><a href=\"#\" onclick=\"deleteDetail(" + q.lookupDetailId + ", '" + q.dataValue + "')\">Delete</a></span>" }; dtr.data.Add(data); } Debug.WriteLine("Def3Maint Controller DataTableDetails data populated."); // Output the JSON in DataTable format fastJSON.JSONParameters param = new fastJSON.JSONParameters(); param.EnableAnonymousTypes = true; result = fastJSON.JSON.ToJSON(dtr, param); Debug.WriteLine("Def3Maint Controller DataTableDetails result:" + result); } catch (Exception excptn) { Debug.WriteLine("Def3Maint Controller DataTableDetails exception:" + excptn.Message); result = excptn.Message + " - " + excptn.Message; } } catch (FormatException excptn) { Debug.WriteLine("Def3Maint Controller DataTableDetails masterId format exception:" + excptn.Message); } return(result); }
public string DataTableMasters(int draw, int start, int length, string searchValue, string searchRegex, string order) { string result = String.Empty; Debug.WriteLine("Def3Maint Controller DataTableMasters draw:" + draw.ToString()); Debug.WriteLine("Def3Maint Controller DataTableMasters start:" + start.ToString()); Debug.WriteLine("Def3Maint Controller DataTableMasters searchValue:" + searchValue); Debug.WriteLine("Def3Maint Controller DataTableMasters searchRegex:" + searchRegex); Debug.WriteLine("Def3Maint Controller DataTableMasters order:" + order); // Lists all the Request parameters foreach (string s in Request.Params.Keys) { Debug.WriteLine(s.ToString() + ":" + Request.Params[s]); } try { // Initialize the DataTable response (later transformed to JSON) DataTableResult dtr = new DataTableResult() { draw = draw, recordsTotal = 1, recordsFiltered = 1, data = new List <string[]>(), error = String.Empty }; // rename to avoid language/library conflicts int iniIndex = start; int noDsplyRecs = length; List <def_LookupMaster> query = formsRepo.GetLookupMasters(); List <def_BaseTypes> types = formsRepo.GetBaseTypes(); string basedropdown = String.Empty; foreach (def_BaseTypes bt in types) { basedropdown += "<option value=\"" + bt.baseTypeId + "\">" + bt.enumeration + "</option>"; } dtr.recordsTotal = dtr.recordsFiltered = query.Count(); foreach (def_LookupMaster q in query.Skip(iniIndex).Take(noDsplyRecs).ToList()) { string dropdown = basedropdown; // Flag the appropriate html option as selected. string findText = "value=\"" + q.baseTypeId; int index = dropdown.IndexOf(findText); dropdown = dropdown.Insert(index - 1, " selected=\"selected\""); string[] data = new string[] { "<span id=\"lkpCd[" + q.lookupMasterId + "]\">" + q.lookupCode + "</span>", "<span id=\"ttl[" + q.lookupMasterId + "]\">" + q.title + "</span>", "<span id=\"bsTyp[" + q.lookupMasterId + "]\">" + formsRepo.GetBaseTypeById(q.baseTypeId).enumeration + "</span>" + "<span id=\"bsTypSelDat[" + q.lookupMasterId + "]\" hidden=\"hidden\">" + "<select class=\"masterBase form-control\" id=\"bsTypSel[" + q.lookupMasterId + "]\" name=\"addMasterBase\">" + dropdown + "</select>" + "</span>", "<span id=\"editMaster[" + q.lookupMasterId + "]\"><a href=\"#\" onclick=\"editMaster(" + q.lookupMasterId + ")\">Edit</a></span>" + "<span id=\"saveMaster[" + q.lookupMasterId + "]\" hidden=\"hidden\"><a href=\"#\" onclick=\"saveMaster(" + q.lookupMasterId + ")\">Save</a></span>", "<span id=\"detailsInquiry[" + q.lookupMasterId + "]\"><a href=\"#\" onclick=\"DetailsInquiry(" + q.lookupMasterId + ", '" + q.title + "')\">View Details</a></span>" + "<span id=\"cancelMaster[" + q.lookupMasterId + "]\" hidden=\"hidden\"><a href=\"#\" onclick=\"cancelMaster(" + q.lookupMasterId + ")\">Cancel</a></span>", "<span id=\"deleteMaster[" + q.lookupMasterId + "]\"><a href=\"#\" onclick=\"deleteMaster(" + q.lookupMasterId + ", '" + q.lookupCode + "')\">Delete</a></span>" }; dtr.data.Add(data); } Debug.WriteLine("Def3Maint Controller DataTableMasters data populated."); // Output the JSON in DataTable format fastJSON.JSONParameters param = new fastJSON.JSONParameters(); param.EnableAnonymousTypes = true; result = fastJSON.JSON.ToJSON(dtr, param); Debug.WriteLine("Def3Maint Controller DataTableMasters result:" + result); } catch (Exception excptn) { Debug.WriteLine("Def3Maint Controller DataTableMasters exception:" + excptn.Message); result = excptn.Message + " - " + excptn.Message; } return(result); }