示例#1
0
        private static string ConvertPath(string path, HostOS os)
        {
#if PORTABLE
            return(path.Replace('\\', '/'));
#else
            switch (os)
            {
            case HostOS.MacOS:
            case HostOS.Unix:
            {
                if (Path.DirectorySeparatorChar == '\\')
                {
                    return(path.Replace('/', '\\'));
                }
            }
            break;

            default:
            {
                if (Path.DirectorySeparatorChar == '/')
                {
                    return(path.Replace('\\', '/'));
                }
            }
            break;
            }
            return(path);
#endif
        }
示例#2
0
        //---------------------------------------------------------------------
        private int UninstallAll(bool removeSysPrereq)
        {
            HostOS           hostOS     = Component.HostEnvironment.hostOS;
            List <Component> components = _components;

            components.Reverse();
            foreach (Component comp in components)
            {
                if (comp.IsSystemPrerequisite && !removeSysPrereq)
                {
                    continue;   // skip this component if this is not a cleanup run
                }
                Console.WriteLine("Uninstalling {0} ...", comp.Name);
                if (!comp.InstallOnThisOS(hostOS))
                {
                    Console.WriteLine("component '{0}' is not necessary for this OS: {1}, uninstall skipped", comp.Name, hostOS.ToString());
                    continue;
                }

                if (!comp.IsInstalled() && !comp.ForceOperation)
                {
                    Console.WriteLine("component '{0}' already uninstalled", comp.Name);
                    continue;
                }
                // ignore failure exit codes when uninstalling
                comp.Uninstall();
            }
            return(0);
        }
示例#3
0
文件: Program.cs 项目: yvdjee/PSEGet
 static void DisplayHelp()
 {
     Console.WriteLine("PSEGet Console. (c) 2016 Arnold Diaz.");
     Console.WriteLine("\tUsage: psegetc -t [url | local path] -df [from date] -dt [to date] -o [output path] -f [csv:<format> | ami:<database path>] -d [date format]");
     Console.WriteLine("\t-t [url:<from: date to: date> | local path]");
     Console.WriteLine("\t\tPSE Report File Path.\n");
     Console.WriteLine("\t-df [from date]");
     Console.WriteLine("\t\tStart download from specified date.");
     Console.WriteLine("\t-dt [to date]");
     Console.WriteLine("\t\tOptional. Download to specified date. Date will default to -df date if not specified.\n");
     Console.WriteLine("\t-o [output path]");
     Console.WriteLine("\t\tOptional. Output Path. Defaults to executable path.\n");
     Console.WriteLine("\t-f [csv:<format> | ami:<database path>]");
     Console.WriteLine("\t\tOptional. Target Output. Defaults to CSV.");
     Console.WriteLine("\t\tCSV Optional <format> defaults to S,D,O,H,L,C,V,F\n");
     Console.WriteLine("\t-d [date format]");
     Console.WriteLine("\t\tOptional Date Format. Defaults to MM/dd/yyyy.\n");
     Console.WriteLine("Example 1 (Download range) : psegetc -t http://www.pse.com.ph/resource/dailyquotationreport/file/ -df 06/20/2016 -dt 06/24/2016 ");
     Console.WriteLine("Example 2 (Download today) : psegetc -t http://www.pse.com.ph/resource/dailyquotationreport/file/ -df today");
     Console.WriteLine("Example 3 (From file)      : psegetc -t c:\\myreports\\stockQuotes_552016.pdf");
     Console.WriteLine("Example 4 (Typical)        : psegetc -t http://www.pse.com.ph/resource/dailyquotationreport/file/ -df 06/20/2016 -dt 06/24/2016 -o c:\\myfolder\\");
     Console.WriteLine("Example 5 (CSV)            : psegetc -t c:\\myreports\\stockQuotes_552016.pdf -o c:\\myfolder\\ -f csv:S,D,C");
     if (HostOS.determineHostEnviroment() == HostOS.HostEnviroment.Windows)
     {
         Console.WriteLine("Example 6 (Amibroker)      : pseget -t c:\\myreports\\stockQuotes_552016.pdf -f ami:\"c:\\program files\\\"");
     }
 }
示例#4
0
        //---------------------------------------------------------------------
        private int InstallAll()
        {
            HostOS hostOS = Component.HostEnvironment.hostOS;

            foreach (Component comp in _components)
            {
                Console.WriteLine("Installing {0} ...", comp.Name);
                if (!comp.InstallOnThisOS(hostOS))
                {
                    Console.WriteLine("component '{0}' is not necessary for this OS: {1}, skipping install", comp.Name, hostOS.ToString());
                    continue;
                }

                if (comp.IsInstalled() && !_forceInstall && !comp.ForceOperation)
                {
                    Console.WriteLine("component '{0}' already installed; found version = {1}", comp.Name, comp.GetVersion());
                    continue;
                }
                int exitCode = comp.Install();
                if (exitCode != 0)
                {
                    Console.WriteLine("Component {0} failed to install, aborting!", comp.Name);
                    return(exitCode);
                }
            }
            return(0);
        }
示例#5
0
        private static string ConvertPath(string path, HostOS os)
        {
#if NO_FILE
            return(path.Replace('\\', '/'));
#else
            if (Path.DirectorySeparatorChar == '/')
            {
                return(path.Replace('\\', '/'));
            }
            else if (Path.DirectorySeparatorChar == '\\')
            {
                return(path.Replace('/', '\\'));
            }
            return(path);
#endif
        }
示例#6
0
        //---------------------------------------------------------------------
        private int ShowStatus()
        {
            HostOS hostOS = Component.HostEnvironment.hostOS;

            foreach (Component comp in _components)
            {
                Console.Write("{0, -15}: ", comp.Name);
                if (comp.InstallOnThisOS(hostOS))
                {
                    bool isInstalled = comp.IsInstalled();
                    Console.WriteLine("Installed: {0}  Version: {1}",
                                      isInstalled ? "Y" : "N", isInstalled ? comp.GetVersion() : "-");
                }
                else
                {
                    Console.WriteLine("Skipped, not required on this OS: {0}", hostOS.ToString());
                    continue;
                }
            }
            return(0);
        }
示例#7
0
        //---------------------------------------------------------------------
        private int ListComponents()
        {
            HostOS hostOS = Component.HostEnvironment.hostOS;

            foreach (Component comp in _components)
            {
                Console.Write("{0, -15}: ", comp.Name);
                if (comp.InstallOnThisOS(hostOS))
                {
                    Console.Write("File: ");
                    foreach (string file in comp.InstallerFiles)
                    {
                        Console.Write("{0} ", file);
                    }
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("Skipped, not required on this OS: {0}", hostOS.ToString());
                    continue;
                }
            }
            return(0);
        }
示例#8
0
		private static string ConvertPath(string path, HostOS os)
		{
#if PORTABLE || NETFX_CORE
            return path.Replace('\\', '/');
#else
			switch (os)
			{
				case HostOS.MacOS:
				case HostOS.Unix:
//                    {
//                        if (Path.DirectorySeparatorChar == '\\')
//                        {
//                            return path.Replace('/', '\\');
//                        }
//                    }
//                    break;
				default:
					{
						if (Path.DirectorySeparatorChar == '/')
						{
							return path.Replace('\\', '/');
						}
						else if (Path.DirectorySeparatorChar == '\\')
						{
							return path.Replace('/', '\\');
						}
					}
					break;
			}
			return path;
#endif
		}
示例#9
0
 private static string ConvertPath(string path, HostOS os)
 {
     #if NO_FILE
     return path.Replace('\\', '/');
     #else
     switch (os)
     {
         case HostOS.MacOS:
         case HostOS.Unix:
             {
                 if (Path.DirectorySeparatorChar == '\\')
                 {
                     return path.Replace('/', '\\');
                 }
             }
             break;
         default:
             {
                 if (Path.DirectorySeparatorChar == '/')
                 {
                     return path.Replace('\\', '/');
                 }
             }
             break;
     }
     return path;
     #endif
 }
示例#10
0
文件: Program.cs 项目: yvdjee/PSEGet
        static void ConvertIt(string fileToConvert)
        {
            IPdfService      pdfService  = new PdfTextSharpService();
            var              pseDocument = new PSEDocument();
            IPSEReportReader reader      = new PSEReportReader2();

            reader.Fill(pseDocument, pdfService.ExtractTextFromPdf(fileToConvert));
            if (_outputFormat.Contains("csv"))
            {
                string[] csvParam  = _outputFormat.Split(':');
                string   csvFormat = string.Empty;
                if (csvParam.Length == 2)
                {
                    csvFormat = csvParam[1];
                    csvFormat = csvFormat.Replace("S", "{S}");
                    csvFormat = csvFormat.Replace("D", "{D}");
                    csvFormat = csvFormat.Replace("O", "{O}");
                    csvFormat = csvFormat.Replace("H", "{H}");
                    csvFormat = csvFormat.Replace("L", "{L}");
                    csvFormat = csvFormat.Replace("C", "{C}");
                    csvFormat = csvFormat.Replace("V", "{V}");
                    csvFormat = csvFormat.Replace("F", "{F}");
                }
                else
                {
                    csvFormat = "{S},{D},{O},{H},{L},{C},{V},{F}";
                }

                var csvOutputSettings = new CSVOutputSettings();
                csvOutputSettings.CSVFormat              = csvFormat;
                csvOutputSettings.DateFormat             = _dateFormat;
                csvOutputSettings.Delimiter              = ",";
                csvOutputSettings.Filename               = Path.GetFileName(fileToConvert).Replace("pdf", "csv");
                csvOutputSettings.OutputDirectory        = _outputPath;
                csvOutputSettings.UseSectorValueAsVolume = true;
                csvOutputSettings.SectorVolumeDivider    = 1000;

                pseDocument.ToCSV(csvOutputSettings);
            }
            else if ((HostOS.determineHostEnviroment() == HostOS.HostEnviroment.Windows) && (_outputFormat.Contains("ami")))
            {
                IAmibrokerService amiService = new AmibrokerService();
                if (!amiService.IsAmibrokerInstalled())
                {
                    throw new Exception("Error: Amibroker is not installed on this machine.");
                }

                string[] amiParam = _outputFormat.Split(':');
                if (amiParam.Length < 2)
                {
                    throw new Exception("Error: Unspecified Amibroker database folder.");
                }
                string amiDatabaseFolder = _outputFormat.Replace("ami:", string.Empty);

                var amiOutputSettings = new AmiOutputSettings();
                amiOutputSettings.DatabaseDirectory      = amiDatabaseFolder;
                amiOutputSettings.SectorVolumeDivider    = 1000;
                amiOutputSettings.UseSectorValueAsVolume = true;

                pseDocument.ToAmibroker(amiOutputSettings);
            }
        }
        // Create Random KMS PID
        public string CreateKMSPID(KMSRequest request)
        {
            // KMS Host OS Type
            List <HostOS> hostOSList = new List <HostOS>
            {
                new HostOS {
                    Type = 55041, OSBuild = 6002, MinimumDay = 146, MinimumYear = 2009
                },                                                                                // Windows Server 2008 SP2:    05/26/2009 SP2 GA
                new HostOS {
                    Type = 55041, OSBuild = 7601, MinimumDay = 53, MinimumYear = 2011
                },                                                                                // Windows Server 2008 R2 SP1: 02/22/2011 SP1 GA
                new HostOS {
                    Type = 5426, OSBuild = 9200, MinimumDay = 248, MinimumYear = 2012
                },                                                                                // Windows Server 2012 RTM:    09/04/2012 RTM GA
                new HostOS {
                    Type = 6401, OSBuild = 9600, MinimumDay = 27, MinimumYear = 2013
                },                                                                                // Windows Server 2012 R2 RTM: 01/27/2013 RTM GA
                new HostOS {
                    Type = 3612, OSBuild = 14393, MinimumDay = 215, MinimumYear = 2016
                }                                                                                 // Windows Server 2016 RTM:    08/02/2016 WZOR LEAK
            };

            // Product Specific KeyConfig
            List <PkeyConfig> pkeyConfigList = new List <PkeyConfig>
            {
                new PkeyConfig {
                    GroupID = 152, PIDRangeMin = 381000000, PIDRangeMax = 392999999
                },                                                                                  // Windows Server 2008 C
                new PkeyConfig {
                    GroupID = 168, PIDRangeMin = 305000000, PIDRangeMax = 312119999
                },                                                                                  // Windows Server 2008 R2 C
                new PkeyConfig {
                    GroupID = 206, PIDRangeMin = 152000000, PIDRangeMax = 191999999
                },                                                                                  // Windows Server 2012
                new PkeyConfig {
                    GroupID = 206, PIDRangeMin = 271000000, PIDRangeMax = 310999999
                },                                                                                  // Windows Server 2012 R2
                new PkeyConfig {
                    GroupID = 206, PIDRangeMin = 471000000, PIDRangeMax = 530999999
                },                                                                                  // Windows Server 2016
                new PkeyConfig {
                    GroupID = 96, PIDRangeMin = 199000000, PIDRangeMax = 217999999
                },                                                                                  // Office 2010
                new PkeyConfig {
                    GroupID = 206, PIDRangeMin = 234000000, PIDRangeMax = 255999999
                },                                                                                  // Office 2013
                new PkeyConfig {
                    GroupID = 206, PIDRangeMin = 437000000, PIDRangeMax = 458999999
                }                                                                                   // Office 2016
            };

            // Product Specific Detection
            int osTypeIndex    = HostServer2016;
            int keyConfigIndex = PkeyConfigWindowsServer2016;

            if (request.ApplicationId == _appIDOffice2010 || request.ApplicationId == _appIDOffice2013 || request.ApplicationId == _appIDOffice2016)
            {
                if (request.KmsCountedId == _kmsCountedIDOffice2010)
                {
                    keyConfigIndex = PkeyConfigOffice14;
                    osTypeIndex    = Random.Next(HostServer2012, HostServer2016 + 1);
                }
                else if (request.KmsCountedId == _kmsCountedIDOffice2013)
                {
                    keyConfigIndex = PkeyConfigOffice15;
                    osTypeIndex    = Random.Next(HostServer2012, HostServer2016 + 1);
                }
                else if (request.KmsCountedId == _kmsCountedIDOffice2016)
                {
                    keyConfigIndex = PkeyConfigOffice16;
                    osTypeIndex    = Random.Next(HostServer2012, HostServer2016 + 1);
                }
                else if (request.KmsCountedId == _kmsCountedIDOffice2019)
                {
                    keyConfigIndex = PkeyConfigOffice16;
                    osTypeIndex    = Random.Next(HostServer2012, HostServer2016 + 1);
                }
            }
            else if (request.ApplicationId == _appIDWindows)
            {
                if (request.KmsCountedId == _kmsCountedIDWindowsVista || request.KmsCountedId == _kmsCountedIDWindowsServer2008A || request.KmsCountedId == _kmsCountedIDWindowsServer2008B || request.KmsCountedId == _kmsCountedIDWindowsServer2008C)
                {
                    keyConfigIndex = Random.Next(PkeyConfigWindowsServer2012, PkeyConfigWindowsServer2016 + 1);
                    osTypeIndex    = Random.Next(HostServer2012, HostServer2016 + 1);
                }
                else if (request.KmsCountedId == _kmsCountedIDWindows7 || request.KmsCountedId == _kmsCountedIDWindowsServer2008R2A || request.KmsCountedId == _kmsCountedIDWindowsServer2008R2B || request.KmsCountedId == _kmsCountedIDWindowsServer2008R2C)
                {
                    keyConfigIndex = Random.Next(PkeyConfigWindowsServer2012, PkeyConfigWindowsServer2016 + 1);
                    osTypeIndex    = Random.Next(HostServer2012, HostServer2016 + 1);
                }
                else if (request.KmsCountedId == _kmsCountedIDWindows8Retail || request.KmsCountedId == _kmsCountedIDWindows8Volume || request.KmsCountedId == _kmsCountedIDWindowsServer2012)
                {
                    keyConfigIndex = Random.Next(PkeyConfigWindowsServer2012, PkeyConfigWindowsServer2016 + 1);
                    osTypeIndex    = Random.Next(HostServer2012, HostServer2016 + 1);
                }
                else if (request.KmsCountedId == _kmsCountedIDWindows81Retail || request.KmsCountedId == _kmsCountedIDWindows81Volume || request.KmsCountedId == _kmsCountedIDWindowsServer2012R2)
                {
                    keyConfigIndex = Random.Next(PkeyConfigWindowsServer2012R2, PkeyConfigWindowsServer2016 + 1);
                    osTypeIndex    = Random.Next(HostServer2012R2, HostServer2016 + 1);
                }
                else if (request.KmsCountedId == _kmsCountedIDWindows10Retail || request.KmsCountedId == _kmsCountedIDWindows10Volume || request.KmsCountedId == _kmsCountedIDWindows10LTSB2015 || request.KmsCountedId == _kmsCountedIDWindows10LTSB2016 || request.KmsCountedId == _kmsCountedIDWindowsServer2016)
                {
                    keyConfigIndex = PkeyConfigWindowsServer2016;
                    osTypeIndex    = HostServer2016;
                }
            }

            // Generate Part 1 & 7: Host Type and KMS Server OS Build
            HostOS osType = hostOSList[osTypeIndex];

            // Generate Part 2: Group ID and Product Key ID Range
            PkeyConfig keyConfig = pkeyConfigList[keyConfigIndex];

            // Generate Part 3 and Part 4: Product Key ID
            long productKeyID = Random.Next(0, int.MaxValue) % (keyConfig.PIDRangeMax - keyConfig.PIDRangeMin) + keyConfig.PIDRangeMin;

            // Generate Part 5: License Channel (00=Retail, 01=Retail, 02=OEM, 03=Volume(GVLK,MAK)) - always 03
            const int licenseChannel = 3;

            // Generate Part 6: Language - use system default language
            int languageCode = CultureInfo.InstalledUICulture.LCID; // GetSystemDefaultLCID();

            /* Generate Part 8: KMS Host Activation Date */
            int minimumDay, minimumYear;

            // Get Minimum Possible Date
            minimumDay  = osType.MinimumDay;
            minimumYear = osType.MinimumYear;

            // Get Current Time Information
            int currentYear = DateTime.Now.Year;           // Year (current year minus 1900).
            int currentDay  = DateTime.Now.DayOfYear;      // Day of Year (0-365; January 1 = 0)

            // Use 2016 for Current Year if time is screwed up.
            if (minimumYear > currentYear)
            {
                currentYear = 2016;
            }

            // Generate Year (Minimum Year to Current Year)
            int year = Random.Next() % (currentYear - (minimumYear - 1)) + minimumYear;

            // Generate Day
            int randomDay = Random.Next() % 365 + 1;

            // Check for future days and limits the random up to current day.
            if ((randomDay > currentDay) && (year == currentYear))
            {
                randomDay = Random.Next() % currentDay + 1;
            }
            // Check for product minimum build year and day and adjust the random accordingly.
            else if ((randomDay < minimumDay) && (year == minimumYear))
            {
                randomDay = minimumDay + (Random.Next() % (365 - minimumDay) + 1);
            }

            // Apply Setting
            string result = string.Format("{0:D5}-{1:D5}-{2:D3}-{3:D6}-{4:D2}-{5}-{6:D4}.0000-{7:D3}{8:D4}",
                                          osType.Type, keyConfig.GroupID, productKeyID / 1000000, productKeyID % 1000000, licenseChannel,
                                          languageCode, osType.OSBuild, randomDay, year);

            return(result);
        }
示例#12
0
 private static string ConvertPath(string path, HostOS os)
 {
     return(path.Replace('\\', '/'));
 }