public PermissionVm Init(long userId, long?id) { var toRet = new PermissionVm { Statuses = BlCode.LoadTable(userId, "PermissionStatus"), ActionMode = Enumerations.ActionMode.Add, Permission = new Permission { Status = "A", Module = new Module() } }; if (id != null) { var permission = LoadSingle(userId, Convert.ToInt64(id)); toRet.Permission = permission; //Create roles tree var blRole = new BlRole(); var roles = blRole.LoadForPermission(userId, permission.Module.Id, permission.Code); toRet.RolesTree = new JavaScriptSerializer().Serialize((from r in roles select new TreeItemVm { id = r.Id.ToUiString(), parent = r.ParentRole == null ? "#" : r.ParentRole.Id.ToString(), text = r.Code ?? "", icon = "fa fa-users colorMain", state = "{\"checked\": \"" + (r.IsActive ? "true" : "false") + "\"}", li_attr = "{\"class\" : \"form-control-label\"}" })); toRet.Signature = BlCommon.GetSignature(toRet.Permission.UserId, toRet.Permission.EntryDate); toRet.ActionMode = Enumerations.ActionMode.Edit; } return(toRet); }
public GridResults LoadPaging(long userId, string search, int pageIndex, out long totalRecords, string sortColumnName = "", string sortOrderBy = "") { //Get current user var user = BlUser.LoadSingle(userId); //Query paged data var results = LoadPaging(userId, CreateFilter(search), user.PageSize, pageIndex - 1, out totalRecords); //Convert results into display model var res = (from r in results select new { r.Id, Type = BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "ErrorType", r.Type.ToString())), Severity = BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "ErrorSeverity", r.Severity.ToString())), Source = r.Source ?? "", Text = r.Text ?? "", User = r.UserId == 0 ? "" : BlUser.LoadSingle(r.UserId).UserName, branch = BlBranch.GetBranchName(user.Id, r.BranchId), LogDate = r.EntryDate.ToString(true) }).ToList(); //Convert display model into json data return(GridVm.FormatResult(res, user.PageSize, pageIndex, totalRecords)); }
public static string FormatFullName(Entity entity, bool withMilitaryId = false) { var toRet = string.Empty; //Title if (CheckEmpty.String(entity.Title) != "") { toRet = BlCode.LoadSingle(Constants.SystemUser, "Title", entity.Title).Value1 + " "; } //Full arabic name toRet += entity.FullArLongName; //Military number if exists if (withMilitaryId) { if (CheckEmpty.String(entity.IdType) != "" && CheckEmpty.String(entity.IdNum) != "") { if (CheckEmpty.String(entity.IdType) == "M") { toRet += " " + entity.IdNum; } } } return(toRet); }
public static QuickSearchResult LoadSingle(long userId, string entity, string id, string parameters = "") { var item = new DdlVm.DdlOption(); switch (entity) { //case "LOCATION": item = BlLocation.LoadQs(userId, Convert.ToInt64(id)); break; //case "LOCATIONEMPLOYEE": item = BlLocation.LoadLocationEmployeeQs(userId, id); break; case "EMPLOYEE": item = BlEmployee.LoadQs(userId, Convert.ToInt64(id), parameters); break; //case "PRODUCT": item = BlProduct.LoadQs(userId, Convert.ToInt64(id)); break; //case "SUPPLIER": item = BlSupplier.LoadQs(userId, Convert.ToInt64(id)); break; case "USER": item = BlUser.LoadQs(userId, Convert.ToInt64(id)); break; case "MODULE": item = BlModule.LoadQs(userId, id); break; case "CODE": item = BlCode.LoadQs(userId, id, parameters); break; //case "WAREHOUSE": item = BlWarehouse.LoadQs(userId, Convert.ToInt64(id), parameters); break; //case "LOCATIONMORAL": item = BlLocationMoral.LoadQs(userId, Convert.ToInt64(id), parameters); break; //case "STOCK": item = BlStock.LoadQs(userId, Convert.ToInt64(id)); break; } var toRet = new QuickSearchResult { id = item.value, text = item.label }; return(toRet); }
public GridResults LoadPaging(long userId, string search, int pageIndex, out long totalRecords, string sortColumnName = "", string sortOrderBy = "") { //Get current user var user = LoadSingle(userId); //Query paged data var results = LoadPaging(userId, CreateFilter(search), user.PageSize, pageIndex - 1, out totalRecords); //Convert results into display model var res = (from r in results select new { r.Id, r.UserName, Name = BlEntity.FormatFullName(r.Entity), Language = BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "Language", r.LanguageId.ToUiString())), r.PageSize, roles = string.Join(",", r.Roles.Select(ro => ro.Code)), Branch = BlBranch.GetBranchName(user.Id, r.BranchId), IsBlocked = r.IsBlocked ? "close colorRed" : "check colorGreen" }).ToList(); //Convert display model into json data return(GridVm.FormatResult(res, user.PageSize, pageIndex, totalRecords)); }
public GridResults LoadPaging(long userId, string search, int pageIndex, out long totalRecords, string sortColumnName = "", string sortOrderBy = "") { //Get current user var user = BlUser.LoadSingle(userId); //Query paged data var results = LoadPaging(userId, CreateFilter(search), user.PageSize, pageIndex - 1, out totalRecords); //Convert results into display model var res = (from r in results select new { r.Id, Gender = r.Entity.Gender == null ? "" : BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "Gender", r.Entity.Gender)), Name = BlEntity.FormatFullName(r.Entity), Number = r.Entity.IdType == "M" ? r.Entity.IdNum : "", r.Entity.FullEnLongName, Level = r.Level == null ? "" : BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "EmployeeLevel", r.Level)), Status = r.Status == "A" ? "check colorGreen" : "close colorRed" }).ToList(); //Convert display model into json data return(GridVm.FormatResult(res, user.PageSize, pageIndex, totalRecords)); }
public EmployeeVm Init(long userId, long?id) { var user = BlUser.LoadSingle(userId); var toRet = new EmployeeVm { Branches = BlBranch.GetLov(userId, true).ToDictionary(i => i.value, i => i.label), Titles = BlCode.LoadTable(userId, "Title"), Genders = BlCode.LoadTable(userId, "Gender"), IdTypes = BlCode.LoadTable(userId, "IdType"), Maritals = BlCode.LoadTable(userId, "Marital"), Statuses = BlCode.LoadTable(userId, "Status"), Levels = BlCode.LoadTable(userId, "EmployeeLevel"), ActionMode = Enumerations.ActionMode.Add, Employee = new Employee { Status = "A", Entity = new Entity { BranchId = user.BranchId, Nationality = 422, Status = "A" }, Level = "0" } }; if (id != null) { var obj = LoadSingle(userId, Convert.ToInt64(id)); toRet.Employee = obj; toRet.ActionMode = Enumerations.ActionMode.Edit; toRet.Signature = BlCommon.GetSignature(toRet.Employee.UserId, toRet.Employee.EntryDate); } return(toRet); }
private void PreSave(long userId, ref User toSave, Enumerations.ActionMode action, string userRoles = "") { if (action == Enumerations.ActionMode.Add) { var defaultPassword = BlCode.LoadSingle(userId, "_System", "DefaultPassword").Value1; toSave.Password = Cryptography.ComputeToHash(defaultPassword); toSave.MustChangePassword = true; toSave.EntryDate = BlCommon.GetServerDateTime(); toSave.LastPasswordUpdate = toSave.EntryDate; //toSave.Branch = BlBranch.LoadSingle(userId, toSave.Branch.Id); } else if (action == Enumerations.ActionMode.Edit) { } toSave.EnteringUserId = userId; toSave.Entity = BlEntity.LoadSingle(userId, toSave.Pin); if (CheckEmpty.String(userRoles) != "") { if (toSave.Roles == null) { toSave.Roles = new List <Role>(); } toSave.Roles.Clear(); foreach (var roleId in userRoles.Split(',')) { toSave.Roles.Add(BlRole.LoadSingle(userId, Convert.ToInt64(roleId))); } } }
private static void UpdateTicketValidity(long userId) { var defaultTimeOut = Convert.ToInt32(BlCode.LoadSingle(userId, "_System", "DefaultTimeOut").Value1); //BlLogError.LogError("BlUser.UpdateTicketValidity", "Key: " + Module + "_DateStamp_" + userId.ToUiString() +", Value: " + BlCommon.GetServerDateTime()); //BlLogError.LogError("BlUser.UpdateTicketValidity", "Key: " + Module + "_ValidTill_" + userId.ToUiString() + ", Value: " + BlCommon.GetServerDateTime().AddMinutes(defaultTimeOut)); //Increment ticket cached lifetime CacheHelper.Add(Module + "_DateStamp_" + userId.ToUiString(), BlCommon.GetServerDateTime(), defaultTimeOut); CacheHelper.Add(Module + "_ValidTill_" + userId.ToUiString(), BlCommon.GetServerDateTime().AddMinutes(defaultTimeOut), defaultTimeOut); }
public UserVm ProfileSave(long userId, UserVm toEdit) { using (var tran = new TransactionScope()) { var user = LoadSingle(toEdit.User.Id, true); if (toEdit.ChangePassword) { if (!Cryptography.ComputeToHash(toEdit.OldPassword).SequenceEqual(user.Password)) { throw new BusinessException("WrongOldPassword"); } if (!Cryptography.ComputeToHash(toEdit.NewPassword).SequenceEqual(Cryptography.ComputeToHash(toEdit.ConfirmPassword))) { throw new BusinessException("NewPasswordDoesNotmatchConfirmation"); } user.LastPasswordUpdate = BlCommon.GetServerDateTime(); if (user.PasswordHistory != "") { var oldPasswordList = CheckEmpty.String(user.PasswordHistory).Split(','); foreach (var pass in oldPasswordList) { if (Cryptography.ComputeToHash(toEdit.NewPassword).SequenceEqual(Convert.FromBase64String(pass))) { throw new BusinessException("NewPasswordFrequentlyUsed"); } } } user.PasswordHistory += user.PasswordHistory == "" ? "" : ","; user.PasswordHistory += Convert.ToBase64String(user.Password); var historyLength = BlCode.LoadSingle(userId, "_System", "PasswordHistroyLength").Value1; if (user.PasswordHistory.Split(',').Length > Convert.ToInt32(historyLength)) { var newPasswordHistroy = user.PasswordHistory.Split(',').ToList(); newPasswordHistroy.RemoveAt(0); user.PasswordHistory = string.Join(",", newPasswordHistroy); } user.Password = Cryptography.ComputeToHash(toEdit.NewPassword); toEdit.ChangePassword = false; } user.UserName = toEdit.User.UserName; user.LanguageId = Convert.ToInt16(toEdit.User.LanguageId); user.PageSize = Convert.ToInt16(toEdit.User.PageSize); Edit(userId, user); //Force cash refresh for module entry CacheHelper.Clear(Module + "_" + user.Id.ToUiString()); BlLog.Log(userId, Module, "Profile change", "UserProfileModified", new object[] { user.UserName }); tran.Complete(); return(toEdit); } }
public UserVm Init(long userId, long?id) { var callingUser = LoadSingle(userId); var toRet = new UserVm { Branches = BlBranch.GetLov(userId, true).ToDictionary(i => i.value, i => i.label), Languages = BlCode.LoadTable(userId, "Language", callingUser.LanguageId == (int)Enumerations.Languages.English ? "Value1" : "Value2"), PageSizes = BlCode.LoadTable(userId, "PageSizes", callingUser.LanguageId == (int)Enumerations.Languages.English ? "Value1" : "Value2"), ActionMode = Enumerations.ActionMode.Add, User = new User { LanguageId = 1, PageSize = 10 } }; if (id != null) { var user = LoadSingle((long)id); user.Pin = user.Entity == null ? user.Pin : user.Entity.Pin; user.Entity = null; //user.Branch = null; toRet.User = user; toRet.Signature = BlCommon.GetSignature(toRet.User.EnteringUserId, toRet.User.EntryDate); //Get all roles and check user assigned ones var blRole = new BlRole(); var roles = blRole.LoadAll(userId).ToList(); if (user.Roles != null) { foreach (var role in user.Roles) { if (roles.Where(r => r.Id == role.Id).Any()) { roles.Where(r => r.Id == role.Id).SingleOrDefault().IsActive = true; } } } toRet.UserRoles = new JavaScriptSerializer().Serialize((from r in roles select new TreeItemVm { id = r.Id.ToUiString(), parent = r.ParentRole == null ? "#" : r.ParentRole.Id.ToUiString(), text = r.Code ?? "", icon = "fa fa-users colorMain", state = "{\"checked\": \"" + (r.IsActive ? "true" : "false") + "\"}", li_attr = "{\"class\" : \"form-control-label\"}" })); //user.Roles = null; toRet.ActionMode = Enumerations.ActionMode.Edit; } return(toRet); }
public void ResetPassword(long userId, long toResetUserId) { using (var tran = new TransactionScope()) { var defaultPassword = BlCode.LoadSingle(userId, "_System", "DefaultPassword").Value1; var toResetUser = LoadSingle(toResetUserId); toResetUser.Password = Cryptography.ComputeToHash(defaultPassword); toResetUser.MustChangePassword = true; BlLog.Log(userId, Module, "Password reset", "UserPasswordReset", new object[] { toResetUser.UserName }); tran.Complete(); } }
public UserVm ProfileInit(long userId) { var user = LoadSingle(userId, true); var toRet = new UserVm { User = user, Languages = BlCode.LoadTable(userId, "Language", user.LanguageId == (int)Enumerations.Languages.English ? "Value1" : "Value2"), PageSizes = BlCode.LoadTable(userId, "PageSizes", user.LanguageId == (int)Enumerations.Languages.English ? "Value1" : "Value2"), Signature = BlCommon.GetSignature(user.EnteringUserId, user.EntryDate), ActionMode = Enumerations.ActionMode.Edit }; return(toRet); }
public static string GetReceiptHeader(long branchId, int headerNum) { var branch = BlBranch.LoadSingle(Constants.SystemUser, branchId); var toRet = string.Empty; switch (branch.Id) { case 1: { if (headerNum == 2) { toRet = BlCode.LoadSingle(Constants.SystemUser, "Receipt_1", "Header2").Value1; } // "مصلحة الديوان"; } if (headerNum == 3) { toRet = branch.Entity.ArFirstName; } break; } case 2: { if (headerNum == 2) { toRet = BlCode.LoadSingle(Constants.SystemUser, "Receipt_2", "Header2").Value1; } // "الفرع الفني"; } if (headerNum == 3) { toRet = branch.Entity.ArFirstName; } break; } case 3: { if (headerNum == 2) { toRet = BlCode.LoadSingle(Constants.SystemUser, "Receipt_3", "Header2").Value1; } // "مصلحة الديوان"; } if (headerNum == 3) { toRet = branch.Entity.ArFirstName; } break; } } return(toRet); }
public ErrorVm Init(long userId, long id) { //Get current user var user = BlUser.LoadSingle(userId); var error = LoadSingle(userId, id); var toRet = new ErrorVm { Type = BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "ErrorType", error.Type.ToUiString())), Severity = BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "ErrorSeverity", error.Severity.ToUiString())), Source = error.Source, Text = error.Text, UserName = BlUser.LoadSingle(error.UserId).UserName, Branch = BlBranch.GetBranchName(user.Id, error.BranchId), Date = error.EntryDate.ToString(true) }; return(toRet); }
public LoginVm Authenticate(LoginVm model) { var hashedPass = Cryptography.ComputeToHash(model.Password); if (hashedPass == null) { throw new BusinessException("InvalidLogin"); } var userRepository = new UserRepository(); var predicate = PredicateBuilder.True <User>(); predicate = predicate.And(u => u.UserName == model.Username); var users = userRepository.LoadSearch(predicate); //Check if any user have same password IStructuralEquatable eqa1 = hashedPass; var user = users.FirstOrDefault(u => eqa1.Equals(u.Password, StructuralComparisons.StructuralEqualityComparer)); if (user == null) { throw new BusinessException("InvalidLogin"); } //Check if user is active if (user.IsBlocked) { throw new BusinessException("UserInactive"); } UpdateTicketValidity(user.Id); model.SecurityToken = Cryptography.Encrypt(JsonConvert.SerializeObject(user.Id), true); model.Password = null; model.Language = BlCode.LoadSingle(user.Id, "Language", user.LanguageId.ToUiString()).Value1; model.BranchId = user.BranchId; model.BranchName = BlBranch.GetBranchName(user.Id); model.CrossBranches = BlPermission.CanDo(user.Id, "BRANCH", "CrossBranches"); model.PageSize = user.PageSize; BlLog.Log(user.Id, Module, "LogIn", "UserSuccessfulLogin", new object[] { user.UserName }); return(model); }
public static Address GetDefaultAddress(long userId, long pin, bool withFullAddress = false) { var predicate = PredicateBuilder.True <Address>(); predicate = predicate.And(m => m.Entity.Pin == pin); predicate = predicate.And(m => m.Sequence == 1); var blAddress = new BlAddress(); var toRet = blAddress.LoadSearch(userId, predicate, 1).SingleOrDefault() ?? new Address() { Country = "0", Province = "0", Caza = "0", Region = "", Street = "", Building = "", Floor = "0", Phone1 = "", Phone2 = "", Phone3 = "", Fax = "" }; if (withFullAddress) { //Set the full address toRet.FullAddress = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}-{9}-{10}", BlCode.LoadSingle(userId, "Country", toRet.Country ?? "0").Value1, BlCode.LoadSingle(userId, "Province", toRet.Province ?? "0").Value1, BlCode.LoadSingle(userId, "Caza", toRet.Caza ?? "0").Value1, toRet.Region, toRet.Street, toRet.Building, BlCode.LoadSingle(userId, "Floor", toRet.Floor ?? "0").Value1, toRet.Phone1, toRet.Phone2, toRet.Phone3, toRet.Fax); } return(toRet); }
public DescriptionVm Init(long userId, long?id) { var toRet = new DescriptionVm { Languages = BlCode.LoadTable(userId, "Language"), DescriptionParents = BlCode.LoadTable(userId, "DescriptionParent"), ActionMode = Enumerations.ActionMode.Add, Description = new Description { LanguageId = 0, Parent = "" } }; if (id != null) { var description = LoadSingle(userId, (long)id); toRet.Description = description; toRet.ActionMode = Enumerations.ActionMode.Edit; } return(toRet); }
public XtraVm Init(long userId, string Object, long id, string property) { long branchId = 0; var toRet = new XtraVm { ActionMode = Enumerations.ActionMode.Add, Properties = BlCode.LoadTable(userId, "ProductOpenProperty_" + branchId, "", branchId.ToString()), Xtra = new Xtra { Object = Object, Id = id } }; if (property != "null") { var obj = LoadSingle(userId, Object, id, property); toRet.Xtra = obj; toRet.ActionMode = Enumerations.ActionMode.Edit; } return(toRet); }
public MenuVm Init(long userId, long?id) { var toRet = new MenuVm { Branches = BlBranch.GetLov(userId).ToDictionary(i => i.value, i => i.label), Statuses = BlCode.LoadTable(userId, "Status"), Menu = new Menu { Status = true }, ActionMode = Enumerations.ActionMode.Add }; if (id != 0) { var menu = LoadSingle(userId, Convert.ToInt64(id)); toRet.Menu = menu; toRet.ActionMode = Enumerations.ActionMode.Edit; } return(toRet); }
public static QuickSearchPagedResult LoadSearch(long userId, string entity, string parameters, string searchTerm, int pageSize, int pageNum) { List <DdlVm.DdlOption> items = null; long count = 0; switch (entity) { //case "LOCATION": items = BlLocation.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; //case "LOCATIONEMPLOYEE": items = BlLocation.LoadLocationEmployeeQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; case "EMPLOYEE": items = BlEmployee.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; //case "PRODUCT": items = BlProduct.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; //case "SUPPLIER": items = BlSupplier.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; case "USER": items = BlUser.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; case "MODULE": items = BlModule.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; case "CODE": items = BlCode.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; //case "WAREHOUSE": items = BlWarehouse.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; //case "LOCATIONMORAL": items = BlLocationMoral.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; //case "STOCK": items = BlStock.LoadQs(userId, parameters, searchTerm, pageSize, pageNum, out count); break; } var toRet = new QuickSearchPagedResult { total = count }; if (items != null) { foreach (var item in items) { toRet.results.Add(new QuickSearchResult { id = item.value, text = item.label }); } } return(toRet); }
public GridResults LoadPaging(long userId, string search, int pageIndex, out long totalRecords, string sortColumnName = "", string sortOrderBy = "") { //Get current user var user = BlUser.LoadSingle(userId); //Query paged data var results = LoadPaging(userId, CreateFilter(search), user.PageSize, pageIndex - 1, out totalRecords); //Convert results into display model var res = (from r in results select new { r.Id, Language = BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "Language", r.LanguageId.ToUiString())), Parent = BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "DescriptionParent", r.Parent)), r.Code, r.Text }).ToList(); //Convert display model into json data return(GridVm.FormatResult(res, user.PageSize, pageIndex, totalRecords)); }
public ModuleVm Init(long userId, string id) { var toRet = new ModuleVm { Branches = BlBranch.GetLov(userId).ToDictionary(i => i.value, i => i.label), Statuses = BlCode.LoadTable(userId, "Status"), Module = new Module { Status = "A" }, ActionMode = Enumerations.ActionMode.Add }; if (id != "null") { var module = LoadSingle(userId, id); toRet.Module = module; //module.User.Roles = null; //module.Author.Roles = null; toRet.Signature = BlCommon.GetSignature(toRet.Module.UserId, toRet.Module.EntryDate); toRet.ActionMode = Enumerations.ActionMode.Edit; } return(toRet); }
public static int DefaultTimeOut() { return(Convert.ToInt32(BlCode.LoadSingle(Constants.SystemUser, "_System", "DefaultTimeOut").Value1)); }
public void Initiate(long userId) { //Make sure multilanguage directory exists var rootDirectory = Constants.GetAppRootDirectory(Constants.GetCallingAssemblyLocalPath()) + "io\\multiLanguage\\"; if (!Directory.Exists(rootDirectory)) { Directory.CreateDirectory(rootDirectory); } //Get system languages var languages = BlCode.LoadSingle(userId, "_System", "SystemLanguages").Value1.Split(','); //Loop over each language and create its resource files foreach (var language in languages) { var files = new Dictionary <string, Dictionary <string, string> >(); //Get language description var languageDesc = BlCode.LoadSingle(userId, "Language", language).Value1; //Get and make sure language directory exists var languageDirectory = rootDirectory + languageDesc + "\\"; if (!Directory.Exists(languageDirectory)) { Directory.CreateDirectory(languageDirectory); } //Load language descriptions var predicate = PredicateBuilder.True <Description>(); var localLanguage = language; predicate = predicate.And(e => e.LanguageId == Convert.ToInt16(localLanguage)); var blDescription = new BlDescription(); var descriptions = blDescription.LoadSearch(userId, predicate).ToList(); //Clear resource cache foreach (var resource in descriptions.Select(d => d.Parent).Distinct()) { CacheHelper.Clear(string.Format("{0}_{1}", languageDesc, resource)); } //Recreate the cache for server side uasge foreach (var description in descriptions) { if (description.Parent == "") { description.Parent = "language"; } if (!files.ContainsKey(description.Parent)) { files.Add(description.Parent, new Dictionary <string, string>()); } files[description.Parent].Add(description.Code, description.Text); CacheHelper.Add(string.Format("{0}_{1}_{2}", languageDesc, description.Parent, description.Code), description.Text); } //Recreate the json files for client side usage foreach (var file in files) { var ioFile = languageDirectory + file.Key + ".js"; if (!File.Exists(ioFile)) { File.Create(ioFile).Close(); } var json = JsonConvert.SerializeObject(file.Value); File.WriteAllText(ioFile, json); } } }