Updates with 0 hours

Mar 25, 2009 at 7:31 PM

This has been brought up a few times, and I thought it might be worth its own discussion.

Right now, this code does not submit status updates to the PM when the Actual work for a task is 0. Usually this is a good thing, as updates with 0 hours aren't much of an update. But in cases where the time was changed from something else to 0, we really do want the update sent.

The code that is currently filtering these updates out is in StatusingPSI.cs, and is included below.

Anyone have any ideas on changing this? I've tried just omitting the check for 0, but then a blank status update is sent for every task listed on the timesheet. PWA displays the tasks that need to have updates submitted with a yellow exclamation point. Anyone know where PWA gets this info from? We just need to filter this list of AssignmentUID's a little differently.

One heavy solution would be to record the TS_LINE_ACT_SUM_VALUE into another table, and on every submit see if the value has changed from the last submit. Assume if the value isn't found that it was zero.

Any other ideas?

(Or if you know that SP2 fixes all of this, and I shouldn't spend time here, I'd appreciate hearing that, too. Really. Please.)


James Fraser
        /// <summary>
        /// Get list of assignments to submit
        /// </summary>
        /// <param name="timesheetDS">Timesheet dataset</param>
        /// <returns>List of assignements</returns>
        public static List<Guid> SubmitStatus(TimesheetWS.TimesheetDataSet timesheetDS, AppLog appLog, bool logEvents)
        {
            List<Guid> assignments = new List<Guid>();
            StatusingWS.StatusingDataSet statDS = new StatusingWS.StatusingDataSet();


            for (int i = 0; i < timesheetDS.Lines.Count; i++)
            {
                if ((timesheetDS.Lines[i].TS_LINE_VALIDATION_TYPE == (int)TimesheetEnum.ValidationType.Verified)
                    &&
                    (timesheetDS.Lines[i].TS_LINE_ACT_SUM_VALUE > 0)

                    )
                {
                    assignments.Add(timesheetDS.Lines[i].ASSN_UID);
                    if (logEvents)
                    {
                        decimal hours = timesheetDS.Lines[i].TS_LINE_ACT_SUM_VALUE / 60000;
                        appLog.WriteLine(string.Format("   Timesheet line: {0}; Project: {1}; Assignment: {2}; Actual Work: {3}", i,
                            timesheetDS.Lines[i].TS_LINE_CACHED_PROJ_NAME,
                            timesheetDS.Lines[i].TS_LINE_CACHED_ASSIGN_NAME,
                            hours.ToString("N2")));
                    }
                }
            }
            return assignments;
        }
Aug 13, 2009 at 10:25 AM

Hi,

Has anyone found any solutions to this problem? I've been working on it all for the last two days and haven't got anywhere.

 

Is the timesheet history perhaps accessible through any of PS Web services?

Cheers,

A

Aug 13, 2009 at 3:16 PM

 

I oviously can't speak for others, but we didn't ever pursue any solutions to this.

You raise an interesting point. Timesheet history can be recorded if the option to enable Timesheet Auditing is turned on in the server settings. This records Timesheet activity to a table in the database. I haven't used this table, so I don't know how hard it would be to get the history of previous changes to a single task.

As I hinted above, if I were asked for recommendations on how to do this right now, I would use the TimesheetSaved event to record the Actual work into a custom table. Then in the SubmitStatus code, I would add a check to that table to see if that changed for a task before submitting an update.

 

James Fraser

Sep 9, 2009 at 1:39 PM

I have managed to come up with a solution that works for us. These are the steps I used:

In UpdateStatus.cs STEP 5 add:

StatusingWS.StatusingDataSet assnDs = statusing.ReadStatus(Guid.Empty, DateTime.MinValue, DateTime.MaxValue);

and change:

List<Guid> assignmentsUID = StatusingPSI.SubmitStatus(timesheetDS, assnDs.Tables["Assignments"], appLog, logEvents);

In statusingPSI.cs change the SubmitStatus() function so that it is as follows:

public static List<Guid> SubmitStatus(TimesheetWS.TimesheetDataSet timesheetDS, DataTable assnTable, AppLog appLog, bool logEvents)
        {
            List<Guid> assignments = new List<Guid>();
            bool assnAdded;
            
            for (int i = 0; i < timesheetDS.Lines.Count; i++)
            {
                assnAdded = false;
                if ((timesheetDS.Lines[i].TS_LINE_VALIDATION_TYPE == (int)TimesheetEnum.ValidationType.Verified))
                {
                    if (timesheetDS.Lines[i].TS_LINE_ACT_SUM_VALUE > 0)
                    {
                        assignments.Add(timesheetDS.Lines[i].ASSN_UID);
                        assnAdded = true;
                    }
                    else
                    {
                        foreach (DataRow row in assnTable.Rows)
                        {
                            if (row["ASSN_UID"].ToString() == timesheetDS.Lines[i].ASSN_UID.ToString() && 
                                row["ASSN_COST_IS_VALID"].ToString() == "False" &&
                                row["WASSN_SEND_UPDATE_NEEDED"].ToString() == "True" && 
                                row["WASSN_ACTUALS_PENDING"].ToString() == "0")
                            {
                                assignments.Add(timesheetDS.Lines[i].ASSN_UID);
                                assnAdded = true;
                            }
                        }
                    }
                    if (logEvents && assnAdded)
                    {
                        decimal hours = timesheetDS.Lines[i].TS_LINE_ACT_SUM_VALUE / 60000;
                        appLog.WriteLine(string.Format("   Timesheet line: {0}; Project: {1}; Assignement: {2}; Actual Work: {3}", i,
                            timesheetDS.Lines[i].TS_LINE_CACHED_PROJ_NAME,
                            timesheetDS.Lines[i].TS_LINE_CACHED_ASSIGN_NAME,
                            hours.ToString("N2")));
                    }
                }
            }
            return assignments;
        }

WASSN_SEND_UPDATE_NEEDED is a flag which marks the assignment as changed. Problem with this particular column is that all assignments on a newly created timesheet are marked as "update is needed". Even the ones on which no time has been filed. Therefore we added a check for ASSN_COST_IS_VALID=false which only changed assignments are. The ASSN_COST_IS_VALID is true on new timesheets. As new timesheets are only "new" once, the check seems to work. When the timesheets are updated and saved, the ASSN_COST_IS_VALID column becomes false.


WASSN_ACTUALS_PENDING is the how the update was done. 0 indicates that it was saved by resource.

The information on these columns was scarce at best.

There might be a better way to do this, but this works and opens for more elegant solutions.

Regards,

Arnar
Camako Data AB

Jan 26, 2010 at 9:54 PM

Hi Chris,

Could you make the addition suggested above by aarnas available in the msi download?

Thanks,

Jim