Log() public method

public Log ( string message ) : void
message string
return void
コード例 #1
0
ファイル: Features.cs プロジェクト: slamj1/win-xenguestagent
 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);
 }
コード例 #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);
        }
コード例 #3
0
 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());
     }
 }
コード例 #4
0
 public void addEvent(string message)
 {
     //Log Information
     wmisession.Log(message);
     el.WriteEntry(message, EventLogEntryType.Information);
 }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
 void handleWorker(object nothing, bool timeout)
 {
     wmisession.Log("Worker process has terminated");
     Stop(true);
 }
コード例 #8
0
        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);
            }
        }
コード例 #9
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(""))
            {
                advert = wmisession.GetXenStoreItem(advertise);
                features.Add(this);

            }
            Disposer.Add(this);
        }
コード例 #10
0
            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;
                }
            }