Descrição e Instalação do Projeto


Esse projeto é uma versão 1.0 foi desenvolvido para facilitar o controle de horas nos projetos desenvolvidos com visual studio e Team foundation 2013, ainda podem ser implementadas muitas melhorias, mas o básico ta ai.

Para utilizar você vai precisar fazer o seguinte:

- Criar um banco de dados no mesmo servidor que está o banco do TFS:

CREATE DATABASE [Tfs_Timesheet]
GO

CREATE TABLE [dbo].[Synchronization](
[DateSynchronization] [datetime] NOT NULL
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[Teste](
[ID] [int] IDENTITY(1,1) NOT NULL,
[WorkItemID] [int] NOT NULL,
[ChangeBy] [nvarchar](512) NOT NULL,
[ChangeDate] [date] NOT NULL,
[Hours] [int] NOT NULL,
CONSTRAINT [PK_Teste] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE TABLE [dbo].[TimesheetEntries](
[entryId] [bigint] IDENTITY(1,1) NOT NULL,
[workItemId] [int] NOT NULL,
[sid] [nvarchar](128) NOT NULL,
[hours] [decimal](18, 4) NOT NULL,
[entryDate] [datetime] NOT NULL,
CONSTRAINT [PK_TimesheetEntries_1] PRIMARY KEY CLUSTERED
(
[entryId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


- Agora você precisa acessar o banco de dados do seu TFS e criar um Job que vai mandar os apontamentos feitos nas tarefas para a timesheet:

USE [msdb]
GO

BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0

IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
BEGIN
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'[Uncategorized (Local)]'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

END

DECLARE @jobId BINARY(16)
EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'TimeSheet',
@enabled=1,
@notify_level_eventlog=0,
@notify_level_email=0,
@notify_level_netsend=0,
@notify_level_page=0,
@delete_level=0,
@description=N'No description available.',
@category_name=N'[Uncategorized (Local)]',
@owner_login_name=N'sa', @job_id = @jobId OUTPUT
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'PreencherTimeSheet',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0, @subsystem=N'TSQL',
@command=N'insert into TimesheetEntries
select
ID workItemId,
[Changed By] sid,
(Fld10039 - ISNULL((select sum(Fld10039) from Tfs_Softway.dbo.WorkItemsLatestAndWere WI where WI.ID = WorkItemsLatestAndWere.ID and WI.Rev = (WorkItemsLatestAndWere.Rev -1)), 0)) Hours,
[Changed Date] entryDate
from
Tfs_Softway.dbo.WorkItemsLatestAndWere
where
Fld10039 <> 0 and
[Changed Date] > (select DateSynchronization from Synchronization)
group by
ID,
Rev,
Fld10039,
[Changed By],
[Changed Date]
having
(Fld10039 - ISNULL((select sum(Fld10039) from Tfs_Softway.dbo.WorkItemsLatestAndWere WI where WI.ID = WorkItemsLatestAndWere.ID and WI.Rev = (WorkItemsLatestAndWere.Rev -1)), 0)) <> 0

update Synchronization set DateSynchronization = (select Max(entryDate) from TimesheetEntries)',
@database_name=N'Tfs_Timesheet',
@flags=0
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'TimeSheet',
@enabled=1,
@freq_type=4,
@freq_interval=1,
@freq_subday_type=2,
@freq_subday_interval=10,
@freq_relative_interval=0,
@freq_recurrence_factor=0,
@active_start_date=20140205,
@active_end_date=99991231,
@active_start_time=0,
@active_end_time=235959,
@schedule_uid=N'bfbf4277-e683-48c3-b49a-122342d3e3c7'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
COMMIT TRANSACTION
GOTO EndSave
QuitWithRollback:
IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:

GO

 

- Agora basta publicar o projeto do site no IIS e utilizar.

Last edited Apr 1, 2014 at 10:09 PM by foxelv, version 6