public DataSet SelectWorkPackageTest(IWorkPackage workPackage) { DataSet tableVerify = new DataSet(); tableVerify = dbEntity.SelectObject(workPackage) as DataSet; return(tableVerify); }
/// <summary> /// Initializes a new instance of the <see cref="PassiveWorker"/> class. /// </summary> /// <param name="workPackage">The work package.</param> /// <param name="referenceRepositoryContainer">The reference repository container.</param> public PassiveWorker( IWorkPackage workPackage, IWorkerRepositoryContainer workerRepositoryContainer) : base(workPackage) { Guard.AgainstNull(() => workerRepositoryContainer); _workerRepositoryContainer = workerRepositoryContainer; _serviceId = Guid.NewGuid(); }
public void VerifyWorkPackage() { Random random = new Random(); IWorkPackage workPackage = BusinessObjectInitializer.CreateWorkPackage(); workPackage.IdProject = random.Next(1, 2); workPackage.IdPhase = random.Next(1, 9); workPackage.Code = DATestUtils.GenerateString(3, true, true); workPackage.Name = DATestUtils.GenerateString(30, true, false); workPackage.Rank = random.Next(1, 100); workPackage.IsActive = true; workPackage.StartYearMonth = DATestUtils.DEFAULT_YEAR_MONTH; workPackage.EndYearMonth = DATestUtils.DEFAULT_YEAR_MONTH; workPackage.LastUpdate = DateTime.Today; workPackage.IdLastUserUpdate = DATestUtils.DEFAULT_ASSOCIATE; int newId = InsertWorkPackageTest(workPackage); Assert.Greater(newId, 0); int rowsAffected = UpdateWorkPackageTest(workPackage); Assert.AreEqual(1, rowsAffected); DataTable resultTable = SelectWorkPackageTest(workPackage).Tables[0]; //Verifies that the table contains the correct column names and order StringCollection columns = new StringCollection(); columns.AddRange(new string[] { "ProjectPhase", "ProjectCode", "Code", "Name", "Rank", "IsActive", "StartYearMonth", "EndYearMonth", "LastUpdate", "LastUserUpdate", "IsProgramManager", "ProjectName", "IdLastUserUpdate", "Id", "IdPhase", "IdProject", "IdProjectFunction" }); DATestUtils.CheckTableStructure(resultTable, columns); int rowCount = DeleteWorkPackageTest(workPackage); Assert.AreEqual(1, rowCount); }
/// <summary> /// Initializes a new instance of the <see cref="DelayedWorker"/> class. /// </summary> /// <param name="workPackage">The work package.</param> /// <param name="dependencyFactory">The dependency factory.</param> /// <param name="referenceRepositoryContainer">The reference repository container.</param> public DelayedWorker( IWorkPackage workPackage, IDependencyFactory dependencyFactory, IWorkerRepositoryContainer workerRepositoryContainer) : base(workPackage, workerRepositoryContainer) { Guard.AgainstNull(() => workPackage); Guard.AgainstNull(() => dependencyFactory); _dependencyFactory = dependencyFactory; }
internal void Enqueue(IWorkPackage work) { //foreach (var query in queries) // workerQueue.Enqueue(query); workerQueue.Enqueue(work); isWorking = true; if (runningWorkers == 0) { StartWorker(); } }
/// <summary> /// Initializes a new instance of the <see cref="BaseWorker"/> class. /// </summary> /// <param name="workPackage">The work package.</param> /// <exception cref="WorkManagerException"></exception> public BaseWorker(IWorkPackage workPackage) : base(workPackage.NameInstance) { try { WorkPackage = workPackage; Name = WorkPackage.NameInstance; Notification = WorkPackage.WorkManager.Notification; _restartAbortedThread = false; _abortThreadOnUnhandledException = WorkPackage.Parameters("abortThreadOnUnhandledException", "false") == "true"; _restartNonResponsive = WorkPackage.Parameters("restartNonResponsive", "false") == "true"; _workSleep = int.Parse(WorkPackage.Parameters("workSleep", "60000")); _threadWatcherInfo = new ThreadWatcherInfo(this, int.Parse(WorkPackage.Parameters("aliveResponseWindow", "0"))); OnInitialize(); } catch (Exception ex) { var eMsg = string.Format("Initialize failed: An unhandled exception was detected in Thread '{0} -> {1}'.", Name, ex.Message); throw new WorkManagerException(eMsg, ex); } }
public override void SetAdditionalProperties(IGenericEntity entity) { try { IWorkPackage workPackage = (IWorkPackage)entity; //read from session the needed values CurrentUser currentUser = (CurrentUser)SessionManager.GetSessionValueNoRedirect((IndBasePage)this.Page, SessionStrings.CURRENT_USER); ApplicationSettings appSettings = (ApplicationSettings)SessionManager.GetSessionValueNoRedirect((IndBasePage)this.Page, SessionStrings.APPLICATION_SETTINGS); CurrentProject currentProject = (CurrentProject)SessionManager.GetSessionValueRedirect((IndPopUpBasePage)this.Page, SessionStrings.CURRENT_PROJECT); base.SetViewEntityProperties(entity); workPackage.IdLastUserUpdate = currentUser.IdAssociate; workPackage.LastUserUpdate = currentUser.AssociateName; if (currentProject != null) //if it is null we will be redirected after this method finishes { workPackage.IdProject = currentProject.Id; } if (this.WP.EditMode == true) { workPackage.IdAssociate = currentUser.IdAssociate; } workPackage.SetSettings(appSettings); } catch (IndException ex) { ReportControlError(ex); return; } catch (Exception ex) { ReportControlError(new IndException(ex)); return; } }
public int DeleteWorkPackageTest(IWorkPackage workPackage) { int rowCount = dbEntity.DeleteObject(workPackage); return(rowCount); }
public int InsertWorkPackageTest(IWorkPackage workPackage) { workPackage.Id = dbEntity.InsertObject(workPackage); return(workPackage.Id); }
public void VerifyInitialBudget() { IInitialBudget initialBudget = BusinessObjectInitializer.CreateInitialBudget(); ICostCenter costCenter = BusinessObjectInitializer.CreateCostCenter(); IWorkPackage workPackage = BusinessObjectInitializer.CreateWorkPackage(); IProject project = BusinessObjectInitializer.CreateProject(); IProjectCoreTeamMember coreTeamMembers = BusinessObjectInitializer.CreateProjectCoreTeamMember(); DBInitialBudget dbInitialBudget = new DBInitialBudget(connManager); DBGenericEntity dbCostCenterEntity = new DBCostCenter(connManager); DBGenericEntity dbWorkPackageEntity = new DBWorkPackage(connManager); DBGenericEntity dbProjectEntity = new DBProject(connManager); DBProjectCoreTeamMember dbCoreteamMember = new DBProjectCoreTeamMember(connManager); Random random = new Random(); initialBudget.IdAssociate = DATestUtils.DEFAULT_ASSOCIATE; initialBudget.IdPhase = random.Next(1, 9); costCenter.Id = random.Next(1000, 2000); costCenter.Name = DATestUtils.GenerateString(50, true, false); costCenter.Code = DATestUtils.GenerateString(10, true, true); costCenter.IdDepartment = random.Next(1, 1); costCenter.IdInergyLocation = random.Next(1, 2); costCenter.IsActive = true; workPackage.IdPhase = initialBudget.IdPhase; workPackage.Code = DATestUtils.GenerateString(3, true, true); workPackage.Name = DATestUtils.GenerateString(30, true, false); workPackage.Rank = random.Next(1, 100); workPackage.IsActive = true; workPackage.StartYearMonth = random.Next(2000, 2079) * 100 + random.Next(1, 12); workPackage.EndYearMonth = random.Next(2000, 2079) * 100 + random.Next(1, 12); workPackage.LastUpdate = DateTime.Today; workPackage.IdLastUserUpdate = DATestUtils.DEFAULT_ASSOCIATE; project.Name = DATestUtils.GenerateString(50, true, false); project.Code = DATestUtils.GenerateString(10, true, true); project.IdProgram = random.Next(1, 2); project.IdProjectType = random.Next(1, 2); project.IsActive = true; initialBudget.Sales = random.Next(50000, 1000000); initialBudget.TotalHours = random.Next(1, 100); initialBudget.ValuedHours = random.Next(1, 100); initialBudget.YearMonth = DATestUtils.DEFAULT_YEAR_MONTH; int newId = InsertCostCenterTest(costCenter, dbCostCenterEntity); //Verifies that the id returned by the insert method is greater than 0 Assert.Greater(newId, 0); initialBudget.IdCostCenter = newId; newId = InsertProjectTest(project, dbProjectEntity); //Verifies that the id returned by the insert method is greater than 0 Assert.Greater(newId, 0); initialBudget.IdProject = newId; workPackage.IdProject = initialBudget.IdProject; coreTeamMembers.IdProject = initialBudget.IdProject; newId = InsertWorkPackageTest(workPackage, dbWorkPackageEntity); //Verifies that the id returned by the insert method is greater than 0 Assert.Greater(newId, 0); initialBudget.IdWP = newId; InsertInitialBudgetMasterTest(initialBudget, dbInitialBudget); coreTeamMembers.IdAssociate = DATestUtils.DEFAULT_ASSOCIATE; coreTeamMembers.IdFunction = DATestUtils.DEFAULT_PROJECT_FUNCTION; //verify if have core team member DataTable dsCoreMember = SelectProjectCoreTeamMemberTest(coreTeamMembers, dbCoreteamMember).Tables[0]; if (dsCoreMember.Rows.Count == 0) { int IdCoreteammember = InsertProjectCoreTeamMemberTest(coreTeamMembers, dbCoreteamMember); } InsertInitialBudgetTest(initialBudget, dbInitialBudget); UpdateInitialBudgetTest(initialBudget, dbInitialBudget); DBWPPreselection tempTable = new DBWPPreselection(connManager); tempTable.BulkInsert("CREATE TABLE #BUDGET_PRESELECTION_TEMP (IdProject INT NOT NULL, IdPhase INT NOT NULL, IdWP INT NOT NULL)"); tempTable.BulkInsert("INSERT INTO #BUDGET_PRESELECTION_TEMP (IdProject,IdPhase,IdWP) VALUES (" + initialBudget.IdProject.ToString() + "," + initialBudget.IdPhase.ToString() + "," + initialBudget.IdWP.ToString() + ")"); DataSet InitialBudgetDS = SelectInitialBudgetTest(initialBudget, dbInitialBudget); //Verifies that the table is not null DataTable tableVerifyPhases = InitialBudgetDS.Tables[0]; DataTable tableVerifyWorkPackages = InitialBudgetDS.Tables[1]; DataTable tableVerifyCostCenters = InitialBudgetDS.Tables[2]; Assert.IsNotNull(tableVerifyPhases, "The table returned should not be null"); Assert.IsNotNull(tableVerifyWorkPackages, "The table returned should not be null"); Assert.IsNotNull(tableVerifyCostCenters, "The table returned should not be null"); //Verifies that the first table is not null Assert.IsNotNull(tableVerifyPhases, "The table returned should not be null"); //Verifies that the table returns the correcty columns DATestUtils.CheckColumn(tableVerifyPhases, 0, "IdProject"); DATestUtils.CheckColumn(tableVerifyPhases, 1, "IdPhase"); DATestUtils.CheckColumn(tableVerifyPhases, 2, "PhaseName"); DATestUtils.CheckColumn(tableVerifyPhases, 3, "TotalHours"); DATestUtils.CheckColumn(tableVerifyPhases, 4, "Averate"); DATestUtils.CheckColumn(tableVerifyPhases, 5, "ValuedHours"); DATestUtils.CheckColumn(tableVerifyPhases, 6, "OtherCosts"); DATestUtils.CheckColumn(tableVerifyPhases, 7, "Sales"); DATestUtils.CheckColumn(tableVerifyPhases, 8, "NetCosts"); //Verifies that the second table is not null Assert.IsNotNull(tableVerifyWorkPackages, "The table returned should not be null"); //Verifies that the table returns the correcty columns DATestUtils.CheckColumn(tableVerifyWorkPackages, 0, "IdProject"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 1, "IdPhase"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 2, "IdWP"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 3, "WPName"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 4, "StartYearMonth"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 5, "EndYearMonth"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 6, "TotalHours"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 7, "Averate"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 8, "ValuedHours"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 9, "OtherCosts"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 10, "Sales"); DATestUtils.CheckColumn(tableVerifyWorkPackages, 11, "NetCosts"); //Verifies that the third table is not null Assert.IsNotNull(tableVerifyWorkPackages, "The table returned should not be null"); //Verifies that the table returns the correcty columns DATestUtils.CheckColumn(tableVerifyCostCenters, 0, "IdProject"); DATestUtils.CheckColumn(tableVerifyCostCenters, 1, "IdPhase"); DATestUtils.CheckColumn(tableVerifyCostCenters, 2, "IdWP"); DATestUtils.CheckColumn(tableVerifyCostCenters, 3, "IdCostCenter"); DATestUtils.CheckColumn(tableVerifyCostCenters, 4, "CostCenterName"); DATestUtils.CheckColumn(tableVerifyCostCenters, 5, "TotalHours"); DATestUtils.CheckColumn(tableVerifyCostCenters, 6, "Averate"); DATestUtils.CheckColumn(tableVerifyCostCenters, 7, "ValuedHours"); DATestUtils.CheckColumn(tableVerifyCostCenters, 8, "OtherCosts"); DATestUtils.CheckColumn(tableVerifyCostCenters, 9, "Sales"); DATestUtils.CheckColumn(tableVerifyCostCenters, 10, "NetCosts"); DATestUtils.CheckColumn(tableVerifyCostCenters, 11, "IdCurrency"); DATestUtils.CheckColumn(tableVerifyCostCenters, 12, "CurrencyCode"); DeleteInitialBudgetTest(initialBudget, dbInitialBudget); int rowCount = DeleteCostCenterTest(costCenter, dbCostCenterEntity); //Verifies that one and only one row is affected by the delete Assert.AreEqual(1, rowCount); rowCount = DeleteWorkPackageTest(workPackage, dbWorkPackageEntity); //Verifies that one and only one row is affected by the delete Assert.AreEqual(1, rowCount); //Verifies that one and only one row is affected by the delete rowCount = DeleteProjectCoreTeamMemberTest(coreTeamMembers, dbCoreteamMember); Assert.AreEqual(1, rowCount); rowCount = DeleteProjectTest(project, dbProjectEntity); //Verifies that one and only one row is affected by the delete Assert.AreEqual(1, rowCount); }
public int DeleteWorkPackageTest(IWorkPackage workPackage, DBGenericEntity dbGenericEntity) { int rowCount = dbGenericEntity.DeleteObject(workPackage); return(rowCount); }
public int InsertWorkPackageTest(IWorkPackage workPackage, DBGenericEntity dbGenericEntity) { workPackage.Id = dbGenericEntity.InsertObject(workPackage); return(workPackage.Id); }
/// <summary> /// Initializes a new instance of the <see cref="BasicWorker" /> class. /// </summary> /// <param name="workPackage">The work package.</param> public BasicWorker( IWorkPackage workPackage) : base(workPackage) { }
internal void Enqueue(IWorkPackage work) { //foreach (var query in queries) // workerQueue.Enqueue(query); workerQueue.Enqueue(work); isWorking = true; if (runningWorkers == 0) StartWorker(); }
/// <summary> /// Resolves the specified name. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <param name="package">The package.</param> /// <returns></returns> public T Resolve <T>(string name, Type type, IWorkPackage package) { return(_container.ResolveNamed <T>(name, new TypedParameter(typeof(IWorkPackage), package))); }
protected override void InitializeObject(IGenericEntity ent) { if (ent is IWorkPackage) { IWorkPackage WorkPackage = (IWorkPackage)ent; DBStoredProcedure spInsert = new DBStoredProcedure(); spInsert.ProcedureName = "catInsertWorkPackage"; WorkPackage.LastUpdate = DateTime.Today; spInsert.AddParameter(new DBParameter("@Code", DbType.String, ParameterDirection.Input, WorkPackage.Code)); spInsert.AddParameter(new DBParameter("@Name", DbType.String, ParameterDirection.Input, WorkPackage.Name)); spInsert.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, WorkPackage.IdProject)); spInsert.AddParameter(new DBParameter("@IdPhase", DbType.Int32, ParameterDirection.Input, WorkPackage.IdPhase)); spInsert.AddParameter(new DBParameter("@IsActive", DbType.Boolean, ParameterDirection.Input, WorkPackage.IsActive)); spInsert.AddParameter(new DBParameter("@Rank", DbType.Int32, ParameterDirection.Input, WorkPackage.Rank)); spInsert.AddParameter(new DBParameter("@StartYearMonth", DbType.Int32, ParameterDirection.Input, WorkPackage.StartYearMonth == ApplicationConstants.INT_NULL_VALUE ? (object)DBNull.Value : (object)WorkPackage.StartYearMonth)); spInsert.AddParameter(new DBParameter("@EndYearMonth", DbType.Int32, ParameterDirection.Input, WorkPackage.EndYearMonth == ApplicationConstants.INT_NULL_VALUE ? (object)DBNull.Value : (object)WorkPackage.EndYearMonth)); spInsert.AddParameter(new DBParameter("@LastUserUpdate", DbType.Int32, ParameterDirection.Input, WorkPackage.IdLastUserUpdate)); DBStoredProcedure spUpdate = new DBStoredProcedure(); spUpdate.ProcedureName = "catUpdateWorkPackage"; spUpdate.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, WorkPackage.Id)); spUpdate.AddParameter(new DBParameter("@Code", DbType.String, ParameterDirection.Input, WorkPackage.Code)); spUpdate.AddParameter(new DBParameter("@Name", DbType.String, ParameterDirection.Input, WorkPackage.Name)); spUpdate.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, WorkPackage.IdProject)); spUpdate.AddParameter(new DBParameter("@IdPhase", DbType.Int32, ParameterDirection.Input, WorkPackage.IdPhase)); spUpdate.AddParameter(new DBParameter("@IsActive", DbType.Boolean, ParameterDirection.Input, WorkPackage.IsActive)); spUpdate.AddParameter(new DBParameter("@Rank", DbType.Int32, ParameterDirection.Input, WorkPackage.Rank)); spUpdate.AddParameter(new DBParameter("@StartYearMonth", DbType.Int32, ParameterDirection.Input, WorkPackage.StartYearMonth == ApplicationConstants.INT_NULL_VALUE ? (object)DBNull.Value : (object)WorkPackage.StartYearMonth)); spUpdate.AddParameter(new DBParameter("@EndYearMonth", DbType.Int32, ParameterDirection.Input, WorkPackage.EndYearMonth == ApplicationConstants.INT_NULL_VALUE ? (object)DBNull.Value : (object)WorkPackage.EndYearMonth)); spUpdate.AddParameter(new DBParameter("@LastUserUpdate", DbType.Int32, ParameterDirection.Input, WorkPackage.IdLastUserUpdate)); DBStoredProcedure spDelete = new DBStoredProcedure(); spDelete.ProcedureName = "catDeleteWorkPackage"; spDelete.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, WorkPackage.IdProject)); spDelete.AddParameter(new DBParameter("@IdPhase", DbType.Int32, ParameterDirection.Input, WorkPackage.IdPhase)); spDelete.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, WorkPackage.Id)); this.AddStoredProcedure("InsertObject", spInsert); this.AddStoredProcedure("UpdateObject", spUpdate); this.AddStoredProcedure("DeleteObject", spDelete); DBStoredProcedure spSelect = new DBStoredProcedure(); spSelect.ProcedureName = "catSelectWorkPackage"; spSelect.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, WorkPackage.IdProject)); spSelect.AddParameter(new DBParameter("@IdPhase", DbType.Int32, ParameterDirection.Input, WorkPackage.IdPhase)); spSelect.AddParameter(new DBParameter("@Id", DbType.Int32, ParameterDirection.Input, WorkPackage.Id)); spSelect.AddParameter(new DBParameter("@IdAssociate", DbType.Int32, ParameterDirection.Input, WorkPackage.IdAssociate)); this.AddStoredProcedure("SelectObject", spSelect); DBStoredProcedure spCheckWPPeriod = new DBStoredProcedure(); spCheckWPPeriod.ProcedureName = "bgtCheckWPPeriod"; spCheckWPPeriod.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, WorkPackage.IdProject)); spCheckWPPeriod.AddParameter(new DBParameter("@IdPhase", DbType.Int32, ParameterDirection.Input, WorkPackage.IdPhase)); spCheckWPPeriod.AddParameter(new DBParameter("@IdWorkPackage", DbType.Int32, ParameterDirection.Input, WorkPackage.Id)); spCheckWPPeriod.AddParameter(new DBParameter("@CachedStartYearMonth", DbType.Int32, ParameterDirection.Input, WorkPackage.StartYearMonth)); spCheckWPPeriod.AddParameter(new DBParameter("@CachedEndYearMonth", DbType.Int32, ParameterDirection.Input, WorkPackage.EndYearMonth)); this.AddStoredProcedure("CheckWPPeriod", spCheckWPPeriod); DBStoredProcedure spGetIntercoCountries = new DBStoredProcedure(); spGetIntercoCountries.ProcedureName = "catSelectIntercoCountries"; spGetIntercoCountries.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, WorkPackage.IdProject)); this.AddStoredProcedure("GetIntercoCountries", spGetIntercoCountries); DBStoredProcedure spGetWorkPackageNewKeys = new DBStoredProcedure(); spGetWorkPackageNewKeys.ProcedureName = "catSelectWorkPackageNewKeys"; spGetWorkPackageNewKeys.AddParameter(new DBParameter("@IdProject", DbType.Int32, ParameterDirection.Input, WorkPackage.IdProject)); spGetWorkPackageNewKeys.AddParameter(new DBParameter("@Code", DbType.String, ParameterDirection.Input, WorkPackage.Code)); this.AddStoredProcedure("GetWorkPackageNewKeys", spGetWorkPackageNewKeys); } }