/// <summary> /// Removes operations. /// Returns a string that is a JSON object representing execution result. /// </summary> /// <param name="recordIds">Array of operations identity</param> /// <returns>JSON-format string. /// Includes serialized object whith fields: /// Success - the method is successfully executed., /// ExMessage - string with error, if Success = false </returns> public string DeleteAdminOperation(Guid[] recordIds) { bool success = false; string exMessage = string.Empty; try { DBSecurityEngine engine = _userConnection.DBSecurityEngine; engine.CheckCanChangeAdminOperationGrantee(); EntitySchema adminOperationTableSchema = _userConnection.EntitySchemaManager.GetInstanceByName("SysAdminOperation"); Entity adminOperationEntity = adminOperationTableSchema.CreateEntity(_userConnection); foreach (var recordId in recordIds) { if (adminOperationEntity.FetchFromDB("Id", recordId)) { adminOperationEntity.Delete(); } } success = true; } catch (Exception ex) { if (ex is SecurityException) { exMessage = ex.Message; } else { exMessage = new LocalizableString(_userConnection.ResourceStorage, "RightsHelper", "LocalizableStrings.NonSecurityExeption.Value"); } } return(JsonConvert.SerializeObject(new { Success = success, ExMessage = exMessage })); }
/// <summary> /// #########, ### ######## ############, /// ########### ######### #### ####### # ########. /// ########## ###### # ####### JSON, # ########### ##########. /// </summary> /// <returns>C##### # ####### JSON. /// ######## ############### ###### # ######: /// Success - ########## ########## ######, /// ExMessage - ##### ######, #### Success = false </returns> public string CheckCanChangeAdminOperationGrantee() { bool success = false; string exMessage = String.Empty; try { DBSecurityEngine engine = _userConnection.DBSecurityEngine; engine.CheckCanChangeAdminOperationGrantee(); success = true; } catch (Exception ex) { if (ex is SecurityException) { exMessage = ex.Message; } else { exMessage = new LocalizableString(_userConnection.ResourceStorage, "RightsHelper", "LocalizableStrings.NonSecurityExeption.Value"); } } return(JsonConvert.SerializeObject(new { Success = success, ExMessage = exMessage })); }
/// <summary> /// Updates or inserts operation. /// </summary> /// <param name="recordId">Operation Id</param> /// <param name="name">Operation name</param> /// <param name="code">Operation code</param> /// <param name="description">Operation description</param> /// <returns>JSON-format string. /// Includes serialized object whith fields: /// Success - the method is successfully executed., /// ExMessage - string with error, if Success = false </returns> public string UpsertAdminOperation(Guid recordId, String name, String code, String description) { bool success = false; string exMessage = string.Empty; try { DBSecurityEngine engine = _userConnection.DBSecurityEngine; engine.CheckCanChangeAdminOperationGrantee(); EntitySchema adminOperationTableSchema = _userConnection.EntitySchemaManager.GetInstanceByName("SysAdminOperation"); Entity adminOperationEntity = adminOperationTableSchema.CreateEntity(_userConnection); if (!adminOperationEntity.FetchFromDB(recordId)) { adminOperationEntity.SetDefColumnValues(); } adminOperationEntity.SetColumnValue("Id", recordId); adminOperationEntity.SetColumnValue("Name", name); adminOperationEntity.SetColumnValue("Code", code); adminOperationEntity.SetColumnValue("Description", description); adminOperationEntity.Save(); success = true; } catch (Exception ex) { if (ex is SecurityException) { exMessage = ex.Message; } else { exMessage = new LocalizableString(_userConnection.ResourceStorage, "RightsHelper", "LocalizableStrings.NonSecurityExeption.Value"); } } return(JsonConvert.SerializeObject(new { Success = success, ExMessage = exMessage })); }