Beispiel #1
0
        public void GetStatusTest()
        {
            OdSyncStatusWS sync = new OdSyncStatusWS();

            var status = sync.GetStatus(@"D:\Onedrive\");

            Assert.AreNotEqual(status, ServiceStatus.NotInstalled);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press 'q' to end or any key to reapeat");
            do
            {
                OdSyncStatusWS os = new OdSyncStatusWS();


                var statuses = os.GetStatus();
                Console.WriteLine("======================================================");
                Console.WriteLine();

                foreach (var status in statuses)
                {
                    Console.WriteLine("{2} - Status = {0} Path = {1}", status.StatusString, status.LocalPath, status.ServiceType);
                }
            } while (Console.ReadKey().KeyChar != 'q');

            try
            {
                host = new ServiceHost(typeof(OdSyncService.OdSyncStatusWS));

                Console.WriteLine("Opening service {0}...", host.Description.ServiceType);
                host.Open();
                Console.WriteLine("Service Opened");
                Console.WriteLine();
                Console.WriteLine("Endpoint(s)");
                Console.WriteLine("===========");
                foreach (var endP in host.Description.Endpoints)
                {
                    Console.WriteLine("{0} ({1})", endP.Address, endP.Binding);
                }
                Console.WriteLine();
                Console.Write("Press any key to close the Service...");
                Console.ReadKey();

                //OdSyncStatusWS sync = new OdSyncStatusWS();

                //var statuses = sync.GetStatus(true);
            }
            finally
            {
                if (host != null)
                {
                    host.Close();
                }
            }
        }
Beispiel #3
0
        protected override void ProcessRecord()
        {
            if (!Environment.UserInteractive)
                throw new InvalidOperationException("Non-Interactive mode detected. OneDrive Status can only be checked interactively");
            if (UacHelper.IsProcessElevated)
                throw new InvalidOperationException("PowerShell is running in Administrator mode. OneDrive status cannot be checked in elevated privileges");
            WriteLog.ShouldLog = IncludeLog;
            if (IncludeLog)
                WriteVerbose("Log file is being saved @ "+WriteLog.FileName);
            if (dllPath == null)
            {
                CopyDLL();
            }

            OdSyncStatusWS os = new OdSyncStatusWS();
            List<StatusDetail> statuses = new List<StatusDetail>();

            // Just Get the Path
            if(!String.IsNullOrEmpty(ByPath))
            {
                if(CLSID == Guid.Empty)
                    WriteObject(os.GetStatus(ByPath).ToString());
                else
                {

                    WriteObject(Native.API.IsCertainType(ByPath, CLSID));
                }
                return;
                
            }
            var statusCol = os.GetStatus();
            foreach(var status in statusCol)
            {
                if (String.IsNullOrEmpty(Type) || status.ServiceType.ToLower().Contains(Type.ToLower().Replace("*", "")))
                {
                    if(CLSID != Guid.Empty)
                    {
                        status.StatusString = Native.API.IsCertainType(status.LocalPath, CLSID) ? "GuidFound "+CLSID.ToString("B") : "GuidNotFound " + CLSID.ToString("B");
                    }
                    statuses.Add(status);

                }

            }
            WriteObject(statuses.ToArray());

        }
Beispiel #4
0
        // private bool disposedValue;

        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            if (!Environment.UserInteractive && ParameterSetName != OnDemandString)
            {
                throw new InvalidOperationException("Non-Interactive mode detected. OneDrive Status can only be checked interactively unless -OnDemandOnly is specified");
            }
            if (UacHelper.IsProcessElevated && ParameterSetName != OnDemandString)
            {
                throw new InvalidOperationException("PowerShell is running in Administrator mode. OneDrive status cannot be checked in elevated privileges");
            }
            OdSyncStatusWS.OnDemandOnly = onDemandOnly;
            WriteLog.ShouldLog          = includeLog;
            if (includeLog)
            {
                WriteVerbose("Log file is being saved @ " + WriteLog.FileName);
            }
            if (onDemandOnly)
            {
                WriteVerbose("On Demand Only check");
                WriteLog.WriteInformationEvent("On Demand Only option selected");
            }
            if (showDllPath)
            {
                WriteVerbose("Show DLL folder is enabled");
            }
            if (dllPath == null)
            {
                CopyDLL();
            }

            if (showDllPath)
            {
                Host.UI.WriteLine($"The temporary DLL path is '{Path.Combine(dllPath, dllName)}'");
            }
            OdSyncStatusWS      os       = new OdSyncStatusWS();
            List <StatusDetail> statuses = new List <StatusDetail>();

            // Just Get the Path
            if (!String.IsNullOrEmpty(ByPath))
            {
                WriteLog.WriteInformationEvent($"Path being tested is '{ByPath}'");
                if (CLSID == Guid.Empty)
                {
                    WriteObject(os.GetStatus(ByPath).ToString());
                }
                else
                {
                    WriteObject(Native.API.IsCertainType(ByPath, CLSID));
                }
                return;
            }
            var statusCol = os.GetStatus();

            foreach (var status in statusCol)
            {
                if (String.IsNullOrEmpty(Type) || status.ServiceType.ToLower().Contains(Type.ToLower().Replace("*", "")))
                {
                    WriteLog.WriteInformationEvent($"Guid Type being tested is '{CLSID}'");
                    if (CLSID != Guid.Empty)
                    {
                        status.StatusString = Native.API.IsCertainType(status.LocalPath, CLSID) ? "GuidFound " + CLSID.ToString("B") : "GuidNotFound " + CLSID.ToString("B");
                    }
                    statuses.Add(status);
                }
            }
            WriteObject(statuses.ToArray());
        }