Developer Journey: Week 5 - Cleaning Up

This week involved tackling scripts for cleaning up old user accounts, managing data consistency across system changes, and preparing for upcoming API integration enhancements.

Developer Journey: Week 5 - Cleaning Up

Introduction: A Week of Troubleshooting and System Enhancements

As I dive deeper into my role, week five brought its own set of unique challenges, from script errors to complex data management issues that required a blend of technical skill and coordination across teams.

Tackling Script Errors for User Account Cleanup

One significant issue this week was with a script meant to clean up older user accounts and their associated folders. The script failed to delete certain read-only files, like shortcut links, which prevented it from removing the entire folder from the server. After some investigation, I modified the script to handle these read-only files effectively, allowing for a complete cleanup. Here’s a simplified version of the C# code I adapted to overcome this hurdle:

using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("Usage: DeleteFolders.exe <UNC_Path1> <UNC_Path2> ...");
            return;
        }

        foreach (var uncPath in args)
        {
            DeleteNetworkFolder(uncPath);
        }
    }

    static void DeleteNetworkFolder(string folderPath)
    {
        try
        {
            if (Directory.Exists(folderPath))
            {
                // Recursively remove read-only attribute from the folder and its contents
                RemoveReadOnlyAttributeRecursively(folderPath);

                // Delete the folder and its contents recursively
                Directory.Delete(folderPath, true);
                Console.WriteLine($"Deleted folder: {folderPath}");
            }
            else
            {
                Console.WriteLine($"Folder not found: {folderPath}");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error deleting folder {folderPath}: {ex.Message}");
        }
    }

    static void RemoveReadOnlyAttributeRecursively(string folderPath)
    {
        try
        {
            // Remove read-only attribute from the folder itself
            if ((File.GetAttributes(folderPath) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
            {
                File.SetAttributes(folderPath, File.GetAttributes(folderPath) & ~FileAttributes.ReadOnly);
            }

            // Remove read-only attribute from all files and subfolders recursively
            foreach (var file in Directory.GetFiles(folderPath))
            {
                if ((File.GetAttributes(file) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                {
                    File.SetAttributes(file, File.GetAttributes(file) & ~FileAttributes.ReadOnly);
                }
            }

            foreach (var subfolder in Directory.GetDirectories(folderPath))
            {
                RemoveReadOnlyAttributeRecursively(subfolder);
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error removing read-only attribute in {folderPath}: {ex.Message}");
        }
    }
}

This adjustment ensured that our cleanup process could continue without leaving residual data behind.

Coordinating Rollbacks After a Name Change Request

A complex situation arose when an employee requested a rollback of their name change, which had already propagated through various systems. This situation affected usernames and numerous database tables, requiring coordination with multiple teams to correct. I led the efforts to reverse these changes, ensuring all systems reflected the original information, demonstrating the importance of clear communication and thorough understanding of our data systems.

Addressing Rehire Identification Issues

Our current HR system assigns new employee IDs to rehired employees without recognizing their previous IDs. This has repeatedly led to duplicate records and data inconsistencies. I’ve been managing this by manually updating SQL tables to ensure all records for rehired employees are consolidated under their original IDs. This process, though currently managed through stored procedures, is slated for automation to increase efficiency and reduce the potential for errors.

Planning for Future API Integrations

Looking forward, a new request emerged to enhance the integration between Workday and FreshService. The goal is to streamline the onboarding process by reducing the manual data entry required by our helpdesk team. I will be exploring ways to extract necessary information from Workday and feed it into a new API on the FreshService side, aiming to automate and simplify the onboarding of future employees.

Conclusion: Continuous Improvement and Forward Planning

Week five emphasized the ongoing need for system improvements and proactive problem-solving. Whether through refining scripts, coordinating team efforts for data consistency, or planning future API integrations, each challenge provides an opportunity to enhance our operations and prepare for more complex tasks ahead.

Privacy