Frideas for 12 April 2024

task

And populated?

of course not

Ok did some checking. Can’t see if it is actually ended, but I can definitely make it go away.

You can see start and stop.

No biggie, query coming up.

Standard UBAQ on SysTask, Add a calculated field and a pre-processing directive on update.
Calculated field value is set to SysTask.History (So you can just flip the bit on or off)

var resultQuery = queryResultDataset.Results.Where(row => !string.IsNullOrEmpty(row.RowMod));

foreach (var ttResult in resultQuery)
{
    ttResult.SysTask_History = ttResult.Calculated_Poof; 
}

SysTaskMaintenance.baq (34.0 KB)

1 Like

Not complaining, but we’d still need to set the TaskStatus to something other than ‘Active’, like ‘Cancelled’ or as we used to say in the mainframe era, ‘Abend’, which was short for “abnormal end.”

Pinky Malinky Yes GIF by NETFLIX

But since I am complaining, sometimes people try to kill the task with the System Monitor and that writes a record to the SysTaskKill and that should be deleted as well.

kill me now sex and the city GIF

1 Like

SysTaskMaintenance2.baq (34.2 KB)

Added another calculated field, tied to SysTask.TaskStatus.

var resultQuery = queryResultDataset.Results.Where(row => !string.IsNullOrEmpty(row.RowMod));

foreach (var ttResult in resultQuery)
{
    ttResult.SysTask_History    = ttResult.Calculated_Poof;
    ttResult.SysTask_TaskStatus = ttResult.Calculated_MarkComplains;  
}
1 Like

I just closed it all down, next time type faster you heartless sob.

Why should it be deleted? Is this a record to take action on, or a history?

I think the Agent is supposed to notice that someone requested the shutdown (kill) but I’m guessing it’s tied to the process, which isn’t running, so that record sits out there.

While we are complaining you should also set the last Activity Message to something like ‘Kevin BAQ Killed this’ I literally set mine to “Agent :poop: the Bed” and I set the TaskStatus to ERROR cause well it was.

That’s probably the best solution, I’ll work up a proper fix later.

2 Likes

I can’t find a way to do that, but I incorporated your suggestion.

I set SysTask.ActivityMsg to a status if it is empty. [Status Changed By (<UserID>)]
If it is not empty, and it finds a previous status change, it replaces it.
If it is not empty, and does not contain a previous status change, it assumes someone was using the message for something and tries a slightly risky append.
If y’all don’t like that, modify it.

SysTask.TaskStatus is set to ERROR if you changed the History status to true.
SysTask.TaskStatus is set to UNKNOWN if you changed the History status to false.
(Why would you? Fat Fingers?)
incredulous questioning GIF

Back to one calculated field on the UBAQ. Calculated_Poof set to SysTask.History

//You people take your own risks here when you copy code like this Func<T>
Action<List<SysTaskKill>> MetallicaSays = (taskKillList) =>
{
    using (var txScope = IceContext.CreateDefaultTransactionScope())
    {
        taskKillList.ForEach(t => Db.DeleteObject(t));
    
        Db.Validate();
        txScope.Complete();
    }
};


var resultQuery = queryResultDataset.Results.Where(row => !string.IsNullOrEmpty(row.RowMod));

foreach (var ttResult in resultQuery)
{
    ttResult.SysTask_History = ttResult.Calculated_Poof;
    
    string activityMessageStart = $"[Status Changed By";
    string activityMessage      = $"{activityMessageStart} ({Session.UserID})]";
    

    if(String.IsNullOrWhiteSpace(ttResult.SysTask_ActivityMsg) || ttResult.SysTask_ActivityMsg.StartsWith("Status Changed By"))
    {
      ttResult.SysTask_ActivityMsg = activityMessage;
    }
    else
    {//It's probably being used for some other purpose (try append) (still slightly risky...)
        
        string temp = String.Empty;
        int findIndex = ttResult.SysTask_ActivityMsg.IndexOf(activityMessageStart);
        if(findIndex != -1)
        {
            //Remove any previous status
            temp = ttResult.SysTask_ActivityMsg.Substring(0, ttResult.SysTask_ActivityMsg.IndexOf(activityMessageStart));
        }
        
        //Will it fit?
        if(temp.Length + activityMessage.Length < 101) //Field Size 100
        {
            ttResult.SysTask_ActivityMsg = temp + activityMessage;
        }
        
        //Nope
        //Leave it alone
   }
    
    ttResult.SysTask_TaskStatus = ttResult.Calculated_Poof ? "ERROR" : "UNKNOWN";
    
    
    var killEmAll = Db.SysTaskKill.Where(k => k.SysTaskNum == ttResult.SysTask_SysTaskNum).ToList();
    
    if(killEmAll.Count > 0) MetallicaSays(killEmAll);
}

Season 2 Reaction GIF by The Lonely Island

1 Like

Of course now I remember the .Remove Extension Method instead of that Substring nonsense.
Thanks @Hally :rofl:

PULL THE PLUG!

An error occurred: Body seems unclear, is it a complete sentence?

^-- As a Headbanger myself, I LOVE this

1 Like