Ejemplo n.º 1
0
 /// <summary>
 /// Constructor from the API.
 /// </summary>
 /// <param name="src"></param>
 internal IndustryJob(SerializableJobListItem src)
 {
     m_state = GetState(src);
     m_jobID = src.JobID;
     m_installedItemID = src.InstalledItemTypeID;
     m_installedItem = StaticBlueprints.GetBlueprintByID(src.InstalledItemTypeID);
     m_outputItemID = src.OutputTypeID;
     m_outputItem = GetOutputItem(src.OutputTypeID);
     m_runs = src.Runs;
     m_activity = (BlueprintActivity) Enum.ToObject(typeof (BlueprintActivity), src.ActivityID);
     m_blueprintType = (BlueprintType) Enum.ToObject(typeof (BlueprintType), src.InstalledItemCopy);
     m_installation = GetInstallation(src.OutputLocationID);
     m_solarSystem = StaticGeography.GetSystem(src.SolarSystemID);
     m_installedTime = src.InstallTime;
     m_installedItemME = src.InstalledItemMaterialLevel;
     m_installedItemPE = src.InstalledItemProductivityLevel;
     m_beginProductionTime = src.BeginProductionTime;
     m_endProductionTime = src.EndProductionTime;
     m_pauseProductionTime = src.PauseProductionTime;
     m_lastStateChange = DateTime.UtcNow;
     m_issuedFor = src.IssuedFor;
     m_activeJobState = GetActiveJobState();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Checks whether the given API object matches with this job.
 /// </summary>
 /// <param name="src"></param>
 /// <returns></returns>
 internal bool IsModified(SerializableJobListItem src)
 {
     return src.EndProductionTime != m_endProductionTime
            || src.PauseProductionTime != m_pauseProductionTime;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Checks whether the given API object matches with this job.
 /// </summary>
 /// <param name="src"></param>
 /// <returns></returns>
 internal bool MatchesWith(SerializableJobListItem src)
 {
     return src.JobID == m_jobID;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the state of a job.
        /// </summary>
        /// <param name="src">The serializable source.</param>
        /// <returns>State of the seriallzable job.</returns>
        private JobState GetState(SerializableJobListItem src)
        {
            if (src.Completed == (int) JobState.Delivered)
            {
                switch ((APIEnumerations.CCPJobCompletedStatus) src.CompletedStatus)
                {
                        // Canceled States
                    case APIEnumerations.CCPJobCompletedStatus.Aborted:
                    case APIEnumerations.CCPJobCompletedStatus.GM_Aborted:
                        return JobState.Canceled;

                        // Failed States
                    case APIEnumerations.CCPJobCompletedStatus.Inflight_Unanchored:
                    case APIEnumerations.CCPJobCompletedStatus.Destroyed:
                    case APIEnumerations.CCPJobCompletedStatus.Failed:
                        return JobState.Failed;

                        // Delivered States
                    case APIEnumerations.CCPJobCompletedStatus.Delivered:
                        return JobState.Delivered;

                    default:
                        throw new NotImplementedException();
                }
            }

            return JobState.Active;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Try to update this job with a serialization object from the API.
        /// </summary>
        /// <param name="src">The serializable source.</param>
        /// <returns>True if import sucessful otherwise, false.</returns>
        internal bool TryImport(SerializableJobListItem src)
        {
            // Note that, before a match is found, all jobs have been marked for deletion : m_markedForDeletion == true

            // Checks whether ID is the same
            if (!MatchesWith(src))
                return false;

            // Prevent deletion
            m_markedForDeletion = false;

            // Update infos (if ID is the same it may have been modified)
            if (IsModified(src))
            {
                m_endProductionTime = src.EndProductionTime;
                m_pauseProductionTime = src.PauseProductionTime;

                m_state = (m_pauseProductionTime == DateTime.MinValue ? JobState.Active : JobState.Paused);
                m_activeJobState = GetActiveJobState();
            }

            // Update state
            JobState state = GetState(src);
            if (m_state != JobState.Paused && state != m_state)
                m_state = state;

            return true;
        }