diff --git a/350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility.v12.suo b/350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility.v12.suo index 2d5b389..3f31db0 100644 --- a/350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility.v12.suo +++ b/350-UTILITIES/Parser/XMLtoJSON_utility/XMLtoJSON_utility.v12.suo diff --git a/350-UTILITIES/SQL_To_Json/Newtonsof_Json_Net45.rar b/350-UTILITIES/SQL_To_Json/Newtonsof_Json_Net45.rar new file mode 100644 index 0000000..4a1c552 --- /dev/null +++ b/350-UTILITIES/SQL_To_Json/Newtonsof_Json_Net45.rar diff --git a/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/Custom.cs b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/Custom.cs index 6fc0404..90e20f2 100644 --- a/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/Custom.cs +++ b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/Custom.cs @@ -9,6 +9,8 @@ using System.Configuration; using System.Data.SqlClient; using System.Configuration; using Newtonsoft.Json.Linq; +using System.Text.RegularExpressions; +using System.Web; namespace SQLToJSON { @@ -16,7 +18,7 @@ namespace SQLToJSON { string connString = string.Empty; public Custom() - { + { connString = Convert.ToString(ConfigurationManager.AppSettings["connectionString"]); } @@ -34,77 +36,138 @@ namespace SQLToJSON { string JSONString = string.Empty; JSONString = JsonConvert.SerializeObject(table); - return JSONString; + string XYX = JSONString.Replace(@"\r", ""); + string YYY = XYX.Replace(@"\n", ""); + string uuu = YYY.Replace(@"\", ""); + + //System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); + + //string vvv = js.Serialize(table); + //JSONString= JToken.Parse(JSONString).ToString(); + //var obj = new JObject(); + //obj["data"] = JToken.FromObject(table); + + // string jsonString = obj.ToString(); + // dynamic DATA = new JObject(); + // var jsonObj = new JObject(); + // dynamic mo = jsonObj; + // mo.data1 = new JObject() as dynamic; + // foreach (var d in table) + // { + // dynamic data = new JObject(); + // data.loginId = d.loginId; + + // data.password = d.password; + // data.firstName = d.firstName; + // data.lastName = d.lastName; + // data.userType = d.userType; + // data.emailId = d.emailId; + // data.isActive = d.isActive; + // data.securityQuestion = d.securityQuestion; + // data.securityAnswer = d.securityAnswer; + // data.creatorId = d.creatorId; + // data.creationDate = d.creationDate; + // data.modifierId = d.modifierId; + // data.modifiedDate = d.modifiedDate; + // data.deactivationDate = d.deactivationDate; + // data.module = d.module; + // // data.ToString(); + // DATA.Add(data.ToString()); + // } + //// } + //// string abc = Convert.ToString(JsonConvert.DeserializeObject(JSONString)); + // //JSONString.Replace(@"\",""); + // //var json = JsonConvert.SerializeObject(new { root = table }, Formatting.Indented); + // //json.Replace(@"\\\", ""); + //string x = DATA.ToString(); + return uuu; } public dynamic GetModifiedTableWithUserModules(DataTable userTable, DataTable moduleTable) { List data2 = null; + List RESULT = new List(); try { - + List data = (from d in userTable.AsEnumerable() - join e in moduleTable.AsEnumerable() - on d.Field("Id") equals - e.Field("UserId") - select new User - { - loginId = d.Field("loginId"), - password = d.Field("password"), - firstName = d.Field("firstName"), - lastName = d.Field("lastName"), - userType = d.Field("userType"), - emailId = d.Field("emailId"), - isActive = d.Field("isActive"), - securityQuestion = d.Field("securityQuestion"), - securityAnswer = d.Field("securityAnswer"), - creatorId = d.Field("creatorId"), - creationDate = d.Field("creationDate"), - modifierId = d.Field("modifierId"), - modifiedDate = d.Field("modifiedDate"), - deactivationDate = d.Field("deactivationDate"), - module = e.Field("Title"), - }).ToList(); + join e in moduleTable.AsEnumerable() + on d.Field("Id") equals + e.Field("UserId") + select new User + { + loginId = d.Field("loginId"), + password = d.Field("password"), + firstName = d.Field("firstName"), + lastName = d.Field("lastName"), + userType = d.Field("userType"), + emailId = d.Field("emailId"), + isActive = d.Field("isActive"), + securityQuestion = d.Field("securityQuestion"), + securityAnswer = d.Field("securityAnswer"), + creatorId = d.Field("creatorId"), + creationDate = d.Field("creationDate"), + modifierId = d.Field("modifierId"), + modifiedDate = d.Field("modifiedDate"), + deactivationDate = d.Field("deactivationDate"), + module = e.Field("Title"),//JsonConvert.SerializeObject(e.Field("Title")), + }).ToList(); - - data2=data.ToList(); + + data2 = data.ToList(); + string previousUserId =""; foreach (var row in data) { string userloginId = row.loginId; - var Modules = (from m in data - where m.loginId == userloginId - select m.module).ToList(); - - string modu= JsonConvert.SerializeObject(Modules); + if (userloginId != previousUserId) + { + previousUserId = userloginId; - var jsonObj = new JObject(); - dynamic mo = jsonObj; - mo.modules = new JArray() as dynamic; + var Modules = (from m in data + where m.loginId == userloginId + select m.module).ToList(); - foreach (var mods in Modules) - { - dynamic modul= new JObject(); - modul.name = mods; - modul.slug = ConfigurationManager.AppSettings[mods]; - mo.modules.Add(modul); - + string modu = JsonConvert.SerializeObject(Modules); + + var jsonObj = new JObject(); + dynamic mo = jsonObj; + mo.modules = new JArray(); + + foreach (var mods in Modules) + { + dynamic modul = new JObject(); + string MO = mods.ToString().Replace(@"\", ""); + modul.name = mods; + modul.slug = ConfigurationManager.AppSettings[(mods.ToString()).Replace(@"\", "")]; + mo.modules.Add(modul); + + } + + var lst = data2.Where(w => w.loginId == userloginId).Select(r => { r.module =(mo).ToString(); return r; }).ToList(); + string moddd = ((from mod in lst + select mod.module).FirstOrDefault().ToString()).Replace(@"\", ""); + string abc = Regex.Unescape(moddd); + var lst2 = data2.Where(w => w.loginId == userloginId).Select(r => { r.module = ((moddd)).ToString(); return r; }).ToList(); + + var reultantRow = lst2.FirstOrDefault(); + //lst.GroupBy(x => x.loginId).Select(g => g.First()); + RESULT.Add(reultantRow); + // data2 = data2.Where(w => w.loginId == userloginId).Select(r => { r.module = mo.ToString(); return r; }).ToList(); } - - data2 = data2.Where(w=>w.loginId == userloginId).Select (r => { r.module = mo.ToString(); return r; }).ToList(); + } - } - - var result = data2.GroupBy(x => x.loginId).Select(g => g.First()); + //var result = data2.GroupBy(x => x.loginId).Select(g => g.First()); string bb = ""; - - return result; + + return RESULT; } - catch (Exception e) { - return e.Message; + catch (Exception e) + { + return e.Message; } - + } } diff --git a/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/Form1.cs b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/Form1.cs index d1dd449..ccb81f3 100644 --- a/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/Form1.cs +++ b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/Form1.cs @@ -1,4 +1,5 @@ -using System; +using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -67,6 +68,7 @@ namespace SQLToJSON File.Delete(@"D:/AIAUser.json"); } System.IO.File.WriteAllText("D:/AIAUser.json", aiaUserJson); + label1.Text = "Conversion Successfull."; } catch (Exception ex) diff --git a/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/SQLToJSON.csproj b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/SQLToJSON.csproj index 7c889d1..102538c 100644 --- a/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/SQLToJSON.csproj +++ b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/SQLToJSON.csproj @@ -39,6 +39,7 @@ + @@ -58,6 +59,8 @@ + + Form1.cs diff --git a/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/StringContent.cs b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/StringContent.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/StringContent.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/StringContent_2.cs b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/StringContent_2.cs new file mode 100644 index 0000000..c97abc8 --- /dev/null +++ b/350-UTILITIES/SQL_To_Json/SQLToJSON/SQLToJSON/StringContent_2.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SQLToJSON +{ + class StringContent + { + } +}