Log() public méthode

public Log ( string message ) : void
message string
Résultat void
Exemple #1
0
 public Feature(string name, string advertise, string control, bool controlmustexist, IExceptionHandler exceptionhandler)
 {
     this.exceptionhandler = exceptionhandler;
     this.name             = name;
     wmisession            = WmiBase.Singleton.GetXenStoreSession("Citrix Xen Service Feature : " + name);
     wmisession.Log("New Feature");
     controlKey            = wmisession.GetXenStoreItem(control);
     this.controlmustexist = controlmustexist;
     try
     {
         if (controlKey.value != "")
         {
             wmisession.Log("Control key " + control + ":" + controlKey.value);
         }
     }
     catch {}
     enabled  = true;
     listener = controlKey.Watch(new EventArrivedEventHandler(onFeatureWrapper));
     if (!advertise.Equals(""))
     {
         this.addAdvert(advertise);
     }
     Disposer.Add(this);
 }
Exemple #2
0
        void resetTime()
        {
            // We need to use FromFileTime to read the xentime stamp into
            // a DateTime object, .net tries to convert it to local
            // time.  So We read it as UTC, then tell .net its already
            // local.
            long internalxentime = (long)WmiBase.Singleton.XenTime;

            if (internalxentime == 0)
            {
                wmisession.Log("unable to reset clock to xentime");
                return;
            }
            DateTime xentime = DateTime.SpecifyKind(
                DateTime.FromFileTimeUtc(internalxentime),
                System.DateTimeKind.Local);

            wmisession.Log("Xentime = " + xentime.ToString());
            // Then set the time, via the Win32 API
            Win32Impl.SYSTEMTIME systime = new Win32Impl.SYSTEMTIME(xentime);
            Win32Impl.SetSystemTime(ref systime);
        }
 void RunProcess(string name, string arg, string comment)
 {
     try
     {
         Process myProcess = new Process();
         myProcess.StartInfo.UseShellExecute = false;
         myProcess.StartInfo.FileName        = name;
         myProcess.StartInfo.Arguments       = arg;
         myProcess.StartInfo.CreateNoWindow  = true;
         myProcess.Start();
         myProcess.WaitForExit(5000);
     }
     catch (Exception e)
     {
         wmisession.Log("Process: unable to " + comment + "\n" + e.ToString());
     }
 }
 public void addEvent(string message)
 {
     //Log Information
     wmisession.Log(message);
     el.WriteEntry(message, EventLogEntryType.Information);
 }
        void WmiCapableServiceThreadHandler()
        {
            try
            {
                wmisession = WmiBase.Singleton.GetXenStoreSession("Features");

                wmisession.Log("Guest Agent Starting");
                Refresher.Add(new PVInstallation(this));

                wmisession.Log("About to run apps");

                RunProcess("wmiadap","/f","refresh WMI ADAP");
                RunProcess("diskperf", "-y","enable disk perf counters");

                wmisession.Log("About to run features");
                new FeatureLicensed(this);
                new FeatureVSSLicensed(this);
                new FeatureDumpLog(this);
                new FeatureGC(this);
                new FeaturePing(this);
                new FeatureDomainJoin(this);
                new FeatureSetComputerName(this);
                new FeatureXSBatchCommand(this);
                new FeatureAutoUpdate(this);

                wmisession.Log("About to try snapshot");
                if (FeatureSnapshot.IsSnapshotSupported())
                {
                    Refresher.Add(new FeatureSnapshot(this));
                }
                else
                {
                    wmisession.Log("Snapshot not supported on this platform");
                    FeatureSnapshot.removeSnapshot(wmisession);
                }
                new FeatureTerminalServicesReset(this);
                new FeatureTerminalServices(this);
                new FeatureStaticIpSetting(this);
                wmisession.Log("About to add refreshers");

                Refresher.Add(new NetInfo(this));
                Refresher.Add(new VolumeInfo());
                Refresher.Add(new MemoryInfo());
                Refresher.Add(new XenAppSessionInfo());

                wmisession.Log("About to add handlers ");
                clipboardhandler = new ClipboardManager(this);
                Disposer.Add(clipboardhandler);
                clipboardhandler.Run();
                Disposer.Add(WmiBase.Singleton.ListenForEvent("CitrixXenStoreUnsuspendedEvent", new EventArrivedEventHandler(handleUnsuspended)));

                Refresher.RefreshAll(true);
                wmisession.Log("running ");
                Refresher.Run(this);

            }
            catch (Exception e)
            {
                HandleException("Service handler", e);
            }
        }
 public void WorkerProcessFinished()
 {
     try
     {
         workerProcess = null;
         WmiBase.Singleton.DebugMsg("Worker process died");
         if ((lastStartAttempt - DateTime.UtcNow) <
             TimeSpan.FromMilliseconds(restartTime))
         {
             Thread.Sleep(restartTime);
             restartTime = restartTime * 2;
             if (restartTime > 120000)
             {
                 restartTime = 120000;
             }
         }
         else
         {
             restartTime = 1000;
         }
         if (running)
         {
             wmisession.Log("Worker process restarting");
             getConsoleAndSpawn();
         }
     }
     catch (Exception e)
     {
         exceptionhandler.HandleException("Clipboard handle worker", e);
     }
 }
 void handleWorker(object nothing, bool timeout)
 {
     wmisession.Log("Worker process has terminated");
     Stop(true);
 }
        void WmiCapableServiceThreadHandler()
        {
            try
            {
                wmisession = WmiBase.Singleton.GetXenStoreSession("Features");

                wmisession.Log("Guest Agent Starting");
                Refresher.Add(new PVInstallation(this));

                wmisession.Log("About to run apps");

                RunProcess("wmiadap", "/f", "refresh WMI ADAP");
                RunProcess("diskperf", "-y", "enable disk perf counters");


                wmisession.Log("About to run features");
                new FeatureLicensed(this);
                new FeatureVSSLicensed(this);
                new FeatureDumpLog(this);
                new FeatureGC(this);
                new FeaturePing(this);
                new FeatureDomainJoin(this);
                new FeatureSetComputerName(this);
                new FeatureXSBatchCommand(this);
                new FeatureAutoUpdate(this);

                wmisession.Log("About to try snapshot");
                if (FeatureSnapshot.IsSnapshotSupported())
                {
                    Refresher.Add(new FeatureSnapshot(this));
                }
                else
                {
                    wmisession.Log("Snapshot not supported on this platform");
                    FeatureSnapshot.removeSnapshot(wmisession);
                }
                new FeatureTerminalServicesReset(this);
                new FeatureTerminalServices(this);
                new FeatureStaticIpSetting(this);
                wmisession.Log("About to add refreshers");

                Refresher.Add(new NetInfo(this));
                Refresher.Add(new VolumeInfo());
                Refresher.Add(new MemoryInfo());
                Refresher.Add(new XenAppSessionInfo());

                wmisession.Log("About to add handlers ");
                clipboardhandler = new ClipboardManager(this);
                Disposer.Add(clipboardhandler);
                clipboardhandler.Run();
                Disposer.Add(WmiBase.Singleton.ListenForEvent("CitrixXenStoreUnsuspendedEvent", new EventArrivedEventHandler(handleUnsuspended)));

                Refresher.RefreshAll(true);
                wmisession.Log("running ");
                Refresher.Run(this);
            }
            catch (Exception e)
            {
                HandleException("Service handler", e);
            }
        }
        public Feature(string name, string advertise, string control, bool controlmustexist, IExceptionHandler exceptionhandler)
        {
            this.exceptionhandler = exceptionhandler;
            this.name = name;
            wmisession = WmiBase.Singleton.GetXenStoreSession("Citrix Xen Service Feature : " + name);
            wmisession.Log("New Feature");
            controlKey = wmisession.GetXenStoreItem(control);
            this.controlmustexist = controlmustexist;
            try
            {
                if (controlKey.value != "")
                {
                    wmisession.Log("Control key "+control+":"+controlKey.value);
                }
            }
            catch {}
            enabled = true;
            listener = controlKey.Watch(new EventArrivedEventHandler(onFeatureWrapper));
            if (!advertise.Equals(""))
            {
                advert = wmisession.GetXenStoreItem(advertise);
                features.Add(this);

            }
            Disposer.Add(this);
        }
            public WorkerProcess(ClipboardAccess clipboard, WmiSession wmisession, IExceptionHandler exceptionhandler, IWorkerProcessHandler wphandler, IntPtr consoletoken)
            {
                this.clipboard = clipboard;
                this.wmisession = wmisession;
                this.exceptionhandler = exceptionhandler;
                this.wphandler = wphandler;

                workerlock = new object();
                try
                {
                    comms = new CommServer(this);
                }
                catch (Exception e)
                {
                    wmisession.Log("Comms server failed to start:" + e.ToString());
                    throw;
                }
                try
                {
                    string path = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Citrix\\XenTools", "Install_Dir", "");
                    string fullpath = string.Format("{0}\\XenDpriv.exe", path);
                    string cmdline = string.Format("XenDpriv.exe {0}", comms.secret);
                    this.worker = new SafeWaitHandle(Win32Impl.CreateUserProcess(consoletoken, fullpath, cmdline), true);
                    workerWaiter = new ProcessWaitHandle(this.worker);
                    registeredWorkerWaiter = ThreadPool.RegisterWaitForSingleObject(workerWaiter, handleWorker, null, Timeout.Infinite, true);
                    this.workerrunning = true;
                    wmisession.Log("Worker Process spawned");
                }
                catch(Exception e)
                {
                    wmisession.Log("Worker process spawn exception : " + e.ToString());
                    comms.CloseMessagePipes();

                    throw;
                }
            }