示例#1
0
 private void FormsTrayApp_Load(object sender, System.EventArgs e)
 {
     if (shutdown)
        {
     this.Close();
        }
        else
        {
         try
         {
             if (!Preferences.HideiFolderInTray)
             {
                 ShowStartupScreen();
             }
             Environment.CurrentDirectory = Application.StartupPath;
             for (int i = 0; i < 3; i++)
             {
                 Process[] processArray = Process.GetProcessesByName("simias");
                 foreach (Process proc in processArray)
                 {
                     if (proc != null)
                     {
                         simiasManager.Stop();
                     }
                 }
             }
             ifWebService = null;
             simiasWebService = null;
             eventQueue = new Queue();
             workEvent = new AutoResetEvent(false);
             eventClient = new IProcEventClient(new IProcEventError(errorHandler), null);
             preferences = new Preferences(ifWebService, simiasWebService, simiasManager);
             preferences.EnterpriseConnect += new Novell.FormsTrayApp.Preferences.EnterpriseConnectDelegate(preferences_EnterpriseConnect);
             preferences.ChangeDefaultDomain += new Novell.FormsTrayApp.Preferences.ChangeDefaultDomainDelegate(preferences_EnterpriseConnect);
             preferences.RemoveDomain += new Novell.FormsTrayApp.Preferences.RemoveDomainDelegate(preferences_RemoveDomain);
             preferences.ShutdownTrayApp += new Novell.FormsTrayApp.Preferences.ShutdownTrayAppDelegate(preferences_ShutdownTrayApp);
             preferences.UpdateDomain += new Novell.FormsTrayApp.Preferences.UpdateDomainDelegate(preferences_UpdateDomain);
             preferences.DisplayiFolderDialog += new Novell.FormsTrayApp.Preferences.DisplayiFolderDialogDelegate(preferences_DisplayiFolderDialog);
             preferences.CreateControl();
             IntPtr handle = preferences.Handle;
             syncLog = new SyncLog();
             syncLog.CreateControl();
             handle = syncLog.Handle;
             infolog = new SyncLog();
             infolog.Customize();
             globalProperties = new GlobalProperties(ifWebService, simiasWebService, eventClient);
             globalProperties.RemoveDomain += new Novell.FormsTrayApp.GlobalProperties.RemoveDomainDelegate(globalProperties_RemoveDomain);
             globalProperties.PreferenceDialog = preferences;
             globalProperties.SyncLogDialog = syncLog;
             globalProperties.CreateControl();
             handle = globalProperties.Handle;
             if (RegularStart)
             {
                 DelayedStart();
             }
             else
             {
                 try
                 {
                     LogInit();
                 }
                 catch { }
                 shellNotifyIcon.Text = resourceManager.GetString("iFolderServices");
                 shellNotifyIcon.Icon = trayIcon;
                 SimiasTimer = new System.Windows.Forms.Timer();
                 SimiasTimer.Interval = 120000;
                 SimiasTimer.Tick += new EventHandler(SimiasTimer_Tick);
                 SimiasTimer.Start();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(string.Format("Exception: {0}--{1}", ex.Message, ex.StackTrace));
             ShutdownTrayApp(ex);
         }
         finally
         {
             CloseStartupScreen();
         }
        }
 }
示例#2
0
 private void FormsTrayApp_Load(object sender, System.EventArgs e)
 {
     if (shutdown)
        {
     this.Close();
        }
        else
        {
     try
     {
      Environment.CurrentDirectory = Application.StartupPath;
      simiasManager.Start();
      SetWebServiceInformation(simiasManager.WebServiceUri, simiasManager.DataPath);
      ifWebService = new iFolderWebService();
      ifWebService.Url = simiasManager.WebServiceUri + "/iFolder.asmx";
      simiasWebService = new SimiasWebService();
      simiasWebService.Url = simiasManager.WebServiceUri + "/Simias.asmx";
      eventQueue = new Queue();
      workEvent = new AutoResetEvent(false);
      eventClient = new IProcEventClient(new IProcEventError(errorHandler), null);
      eventClient.Register();
      if (!eventError)
      {
       eventClient.SetEvent(IProcEventAction.AddNodeChanged, new IProcEventHandler(trayApp_nodeEventHandler));
       eventClient.SetEvent(IProcEventAction.AddNodeCreated, new IProcEventHandler(trayApp_nodeEventHandler));
       eventClient.SetEvent(IProcEventAction.AddNodeDeleted, new IProcEventHandler(trayApp_nodeEventHandler));
       eventClient.SetEvent(IProcEventAction.AddCollectionSync, new IProcEventHandler(trayApp_collectionSyncHandler));
       eventClient.SetEvent(IProcEventAction.AddFileSync, new IProcEventHandler(trayApp_fileSyncHandler));
       eventClient.SetEvent(IProcEventAction.AddNotifyMessage, new IProcEventHandler(trayApp_notifyMessageHandler));
      }
      preferences = new Preferences(ifWebService, simiasWebService, simiasManager);
      preferences.EnterpriseConnect += new Novell.FormsTrayApp.Preferences.EnterpriseConnectDelegate(preferences_EnterpriseConnect);
      preferences.ChangeDefaultDomain += new Novell.FormsTrayApp.Preferences.ChangeDefaultDomainDelegate(preferences_EnterpriseConnect);
      preferences.RemoveDomain += new Novell.FormsTrayApp.Preferences.RemoveDomainDelegate(preferences_RemoveDomain);
      preferences.ShutdownTrayApp += new Novell.FormsTrayApp.Preferences.ShutdownTrayAppDelegate(preferences_ShutdownTrayApp);
      preferences.UpdateDomain += new Novell.FormsTrayApp.Preferences.UpdateDomainDelegate(preferences_UpdateDomain);
      preferences.CreateControl();
      IntPtr handle = preferences.Handle;
      syncLog = new SyncLog();
      syncLog.CreateControl();
      handle = syncLog.Handle;
      LocalService.Start(simiasWebService, simiasManager.WebServiceUri, simiasManager.DataPath);
      LocalService.Start(ifWebService, simiasManager.WebServiceUri, simiasManager.DataPath);
      simiasRunning = true;
      globalProperties = new GlobalProperties(ifWebService, simiasWebService, eventClient);
      globalProperties.RemoveDomain += new Novell.FormsTrayApp.GlobalProperties.RemoveDomainDelegate(globalProperties_RemoveDomain);
      globalProperties.PreferenceDialog = preferences;
      globalProperties.SyncLogDialog = syncLog;
      globalProperties.CreateControl();
      handle = globalProperties.Handle;
      bool accountPrompt = false;
      try
      {
       globalProperties.InitializeServerList();
       DomainInformation[] domains;
       domains = this.simiasWebService.GetDomains(false);
       foreach(DomainInformation dw in domains)
       {
        try
        {
     if (dw.IsSlave)
     {
      preferences.AddDomainToList(dw);
     }
     globalProperties.AddDomainToList(dw);
     preferences.SetProxyForDomain( dw.HostUrl, false );
        }
        catch {}
       }
       if (domains.Length.Equals(0))
       {
        accountPrompt = true;
       }
      }
      catch {}
      if (worker == null)
      {
       worker = new Thread(new ThreadStart(eventThreadProc));
       worker.Start();
      }
      shellNotifyIcon.Text = resourceManager.GetString("iFolderServices");
      shellNotifyIcon.Icon = trayIcon;
      updateOverlayIcons();
      if (accountPrompt)
      {
       notifyType = NotifyType.CreateAccount;
       shellNotifyIcon.DisplayBalloonTooltip(resourceManager.GetString("createAccountTitle"), resourceManager.GetString("createAccount"), BalloonType.Info);
      }
     }
     catch (Exception ex)
     {
      ShutdownTrayApp(ex);
     }
        }
 }