public void SaveProcessedTradeInfo(DataTable dataTable, string tableName)
 {
     try
     {
         _dbConnection.ConnectDatabase();
         _dbConnection.BulkCopy(dataTable, tableName);
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _dbConnection.CloseDatabase();
     }
 }
예제 #2
0
 public void SaveProcessedBonusRightShare(DataTable bonusRightDataTable, string tableName)
 {
     try
     {
         _dbConnection.ConnectDatabase();
         _dbConnection.BulkCopy(bonusRightDataTable, tableName);
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _dbConnection.CloseDatabase();
     }
 }
예제 #3
0
        //Bulk Save

        public void Save_ToTemp(DataTable dt, string tableName)
        {
            try
            {
                _dbConnection.ConnectDatabase();
                _dbConnection.BulkCopy(dt, tableName);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                _dbConnection.CloseDatabase();
            }
        }
 public void SaveProcessedStockSplit(DataTable stockSplitDataTable, string tableName)
 {
     try
     {
         _dbConnection.ConnectDatabase();
         _dbConnection.BulkCopy(stockSplitDataTable, tableName);
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _dbConnection.CloseDatabase();
     }
 }
 public void InsertDataGeneratePLTP(DataTable dataTable)
 {
     string queryString = @"EXECUTE GeneratePLTP;";
     try
     {
         _dbConnection.ConnectDatabase();
         _dbConnection.ExecuteNonQuery(queryString);
         _dbConnection.BulkCopy(dataTable, "SBP_LTP");
     }
     catch (Exception exception)
     {
         throw exception;
     }
     finally
     {
         _dbConnection.CloseDatabase();
     }
 }
예제 #6
0
        public void SetupData()
        {
            SetupPeople();
            var personFaker    = PersonFaker();
            var leaveRequester = personFaker.Generate();

            DbConnection.Insert(leaveRequester);
            var leaveRequesterOrgGroup = AutoFaker.Generate <OrgGroup>();

            leaveRequesterOrgGroup.Id = leaveRequester.Staff.OrgGroupId ??
                                        (Guid)(leaveRequester.Staff.OrgGroupId = Guid.NewGuid());
            DbConnection.Insert(leaveRequesterOrgGroup);
            DbConnection.Insert(leaveRequester.Staff);

            var leaveApprover = personFaker.Generate();

            DbConnection.Insert(leaveApprover);
            DbConnection.Insert(leaveApprover.Staff);
            var leaveRequest = AutoFaker.Generate <LeaveRequest>();

            leaveRequest.PersonId     = leaveRequester.Id;
            leaveRequest.ApprovedById = leaveApprover.Id;
            DbConnection.Insert(leaveRequest);

            var personWithRole = personFaker.Generate();

            DbConnection.Insert(personWithRole);
            DbConnection.Insert(personWithRole.Staff);
            var personRoleFaker = new AutoFaker <PersonRole>().RuleFor(role => role.PersonId, personWithRole.Id);
            var personRoles     = personRoleFaker.Generate(5);

            personRoles[0].Active = true; //always have at least one active
            DbConnection.BulkCopy(personRoles);
            var grade = AutoFaker.Generate <Grade>();

            DbConnection.Insert(grade);
            var jobs = personRoles.Select(role => JobFaker()
                                          .RuleFor(job => job.Id, role.JobId)
                                          .RuleFor(job => job.GradeId, grade.Id)
                                          .Generate()).ToList();
            var evaluation = AutoFaker.Generate <Evaluation>();

            evaluation.PersonId  = personWithRole.Id;
            evaluation.Evaluator = leaveApprover.Id;
            evaluation.RoleId    = personRoles[0].Id;
            DbConnection.Insert(evaluation);

            DbConnection.BulkCopy <Job>(jobs);
            DbConnection.BulkCopy(jobs.Select(job => job.OrgGroup));
            SetupTraining();
            InsertUser();

            var personWithEmergencyContact = personFaker.Generate("default,notStaff");

            DbConnection.Insert(personWithEmergencyContact);
            var contactPerson = personFaker.Generate("default,notStaff");

            DbConnection.Insert(contactPerson);
            var emergencyContact = AutoFaker.Generate <EmergencyContact>();

            emergencyContact.ContactId = contactPerson.Id;
            emergencyContact.PersonId  = personWithEmergencyContact.Id;
            DbConnection.Insert(emergencyContact);

            DbConnection.Insert(new Attachment
            {
                AttachedToId = Guid.NewGuid(),
                DownloadUrl  = "someurl.com",
                FileType     = "picture",
                GoogleId     = "someRandomId123",
                Id           = Guid.NewGuid(),
                Name         = "hello attachments"
            });

            DbConnection.Insert(AutoFaker.Generate <Grade>());
            DbConnection.Insert(AutoFaker.Generate <MissionOrg>());
            DbConnection.Insert(AutoFaker.Generate <Holiday>());
            DbConnection.Insert(AutoFaker.Generate <IdentityRoleClaim <int> >());
            DbConnection.Insert(AutoFaker.Generate <IdentityUserClaim <int> >());
            DbConnection.Insert(AutoFaker.Generate <IdentityUserLogin <int> >());
            DbConnection.Insert(AutoFaker.Generate <IdentityUserRole <int> >());
            DbConnection.Insert(AutoFaker.Generate <IdentityUserToken <int> >());
        }
예제 #7
0
        public void SetupPeople()
        {
            if (Jacob != null)
            {
                return;
            }
            var faker = PersonFaker();

            Jacob                     = faker.Generate();
            Jacob.FirstName           = "Jacob";
            JacobSupervisor           = faker.Generate();
            JacobSupervisor.FirstName = "Bob";
            var jacobWife = faker.Generate();

            jacobWife.SpouseId = Jacob.Id;
            Jacob.SpouseId     = jacobWife.Id;

            var jacobDonor = AutoFaker.Generate <Donor>();

            Jacob.DonorId = jacobDonor.Id;

            Assert.Empty(DbConnection.People);
            DbConnection.Insert(Jacob);
            DbConnection.Insert(jacobWife);
            DbConnection.Insert(JacobSupervisor);
            DbConnection.BulkCopy(faker.Generate(5));
            DbConnection.Insert(Jacob.Staff);
            DbConnection.Insert(JacobSupervisor.Staff);
            DbConnection.Insert(jacobDonor);
            InsertUser("jacob", Jacob.Id, new[] { "admin" });

            var jacobParentGroup = AutoFaker.Generate <OrgGroup>();

            jacobParentGroup.Id                   = Guid.NewGuid();
            jacobParentGroup.Supervisor           = InsertPerson().Id;
            jacobParentGroup.ApproverIsSupervisor = true;
            DbConnection.Insert(jacobParentGroup);

            var jacobGroup = AutoFaker.Generate <OrgGroup>();

            jacobGroup.Id                   = Jacob.Staff.OrgGroupId ?? Guid.Empty;
            jacobGroup.ParentId             = jacobParentGroup.Id;
            jacobGroup.Supervisor           = JacobSupervisor.Id;
            jacobGroup.ApproverIsSupervisor = true;
            DbConnection.Insert(jacobGroup);


            var jacobMissionOrg = AutoFaker.Generate <MissionOrg>();

            jacobMissionOrg.Id = Jacob.Staff.MissionOrgId ?? Guid.Empty;
            DbConnection.Insert(jacobMissionOrg);
            var jacobMissionOrgYear = AutoFaker.Generate <MissionOrgYearSummary>();

            jacobMissionOrgYear.MissionOrgId = jacobMissionOrg.Id;
            DbConnection.Insert(jacobMissionOrgYear);

            var jacobDonation = AutoFaker.Generate <Donation>();

            jacobDonation.PersonId     = Jacob.Id;
            jacobDonation.MissionOrgId = jacobMissionOrg.Id;
            DbConnection.Insert(jacobDonation);
            var jacobJob = InsertJob(job =>
            {
                job.OrgGroup   = null;
                job.OrgGroupId = jacobGroup.Id;
            });

            InsertRole(role =>
            {
                role.PersonId = Jacob.Id;
                role.JobId    = jacobJob.Id;
            });

            //endorsments
            var endorsement = AutoFaker.Generate <Endorsement>();

            DbConnection.Insert(endorsement);
            var jacobEndorsement = AutoFaker.Generate <StaffEndorsement>();

            jacobEndorsement.EndorsementId = endorsement.Id;
            jacobEndorsement.PersonId      = Jacob.Id;
            DbConnection.Insert(jacobEndorsement);
            var requiredEndorsement = AutoFaker.Generate <RequiredEndorsement>();

            requiredEndorsement.EndorsementId = endorsement.Id;
            requiredEndorsement.JobId         = jacobJob.Id;
            DbConnection.Insert(requiredEndorsement);

            var education = AutoFaker.Generate <Education>();

            education.PersonId = Jacob.Id;
            DbConnection.Insert(education);
        }