Example #1
0
        public async static Task<SYS_tblGroupUserDRO> InsertUpdateGroupUser(SYS_tblGroupUserDTO item, SYS_tblActionLogDTO actionLog)
        {
            SYS_tblGroupUserDRO result = new SYS_tblGroupUserDRO();
            try
            {
                string url = string.Format(@"{0}/InsertUpdateGroupUser", GetBaseUrl());
                var postData = new SYS_tblGroupUserDCO
                {
                    GroupID = string.IsNullOrEmpty(item.GroupID) ? "0" : item.GroupID,
                    GroupCode = item.GroupCode,
                    VNName = item.VNName,
                    ENName = item.ENName,
                    Note = item.Note,
                    IsDefault = item.IsDefault,
                    Active = item.Active,
                    Activity = item.Activity,
                    UserID = item.UserID,
                    LanguageID = item.LanguageID
                };
                var json_data = "{\"groupUser\":" + JsonConvert.SerializeObject(postData, new JsonSerializerSettings
                {
                    DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
                }) + "}";

                result = await SYS_tblGroupUserDAO.InsertUpdateGroupUser(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;
        }
Example #2
0
        public async static Task<SYS_tblGroupUserDRO> InsertUpdateGroupUser(string url, string json_data)
        {
            SYS_tblGroupUserDRO result = new SYS_tblGroupUserDRO();
            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_tblGroupUserDRO>(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;
        }
Example #3
0
        public async static Task<SYS_tblGroupUserDRO> GetGroupUserItem(string username, string language, string group_user_id)
        {
            SYS_tblGroupUserDRO result = new SYS_tblGroupUserDRO();
            try
            {
                string url = string.Format(@"{0}/GetGroupUserByID?Username={1}&LanguageID={2}&GroupID={3}", GetBaseUrl(), username, language, group_user_id);

                result = await SYS_tblGroupUserDAO.GetGroupUserItem(url);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                result.ResponseItem.Message = ex.Message;
            }

            return result;
        }
Example #4
0
        public async static Task<SYS_tblGroupUserDRO> GetAllGroupUsers(string username, string language, bool is_combobox, SYS_tblActionLogDTO actionLog)
        {
            SYS_tblGroupUserDRO result = new SYS_tblGroupUserDRO();
            try
            {
                string url = string.Format("{0}/GetAllGroupUsers?Username={1}&LanguageID={2}&GetComboBox={3}", GetBaseUrl(), username, language, is_combobox ? "True" : "False");

                result = await SYS_tblGroupUserDAO.GetAllGroupUsers(url);
                if (string.IsNullOrEmpty(result.ResponseItem.Message))
                    if (actionLog != null) result.ResponseItem = await SYS_tblActionLogBUS.InsertUpdateLog(actionLog);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                result.ResponseItem.Message = ex.Message;
            }

            return result;
        }
Example #5
0
        public async static Task<SYS_tblGroupUserDRO> DeleteGroupUser(string group_id_list, string group_code_list, string username, string language, SYS_tblActionLogDTO actionLog)
        {
            SYS_tblGroupUserDRO result = new SYS_tblGroupUserDRO();
            try
            {
                string url = string.Format(@"{0}/DeleteGroupUser?Username={1}&LanguageID={2}&GroupUserIDList={3}&GroupUserCodeList={4}", GetBaseUrl(), username, language, group_id_list, group_code_list);

                result = await SYS_tblGroupUserDAO.DeleteGroupUser(url);
                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;
        }
Example #6
0
        private async Task DeleteGroupUser()
        {
            group_code_list = "";
            group_id_list = "";
            foreach (int index in grvGroupUser.GetSelectedRows())
            {
                group_code_list = string.Join("$", group_code_list, grvGroupUser.GetRowCellDisplayText(index, gcolGroupCode));
                group_id_list = string.Join("$", group_id_list, grvGroupUser.GetRowCellDisplayText(index, gcolGroupID));
            }

            if (group_code_list.Length > 0) group_code_list = group_code_list.Substring(1);
            if (group_id_list.Length > 0) group_id_list = group_id_list.Substring(1);

            SYS_tblGroupUserDRO result = new SYS_tblGroupUserDRO();
            result.ResponseItem.Message = "ready";
            if (!string.IsNullOrEmpty(group_id_list))
            {
                try
                {
                    if (group_id_list.Contains("$"))
                    {
                        if (CommonEngine.ShowConfirmMessageAlert(LanguageEngine.GetMessageCaption("000012", ConfigEngine.Language).Replace("$Count$", group_id_list.Split('$').Length.ToString())))
                        {
                            CommonEngine.ShowWaitForm(this);
                            result = await SYS_tblGroupUserBUS.DeleteGroupUser(group_id_list, group_code_list, CommonEngine.userInfo.UserID, ConfigEngine.Language, new SYS_tblActionLogDTO
                            {
                                Activity = BaseConstant.COMMAND_INSERT_EN,
                                UserID = CommonEngine.userInfo.UserID,
                                LanguageID = ConfigEngine.Language,
                                ActionEN = BaseConstant.COMMAND_DELETE_LIST_EN,
                                ActionVN = BaseConstant.COMMAND_DELETE_LIST_VI,
                                FunctionID = "9",
                                DescriptionVN = string.Format("Tài khoản '{0}' vừa xóa thành công nhóm người dùng có mã '{1}'.", CommonEngine.userInfo.UserID, group_code_list.Replace("$", ", ")),
                                DescriptionEN = string.Format("Account '{0}' has deleted group user successfully with group code are '{1}'.", CommonEngine.userInfo.UserID, group_code_list.Replace("$", ", "))
                            });
                        }
                    }
                    else
                    {
                        if (CommonEngine.ShowConfirmMessageAlert(LanguageEngine.GetMessageCaption("000005", ConfigEngine.Language)))
                        {
                            CommonEngine.ShowWaitForm(this);
                            result = await SYS_tblGroupUserBUS.DeleteGroupUser(group_id_list, group_code_list, CommonEngine.userInfo.UserID, ConfigEngine.Language, new SYS_tblActionLogDTO
                            {
                                Activity = BaseConstant.COMMAND_DELETE_EN,
                                UserID = CommonEngine.userInfo.UserID,
                                LanguageID = ConfigEngine.Language,
                                ActionEN = BaseConstant.COMMAND_DELETE_EN,
                                ActionVN = BaseConstant.COMMAND_DELETE_VI,
                                FunctionID = "9",
                                DescriptionVN = string.Format("Tài khoản '{0}' vừa xóa thành công nhóm người dùng có mã '{1}'.", CommonEngine.userInfo.UserID, group_code_list),
                                DescriptionEN = string.Format("Account '{0}' has deleted group user successfully with group code is '{1}'.", CommonEngine.userInfo.UserID, group_code_list)
                            });
                        }
                    }

                    if (!CommonEngine.CheckValidResponseItem(result.ResponseItem)) return;
                    if (!result.ResponseItem.Message.Equals("ready"))
                        if (string.IsNullOrEmpty(result.ResponseItem.Message)) await GetAllGroupUsers();
                        else CommonEngine.ShowMessage(result.ResponseItem.Message, IMC.Helper.MessageType.Error);
                }
                catch (Exception ex)
                {
                    CommonEngine.ShowExceptionMessage(ex);
                }
                finally
                {
                    CommonEngine.CloseWaitForm();
                }
            }
            else CommonEngine.ShowMessage("000027", IMC.Helper.MessageType.Warning, true);
        }