Sijin Joseph's blog

My experiences with .Net

January 2005 - Posts

What a wierd bug or feature?
A couple of days back i was working on an app, when i came across this problem. So the thing is that there are two events in DataTable, one is called OnRowChanging and the other is called OnRowChanged. Well i figured since i wanted to access the newly added row in the table OnRowChanged would be a good choice. Well as it turns out the row isn't added to the table in the OnRowChanged event infact there is no event which you can catch after the row has been added to the table. Now is that a bug or is it by design?
 
So the workaround that i had to do was to get the row from the DefaultView of the table. The defaultView needs to have the newly added row so that any controls that are bound correctly show newly added rows.
Posted: Jan 20 2005, 05:32 PM by Sijin Joseph | with 1 comment(s)
Filed under:
VSS Automation script
In our company we have a policy of creating a checkin mail that describes the files that you are checking in and what changes or bugs have been fixed in that checkin. The process of creating the mail involved opening VSS and then getting a list of all checked out files and then copying and pasting that to the mail. I've always wanted to get into windows scripting and i thought what better oppurtunity than this. So i wrote this small script that gets a list of all checked out files from VSS and then creates a new mail with the required info already filled in.
 
 
  var oVss = new ActiveXObject("SourceSafe");
  oVss.Open("
<Insert path to srcsafe.ini>");
  var oProj = oVss.VSSItem("<Insert project path e.g. $/");
    
  var allProjects = new Array();
  allProjects = GetAllProjects(oProj,allProjects);
    
  var output = "";
  var projItem;
  var projEnumerator = new Enumerator(allProjects);
  for (; !projEnumerator.atEnd() ; projEnumerator.moveNext() )
  {
      projItem = projEnumerator.item();
      var checkouts = GetCheckedOutFiles(projItem);
   
      if(checkouts.length > 0)
      {
          output += projItem.Spec + "\n";
          var checkoutEnumerator = new Enumerator(checkouts);
          for(;!checkoutEnumerator.atEnd();checkoutEnumerator.moveNext())
          {
              var checkoutItem = checkoutEnumerator.item();
              output += "\t" + checkoutItem + "\n";
          }
    
          output += "\n";
      }
  }
  
  var olApp = new ActiveXObject("Outlook.Application");
  var mailItem = olApp.CreateItem(0 /*olMailItem*/);
  mailItem.Recipients.Add("<Insert e-mail address to send mail to>");
  mailItem.Body = "\n" + output;
  mailItem.Display();
  
  function GetCheckedOutFiles( projectItem )
  {
      var checkouts = new Array();
      var itemEnumerator = new Enumerator(projectItem.items(false));
      for(; !itemEnumerator.atEnd(); itemEnumerator.moveNext())
      {
          var item = itemEnumerator.item();
          //File
          if(item.Type == 1/*VSSITEM_FILE*/ && item.IsCheckedOut == 2 /*VSSFILE_CHECKEDOUT_ME*/)
          {
               checkouts.push(item.Name);
           }
       }
       return checkouts;
  } 
  
  function GetAllProjects( rootItem )
  {
      var projects = new Array();
      var items = new Enumerator(rootItem.items(false));
   
      for(;!items.atEnd();items.moveNext())
      {
          var item = items.item();
          //Project
          if(item.Type == 0 /*VSSITEM_PROJECT*/)
          {
              projects.push(item);
      
              var subProjects = GetAllProjects(item);
              var subProjectEnumerator = new Enumerator(subProjects);
              for(;!subProjectEnumerator.atEnd();subProjectEnumerator.moveNext())
              {
                  var subProjectItem = subProjectEnumerator.item();
                  projects.push(subProjectItem);
              }
          }
   }
    return projects;
  }
  
  function printItems(items, prop)
  {
      var itemEnumerator = new Enumerator(items);
      for(;!itemEnumerator.atEnd();itemEnumerator.moveNext() )
      {
          var item = itemEnumerator.item();
          WScript.Echo(item[prop]);
       }
  }
What a way to start the new year..
On 3rd January i got a mail from Microsoft saying that i had been selected as an MVP for Visual C# , now that is some new years gift. I am waiting for my first set of MSDN Universal DVD's ... woot :)
Posted: Jan 06 2005, 10:21 AM by Sijin Joseph | with 3 comment(s)
Filed under:
More Posts