예제 #1
0
 /// <summary>
 /// Gets the instance of the unique object as its going to keep the data updated by itself
 /// </summary>
 /// <returns>Instance of the PlansDirectoy object</returns>
 public static PlansDirectory GetInstance()
 {
     if (instance == null)
     {
         instance = new PlansDirectory();
     }
     return(instance);
 }
예제 #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 private PlansDirectory()
 {
     instance = this;
 }
예제 #3
0
        /// <summary>
        /// Checks for updates on the test plan
        /// </summary>
        /// <param name="oem"></param>
        public void CheckForTestPlanUpdates(OEM oem)
        {
            try
            {
                Process thisProc = Process.GetCurrentProcess();
                if (thisProc.ProcessName != "devenv")
                {
                    string localTestPlanLocation = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), Path.GetFileName(ONLINE_PLANS_DIRECTORY));

                    if (!File.Exists(localTestPlanLocation))
                    {
                        File.Copy(ONLINE_PLANS_DIRECTORY, localTestPlanLocation, true);
                    }
                    if (!FileVersionHandler.CompareVersions(localTestPlanLocation, ONLINE_PLANS_DIRECTORY))
                    {
                        File.Copy(ONLINE_PLANS_DIRECTORY, localTestPlanLocation, true);
                    }

                    PlansDirectory plansDirectory = PlansDirectory.GetInstance();
                    plansDirectory.UpdateDataFromFile(localTestPlanLocation);
                    ArrayList plans = plansDirectory.Plans;
                    foreach (Plan plan in plans)
                    {
                        if (plan.FileName == oem.TestPlan)
                        {
                            if (plan.Version != oem.TestPlanVersion)
                            {
                                UpdateTestPlan(oem, plan.Version);
                                if (WTMTestPlanUpdateCheckSuccessfull != null)
                                {
                                    WTMTestPlanUpdateCheckSuccessfull(oem);
                                }
                            }
                        }
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.FILE_NOT_FOUND, ex);
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.UNAUTHORIZED_ACCESS, ex);
                }
            }
            catch (DirectoryNotFoundException ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.DIRECTORY_NOT_FOUND, ex);
                }
            }
            catch (IOException ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.IO_EXCEPTION, ex);
                }
            }
            catch (Exception ex)
            {
                if (WTMTestPlanCheckForUpdatesError != null)
                {
                    WTMTestPlanCheckForUpdatesError(WTMTestPlanCheckForUpdatesErrorType.UNKNOWN_ERROR, ex);
                }
            }
        }