コード例 #1
0
        /// <summary>
        /// Recalculates the object TotalMinutes and TotalApproved.
        /// </summary>
        /// <param name="objectId">The object id.</param>
        /// <param name="objectTypeId">The object type id.</param>
        /// <param name="projectId">The project id.</param>
        private static void RecalculateObjectAndProject(int?objectId, int?objectTypeId, int projectId)
        {
            using (DbTransaction tran = DbTransaction.Begin())
            {
                if (objectId.HasValue && objectTypeId.HasValue)
                {
                    DbTimeTracking.RecalculateObject(objectId.Value, objectTypeId.Value, projectId);
                }

                if (projectId > 0)
                {
                    DbTimeTracking.RecalculateProject(projectId);
                }

                tran.Commit();
            }
        }
コード例 #2
0
        /// <summary>
        /// Recalculates the project and objects TotalMinutes and TotalApproved.
        /// </summary>
        /// <param name="block">The block.</param>
        private static void RecalculateProjectAndObjects(TimeTrackingBlock block)
        {
            int projectId = GetProjectIdByTimeTrackingBlock(block);

            if (projectId > 0)
            {
                TimeTrackingEntry[] entryList = TimeTrackingEntry.List(
                    FilterElement.EqualElement("ParentBlockId", block.PrimaryKeyId.Value),
                    FilterElement.IsNotNullElement("ObjectId"),
                    FilterElement.IsNotNullElement("ObjectTypeId"));
                foreach (TimeTrackingEntry entry in entryList)
                {
                    DbTimeTracking.RecalculateObject((int)entry.Properties["ObjectId"].Value, (int)entry.Properties["ObjectTypeId"].Value, block.ProjectId.Value);
                }

                DbTimeTracking.RecalculateProject(projectId);
            }
        }