コード例 #1
0
        private SoftwareInfo GetSoftwareInfoForKey(RegistryKey sk)
        {
            string   DisplayName      = "";
            string   DisplayVersion   = "";
            string   InstallDateRaw   = "";
            DateTime InstallDate      = NullDateTime;
            string   Publisher        = "";
            string   URLInfoAbout     = "";
            Int64    InstallDateAsInt = 0;

            if (sk.GetValue("DisplayName") != null)
            {
                DisplayName = sk.GetValue("DisplayName").ToString().Replace("\0", string.Empty).Trim();
            }

            if (sk.GetValue("DisplayVersion") != null)
            {
                DisplayVersion = sk.GetValue("DisplayVersion").ToString().Replace("\0", string.Empty).Trim();
            }

            if (sk.GetValue("InstallDate") != null)
            {
                InstallDateRaw = sk.GetValue("InstallDate").ToString().Replace("\0", string.Empty).Trim();
            }

            if (sk.GetValue("InstallDate") != null && !string.IsNullOrEmpty(sk.GetValue("InstallDate").ToString()))
            {
                string s = sk.GetValue("InstallDate").ToString().Replace("\0", string.Empty).Trim();

                if (s.Contains("/"))
                {
                    DateTime.TryParse(s, out InstallDate);
                }
                else if (s.Length == 8)
                {
                    if (int.TryParse(s.Substring(0, 4), out int year) && int.TryParse(s.Substring(4, 2), out int month) && int.TryParse(s.Substring(6, 2), out int day))
                    {
                        InstallDate = new DateTime(year, month, day);
                    }
                }
                else if (Int64.TryParse(s, out InstallDateAsInt))
                {
                    InstallDate = InstallDate.AddSeconds(InstallDateAsInt);
                }
            }

            if (sk.GetValue("Publisher") != null)
            {
                Publisher = sk.GetValue("Publisher").ToString().Replace("\0", string.Empty).Trim();
            }

            if (sk.GetValue("URLInfoAbout") != null)
            {
                URLInfoAbout = sk.GetValue("URLInfoAbout").ToString().Replace("\0", string.Empty).Trim();
            }


            return(new SoftwareInfo(DisplayName, DisplayVersion, InstallDateRaw, InstallDate, Publisher, URLInfoAbout));
        }
コード例 #2
0
        public override string ToString()
        {
            StringBuilder details = new StringBuilder();

            details.AppendLine(Caption);
            details.Append('\t').Append("Availability: ").Append(Decode.Availability(Availability)).AppendLine();
            details.Append('\t').Append("BytesPerSector: ").Append(BytesPerSector).AppendLine();
            details.Append('\t').Append("Capabilities: ").Append(Capabilities).AppendLine();
            details.Append('\t').Append("CapabilityDescriptions: ").Append(string.Join(", ", CapabilityDescriptions)).AppendLine();
            details.Append('\t').Append("CompressionMethod: ").Append(CompressionMethod).AppendLine();
            details.Append('\t').Append("ConfigManagerErrorCode: ").Append(Decode.ConfigManagerErrorCode(ConfigManagerErrorCode)).AppendLine();
            details.Append('\t').Append("ConfigManagerUserConfig: ").Append(ConfigManagerUserConfig).AppendLine();
            details.Append('\t').Append("CreationClassName: ").Append(CreationClassName).AppendLine();
            details.Append('\t').Append("DefaultBlockSize: ").Append(DefaultBlockSize).AppendLine();
            details.Append('\t').Append("Description: ").Append(Description).AppendLine();
            details.Append('\t').Append("DeviceId: ").Append(DeviceId).AppendLine();
            details.Append('\t').Append("ErrorCleared: ").Append(ErrorCleared).AppendLine();
            details.Append('\t').Append("ErrorDescription: ").Append(ErrorDescription).AppendLine();
            details.Append('\t').Append("ErrorMethodology: ").Append(ErrorMethodology).AppendLine();
            details.Append('\t').Append("FirmwareRevision: ").Append(FirmwareRevision).AppendLine();
            details.Append('\t').Append("Index: ").Append(Index).AppendLine();
            details.Append('\t').Append("InterfaceType: ").Append(InterfaceType).AppendLine();
            details.Append('\t').Append("InstallDate: ").Append(InstallDate.ToString("u")).AppendLine();
            details.Append('\t').Append("LastErrorCode: ").Append(LastErrorCode).AppendLine();
            details.Append('\t').Append("Manufacturer: ").Append(Manufacturer).AppendLine();
            details.Append('\t').Append("MaxBlockSize: ").Append(MaxBlockSize).AppendLine();
            details.Append('\t').Append("MaxMediaSize: ").Append(MaxMediaSize).AppendLine();
            details.Append('\t').Append("MediaLoaded: ").Append(MediaLoaded).AppendLine();
            details.Append('\t').Append("MediaType: ").Append(MediaType).AppendLine();
            details.Append('\t').Append("MinBlockSize: ").Append(MinBlockSize).AppendLine();
            details.Append('\t').Append("Model: ").Append(Model).AppendLine();
            details.Append('\t').Append("Name: ").Append(Name).AppendLine();
            details.Append('\t').Append("NeedsCleaning: ").Append(NeedsCleaning).AppendLine();
            details.Append('\t').Append("NumberOfMediaSupported: ").Append(NumberOfMediaSupported).AppendLine();
            details.Append('\t').Append("Partitions: ").Append(Partitions).AppendLine();
            details.Append('\t').Append("PNPDeviceID: ").Append(PnpDeviceId).AppendLine();
            details.Append('\t').Append("PowerManagementCapabilities: ").Append(Decode.PowerManagementCapabilities(PowerManagementCapabilities)).AppendLine();
            details.Append('\t').Append("PowerManagementSupported: ").Append(PowerManagementSupported).AppendLine();
            details.Append('\t').Append("SCSIBus: ").Append(ScsiBus).AppendLine();
            details.Append('\t').Append("SCSILogicalUnit: ").Append(ScsiLogicalUnit).AppendLine();
            details.Append('\t').Append("SCSIPort: ").Append(ScsiPort).AppendLine();
            details.Append('\t').Append("SCSITargetId: ").Append(ScsiTargetId).AppendLine();
            details.Append('\t').Append("SectorsPerTrack: ").Append(SectorsPerTrack).AppendLine();
            details.Append('\t').Append("SerialNumber: ").Append(SerialNumber).AppendLine();
            details.Append('\t').Append("Signature: ").Append(Signature).AppendLine();
            details.Append('\t').Append("Size: ").Append(Size).AppendLine();
            details.Append('\t').Append("Status: ").Append(Status).AppendLine();
            details.Append('\t').Append("StatusInfo: ").Append(Decode.StatusInfo(StatusInfo)).AppendLine();
            details.Append('\t').Append("SystemCreationClassName: ").Append(SystemCreationClassName).AppendLine();
            details.Append('\t').Append("SystemName: ").Append(SystemName).AppendLine();
            details.Append('\t').Append("TotalCylinders: ").Append(TotalCylinders).AppendLine();
            details.Append('\t').Append("TotalHeads: ").Append(TotalHeads).AppendLine();
            details.Append('\t').Append("TotalSectors: ").Append(TotalSectors).AppendLine();
            details.Append('\t').Append("TotalTracks: ").Append(TotalTracks).AppendLine();
            details.Append('\t').Append("TracksPerCylinder: ").Append(TracksPerCylinder).AppendLine();

            return(details.ToString());
        }
コード例 #3
0
 private string GetInstallDateString()
 {
     try
     {
         return DateTime.MinValue.Equals(InstallDate) ? string.Empty : InstallDate.ToShortDateString();
     }
     catch (SystemException)
     {
         return string.Empty;
     }
 }
コード例 #4
0
        public string ToLongString()
        {
            var sb = new StringBuilder();

            sb.Append(DisplayName);
            sb.AppendFormat(" | {0}", Publisher);
            sb.AppendFormat(" | {0}", DisplayVersion);
            sb.AppendFormat(" | {0}", DateTime.MinValue.Equals(InstallDate) ? "" : InstallDate.ToShortDateString());
            sb.AppendFormat(" | {0}", EstimatedSize);
            sb.AppendFormat(" | {0}", RegistryPath);
            sb.AppendFormat(" | {0}", UninstallerKind);
            sb.AppendFormat(" | {0}", UninstallString);
            sb.AppendFormat(" | {0}", QuietUninstallString);
            sb.AppendFormat(" | {0}", Comment);

            return(sb.ToString());
        }
コード例 #5
0
        /// <summary>
        /// Assigns <see cref="IsValid" /> and <see cref="LicenseType" /> based on whether the trial period has expired.
        /// </summary>
        private void ValidateBlankLicenseKey()
        {
            // No key has been entered, which means we're either in the trial period or it has expired.
            var isInTrialPeriod = (InstallDate.AddDays(GlobalConstants.TrialNumberOfDays) >= DateTime.Today);

            if (isInTrialPeriod)
            {
                IsValid     = true;
                LicenseType = LicenseLevel.Trial;
            }
            else
            {
                IsValid          = false;
                KeyInvalidReason = "Product key has not been entered and trial period has expired";
                LicenseType      = LicenseLevel.TrialExpired;
            }
        }
コード例 #6
0
        public void SerializeTo(Stream stream)
        {
            var bw = new BinaryWriter(stream);

            bw.Write(PacketId);
            bw.Write(CountryCode);
            bw.Write(CountryName);
            bw.Write(TimeZone);
            bw.Write(Latitude);
            bw.Write(Longitude);
            bw.Write(InstalledAntivirus);
            bw.Write(InstalledFirewall);
            bw.Write(ThisPath);
            bw.Write(OperatingSystem);
            bw.Write(IsAdmin);
            bw.Write(InstallDate.ToBinary());
            bw.Write(RunningTime);
            bw.Write(ComputerName);
        }
コード例 #7
0
ファイル: AssetDto.cs プロジェクト: FredericVets/LinkIT
        public override int GetHashCode()
        {
            var hashCode = -133760364;

            hashCode = hashCode * -1521134295 + base.GetHashCode();
            hashCode = hashCode * -1521134295 + CreationDate.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(CreatedBy);

            hashCode = hashCode * -1521134295 + ModificationDate.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ModifiedBy);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(IctsReference);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Tag);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Serial);

            hashCode = hashCode * -1521134295 + EqualityComparer <ProductDto> .Default.GetHashCode(Product);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Description);

            hashCode = hashCode * -1521134295 + InvoiceDate.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(InvoiceNumber);

            hashCode = hashCode * -1521134295 + Price.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(PaidBy);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Owner);

            hashCode = hashCode * -1521134295 + InstallDate.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(InstalledBy);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Remark);

            hashCode = hashCode * -1521134295 + TeamAsset.GetHashCode();

            return(hashCode);
        }
コード例 #8
0
        private string GenerateReport()
        {
            // Get information about the truck, trailer, driver
            string truck    = tb_truck.Text;
            string trailer  = tb_trailer.Text;
            string driver   = tb_driver.Text;
            string filename = String.Empty;

            // Test for null or empty strings
            if (String.IsNullOrEmpty(truck))
            {
                truck = "not assigned";
            }
            if (String.IsNullOrEmpty(trailer))
            {
                trailer = "not assigned";
            }
            if (String.IsNullOrEmpty(driver))
            {
                driver = "_______________";
            }

            // Get today's date
            string date = InstallDate.ToString("yyyy-MM-dd");

            // Get the My Documents path
            string MyDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            // Check if output folder already exists
            string OutputPath = @MyDocumentsPath + @"\Truck Loads\" + @"\" + date.Substring(0, 7) + @"\";

            Console.WriteLine(OutputPath);
            if (!File.Exists(OutputPath))
            {
                Directory.CreateDirectory(OutputPath);
            }

            // Get the final count of items
            ItemCounts counts = UpdateList();

            // If the counts list is null, show a warning to the user and do not generate a PDF
            if (counts.Covers != null)
            {
                // Get items from accessory list
                List <Accessory> AccList = new List <Accessory>();
                int    qty  = 0;
                string item = "";

                // Call default constructor
                Createpdf pdf = new Createpdf();

                if (accDGV.Rows.Count != 0)
                {
                    foreach (DataGridViewRow row in accDGV.Rows)
                    {
                        item = row.Cells[0].Value.ToString();
                        qty  = Convert.ToInt32(row.Cells[1].Value);
                        Accessory acc = new Accessory(item, qty);
                        AccList.Add(acc);
                    }
                    // Generate the PDF
                    pdf = new Createpdf(truck, trailer, driver, counts, AccList, date);
                }
                else
                {
                    // Generate the PDF
                    pdf = new Createpdf(truck, trailer, driver, counts, date);
                }

                // Create a MigraDoc document
                Document document = pdf.CreateDocument();
                document.UseCmykColor = true;

                // Create a renderer for PDF that uses Unicode font encoding
                PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true)
                {
                    // Set the MigraDoc document
                    Document = document
                };

                // Create the PDF document
                pdfRenderer.RenderDocument();

                // Save the PDF document...
                // TODO: Check if file already exists
                filename = string.Format(@"{0}MaterialList_{2}_truck{1}.pdf", OutputPath, truck, date);

                pdfRenderer.Save(filename);

                // ...and start a viewer if desired
                if (ShowPDF == true)
                {
                    Process.Start(filename);
                }
            }
            else
            {
                MessageBox.Show("You can not generate a list at this point, because you have no tents listed. Please add tents to this load.",
                                "Empty List", MessageBoxButtons.OK, MessageBoxIcon.Error);
                filename = string.Empty;
            }

            return(filename);
        }