Exemplo n.º 1
0
    public static OperatingSystemInfo GetOperatingSystemInfo(ManagementScope scope)
    {
        OperatingSystemInfo operatingSystemInfo = new OperatingSystemInfo();

        using (ManagementObject managementObject = WMIUtils.QueryFirst(scope, "Select * from Win32_OperatingSystem"))
        {
            string str = managementObject["Version"].ToString();
            if (!string.IsNullOrEmpty(str))
            {
                string[] strArray = str.Split(".".ToCharArray());
                operatingSystemInfo.VersionString = str;
                operatingSystemInfo.Version       = new OperatingSystemVersion()
                {
                    Major = Convert.ToInt32(strArray[0]),
                    Minor = Convert.ToInt32(strArray[1]),
                    Build = Convert.ToInt32(managementObject["BuildNumber"])
                };
            }
            operatingSystemInfo.ServicePack = string.Format("{0}.{1}.0.0", (object)Convert.ToInt32(managementObject["ServicePackMajorVersion"]).ToString(), (object)Convert.ToInt32(managementObject["ServicePackMinorVersion"]).ToString());
            operatingSystemInfo.ProductType = (OperatingSystemProductType)(uint)managementObject["ProductType"];
            if (managementObject["OSProductSuite"] != null)
            {
                operatingSystemInfo.ProductSuite = (int)(uint)managementObject["OSProductSuite"];
            }
            operatingSystemInfo.Architecture = WMIUtils.GetCPUArchitecture(scope, operatingSystemInfo.Version.Major);
        }
        return(operatingSystemInfo);
    }
Exemplo n.º 2
0
    public static string CreateNetShScript(ServerNicInfo[] Nics, OperatingSystemInfo OsInfo, string fileName)
    {
        string str = string.Empty;

        foreach (ServerNicInfo replicaNic in Nics)
        {
            if (NetShUtils.IsNicMapped(replicaNic))
            {
                str = str + "net start >> WAN-Failover-Results.log\r\n" + "ping 127.0.0.1 -n 20 >> WAN-Failover-Results.log\r\n" + "net start >> WAN-Failover-Results.log\r\n" + "netsh interface ip set address \"" + replicaNic.FriendlyName + "\" dhcp >> WAN-Failover-Results.log\r\n" + "netsh interface ip set dns \"" + replicaNic.FriendlyName + "\" dhcp >> WAN-Failover-Results.log\r\n";
                if (replicaNic.IPAddresses != null && replicaNic.IPAddresses.Length != 0)
                {
                    for (int index = 0; index < replicaNic.IPAddresses.Length; ++index)
                    {
                        str += NetShUtils.AddressNetShCmd(index == 0, replicaNic.FriendlyName, replicaNic.IPAddresses[index], replicaNic.IPMasks[index], OsInfo);
                    }
                }
                if (replicaNic.IPGateways != null && replicaNic.IPGateways.Length != 0)
                {
                    for (int index = 0; index < replicaNic.IPGateways.Length; ++index)
                    {
                        str += NetShUtils.GatewayNetShCmd(index == 0, replicaNic.FriendlyName, replicaNic.IPGateways[index], "0", OsInfo);
                    }
                }
                if (replicaNic.DNSAddrs != null && replicaNic.DNSAddrs.Length != 0)
                {
                    for (int index = 0; index < replicaNic.DNSAddrs.Length; ++index)
                    {
                        str += NetShUtils.DnsNetShCmd(index == 0, replicaNic.FriendlyName, replicaNic.DNSAddrs[index], OsInfo);
                    }
                }
            }
        }
        return(str + "ipconfig /registerdns >> WAN-Failover-Results.log\r\n");
    }
Exemplo n.º 3
0
 public void Dispose()
 {
     _abort = true;
     _operatingSystemInfo = null !;
     _globalSystemInfo    = null !;
     _globalSystemInfo    = null !;
 }
Exemplo n.º 4
0
 /// <summary>Clear the values back to defaults</summary>
 public void Clear()
 {
     MachineInfo.Clear();
     OperatingSystemInfo.Clear();
     ApplicationInfo.Clear();
     UserInfo.Clear();
 }
        private static IFolder GetFolder()
        {
            var steamID = string.Empty;

            if (SteamAPI.Init())
            {
                LogManager.WriteLine("SteamAPI.Init() success.");
                steamID = SteamUser.GetSteamID().GetAccountID().ToString();
                SteamAPI.Shutdown();
                LogManager.WriteLine("SteamAPI.Shutdown().");
            }
            else
            {
                LogManager.WriteLine("SteamAPI.Init() failure.");

                switch (OperatingSystemInfo.GetOperatingSystemInfo().OperatingSystemType)
                {
                case OperatingSystemType.Windows:
                    if (Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam\ActiveProcess", "ActiveUser", null) is int userID)
                    {
                        steamID = userID.ToString();
                    }
                    break;

                default:
                    LogManager.WriteLine("Couldn't get Steam data.");
                    break;
                }
            }

            return(string.IsNullOrEmpty(steamID)
                ? (IFolder) new NonExistingFolder("")
                : (IFolder) new SteamUserDataFolder().GetFolder(steamID));
        }
Exemplo n.º 6
0
        public static void DumpSystemInfo()
        {
            OperatingSystemInfo osInfo = OperatingSystemInfo.GetOperatingSystemInfo();

            Console.WriteLine("");
            Console.WriteLine("---------------------------------");
            Console.WriteLine($"OS Name: {osInfo.Name}");
            Console.WriteLine($"Architecture: {osInfo.Architecture}");
            Console.WriteLine($"dotnet RuntimeInformation.FrameworkDescription: {RuntimeInformation.FrameworkDescription}");
            Console.WriteLine("");

            // CPUs
            int idx = 0;

            foreach (CPUInfo cpuInfo in osInfo.Hardware.CPUs)
            {
                Console.WriteLine($"CPU {idx}");
                Console.WriteLine($"   Brand: {cpuInfo.Brand}");
                Console.WriteLine($"   Name: {cpuInfo.Name}");
                Console.WriteLine($"   Architecture: {cpuInfo.Architecture}");
                Console.WriteLine($"   Cores: {cpuInfo.Cores}");
                Console.WriteLine($"   Frequency: {cpuInfo.Frequency}");
                idx++;
            }

            RAMInfo ramInfo = osInfo.Hardware.RAM;

            Console.WriteLine("");
            Console.WriteLine($"RAM {ramInfo.Total:#,###} kilobytes");
            Console.WriteLine("---------------------------------");
            Console.WriteLine("");
        }
Exemplo n.º 7
0
        public static void DumpSystemInfo()
        {
            OperatingSystemInfo osInfo = OperatingSystemInfo.GetOperatingSystemInfo();

            Console.WriteLine("");
            Console.WriteLine("---------------------------------");
            Console.WriteLine($"OS Name: {osInfo.Name}");
            Console.WriteLine($"Architecture: {osInfo.Architecture}");
            Console.WriteLine($".NET Framework: {GetCurrentFrameworkVersionBasedOnWindowsRegistry()} (CLR {osInfo.FrameworkVersion})");
            Console.WriteLine("");

            // CPUs
            int idx = 0;

            foreach (CPUInfo cpuInfo in osInfo.Hardware.CPUs)
            {
                Console.WriteLine($"CPU {idx}");
                Console.WriteLine($"   Brand: {cpuInfo.Brand}");
                Console.WriteLine($"   Name: {cpuInfo.Name}");
                Console.WriteLine($"   Architecture: {cpuInfo.Architecture}");
                Console.WriteLine($"   Cores: {cpuInfo.Cores}");
                Console.WriteLine($"   Frequency: {cpuInfo.Frequency}");
                idx++;
            }

            RAMInfo ramInfo = osInfo.Hardware.RAM;

            Console.WriteLine("");
            Console.WriteLine($"RAM {ramInfo.Total:#,###} kilobytes");
            Console.WriteLine("---------------------------------");
            Console.WriteLine("");
        }
Exemplo n.º 8
0
        public void Delete(ISnapshot sn)
        {
            Logger.Append(Severity.DEBUG, "Deleting snapshot " + sn.Path + " (id " + sn.Id + ")");
            if (!OperatingSystemInfo.IsAtLeast(OSVersionName.WindowsServer2003))
            {
                // Deleting is unnecessary on XP since snaps are non-persistent
                // and automatically released on Disposing VSS objects.
                return;
            }


            try{
                IVssImplementation vssi = VssUtils.LoadImplementation();
                using (IVssBackupComponents oVSS = vssi.CreateVssBackupComponents()){
                    oVSS.InitializeForBackup(null);
                    oVSS.SetContext(VssSnapshotContext.All);
                    oVSS.DeleteSnapshot(sn.Id, true);
                }

                Logger.Append(Severity.INFO, "Deleted snapshot " + sn.Path + " (id " + sn.Id + ")");
            }
            catch (Exception vsse) {
                Logger.Append(Severity.WARNING, "Unable to delete snapshot " + sn.Path + " (id " + sn.Id + "): " + vsse.Message);
                //backup.Dispose();
                throw vsse;
            }
        }
Exemplo n.º 9
0
        public void ResolverMatchesOsInfo()
        {
            var resolver   = new OperatingSystemResolver();
            var detectedOS = resolver.Detect();
            var osInfo     = new OperatingSystemInfo();

            Assert.Equal(detectedOS, osInfo.Platform);
        }
Exemplo n.º 10
0
 public static bool IsWin2K8R2(OperatingSystemInfo osInfo)
 {
     if (osInfo.Version.Major == 6)
     {
         return(osInfo.Version.Minor == 1);
     }
     return(false);
 }
Exemplo n.º 11
0
        public void BasicTest()
        {
            var osInfo = new OperatingSystemInfo();

            Assert.NotEmpty(osInfo.Version);
            Assert.NotEmpty(osInfo.Name);
            Assert.NotEmpty(osInfo.Build);
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            Console.WriteLine(OperatingSystemInfo.Get().ToString());
            DSSwitch.NiceApiLibrary_StartUp(s_Log, true);
            s_Log.logSQL = true;

            bool     go   = true;
            Question ques = new Question();

            ques.Add(new QuestionOption("Email templates", EmailTemplates.Go));
            ques.Add(new QuestionOption("Add Tel# to free account...", NumberManager.AddToFree));
            ques.Add(new QuestionOption("Add Tel# to COMMERCIAL account...", NumberManager.Manager));
            ques.Add(new QuestionOption("Get Credit", WhatsappMessages.CheckCredit));
            ques.Add(new QuestionOption("EmailFromAPpiKey", Tests.EmailFromAPpiKey));

            // ques.Add(new QuestionOption("Send Moved emails", ); rrt//SendMovedEmail.Go(s_LogZap); break;
            //ques.Add(new QuestionOption("Send Nice test mail", SendNiceTestMail.Go));
            ques.Add(new QuestionOption("show Lib Version", Others.LibVersion));
            //            ques.Add(new QuestionOption("Just a log message", Others.JustALogMessage));
            ques.Add(new QuestionOption("Send Whatsapp messages...", WhatsappMessages.Go));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys01", WhatsappMessages.GoSys01));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys02", WhatsappMessages.GoSys02));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys03", WhatsappMessages.GoSys03));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys03 group", WhatsappMessages.GoSys03group));
            ques.Add(new QuestionOption("Send Whatsapp messages Sys04", WhatsappMessages.GoSys04));
            ques.Add(new QuestionOption("Send Whatsapp messages SysTest", WhatsappMessages.GoSysTest));
            //            ques.Add(new QuestionOption("Send ANY email", SendEmail.All));
            ques.Add(new QuestionOption("Show Logs", ShowLogs.Go));
            //ques.Add(new QuestionOption("Test SQL Copy", SQLCopy.Go));
            ques.Add(new QuestionOption("IIS Log All (dataLogger output)", IISLog.All));
            ques.Add(new QuestionOption("IIS Log Day Sum (dataLogger output)", IISLog.DaySummary));
            ques.Add(new QuestionOption("Tel# Analyser", TelNumberAnalyser.Analyse));
//            ques.Add(new QuestionOption("Test commercial code changes", CommercialCodeChange.Test));
            //ques.Add(new QuestionOption("Send Tel Check...", NumberManager.SendTelCheck));
            //ques.Add(new QuestionOption("Send Tel Sync (Dangerous)...", NumberManager.SendTelSync));
            ques.Add(new QuestionOption("Show Data_MessageFile content ...", ShowData_MessageFileContent.ShowAll));
            ques.Add(new QuestionOption("Get new APIId ...", Others.GetNewAPIId));
            //ques.Add(new QuestionOption("Test LibAPI...", Tests.LibAPI));
            ques.Add(new QuestionOption("Show Wallet contents", ShowWallet.Go));
            ques.Add(new QuestionOption("Ftp backup", FtpBackup.Go));
//            ques.Add(new QuestionOption("Sql Tester", SqlTesterForm.Show));
            ques.Add(new QuestionOption("Set LowLevelHttpDumping", delegate(IMyLog log, QuestionOption it) { LowLevelHttpDumper.Enabled = true; }));
            //ques.Add(new QuestionOption("500 Error Test", WhatsappMessages.Error500));
            //            ques.Add(new QuestionOption("Tests.TestQueuePriority", Tests.TestQueuePriority));
            //ques.Add(new QuestionOption("MultySystem Debug", Tests.MultySystemDebugs));
            //ques.Add(new QuestionOption("cUrl Command", cUrl_Command.Go));
            //ques.Add(new QuestionOption("Debug Loopback process...", Tests.DebugLoopback));
            //ques.Add(new QuestionOption("Debug DisplayTextControllerPart_MultiLine", Tests.DebugDisplayTextControllerPart_MultiLine));
            //ques.Add(new QuestionOption("Debug Android Sync in low lib", Tests.DebugAndroidSyncInLowLib));
            //ques.Add(new QuestionOption("Debug Debug_DirectTel", Tests.Debug_DirectTel));



            while (go)
            {
                ques.AskAndAct("What to do (SQLite Version", s_Log);
            }
        }
Exemplo n.º 13
0
 public static void GetOperatingSystemInfo(ManagementScope scope, ref OperatingSystemInfo OsInfo, ref string systemPath, ref string systemVolume)
 {
     OsInfo = WMIUtils.GetOperatingSystemInfo(scope);
     using (ManagementObject managementObject = WMIUtils.QueryFirst(scope, "Select * from Win32_OperatingSystem"))
     {
         systemPath   = managementObject["SystemDirectory"].ToString().Replace("\\system32", "");
         systemVolume = systemPath.Substring(0, 2);
     }
 }
Exemplo n.º 14
0
        private void OnMachineInfoRequest(INetworkConnection con, Packet packet)
        {
            bool cpu, gpu, drives, mainboard, os, ram;

            cpu = gpu = drives = mainboard = os = ram = false;

            PacketGenericMessage m = packet as PacketGenericMessage;

            m.ReplyPacket = CreateStandardReply(packet, ReplyType.OK, "");

            if (m.Parms.GetBoolProperty("cpu").GetValueOrDefault(false))
            {
                cpu = true;
                CPUInfo ci = MachineInfo.ReadCPUInfo();
                m.ReplyPacket.Parms.SetProperty("cpu", ci.ToString());
            }
            if (m.Parms.GetBoolProperty("gpu").GetValueOrDefault(false))
            {
                gpu = true;
                VideoCardInfo gi = MachineInfo.ReadGPUInfo();
                m.ReplyPacket.Parms.SetProperty("gpu", gi.ToString());
            }
            if (m.Parms.GetBoolProperty("drives").GetValueOrDefault(false))
            {
                drives = true;
                PatcherLib.DriveInfo di = MachineInfo.ReadLogicalDiskInfo();
                m.ReplyPacket.Parms.SetProperty("drives", di.ToString());
            }
            if (m.Parms.GetBoolProperty("mainboard").GetValueOrDefault(false))
            {
                mainboard = true;
                MotherboardInfo mi = MachineInfo.ReadMotherboardInfo();
                m.ReplyPacket.Parms.SetProperty("mainboard", mi.ToString());
            }
            if (m.Parms.GetBoolProperty("os").GetValueOrDefault(false))
            {
                os = true;
                OperatingSystemInfo osr = MachineInfo.ReadOperatingSystemInfo();
                m.ReplyPacket.Parms.SetProperty("os", osr.ToString());
            }
            if (m.Parms.GetBoolProperty("ram").GetValueOrDefault(false))
            {
                ram = true;
                RamInfo ri = MachineInfo.ReadRAMInfo();
                m.ReplyPacket.Parms.SetProperty("ram", ri.ToString());
            }

            if (MachineInfoRequestArrived != null)
            {
                MachineInfoRequestArrived(cpu, gpu, mainboard, drives, os, ram);
            }
        }
Exemplo n.º 15
0
        public frmQuickUpload()
        {
            Client.form_QuickUpload     = this;
            encoder_params_jpg.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 95L);

            ImageCodecInfo[] images = ImageCodecInfo.GetImageDecoders();

            // Get all the codecs for encoding the images.
            foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders())
            {
                if (codec.MimeType == "image/jpeg")
                {
                    codec_jpeg = codec;
                }
            }

            InitializeComponent();

            _panDropUpload.Height  = 0;
            _panDropUpload.Visible = true;

            // Immediately hide the confirmation row.
            _tlpUploadTable.RowStyles[1].Height = 0;
            _panConfirmUpload.Visible           = false;

            // Make the form load the previous saved height if there is any.
            int saved_win_height = Client.config.get <int>("frmquickupload.window.height");

            this.Height = (saved_win_height == 0) ? this.Height : saved_win_height;

            // Make sure the form is the correct size.  Windows XP's form widths are less than 7's.
            OperatingSystemInfo osi = Utilities.getOSInfo();

            if (osi.os.Contains("XP"))
            {
                Size min_size = new Size()
                {
                    Height = this.MinimumSize.Height - 8,
                    Width  = this.MinimumSize.Width - 8
                };

                Size max_size = new Size()
                {
                    Height = this.MaximumSize.Height - 8,
                    Width  = this.MaximumSize.Width - 8
                };

                this.MinimumSize = min_size;
                this.MaximumSize = max_size;
                this.Size        = min_size;
            }
        }
Exemplo n.º 16
0
 public static bool ClusterIsPathOnSharedVolume(IUIHost host, string path)
 {
     if (OperatingSystemInfo.IsAtLeast(OSVersionName.Windows7))
     {
         host.WriteVerbose("- Calling ClusterIsPathOnSharedVolume(\"{0}\")...", path);
         return(NativeMethods.ClusterIsPathOnSharedVolume(path));
     }
     else
     {
         host.WriteVerbose("- Skipping call to ClusterIsPathOnSharedVolume; function does not exist on this OS.");
         return(false);
     }
 }
Exemplo n.º 17
0
    public static VolumeInfo[] GetVolumes(ManagementScope scope)
    {
        ObjectQuery         query          = new ObjectQuery("Select * from Win32_LogicalDisk");
        List <VolumeInfo>   volumeInfoList = new List <VolumeInfo>();
        OperatingSystemInfo OsInfo         = (OperatingSystemInfo)null;
        string empty1 = string.Empty;
        string empty2 = string.Empty;

        WMIUtils.GetOperatingSystemInfo(scope, ref OsInfo, ref empty1, ref empty2);
        using (ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher(scope, query))
        {
            using (ManagementObjectCollection objectCollection = managementObjectSearcher.Get())
            {
                foreach (ManagementObject managementObject in objectCollection)
                {
                    try
                    {
                        uint num1 = (uint)managementObject["DriveType"];
                        if ((int)num1 == 3)
                        {
                            string str1 = managementObject["Name"].ToString();
                            string str2 = managementObject["FileSystem"].ToString();
                            if (!string.IsNullOrEmpty(str1))
                            {
                                if (!string.IsNullOrEmpty(str2))
                                {
                                    VolumeInfo volumeInfo1 = new VolumeInfo();
                                    volumeInfo1.DriveLetter = str1.Replace(":", "");
                                    volumeInfo1.Format      = str2;
                                    volumeInfo1.Label       = managementObject["VolumeName"].ToString();
                                    volumeInfo1.DiskSizeMB  = (long)((ulong)managementObject["Size"] / 1048576UL);
                                    volumeInfo1.FreeSpaceMB = (long)((ulong)managementObject["FreeSpace"] / 1048576UL);
                                    volumeInfo1.DriveType   = (int)num1;
                                    int num2 = empty2.StartsWith(str1) ? 1 : 0;
                                    volumeInfo1.IsSystemVolume = num2 != 0;
                                    VolumeInfo volumeInfo2 = volumeInfo1;
                                    volumeInfo2.UsedSpaceMB = volumeInfo2.DiskSizeMB - volumeInfo2.FreeSpaceMB;
                                    volumeInfoList.Add(volumeInfo2);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }
        return(volumeInfoList.ToArray());
    }
Exemplo n.º 18
0
    public static string GetGuestOS(OperatingSystemInfo osInfo)
    {
        string str = (string)null;

        if (5 == osInfo.Version.Major)
        {
            str = osInfo.Version.Minor != 0 ? (1 != osInfo.Version.Minor ? ((osInfo.ProductSuite & 2) != 2 ? (osInfo.Architecture != OperatingSystemArchitecture.x86 ? (osInfo.Architecture != OperatingSystemArchitecture.x64 ? "NotSupported" : "winNetStandard64Guest") : "winNetStandardGuest") : (osInfo.Architecture != OperatingSystemArchitecture.x86 ? (osInfo.Architecture != OperatingSystemArchitecture.x64 ? "NotSupported" : "winNetEnterprise64Guest") : "winNetEnterpriseGuest")) : (osInfo.Architecture != OperatingSystemArchitecture.x86 ? (osInfo.Architecture != OperatingSystemArchitecture.x64 ? "NotSupported" : "winXPPro64Guest") : "winXPProGuest")) : ((osInfo.ProductSuite & 2) != 2 ? "win2000ServGuest" : "win2000AdvServGuest");
        }
        else if (6 == osInfo.Version.Major)
        {
            str = osInfo.Version.Minor != 0 ? (1 != osInfo.Version.Minor ? (osInfo.ProductType != OperatingSystemProductType.Workstation ? (osInfo.Architecture != OperatingSystemArchitecture.x64 ? "NotSupported" : "windows8Server64Guest") : (osInfo.Architecture != OperatingSystemArchitecture.x86 ? (osInfo.Architecture != OperatingSystemArchitecture.x64 ? "NotSupported" : "windows8_64Guest") : "windows8Guest")) : (osInfo.ProductType != OperatingSystemProductType.Workstation ? (osInfo.Architecture != OperatingSystemArchitecture.x64 ? "NotSupported" : "windows7Server64Guest") : (osInfo.Architecture != OperatingSystemArchitecture.x86 ? (osInfo.Architecture != OperatingSystemArchitecture.x64 ? "NotSupported" : "windows7_64Guest") : "windows7Guest"))) : (osInfo.ProductType != OperatingSystemProductType.Workstation ? (osInfo.Architecture != OperatingSystemArchitecture.x86 ? (osInfo.Architecture != OperatingSystemArchitecture.x64 ? "NotSupported" : "winLonghorn64Guest") : "winLonghornGuest") : (osInfo.Architecture != OperatingSystemArchitecture.x86 ? (osInfo.Architecture != OperatingSystemArchitecture.x64 ? "NotSupported" : "winVista64Guest") : "winVistaGuest"));
        }
        return(str);
    }
Exemplo n.º 19
0
Arquivo: VSS.cs Projeto: radtek/BackO
        public VSS(BackupLevel level)
        {
            this.RestorePosition    = RestoreOrder.AfterStorage;
            this.ExplodedComponents = new List <string>();
            Metadata  = new SPOMetadata();
            BasePaths = new List <BasePath>();
            IVssImplementation vss = VssUtils.LoadImplementation();

            backup = vss.CreateVssBackupComponents();
            //Logger.Append(Severity.DEBUG, "0/6 Initializing Snapshot ("+ ((BasePaths == null)? "NON-component mode" : "component mode")+")");
            backup.InitializeForBackup(null);
            VssBackupType vssLevel = VssBackupType.Full;

            if (level == BackupLevel.Full)
            {
                vssLevel = VssBackupType.Full;
            }
            else if (level == BackupLevel.Refresh)
            {
                vssLevel = VssBackupType.Incremental;
            }

            /*	else if (level == BackupLevel.Differential)
             *                      vssLevel = VssBackupType.Differential;*/
            else if (level == BackupLevel.TransactionLog)
            {
                vssLevel = VssBackupType.Log;
            }
            //if(spoPaths == null) // component-less snapshot set
            //		backup.SetBackupState(false, true, VssBackupType.Full, false);
            //else
            backup.SetBackupState(true, true, vssLevel, false);
            if (OperatingSystemInfo.IsAtLeast(OSVersionName.WindowsServer2003))
            {
                // The only context supported on Windows XP is VssSnapshotContext.Backup
                backup.SetContext(VssSnapshotContext.AppRollback);
            }
            //Logger.Append(Severity.DEBUG, "1/6 Gathering writers metadata and status");
            using (IVssAsync async = backup.GatherWriterMetadata()){
                async.Wait();
                async.Dispose();
            }
            // gather writers status before adding backup set components
            using (IVssAsync async = backup.GatherWriterStatus()){
                async.Wait();
                async.Dispose();
            }
        }
Exemplo n.º 20
0
        private static IFolder GetFolder()
        {
            if (Settings.Default.RunFactorioViaSteam)
            {
                if (SteamAPI.Init())
                {
                    LogManager.WriteLine("SteamAPI.Init() success.");
                    SteamAppList.GetAppInstallDir(new AppId_t(427520), out var factorioInstallPath, 260);
                    SteamAPI.Shutdown();
                    LogManager.WriteLine("SteamAPI.Shutdown().");
                    return(new FolderFromPath(factorioInstallPath));
                }
                else
                {
                    LogManager.WriteLine("SteamAPI.Init() failure.");

                    switch (OperatingSystemInfo.GetOperatingSystemInfo().OperatingSystemType)
                    {
                    case OperatingSystemType.Windows:
                        if (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 427520", "InstallLocation", null) is string path)
                        {
                            return(new FolderFromPath(path));
                        }
                        break;

                    default:
                        LogManager.WriteLine("Couldn't get Steam data.");
                        break;
                    }
                }
            }
            else
            {
                switch (OperatingSystemInfo.GetOperatingSystemInfo().OperatingSystemType)
                {
                case OperatingSystemType.Windows:
                    if (Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Factorio_is1", "InstallLocation", null) is string path)
                    {
                        return(new FolderFromPath(path));
                    }
                    break;
                }

                return(new FolderFromPath(Settings.Default.FactorioNonSteamFolderPath));
            }

            return(new NonExistingFolder(""));
        }
Exemplo n.º 21
0
        public frmLogin()
        {
            Client.form_Login = this;
            connector         = new ServerConnector(this);

            InitializeComponent();

            tween_image_height      = new Tween(_picLogo, "Height", dtxCore.EasingEquations.expoEaseOut);
            _picLogo.LoadCompleted += new AsyncCompletedEventHandler(_picLogo_LoadCompleted);

            // Threading
            loadLogoWorker.DoWork             += new DoWorkEventHandler(loadLogoWorker_DoWork);
            loadLogoWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(loadLogoWorker_RunWorkerCompleted);

            // Add the native context menu.
            _notifyIcon.ContextMenu = _contextMenu;

            // Make sure the form is the correct size.  Windows XP's form widths are less than 7's.
            OperatingSystemInfo osi = Utilities.getOSInfo();

            if (osi.os.Contains("XP"))
            {
                Size min_size = new Size()
                {
                    Height = this.MinimumSize.Height - 8,
                    Width  = this.MinimumSize.Width - 8
                };

                Size max_size = new Size()
                {
                    Height = this.MaximumSize.Height - 8,
                    Width  = this.MaximumSize.Width - 8
                };

                this.MinimumSize = min_size;
                this.MaximumSize = max_size;
                this.Size        = min_size;
            }

            // Timer to ensure the session does not expire.
            ping_timer.Enabled  = false;
            ping_timer.Tick    += new EventHandler(ping_timer_Tick);
            ping_timer.Interval = 1000 * 30;             // 20 seconds.


            frmLogin_Activated(new object(), new EventArgs());
        }
Exemplo n.º 22
0
        public override void Deserialize(BitReader reader)
        {
            Username = reader.ReadString(wide: true);

            Password = reader.ReadString(42, true);

            ComLang = reader.Read <ushort>();

            Platform = (PlatformType)reader.Read <byte>();

            MemoryInfo = reader.ReadString(256, true);

            GraphicsDriverInfo = reader.ReadString(128, true);

            Processor = reader.Read <ProcessorInfo>();

            OperatingSystem = new OperatingSystemInfo();
            OperatingSystem.Deserialize(reader);
        }
Exemplo n.º 23
0
        public override bool CollectReportData()
        {
            Boolean result = false;

            try
            {
                // productInfoItems.Clear();



                //List<String> test = InputConnectionInfo.DatabaseFields;

                foreach (ManagementObject mo in searcher.Get().AsParallel())
                {
                    OperatingSystemInfo productInfo = new OperatingSystemInfo()
                    {
                    };
                    foreach (String itemProp in InputConnectionInfo.WMIFields)
                    {
                        productInfo.GetType().GetProperty(itemProp).SetValue(productInfo, (WMIQueryBuilder.GetValue(mo, itemProp)), null);
                    }
                    productInfo.TimeStamp  = InputConnectionInfo.TimeStamp;
                    productInfo.SystemName = MachineDetails.ServerName;
                    UpdateStatus(productInfo.Name);
                    productInfoItems.Add(productInfo);
                    if (IsCancelRequested)
                    {
                        break;
                    }
                }

                result = true;
            }
            catch (Exception ex)
            {
                AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error);
            }

            return(result);
        }
Exemplo n.º 24
0
        private static IFolder GetFolder()
        {
            var steamProcess = System.Array.Find(Process.GetProcessesByName("steam"), p => p.MainModule.FileVersionInfo.CompanyName.Equals("Valve Corporation") && p.MainModule.FileVersionInfo.ProductName.Equals("Steam Client Bootstrapper"));

            if (steamProcess != null)
            {
                return(new FolderFromPath(System.IO.Path.GetDirectoryName(steamProcess.MainModule.FileName)));
            }

            switch (OperatingSystemInfo.GetOperatingSystemInfo().OperatingSystemType)
            {
            case OperatingSystemType.Windows:
                return(Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam", "SteamPath", null) is string steamPath
                        ? (IFolder) new FolderFromPath(steamPath)
                        : (IFolder) new NonExistingFolder(""));

            default:
                LogManager.WriteLine("Couldn't get Steam folder.");
                break;
            }

            return(new NonExistingFolder(""));
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            IVssImplementation vssImplementation = VssUtils.LoadImplementation();

            using (IVssBackupComponents backup = vssImplementation.CreateVssBackupComponents())
            {
                backup.InitializeForBackup(null);

                if (OperatingSystemInfo.IsAtLeast(OSVersionName.WindowsServer2003))
                {
                    // This does not work on Windows XP, since the only context supported
                    // on Windows XP is VssSnapshotContext.Backup which is the default.
                    backup.SetContext(VssSnapshotContext.All);
                }

                foreach (VssSnapshotProperties prop in backup.QuerySnapshots())
                {
                    Console.WriteLine("Snapshot ID: {0:B}", prop.SnapshotId);
                    Console.WriteLine("Snapshot Set ID: {0:B}", prop.SnapshotSetId);
                    Console.WriteLine("Original Volume Name: {0}", prop.OriginalVolumeName);
                    Console.WriteLine();
                }
            }
        }
Exemplo n.º 26
0
        private void GetInfo()
        {
            ushort i = 0;
            ushort j = 0;

            while (true)
            {
                if (_abort)
                {
                    break;
                }

                i++;
                j++;
                if (ushort.MaxValue - i < 100)
                {
                    i = 0;
                }

                if (ushort.MaxValue - j < 100)
                {
                    j = 0;
                }

                lock (_lockObj)
                {
                    if ((j % 10 == 0 || j == 1)) //10秒更新一次内存情况
                    {
                        _operatingSystemInfo         = null !;
                        _operatingSystemInfo         = OperatingSystemInfo.GetOperatingSystemInfo();
                        _operatingSystemType         = _operatingSystemInfo.OperatingSystemType;
                        _globalSystemInfo.MemoryInfo = getMeminfo();
                    }

                    if (i % 120 == 0 || i == 1) //2分钟更新一次硬盘情况
                    {
                        _globalSystemInfo.DriveInfo = DiskInfoValue.GetDrivesInfo();
                    }

                    switch (_operatingSystemType)
                    {
                    case OperatingSystemType.Windows:
                        _globalSystemInfo.CpuLoad     = CPUWinLoadValue.CPULOAD;
                        _globalSystemInfo.NetWorkStat = NetWorkWinValue3.GetNetworkStat();
                        break;

                    case OperatingSystemType.MacOSX:
                        _globalSystemInfo.CpuLoad     = CPUMacOSLoadValue.CPULOAD;
                        _globalSystemInfo.NetWorkStat = NetWorkMacValue.GetNetworkStat();
                        break;

                    case OperatingSystemType.Linux:
                        _globalSystemInfo.CpuLoad     = CPULinuxLoadValue.CPULOAD;
                        _globalSystemInfo.NetWorkStat = NetWorkLinuxValue.GetNetworkStat();
                        break;
                    }

                    _globalSystemInfo.UpdateTime = DateTime.Now;
                }

                Thread.Sleep(1000);
            }
        }
Exemplo n.º 27
0
 public Environment()
 {
     OSVersion = new OperatingSystemInfo();
 }
Exemplo n.º 28
0
        internal static void StartUp(IMyLog _log, bool waitUntilStartupIsDone)
        {
            maintenanceLog = new MyMemoryLog();

            IMyLog log = new MyManyLog(new List <IMyLog>()
            {
                maintenanceLog, _log
            });

            log.Info("DSSwitch.StartUp");
            System.Reflection.Assembly.GetAssembly(typeof(IMyLog)).GetAssemblyVersion().ToList().ForEach(_ => log.Debug(_));

            ManualResetEvent bgDone = new ManualResetEvent(false);

            Thread bg = new Thread(
                delegate()
            {
                try
                {
                    log.Debug("This is the startup background thread.");
                    log.Debug(OperatingSystemInfo.Get().ToString());
                    log.Debug(System.Reflection.Assembly.GetExecutingAssembly().Location);
                    log.Debug(log.GetLoggerInfo());
                    log.Debug("Reading instruction file");
                    string instruction = "IniAndRunFile";
                    try
                    {
                        //instruction =
                        //    File.ReadAllText(
                        //        FolderNames.GetFolder(MyFolders.ASP_ServerStateFolder) + "\\StartupInstruction.txt")
                        //        .Trim()
                        //        .Replace("\r", "")
                        //        .Replace("\n", "")
                        //        .Replace("\t", "")
                        //        .Replace(" ", "");
                    }
                    catch (SystemException)
                    {
                        log.Error("Unable to read instruction file, using default values.");
                    }
                    log.Debug("=> " + instruction);
                    foreach (string i1 in instruction.Split(new char[] { ',' }))
                    {
                        log.Debug("-> " + i1);
                        switch (i1)
                        {
                        case "Wait":
                            try
                            {
                                log.Debug("Waiting...");
                                Thread.Sleep(5000);
                                log.Debug("Waiting done");
                            }
                            catch (Exception ex)
                            {
                                log.Error(ex.ToString());
                            }
                            break;

                        //case "SQLiteLogFilename":
                        //    try
                        //    {
                        //        log.Debug(FolderNames.GetFolder(MyFolders.sqlite_All));
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        //case "SQLiteTestStartup":
                        //    try
                        //    {
                        //        log.Debug(TestStartUp());
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        //case "SQLiteExists":
                        //    try
                        //    {
                        //        if (File.Exists(FolderNames.GetFolder(MyFolders.sqlite_All)))
                        //        {
                        //            log.Info("SQLite is there.");
                        //        }
                        //        else
                        //        {
                        //            log.Info("SQLite is NOT there.");
                        //        }
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        //case "CopyToSQLiteIfNotExist":
                        //    try
                        //    {
                        //        if (File.Exists(FolderNames.GetFolder(MyFolders.sqlite_All)))
                        //        {
                        //            log.Info("SQLite is there. So nothing to copy");
                        //        }
                        //        else
                        //        {
                        //            if (sqLiteConnectionHolder.StartUp(log))
                        //            {
                        //                File2DbConverter.Convert(true, log);
                        //            }
                        //        }
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        //case "IniAndRunSQLite":
                        //    try
                        //    {
                        //        if (sqLiteConnectionHolder.StartUp(log))
                        //        {
                        //            appUser_SQLite = new Data_AppUserFileHandling_SQLite(log);
                        //            appWallet_SQLite = new Data_AppUserWalletHandling_SQLite(log);
                        //            sql_SQLite = new Data_SqlHandling_SQLite(log);
                        //            msg00_SQLite = new Data_Net__00NormalMessage_SQLite(log);
                        //            msg02_SQLite = new Data_Net__02ScreenshotRequest_SQLite(log);
                        //            msg04_SQLite = new Data_Net__04CheckTelNumbers_SQLite(log);
                        //            ChangeDataSource(eDataSource.SQLite);
                        //            underMaintenance = false;
                        //            log.Info("Startup.Running");
                        //        }
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        log.Error(ex.ToString());
                        //    }
                        //    break;

                        case "IniAndRunFile":
                            try
                            {
                                _data_Full = new DataFull_File();

                                var ini = _data_Full.GetSystems(true);


                                //appUser_File = new Data_AppUserFileHandling_File();
                                //appWallet_File = new Data_AppUserWalletHandling_File();
                                //sql_File = new Data_SqlHandling_File();
                                //msg00_File = new Data_Net__00NormalMessage_File();
                                //msg02_File = new Data_Net__02ScreenshotRequest_File();
                                //msg04_File = new Data_Net__04CheckTelNumbers_File();
                                //ChangeDataSource(eDataSource.File);
                                underMaintenance = false;
                                log.Info("Startup.Running");
                            }
                            catch (Exception ex)
                            {
                                log.Error(ex.ToString());
                            }
                            break;

                        default:
                            log.Error("instruction not recognised");
                            break;
                        }
                    }
                }
                catch (SystemException se)
                {
                    log.Error(se.Message);
                }
                bgDone.Set();
            });

            bg.Start();

            if (waitUntilStartupIsDone)
            {
                bgDone.WaitOne();
            }
            log.Info("DSSwitch.StartUp done");
        }
Exemplo n.º 29
0
Arquivo: VSS.cs Projeto: radtek/BackO
        public void SetItems(List <string> spoPaths)
        {
            foreach (IVssExamineWriterMetadata writer in backup.WriterMetadata)
            {
                foreach (string spo in spoPaths)
                {
                    try{
                        Logger.Append(Severity.TRIVIA, "Searching writer and/or component matching " + spo + ", current writer=" + writer.InstanceName);
                        int index = spo.IndexOf(writer.WriterName);
                        if (index < 0 && spo != "*")
                        {
                            continue;
                        }
                        bool found = false;

                        // First we check that the writer's status is OK, else we don't add it to avoid failure of complete snapshot if it's not
                        bool writerOk = false;
                        foreach (VssWriterStatusInfo status in backup.WriterStatus)
                        {
                            if (status.Name == writer.WriterName)
                            {
                                if (status.State == VssWriterState.Stable)
                                {
                                    // if we get there it means that we are ready to add the wanted component to VSS set
                                    writerOk = true;
                                    Metadata.Metadata.Add(writer.WriterName, writer.SaveAsXml());
                                }
                                else
                                {
                                    Logger.Append(Severity.ERROR, "***Cannot add writer " + status.Name + " to snapshot set,"
                                                  + " status=" + status.State.ToString() + ". Backup data  managed by this writer may not be consistent. Restore will be hazardous.");
                                    if (OperatingSystemInfo.IsAtLeast(OSVersionName.WindowsServer2003))
                                    {
                                        backup.DisableWriterClasses(new Guid[] { writer.WriterId });
                                    }
                                }
                            }
                        }

                        bool addAllComponents = false;
                        if (spo.Length == index + writer.WriterName.Length || spo == "*" || spo == "" + writer.WriterName + @"\*")
                        {
                            addAllComponents = true;
                        }
                        // exclude items indicated by writer
                        foreach (VssWMFileDescription file in writer.ExcludeFiles)
                        {
                            BasePath bp = new BasePath();
                            bp.Type = "FS";
                            bp.Path = file.Path;
                            bp.ExcludePolicy.Add(file.FileSpecification);
                            //bp.ExcludedPaths = writer.E
                            bp.Recursive = file.IsRecursive;
                            BasePaths.Add(bp);
                        }
                        foreach (IVssWMComponent component in writer.Components)
                        {
                            found = false;
                            Console.WriteLine("***createvolsnapshot : current component is :" + component.LogicalPath + @"\" + component.ComponentName);
                            if ((!addAllComponents) && spo.IndexOf(component.LogicalPath + @"\" + component.ComponentName) < 0)
                            {
                                continue;
                            }
                            Logger.Append(Severity.TRIVIA, "***Asked to recursively select all '" + writer.WriterName + "' writer's components");
                            if (OperatingSystemInfo.IsAtLeast(OSVersionName.WindowsServer2003))
                            {
                                foreach (VssWMDependency dep in  component.Dependencies)
                                {
                                    Logger.Append(Severity.TRIVIA, "***Component " + component.ComponentName + " depends on component " + dep.ComponentName + " TODO TODO TODO add it automatically");
                                }
                            }
                            if (component.Selectable)
                            {
                                backup.AddComponent(writer.InstanceId, writer.WriterId, component.Type, component.LogicalPath, component.ComponentName);
                            }
                            //Logger.Append (Severity.INFO, "***Added writer '"+writer.WriterName+"' component "+component.ComponentName);
                            this.ExplodedComponents.Add(writer.WriterName + @"\" + component.LogicalPath + @"\" + component.ComponentName);
                            found = true;

                            // Second we need to find every drive containing files necessary for writer's backup
                            // and add them to drives list, in case they weren't explicitely selected as part of backuppaths
                            List <VssWMFileDescription> componentFiles = new List <VssWMFileDescription>();
                            componentFiles.AddRange(component.Files);
                            componentFiles.AddRange(component.DatabaseFiles);
                            componentFiles.AddRange(component.DatabaseLogFiles);
                            foreach (VssWMFileDescription file in componentFiles)
                            {
                                if (string.IsNullOrEmpty(file.Path))
                                {
                                    continue;
                                }
                                //Console.WriteLine ("***component file path="+file.Path+", alt backuplocation="+file.AlternateLocation
                                //	+", backuptypemask="+file.BackupTypeMask.ToString()+", spec="+file.FileSpecification+", recursive="+file.IsRecursive);
                                BasePath bp = new BasePath();
                                bp.Path = file.Path;
                                bp.Type = "FS";                         //BasePath.PathType.FS;
                                bp.IncludePolicy.Add(file.FileSpecification);
                                bp.Recursive = file.IsRecursive;
                                BasePaths.Add(bp);
                            }

                            //backup.SetBackupSucceeded(writer.InstanceId, writer.WriterId, component.Type, component.LogicalPath, component.ComponentName, false);
                            //Logger.Append(Severity.TRIVIA, "Added writer/component "+spo);
                            //break;
                        }
                        //metadata.Metadata.Add(writer.SaveAsXml());
                        // Retrieve Backup Components Document
                        //Metadata.Metadata.Add("bcd", backup.SaveAsXml());

                        if (found == false)
                        {
                            Logger.Append(Severity.WARNING, "Could not find VSS component " + spo + " which was part of backup paths");
                        }
                    }
                    catch (Exception e) {
                        Console.WriteLine(" *** SetItems() : error " + e.Message);
                    }
                }
            }
            //backup.BackupComplete();
            backup.FreeWriterStatus();
            backup.FreeWriterMetadata();
            backup.AbortBackup();
            backup.Dispose();
        }
Exemplo n.º 30
0
 private static string DnsNetShCmd(bool first, string name, string addr, OperatingSystemInfo OsInfo)
 {
     return("netsh interface " + NetShUtils.IPCmd(addr) + (first ? " set dns " : " add dns ") + "\"" + name + "\" " + (first ? "static " : "") + addr + " >> WAN-Failover-Results.log\r\n");
 }