public JsonResult InstallPackages(string packages) { try { var packagesToInstall = new JavaScriptSerializer().Deserialize<IEnumerable<PackageModel>>(packages); var context = new SelfUpdaterEntities(); foreach (var self in packagesToInstall.Select(pack => new SelfUpdatingPackages { PackageId = pack.Name, PackageVersion = pack.Version, Source = pack.Source, Install = pack.Install})) { context.AddToSelfUpdatingPackages(self); } context.SaveChanges(); var config = WebConfigurationManager.OpenWebConfiguration("~/"); var section = config.GetSection("system.web/httpRuntime"); ((HttpRuntimeSection)section).WaitChangeNotification = 123456789; ((HttpRuntimeSection)section).MaxWaitChangeNotification = 123456789; config.Save(); return Json("Ok"); } catch(Exception e) { ErrorHandler.Publish(LogLevel.Error, e); Response.StatusCode = 500; return Json(e.Message); } }
static void LoadOverrides() { var deserialized = new JavaScriptSerializer().Deserialize<Override[]>(Settings.Default.ArchivePathOverrides); var overrides = new List<KeyValuePair<Regex, string>>(); deserialized .Select(x => CreateOverride(x.Expression, x.Path)) .Each(overrides.Add); ArchivePathOverrides = overrides; }
public string GetUnitFollowListChiTieu(string lstChiTieu) { var result = new List<DonViTinhObject>(); var chiTieuData = new JavaScriptSerializer().Deserialize<List<HeaderObject>>(lstChiTieu); var lstIdChiTieu = chiTieuData.Select(ct => ct.Id).ToList(); var data = _db.TK_ChiTieu .Where(ct => lstIdChiTieu.Contains(ct.ChiTieu_Id)) .Select(ct => new DonViTinhObject { Id = ct.ChiTieu_Id, Title = ct.DM_DonViTinh.TenDonViTinh, Value = ct.DM_DonViTinh.ValueFormat }).ToList(); lstIdChiTieu.ForEach(ict => { var item = data.FirstOrDefault(d => d.Id == ict); if (item == null) { result.Add(new DonViTinhObject { Id = ict, Title = "Mặc định", Value = "0,0" }); } else { result.Add(item); } }); return new JavaScriptSerializer().Serialize(result); }
public string GetListThongKe2(string lstChiTieu_Id, string lstId) { if (lstChiTieu_Id == null) { lstChiTieu_Id = ""; } var chiTieuData = new JavaScriptSerializer().Deserialize<List<HeaderObject>>(lstChiTieu_Id); var doiTuongData = new JavaScriptSerializer().Deserialize<List<HeaderObject>>(lstId); var lstIdChiTieu = chiTieuData.Select(ct => ct.Id).ToList(); var lstIdDoiTuong = doiTuongData.Select(dt => dt.Id).ToList(); var result = _db.TK_ThongKe .Where(tk => lstIdChiTieu.Contains(tk.ChiTieu_Id) && lstIdDoiTuong.Contains(tk.DoiTuong_Id)); //.Select(tk => new DataObject //{ // IdLeft = tk.Id, // IdTop = tk.ChiTieu_Id, // GiaTri = (decimal)tk.GiaTriThongKe //}).ToList(); List<DataObject> LstThongKe = new List<DataObject>(); foreach (var thongke in result) { LstThongKe.Add(new DataObject { IdLeft = thongke.ChiTieu_Id, IdTop = thongke.ChiTieu_Id, GiaTri = Convert.ToDecimal(thongke.GiaTriThongKe) }); } return new JavaScriptSerializer().Serialize(LstThongKe); }