internal StoreIntegrityCheckJob(DatabaseId databaseId, Guid requestGuid, JobFlags flags, MailboxCorruptionType[] taskIds) : this()
 {
     this.creationTime = new DateTime?(DateTime.UtcNow.ToLocalTime());
     this.flags        = flags;
     this.tasks        = taskIds;
     this.timeInServer = null;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the actual ClassJob from the in-game sheets for this JobFlags.
        /// </summary>
        /// <param name="job">A JobFlags enum member.</param>
        /// <param name="data">A DataManager to get the ClassJob from.</param>
        /// <returns>A ClassJob if found or null if not.</returns>
        public static ClassJob ClassJob(this JobFlags job, DataManager data)
        {
            var result = Math.Log2((double)job);

            return(result % 1 == 0
                ? data.GetExcelSheet <ClassJob>().GetRow((uint)result)
                : null);
        }
Ejemplo n.º 3
0
        private static bool isRequiredJob(short jobTrack, ushort reqJob)
        {
            JobFlags job = 0;

            switch (jobTrack)
            {
            case 0: job = JobFlags.Beginner; break;

            case 1: job = JobFlags.Warrior; break;

            case 2: job = JobFlags.Mage; break;

            case 3: job = JobFlags.Archer; break;

            case 4: job = JobFlags.Thief; break;
            }
            return(reqJob == 0 || ((short)job & reqJob) > 0);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get the actual ClassJob from the in-game sheets for this JobFlags.
        /// </summary>
        /// <param name="job">A JobFlags enum member.</param>
        /// <param name="data">A DataManager to get the ClassJob from.</param>
        /// <returns>A ClassJob if found or null if not.</returns>
        public static ClassJob ClassJob(this JobFlags job, DataManager data)
        {
            var jobs = data.GetExcelSheet <ClassJob>();

            uint?row = job switch
            {
                JobFlags.Gladiator => 1,
                JobFlags.Pugilist => 2,
                JobFlags.Marauder => 3,
                JobFlags.Lancer => 4,
                JobFlags.Archer => 5,
                JobFlags.Conjurer => 6,
                JobFlags.Thaumaturge => 7,
                JobFlags.Paladin => 19,
                JobFlags.Monk => 20,
                JobFlags.Warrior => 21,
                JobFlags.Dragoon => 22,
                JobFlags.Bard => 23,
                JobFlags.WhiteMage => 24,
                JobFlags.BlackMage => 25,
                JobFlags.Arcanist => 26,
                JobFlags.Summoner => 27,
                JobFlags.Scholar => 28,
                JobFlags.Rogue => 29,
                JobFlags.Ninja => 30,
                JobFlags.Machinist => 31,
                JobFlags.DarkKnight => 32,
                JobFlags.Astrologian => 33,
                JobFlags.Samurai => 34,
                JobFlags.RedMage => 35,
                JobFlags.BlueMage => 36,
                JobFlags.Gunbreaker => 37,
                JobFlags.Dancer => 38,
                JobFlags.Reaper => 39,
                JobFlags.Sage => 40,
                _ => null,
            };

            return(row == null ? null : jobs.GetRow((uint)row));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Tests if this slot is accepting a job.
 /// </summary>
 /// <param name="flag">Job to test.</param>
 public bool this[JobFlags flag] => (this.accepting & (uint)flag) > 0;
        internal static StoreIntegrityCheckJob CreateStoreIntegrityCheckJob(Database database, Guid mailboxGuid, StoreIntegrityCheckRequestFlags flags, MailboxCorruptionType[] taskIds, Task.TaskErrorLoggingDelegate writeError, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskVerboseLoggingDelegate writeVerbose)
        {
            List <StoreIntegrityCheckJob> result = null;

            try
            {
                StoreIntegrityCheckAdminRpc.ExecuteAdminRpc(database.Guid, delegate(ExRpcAdmin rpcAdmin, string serverFqdn)
                {
                    uint[] array = new uint[taskIds.Length];
                    for (int i = 0; i < taskIds.Length; i++)
                    {
                        array[i] = (uint)taskIds[i];
                    }
                    int num;
                    int num2;
                    rpcAdmin.GetAdminVersion(out num, out num2);
                    if (num < 7 || (num == 7 && num2 < 15))
                    {
                        string input;
                        rpcAdmin.ISIntegCheck(database.Guid, mailboxGuid, (uint)flags, array.Length, array, out input);
                        JobFlags jobFlags = JobFlags.None;
                        if ((flags & StoreIntegrityCheckRequestFlags.DetectOnly) == StoreIntegrityCheckRequestFlags.DetectOnly)
                        {
                            jobFlags |= JobFlags.DetectOnly;
                        }
                        if ((flags & (StoreIntegrityCheckRequestFlags)2147483648U) == (StoreIntegrityCheckRequestFlags)2147483648U)
                        {
                            jobFlags |= (JobFlags)2147483648U;
                        }
                        if ((flags & StoreIntegrityCheckRequestFlags.Force) == StoreIntegrityCheckRequestFlags.None)
                        {
                            jobFlags |= JobFlags.Background;
                        }
                        StoreIntegrityCheckJob item = new StoreIntegrityCheckJob(new DatabaseId(null, serverFqdn, database.Name, database.Guid), Guid.Parse(input), jobFlags, (from x in array
                                                                                                                                                                               select(MailboxCorruptionType) x).ToArray <MailboxCorruptionType>());
                        result = new List <StoreIntegrityCheckJob>();
                        result.Add(item);
                        return;
                    }
                    PropValue[][] array2 = rpcAdmin.StoreIntegrityCheckEx(database.Guid, mailboxGuid, Guid.Empty, 1U, (uint)flags, array, StoreIntegrityCheckAdminRpc.JobPropTags);
                    result = new List <StoreIntegrityCheckJob>(array2.Length);
                    foreach (PropValue[] propValues in array2)
                    {
                        StoreIntegrityCheckJob item2 = new StoreIntegrityCheckJob(new DatabaseId(null, serverFqdn, database.Name, database.Guid), propValues);
                        result.Add(item2);
                    }
                }, writeError, writeWarning, writeVerbose);
            }
            catch (MapiExceptionNetworkError innerException)
            {
                writeError(new OnlineIsIntegException(database.Identity.ToString(), Strings.ServiceUnavaiable, innerException), ErrorCategory.ResourceUnavailable, database.Identity);
            }
            catch (MapiExceptionMdbOffline innerException2)
            {
                writeError(new OnlineIsIntegException(database.Identity.ToString(), Strings.DatabaseOffline, innerException2), ErrorCategory.InvalidOperation, database.Identity);
            }
            catch (MapiExceptionISIntegMdbTaskExceeded innerException3)
            {
                writeError(new OnlineIsIntegException(database.Identity.ToString(), Strings.DatabaseWideTasksExceeded, innerException3), ErrorCategory.InvalidOperation, database.Identity);
            }
            catch (MapiExceptionISIntegQueueFull innerException4)
            {
                writeError(new OnlineIsIntegException(database.Identity.ToString(), Strings.IsIntegQueueFull, innerException4), ErrorCategory.InvalidOperation, database.Identity);
            }
            catch (MapiExceptionUnknownUser)
            {
                writeWarning(Strings.WarningMailboxNeverBeenLoggedOn(mailboxGuid.ToString(), database.Identity.ToString()));
            }
            catch (MapiPermanentException ex)
            {
                writeError(new OnlineIsIntegException(database.Identity.ToString(), Strings.UnexpectedError(ex.ToString()), ex), ErrorCategory.InvalidOperation, database.Identity);
            }
            catch (MapiRetryableException ex2)
            {
                writeError(new OnlineIsIntegException(database.Identity.ToString(), Strings.UnexpectedError(ex2.ToString()), ex2), ErrorCategory.InvalidOperation, database.Identity);
            }
            return(StoreIntegrityCheckJob.Aggregate(result));
        }
        internal static StoreIntegrityCheckJob Aggregate(IList <StoreIntegrityCheckJob> jobs)
        {
            if (jobs == null || jobs.Count == 0)
            {
                return(null);
            }
            if (jobs.Count == 1)
            {
                return(jobs[0]);
            }
            HashSet <MailboxCorruptionType> hashSet = new HashSet <MailboxCorruptionType>();
            TimeSpan timeSpan = default(TimeSpan);
            List <StoreIntegrityCheckJob.Corruption> list = new List <StoreIntegrityCheckJob.Corruption>();
            DatabaseId  databaseId  = jobs[0].databaseId;
            Guid        guid        = jobs[0].requestGuid;
            Guid        empty       = jobs[0].mailboxGuid;
            Guid        guid2       = jobs[0].jobGuid;
            JobFlags    jobFlags    = JobFlags.None;
            JobSource   jobSource   = jobs[0].source;
            JobPriority jobPriority = jobs[0].priority;
            JobState    jobState    = jobs[0].state;
            DateTime?   dateTime    = null;
            DateTime?   dateTime2   = null;
            int         num         = 0;
            int         num2        = 0;
            DateTime?   dateTime3   = jobs[0].finishTime;
            long        num3        = 0L;
            bool        flag        = false;

            for (int i = 0; i < jobs.Count; i++)
            {
                StoreIntegrityCheckJob storeIntegrityCheckJob = jobs[i];
                if (storeIntegrityCheckJob.mailboxGuid != empty)
                {
                    empty = Guid.Empty;
                }
                if (!hashSet.Contains(storeIntegrityCheckJob.Tasks[0]))
                {
                    hashSet.Add(storeIntegrityCheckJob.Tasks[0]);
                }
                if (dateTime == null)
                {
                    dateTime = storeIntegrityCheckJob.creationTime;
                }
                else if (dateTime != null && storeIntegrityCheckJob.creationTime != null && dateTime.Value > storeIntegrityCheckJob.creationTime.Value)
                {
                    dateTime = storeIntegrityCheckJob.creationTime;
                }
                if (dateTime2 == null)
                {
                    dateTime2 = storeIntegrityCheckJob.lastExecutionTime;
                }
                if (dateTime2 != null && storeIntegrityCheckJob.lastExecutionTime != null && dateTime2 < storeIntegrityCheckJob.lastExecutionTime.Value)
                {
                    dateTime2 = storeIntegrityCheckJob.lastExecutionTime;
                }
                if (dateTime3 != null && storeIntegrityCheckJob.finishTime != null)
                {
                    if (dateTime3.Value < storeIntegrityCheckJob.finishTime.Value)
                    {
                        dateTime3 = storeIntegrityCheckJob.finishTime;
                    }
                }
                else
                {
                    dateTime3 = null;
                }
                if (storeIntegrityCheckJob.TimeInServer != null)
                {
                    timeSpan += storeIntegrityCheckJob.TimeInServer.Value;
                }
                jobFlags |= storeIntegrityCheckJob.flags;
                if (storeIntegrityCheckJob.state != jobState)
                {
                    if ((storeIntegrityCheckJob.state == JobState.Succeeded || storeIntegrityCheckJob.state == JobState.Failed) && (jobState == JobState.Succeeded || jobState == JobState.Failed))
                    {
                        jobState = JobState.Failed;
                    }
                    else
                    {
                        jobState = JobState.Running;
                    }
                }
                num3 += (long)storeIntegrityCheckJob.progress;
                if (storeIntegrityCheckJob.corruptions != null)
                {
                    list.AddRange(storeIntegrityCheckJob.corruptions);
                }
                num  += storeIntegrityCheckJob.CorruptionsDetected;
                num2 += storeIntegrityCheckJob.CorruptionsFixed;
                if (storeIntegrityCheckJob.errorCode != null && storeIntegrityCheckJob.errorCode.Value != 0)
                {
                    flag = true;
                }
            }
            num3 /= (long)jobs.Count;
            int?num4 = null;

            if (flag)
            {
                num4 = new int?(-2147467259);
            }
            return(new StoreIntegrityCheckJob(databaseId, empty, guid, Guid.Empty, jobFlags, hashSet.ToArray <MailboxCorruptionType>(), jobState, jobSource, jobPriority, (short)num3, dateTime, dateTime2, dateTime3, new TimeSpan?(timeSpan), num4, num, num2, list.ToArray()));
        }
 internal StoreIntegrityCheckJob(DatabaseId databaseId, Guid mailboxGuid, Guid requestGuid, Guid jobGuid, JobFlags flags, MailboxCorruptionType[] taskIds, JobState state, JobSource source, JobPriority priority, short progress, DateTime?creationTime, DateTime?lastExecutionTime, DateTime?finishTime, TimeSpan?timeInServer, int?errorCode, int corruptionsDetected, int corruptionsFixed, StoreIntegrityCheckJob.Corruption[] corruptions) : this()
 {
     this.databaseId          = databaseId;
     this.mailboxGuid         = mailboxGuid;
     this.requestGuid         = requestGuid;
     this.jobGuid             = jobGuid;
     this.flags               = flags;
     this.tasks               = taskIds;
     this.state               = state;
     this.source              = source;
     this.priority            = priority;
     this.progress            = progress;
     this.creationTime        = creationTime;
     this.lastExecutionTime   = lastExecutionTime;
     this.finishTime          = finishTime;
     this.timeInServer        = timeInServer;
     this.errorCode           = errorCode;
     this.corruptions         = corruptions;
     this.corruptionsDetected = corruptionsDetected;
     this.corruptionsFixed    = corruptionsFixed;
 }