コード例 #1
0
 /// <summary>
 /// Deserialization constructor.
 /// </summary>
 /// <param name="group"></param>
 /// <param name="src"></param>
 internal StaticCertificateClass(StaticCertificateGroup group, SerializableCertificateClass src)
 {
     ID = src.ID;
     Name = src.Name;
     Description = src.Description;
     Group = group;
     Certificate = new StaticCertificate(this, src.Certificate);
 }
コード例 #2
0
ファイル: Certificates.cs プロジェクト: RapidFiring/evemon
        /// <summary>
        /// Exports the certificates classes.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        private static IEnumerable<SerializableCertificateClass> ExportCertificateClasses(IHasID group)
        {
            List<SerializableCertificateClass> listOfCertClasses = new List<SerializableCertificateClass>();

            // Exclude unused classes
            foreach (CrtClasses certClass in Database.CrtClassesTable)
            {
                Util.UpdatePercentDone(Database.CertificatesTotalCount);

                SerializableCertificateClass crtClass = new SerializableCertificateClass
                {
                    ID = certClass.ID,
                    Name = certClass.ClassName,
                    Description = certClass.Description
                };

                // Export certificate
                SerializableCertificate certificate = Database.CrtCertificatesTable
                    .Where(x => x.ClassID == certClass.ID && x.GroupID == group.ID).Select(ExportCertificate).FirstOrDefault();

                if (certificate == null)
                    continue;

                // Add certificate to class
                crtClass.Certificate = certificate;

                // Add certificate class to classes
                listOfCertClasses.Add(crtClass);
            }
            return listOfCertClasses;
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: wow4all/evemu_server
        /// <summary>
        /// Generate the certificates datafile.
        /// </summary>        
        private static void GenerateCertificates()
        {
            Console.WriteLine();
            Console.Write(@"Generated certificates datafile... ");

            s_counter = 0;
            s_percentOld = 0;
            s_text = String.Empty;
            s_startTime = DateTime.Now;

            // Export certificates categories
            var listOfCertCategories = new List<SerializableCertificateCategory>();

            foreach (CrtCategories category in s_crtCategories.OrderBy(x => x.CategoryName))
            {
                var crtCategory = new SerializableCertificateCategory
                                      {
                                          ID = category.ID,
                                          Name = category.CategoryName,
                                          Description = category.Description
                                      };

                // Export certificates classes
                var listOfCertClasses = new List<SerializableCertificateClass>();

                int categoryID = 0;
                foreach (CrtClasses certClass in s_crtClasses)
                {
                    // Exclude unused classes
                    int id = certClass.ID;
                    if (id == 104 || id == 106 || id == 111)
                        continue;

                    var crtClasses = new SerializableCertificateClass
                                         {
                                             ID = certClass.ID,
                                             Name = certClass.ClassName,
                                             Description = certClass.Description
                                         };

                    // Export certificates
                    var listOfCertificates = new List<SerializableCertificate>();

                    foreach (var certificate in s_certificates.Where(x => x.ClassID == certClass.ID))
                    {
                        UpdatePercentDone(s_certGenTotal);

                        var crtCertificates = new SerializableCertificate
                                                  {
                                                      ID = certificate.ID,
                                                      Grade = GetGrade(certificate.Grade),
                                                      Description = certificate.Description
                                                  };

                        // Export prerequesities
                        var listOfPrereq = new List<SerializableCertificatePrerequisite>();

                        foreach (CrtRelationships relationship in s_crtRelationships
                            .Where(x => x.ChildID == certificate.ID))
                        {
                            var crtPrerequisites = new SerializableCertificatePrerequisite
                                                       {
                                                           ID = relationship.ID,
                                                       };

                            if (relationship.ParentTypeID != null) // prereq is a skill
                            {
                                var skill = s_types.First(x => x.ID == relationship.ParentTypeID);
                                crtPrerequisites.Kind = SerializableCertificatePrerequisiteKind.Skill;
                                crtPrerequisites.Name = skill.Name;
                                crtPrerequisites.Level = relationship.ParentLevel.ToString();
                            }
                            else // prereq is a certificate
                            {
                                CrtCertificates cert = s_certificates.First(x => x.ID == relationship.ParentID);
                                CrtClasses crtClass = s_crtClasses.First(x => x.ID == cert.ClassID);
                                crtPrerequisites.Kind = SerializableCertificatePrerequisiteKind.Certificate;
                                crtPrerequisites.Name = crtClass.ClassName;
                                crtPrerequisites.Level = GetGrade(cert.Grade).ToString();
                            }

                            // Add prerequisite
                            listOfPrereq.Add(crtPrerequisites);
                        }

                        // Export recommendations
                        var listOfRecom = new List<SerializableCertificateRecommendation>();

                        foreach (CrtRecommendations recommendation in s_crtRecommendations
                            .Where(x => x.CertificateID == certificate.ID))
                        {
                            // Finds the ships name
                            InvType shipName = s_types.First(x => x.ID == recommendation.ShipTypeID);

                            var crtRecommendations = new SerializableCertificateRecommendation
                                                         {
                                                             ID = recommendation.ID,
                                                             Ship = shipName.Name,
                                                             Level = recommendation.Level
                                                         };

                            // Add recommendation
                            listOfRecom.Add(crtRecommendations);
                        }

                        //Add prerequisites to certificate
                        crtCertificates.Prerequisites = listOfPrereq.ToArray();

                        // Add recommendations to certificate
                        crtCertificates.Recommendations = listOfRecom.ToArray();

                        // Add certificate
                        listOfCertificates.Add(crtCertificates);

                        // Storing the certificate categoryID for use in classes
                        categoryID = certificate.CategoryID;
                    }

                    // Grouping certificates according to their classes
                    if (categoryID == category.ID)
                    {
                        // Add certificates to classes
                        crtClasses.Certificates = listOfCertificates.OrderBy(x => x.Grade).ToArray();

                        // Add certificate class
                        listOfCertClasses.Add(crtClasses);
                    }
                }

                // Add classes to categories
                crtCategory.Classes = listOfCertClasses.ToArray();

                // Add category
                listOfCertCategories.Add(crtCategory);
            }

            s_endTime = DateTime.Now;
            Console.WriteLine(String.Format(" in {0}", s_endTime.Subtract(s_startTime)).TrimEnd('0'));

            // Serialize
            var datafile = new CertificatesDatafile();
            datafile.Categories = listOfCertCategories.ToArray();
            Util.SerializeXML(datafile, DatafileConstants.CertificatesDatafile);
        }