Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Embracing OpenSource
- CM Bridge
- teamscript
- Software Change and Configuration Management
- DIM14
- CKEditor
- SBM
- Customization
- Continuous Integration
- build
- 소스코드관리
- CM14
- Serena software
- Dimensions Pulse
- SharePoint
- AppScript
- 버전관리
- TeamTrack
- SCCM
- IntelliJ IDEA
- Dimensions CM
- integration
- 엔터프라이즈 SCCM
- Jenkins
- Serena Dimensions CM
- 세레나소프트웨어
- Stream
- UseCase
- Enterprise Software Change and Configuration Management
- BPM
Archives
- Today
- Total
this and that
SBM AppScript Use Cases - 04. Subtask Time Calculation 본문
Subtask에 대해 처리한 시간을 취합하여 상위 WCR에 입력하는 스크립트.
Child Task의 등록시간과 종료시간의 차이를 계산하여 취합.
첨부할 Note의 이름은 Number of Hours spent on Assessment. 보여지는 시간 포맷은 hh:mm:ss.
Assessment 완료 시점에 Post-transition을 통하여 실행이 된다.
' Name: calcSubTasksTime ' Function: After the completion of all subtasks for a parent item, ' retrieve each subtask and calculate the total amount of time ' that it took for all subtasks to complete. This total equals the ' summation of the open time (Close - Submit dates) for each subtask. ' Store the results in a new Note on the parent item indicating ' the time using the following format: hh:mm:ss (01:23:09) ' Context: Post-transition for Assessment Complete transition ' ' Date: 03/09/2006 ' For use in the TeamTrack TeamScript course examples. ' Require all vars to be declared before use (and then declare some) Option Explicit ' Parent Item information Const SUBTASK_FLD = "CHILD_TASKS" Const PARENT_TABLE_ID = 1008 ' Sub-task project ID, table ID, and Start and End time fields Const PROJECT_ID = 31 Const CHILD_TABLE_ID = 1000 Const START_FLD = "SUBMITDATE" Const END_FLD = "CLOSEDATE" ' Attachement type for a Note attachment Const ATTACH_TYPE = 128 ' Variables used to retreive data from the items Dim objItem, objFlds, objFld, strSubtaskIds ' Get the current item Set objItem = Shell.Item ' Read the comma separated unique id list of subtask items Set objFlds = objItem.Fields() Set objFld = objFlds.FindField(SUBTASK_FLD) objFld.GetValue strSubtaskIds ' Parse the list of sub-task items so we can look them up individually Dim nStart, nEnd, nLength, objSub, nSum, nId, nStartFld, nEndFld ' Set variables needed to parse the parent's list of child subtasks (multi-relational field value) nLength = Len(strSubtaskIds) nStart = 2 nEnd = nStart ' Create the object to hold a Child subtask item Set objSub = Ext.CreateVarRecord(CHILD_TABLE_ID) ' Loop through the Parent's list of subtasks and process each child do while nStart <= nLength ' The child record IDs reside between pairs of commas nEnd = InStr(nStart,strSubtaskIds, ",") nId = Mid(strSubtaskIds,nStart, nEnd - nStart) Call Ext.LogInfoMsg("Id: "&nId) ' Retrieve the child item and calculate the time the item was open call objSub.Read(nId) call objSub.GetFieldValue(START_FLD,nStartFld) call objSub.GetFieldValue(END_FLD,nEndFld) nSum = nSum + (nEndFld - nStartFld) ' Position for the next child ID nStart = nEnd + 1 loop ' Calculate the Hours:Minutes:Seconds Dim nHours, nMinutes, nSeconds, strTotalTime nHours = Int(nSum / 3600) nSum = nSum - (nHours * 3600) nMinutes = Int(nSum / 60) nSeconds = nSum - (nMinutes * 60) ' Format the Hours:Minutes:Seconds strTotalTime = "" If nHours < 10 Then strTotalTime = strTotalTime&"0"&nHours Else strTotalTime = strTotalTime&nHours End If If nMinutes < 10 Then strTotalTime = strTotalTime&":0"&nMinutes Else strTotalTime = strTotalTime&":"&nMinutes End If If nSeconds < 10 Then strTotalTime = strTotalTime&":0"&nSeconds Else strTotalTime = strTotalTime&":"&nSeconds End If Dim objAttachment Set objAttachment = Ext.CreateAppRecord(Ext.TableId("TS_ATTACHMENTS")) ' The attachment record has a lot of fields to fill in nId= objItem.GetId() call objAttachment.SetFieldValue("CASEID", nId) nId = Shell.User.GetId() call objAttachment.SetFieldValue("AUTHORID",nId) call objAttachment.SetFieldValue("TIME", Ext.DateToDBLong(now)) call objAttachment.SetFieldValue("TYPE",ATTACH_TYPE) call objAttachment.SetFieldValue("TITLE","Number of Hours spent on Assessment") call objAttachment.SetFieldValue("CONTENTS", "Total Hours = "&strTotalTime) call objAttachment.SetFieldValue("SRCTABLEID",PARENT_TABLE_ID) ' Add the new Note record Call objAttachment.Add()
'SBM' 카테고리의 다른 글
AppScript를 이용하여 임의의 사용자에게 메일 보내기 (1) | 2012.06.07 |
---|---|
SBM with Gantt Chart (3) | 2011.12.13 |
SBM AppScript Use Cases - 03. Auto-Subtasks for Assessors (0) | 2011.11.22 |
SBM AppScript Use Cases - 02. Calculate Work Effort Difference (0) | 2011.10.28 |
SBM AppScript Use Cases - 01. Validate Work Effort Fields (0) | 2011.10.28 |
Comments