public static string GetSignature(long userId, DateTime entryDate) { var user = BlUser.LoadSingle(userId); var label = BlDescription.GetDescription(Enumerations.DescriptionResources.Language, "lblSignature", user.LanguageId); return(string.Format(label, user.UserName, DateUtilities.FormatDateForDisplay(entryDate, true))); }
public static void InitiateService() { //Initiate and create all multilanguage files/directories for all languages var blDescription = new BlDescription(); blDescription.Initiate(Constants.SystemUser); //Make sure temp directory exists var tempDirectory = Constants.GetAppRootDirectory(Constants.GetCallingAssemblyLocalPath()) + "io\\temp\\"; if (!Directory.Exists(tempDirectory)) { Directory.CreateDirectory(tempDirectory); } //Clean temporary directory var di = new DirectoryInfo(tempDirectory); foreach (var file in di.GetFiles()) { file.Delete(); } foreach (var dir in di.GetDirectories()) { dir.Delete(true); } }
private static void PreSave(long userId, ref Xtra toSave, Enumerations.ActionMode action) { var user = BlUser.LoadSingle(userId); if (action == Enumerations.ActionMode.Add) { //Check if previously exists if (LoadSingle(userId, toSave.Object, toSave.Id, toSave.Property) != null) { throw new BusinessException("AlreadyExists1", BlDescription.GetDescription(Enumerations.DescriptionResources.Language, "lblProperty", user.LanguageId)); } } }
private static string BuildMenuItem(User user, Menu menuItem, bool forEdit) { if (forEdit) { return(string.Format("<input type='radio' name='chkMenu' id='chkMenu' value='{0}'/>{1}", menuItem.Id, BlDescription.GetDescription(Enumerations.DescriptionResources.Language, menuItem.DescriptionCode, user.LanguageId, true))); } if (menuItem.Module == null && menuItem.Parent == null) { return(string.Format("<a href='#' {1}>{0} <span class='caret'></a>", BlDescription.GetDescription(Enumerations.DescriptionResources.Language, menuItem.DescriptionCode, user.LanguageId, true), menuItem.Details)); } if (menuItem.Module == null) { return(string.Format("<a href='#' {1}>{0} </a>", BlDescription.GetDescription(Enumerations.DescriptionResources.Language, menuItem.DescriptionCode, user.LanguageId, true), menuItem.Details)); } return(string.Format("<a href='../{1}' target='content'>{2}</a>", Constants.GetWebAppRootUrl(), CheckEmpty.String(menuItem.Module.Path) + "?ts=" + DateUtilities.GetDateStamp(BlCommon.GetServerDateTime(), true), BlDescription.GetDescription(Enumerations.DescriptionResources.Language, menuItem.DescriptionCode, user.LanguageId, true))); }
public static void HandleError(long userId, ref BusinessException ex, MethodBase method, bool rethrow = true) { var message = BlDescription.GetDescription(Enumerations.DescriptionResources.Exceptions, ex.ExceptionCode); if (ex.ExtraVariables != null) { foreach (var variable in ex.ExtraVariables.Split('_')) { message = message.Replace("{" + ex.ExtraVariables.Split('_').ToList().IndexOf(variable) + "}", BlDescription.GetDescription(Enumerations.DescriptionResources.Language, variable)); } } var exception = (Exception)ex; LogError(GetExceptionSource(ref method, ref exception), message, ex.Type, ex.Severity, userId); if (rethrow) { throw ex; } }
public static void Log(long userId, string moduleId, string action, string text, object[] args = null) { //Leave if module logging not enabled var module = BlModule.LoadSingle(userId, moduleId); if (module != null) { if (!module.EnableLogging) { return; } } var log = new Log { Module = module, Action = action, Text = BlDescription.GetDescription(Enumerations.DescriptionResources.Exceptions, text, 1, true) ?? text }; if (args != null) { try { log.Text = string.Format(log.Text, args); } catch (Exception) { // ignored } } var blLog = new BlLog(); blLog.Create(userId, log); }
private static IEnumerable <TreeItemVm> ConstructTreeNode(long userId, IEnumerable <Role> roles, bool allowView, bool allowAdd, bool allowEdit, bool allowDelete) { var user = BlUser.LoadSingle(userId); var toRet = new List <TreeItemVm>(); foreach (var role in roles) { TreeItemVm treeNode; var actions = "</span>"; actions += "<span id='actions_" + role.Id + "' style='display:none'> "; if (allowView) { actions += "<a class='treeAction' onclick='javascript:ViewAction(" + role.Id + ");'><span>" + BlDescription.GetDescription(Enumerations.DescriptionResources.Language, "lblView", user.LanguageId) + "</span></a> "; } if (allowAdd) { actions += "<a class='treeAction' onclick='javascript:AddAction(" + role.Id + ");'><span>" + BlDescription.GetDescription(Enumerations.DescriptionResources.Language, "lblAdd", user.LanguageId) + "</span></a> "; } if (allowEdit) { actions += "<a class='treeAction' onclick='javascript:EditAction(" + role.Id + ");'><span>" + BlDescription.GetDescription(Enumerations.DescriptionResources.Language, "lblEdit", user.LanguageId) + "</span></a> "; } if (allowDelete) { actions += "<a class='treeAction' onclick='javascript:DeleteAction(" + role.Id + ");'><span>" + BlDescription.GetDescription(Enumerations.DescriptionResources.Language, "lblDelete", user.LanguageId) + "</span></a> "; } actions += "<span>"; if (role.Id == 0) { treeNode = new TreeItemVm { id = "0", parent = "#", text = "<span onclick='ShowDetails(0);'>Root" + actions + "</span>", icon = "fa fa-briefcase fa-lg colorMain", state = "{\"opened\": \"true\"}", li_attr = "{\"class\" : \"form-control-label\"}" }; } else { treeNode = new TreeItemVm { id = role.Id.ToUiString(), parent = role.ParentRole == null ? "0" : role.ParentRole.Id.ToUiString(), text = "<span onclick='ShowDetails(" + role.Id + ");'>" + role.Code + actions + "</span>", icon = "fa fa-users fa-lg colorMain", li_attr = "{\"class\" : \"form-control-label\"}" }; } toRet.Add(treeNode); } return(toRet); }