public async static Task<SYS_tblPermissionDRO> UpdatePermission(string url, string json_data) { SYS_tblPermissionDRO result = new SYS_tblPermissionDRO(); try { var response_data = await HttpPost(url, json_data); if (response_data.ToLower().StartsWith("error")) { result.ResponseItem.IsError = true; string[] tmp = response_data.Split('|'); result.ResponseItem.ErrorCode = tmp[1]; result.ResponseItem.ErrorMessage = tmp[2]; } else { var response_collection = JsonConvert.DeserializeObject<SYS_tblPermissionDRO>(response_data + ""); if (response_collection != null) { result.ResponseItem.Message = response_collection.ResponseItem.Message; } } } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<SYS_tblPermissionDRO> GetPermissionItem(string username, string language_id, string function_id) { SYS_tblPermissionDRO result = new SYS_tblPermissionDRO(); try { string url = string.Format("{0}/GetPermissionItem?Username={1}&LanguageID={2}&FunctionID={3}", GetBaseUrl(), username, language_id, function_id); result = await SYS_tblPermissionDAO.GetPermissionItem(url); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<SYS_tblPermissionDRO> GetPermissionList(string username, string language_id, string id, bool is_user) { SYS_tblPermissionDRO result = new SYS_tblPermissionDRO(); try { string url = string.Format("{0}/GetPermissionList?Username={1}&LanguageID={2}&ID={3}&IsUser={4}", GetBaseUrl(), username, language_id, id, is_user); result = await SYS_tblPermissionDAO.GetPermissionList(url); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
public async static Task<SYS_tblPermissionDRO> UpdatePermission(string username, string language_id, List<SYS_tblPermissionDTO> permissions, bool is_user, SYS_tblActionLogDTO actionLog) { SYS_tblPermissionDRO result = new SYS_tblPermissionDRO(); try { string url = string.Format("{0}/UpdatePermission", GetBaseUrl()); var json_data = "{\"Username\":\"" + username + "\",\"LanguageID\":\"" + language_id + "\",\"IsUser\":" + (is_user ? "true" : "false") + ",\"permissionList\":" + JsonConvert.SerializeObject(permissions, new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.MicrosoftDateFormat }) + "}"; result = await SYS_tblPermissionDAO.UpdatePermission(url, json_data); if (string.IsNullOrEmpty(result.ResponseItem.Message)) result.ResponseItem = await SYS_tblActionLogBUS.InsertUpdateLog(actionLog); } catch (Exception ex) { logger.Error(ex); result.ResponseItem.Message = ex.Message; } return result; }
private async Task SavePermission(TreeListNodes nodes, bool is_user) { List<SYS_tblPermissionDTO> permissionList = new List<SYS_tblPermissionDTO>(); try { CommonEngine.ShowWaitForm(this); SYS_tblPermissionDRO result = new SYS_tblPermissionDRO(); permissionList = GetAllPermission(nodes); foreach (var item in oldPermissionList) { var _item = (from per in permissionList where per.ID == item.ID && per.FunctionID == item.FunctionID select per).FirstOrDefault(); if (_item != null) { if (_item.AllowInsert == item.AllowInsert && _item.AllowUpdate == item.AllowUpdate && _item.AllowDelete == item.AllowDelete && _item.AllowPrint == item.AllowPrint && _item.AllowImport == item.AllowImport && _item.AllowExport == item.AllowExport && _item.AllowAll == item.AllowAll && _item.AllowAccess == item.AllowAccess && _item.UserLevelID == item.UserLevelID && _item.Note == item.Note) permissionList.Remove(_item); } } string strMessage = LanguageEngine.GetMessageCaption("000024", ConfigEngine.Language).Replace("$Type$", is_user ? (ConfigEngine.Language.Equals("vi") ? "người dùng" : "user") : (ConfigEngine.Language.Equals("vi") ? "nhóm người dùng" : "group user")).Replace("$Name$", trlUser.FocusedNode.GetDisplayText(tlcName)); result = await SYS_tblPermissionBUS.UpdatePermission(CommonEngine.userInfo.UserID, ConfigEngine.Language, permissionList, is_user, new SYS_tblActionLogDTO { Activity = BaseConstant.COMMAND_INSERT_EN, UserID = CommonEngine.userInfo.UserID, LanguageID = ConfigEngine.Language, ActionEN = BaseConstant.COMMAND_UPDATE_EN, ActionVN = BaseConstant.COMMAND_UPDATE_VI, FunctionID = "24", DescriptionVN = strMessage.Replace("$IsError$", "thành công"), DescriptionEN = strMessage.Replace("$IsError$", "successfully") }); CommonEngine.CloseWaitForm(); if (CommonEngine.CheckValidResponseItem(result.ResponseItem)) { if (string.IsNullOrEmpty(result.ResponseItem.Message)) CommonEngine.ShowMessage(strMessage.Replace("$IsError$", ConfigEngine.Language.Equals("vi") ? "thành công" : "successfully").Trim(), MessageType.Success); else CommonEngine.ShowMessage(strMessage.Replace("$IsError$", ConfigEngine.Language.Equals("vi") ? "thất bại" : "failed").Trim(), MessageType.Error); await LoadPermission(trlUser.FocusedNode.GetDisplayText(tlcCode) + "", rootNode, trlUser.FocusedNode.Level == 0 ? false : true); } else return; } catch (Exception ex) { CommonEngine.ShowExceptionMessage(ex); } }