예제 #1
0
        private void cbbSheet_SelectedIndexChanged1(object sender, EventArgs e)
        {
            DataTable dt = tableCollection[cbbSheet.SelectedItem.ToString()];

            //dgv_NguoiDung.DataSource = dt;
            if (dt != null)
            {
                List <ImportUser> uSERs = new List <ImportUser>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ImportUser uSER = new ImportUser();
                    uSER.f_HoTen       = dt.Rows[i]["f_HoTen"].ToString();
                    uSER.f_Email       = dt.Rows[i]["f_Email"].ToString();
                    uSER.f_NgaySinh    = dt.Rows[i]["f_NgaySinh"].ToString();
                    uSER.f_GioiTinh    = dt.Rows[i]["f_GioiTinh"].ToString();
                    uSER.f_Phone       = dt.Rows[i]["f_Phone"].ToString();
                    uSER.f_MaSo        = dt.Rows[i]["f_MaSo"].ToString();
                    uSER.f_TenDangNhap = dt.Rows[i]["f_TenDangNhap"].ToString();
                    uSER.f_MatKhau     = dt.Rows[i]["f_MatKhau"].ToString();
                    uSER.f_IDPhanQuyen = dt.Rows[i]["f_IDPhanQuyen"].ToString();
                    uSERs.Add(uSER);
                }
                importUserBindingSource.DataSource = uSERs;
            }
        }
        public ActionResult Create()
        {
            // Obtain your OAuth token
            var accessToken    = RequestItemsService.User.AccessToken;
            var basePath       = RequestItemsService.Session.AdminApiBasePath;
            var accountId      = RequestItemsService.Session.AccountId;
            var organizationId = RequestItemsService.OrganizationId;

            try
            {
                // Call the Admin API to create a new user
                OrganizationImportResponse organizationImportResponse = ImportUser.CreateBulkImportRequest(
                    accessToken, basePath, accountId, organizationId, Config.docCsv);

                //Show results
                ViewBag.h1                 = "Add users via bulk import";
                ViewBag.message            = "Results from UserImport:addBulkUserImport method:";
                ViewBag.Locals.Json        = JsonConvert.SerializeObject(organizationImportResponse, Formatting.Indented);
                ViewBag.AdditionalLinkText = "Check the request status";
                ViewBag.AdditionalLink     = "CheckStatus?id=" + organizationImportResponse.Id;

                return(View("example_done"));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }
예제 #3
0
        private void MBtnImportUser_Click(object sender, EventArgs e)
        {
            if (!rqImportData.IsValid)
            {
                rqImportData.ControlToValidate.Focus();

                return;
            }

            try
            {
                Path = mTxtImportPath.Text;
                ImportUser?.Invoke(this, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi nhập dữ liệu: " + ex.Message);
            }
        }
예제 #4
0
        public async Task <ImportUserResponse> Any(ImportUser request)
        {
            if (string.IsNullOrEmpty(request.Email) && string.IsNullOrEmpty(request.UserName))
            {
                throw new ArgumentNullException(nameof(request.Email));
            }

            if (string.IsNullOrEmpty(request.RefSource))
            {
                throw new ArgumentNullException(nameof(request.RefSource));
            }

            if (string.IsNullOrEmpty(request.RefIdStr) && request.RefId == null)
            {
                throw new ArgumentNullException(nameof(request.RefId));
            }

            var existingUser =
                (string.IsNullOrEmpty(request.Email) ? null : AuthRepository.GetUserAuthByUserName(request.Email))
                ?? (string.IsNullOrEmpty(request.UserName) ? null : AuthRepository.GetUserAuthByUserName(request.UserName));

            if (existingUser != null)
            {
                throw HttpError.Conflict("Email and UserName must be unique");
            }

            var session = SessionAs <CustomUserSession>();

            var user = request.ConvertTo <CustomUserAuth>();

            user.CreatedDate = user.ModifiedDate = DateTime.Now;
            user.CreatedBy   = session.UserName;

            var userId = (int)await Db.InsertAsync(user, selectIdentity : true);

            return(new ImportUserResponse {
                Id = userId
            });
        }
        public ActionResult CheckStatus(string id)
        {
            try
            {
                // Obtain your OAuth token
                var accessToken    = RequestItemsService.User.AccessToken;
                var basePath       = RequestItemsService.Session.AdminApiBasePath;
                var organizationId = RequestItemsService.OrganizationId;
                OrganizationImportResponse organizationImportResponse = ImportUser.CheckkStatus(accessToken, basePath, organizationId, Guid.Parse(id));

                //Show results
                ViewBag.h1          = "Check status of users bulk import";
                ViewBag.message     = "Results from UserImport:getBulkUserImportRequest method:";
                ViewBag.Locals.Json = JsonConvert.SerializeObject(organizationImportResponse, Formatting.Indented);
                return(View("example_done"));
            }
            catch (ApiException apiException)
            {
                ViewBag.errorCode    = apiException.ErrorCode;
                ViewBag.errorMessage = apiException.Message;

                return(View("Error"));
            }
        }
예제 #6
0
        private void btnUserImport_Click(object sender, EventArgs e)
        {
            ImportUser iu = new ImportUser();

            iu.Show();
        }