/// <summary>
 /// Refresh all ship fit data.
 /// </summary>
 public void RefreshShipFits()
 {
     ShipFitManager.RefreshAllFittingStrings();
     ShipFitManager.RefreshAllFittingHashes();
     ShipFitManager.RefreshAllShipFitPackagedVolumes();
     ShipFitManager.RefreshShipFitContractCounts();
 }
        /// <summary>
        /// Fetches and returns a Doctrine Ships ship fit.
        /// </summary>
        /// <param name="shipFitId">The id for which a ship fit object should be returned.</param>
        /// <param name="accountId">The currently logged-in account id for security checking and settings profile lookup.</param>
        /// <returns>A ship fit object or null if the account id is not authorised to view the fit or it is not found.</returns>
        public ShipFit GetShipFitDetail(int shipFitId, int accountId)
        {
            SettingProfile settingProfile;

            settingProfile = AccountManager.GetAccountSettingProfile(accountId);

            return(ShipFitManager.GetShipFitDetail(shipFitId, accountId, settingProfile));
        }
        /// <summary>
        /// Refresh the contracts of the sales agents with the oldest refresh time and update contract counts.
        /// </summary>
        /// <param name="force">Indicates that all sales agents should be refreshed, ignoring their LastContractRefresh values.</param>
        /// <param name="batchSize">The number of sales agents to refresh at a time.</param>
        public void RefreshContracts(bool force, int batchSize)
        {
            // Refresh the contracts.
            ContractManager.RefreshContracts(force, batchSize);

            // Refresh the number of valid contracts available for each ship fit.
            ShipFitManager.RefreshShipFitContractCounts();

            // Refresh the number of contracts available for each sales agent.
            SalesAgentManager.RefreshSalesAgentContractCounts();
        }
Ejemplo n.º 4
0
 public ShipFitTests()
 {
     //this.doctrineShipsServices = new DoctrineShipsServices(doctrineShipsRepository, eveDataSource, doctrineShipsValidation, logger);
     this.controller              = new SearchController(doctrineShipsServices);
     this.unitOfWork              = new UnitOfWork(new DoctrineShipsContext());
     this.eveDataSource           = new EveDataSourceCached(logger);
     this.doctrineShipsRepository = new DoctrineShipsRepository(unitOfWork);
     this.doctrineShipsValidation = new DoctrineShipsValidation(doctrineShipsRepository);
     this.shipFitManager          = new ShipFitManager(doctrineShipsRepository, eveDataSource, doctrineShipsValidation, logger);
     this.loggerStore             = new DoctrineShipsRepository(unitOfWork);
     this.logger = new SystemLogger(loggerStore);
 }
        /// <summary>
        /// Forces a contract refresh for a single sales agent. This operation is only permitted once every 30 minutes.
        /// </summary>
        /// <param name="accountId">The account Id of the requestor. The account Id should own the sales agent being refreshed.</param>
        /// <param name="salesAgentId">The id of the sales agent for which a contract refresh is to be forced.</param>
        /// <returns>Returns true if the force was successful or false if not.</returns>
        public bool ForceContractRefresh(int accountId, int salesAgentId)
        {
            // Force a contract refresh for this sales agent and store the result.
            var result = ContractManager.ForceContractRefresh(accountId, salesAgentId);

            // Refresh the number of valid contracts available for each ship fit.
            ShipFitManager.RefreshShipFitContractCounts();

            // Refresh the number of contracts available for each sales agent.
            SalesAgentManager.RefreshSalesAgentContractCounts();

            return(result);
        }
 /// <summary>
 /// Updates a doctrine for a particular account.
 /// </summary>
 /// <param name="doctrine">A partially populated doctrine object to be updated.</param>
 /// <returns>Returns a validation result object.</returns>
 public IValidationResult UpdateDoctrine(Doctrine doctrine)
 {
     return(ShipFitManager.UpdateDoctrine(doctrine));
 }
 /// <summary>
 /// Updates a doctrine ship fit list for a particular account.
 /// </summary>
 /// <param name="accountId">The account Id of the requestor. The account Id should own the doctrine being updated.</param>
 /// <param name="doctrineId">The doctrine Id to be updated.</param>
 /// <param name="doctrineShipFitIds">An array of ship fit ids to be assigned to the doctrine.</param>
 /// <returns>Returns a validation result object.</returns>
 public IValidationResult UpdateDoctrineShipFits(int accountId, int doctrineId, int[] doctrineShipFitIds)
 {
     return(ShipFitManager.UpdateDoctrineShipFits(accountId, doctrineId, doctrineShipFitIds));
 }
 /// <summary>
 /// Deletes a doctrine.
 /// </summary>
 /// <param name="accountId">The account Id of the requestor. The account Id should own the doctrine being deleted.</param>
 /// <param name="doctrineId">The doctrine Id to be deleted.</param>
 /// <returns>Returns true if the deletion was successful or false if not.</returns>
 public bool DeleteDoctrine(int accountId, int doctrineId)
 {
     return(ShipFitManager.DeleteDoctrine(accountId, doctrineId));
 }
 /// <summary>
 /// <para>Adds a Doctrine.</para>
 /// </summary>
 /// <param name="doctrine">A populated doctrine object.</param>
 /// <returns>Returns a validation result object.</returns>
 public IValidationResult AddDoctrine(Doctrine doctrine)
 {
     return(ShipFitManager.AddDoctrine(doctrine));
 }
 /// <summary>
 /// Returns a list of doctrines that include a particular ship fit.
 /// </summary>
 /// <param name="shipFitId">The shipfit for which the doctrines should be returned.</param>
 /// <returns>A list of doctrine objects.</returns>
 public IEnumerable <Doctrine> GetDoctrinesByShipFit(int shipFitId)
 {
     return(ShipFitManager.GetDoctrines(shipFitId));
 }
 /// <summary>
 /// Returns a doctrine for a given account and doctrine id.
 /// </summary>
 /// <param name="accountId">The currently logged-in account id for security checking.</param>
 /// <param name="doctrineId">The id for which a doctrine object should be returned.</param>
 /// <returns>A doctrine object.</returns>
 public Doctrine GetDoctrineDetail(int accountId, int doctrineId)
 {
     return(ShipFitManager.GetDoctrineDetail(accountId, doctrineId));
 }
 /// <summary>
 /// Generate and returns an EFT fitting string for a ship fit.
 /// </summary>
 /// <param name="shipFitId">The id of a doctrine ships ship fit.</param>
 /// <param name="accountId">The currently logged-in account id for security checking.</param>
 /// <returns>Returns a string containing an EFT fitting or an empty string if an error occurs.</returns>
 public string GetEftFittingString(int shipFitId, int accountId)
 {
     return(ShipFitManager.GetEftFittingString(shipFitId, accountId));
 }
 /// <summary>
 /// Returns a list of all doctrines for a given account.
 /// </summary>
 /// <param name="accountId">The account for which the doctrines should be returned.</param>
 /// <returns>A list of doctrine objects.</returns>
 public IEnumerable <Doctrine> GetDoctrineList(int accountId)
 {
     return(ShipFitManager.GetDoctrineList(accountId));
 }
 /// <summary>
 /// Returns a list of contracts for a given ship fit.
 /// </summary>
 /// <param name="shipFitId">The id of the ship fit for which contracts should be returned.</param>
 /// <returns>A list of ship fit contract objects.</returns>
 public IEnumerable <Contract> GetShipFitContracts(int shipFitId)
 {
     return(ShipFitManager.GetShipFitContracts(shipFitId));
 }
 /// <summary>
 /// Updates a ship fit for a particular account.
 /// </summary>
 /// <param name="shipFit">A partially populated ship fit object to be updated.</param>
 /// <returns>Returns a validation result object.</returns>
 public IValidationResult UpdateShipFit(ShipFit shipFit)
 {
     return(ShipFitManager.UpdateShipFit(shipFit));
 }
 /// <summary>
 /// Updates the state of a ship fit's contract availability monitoring.
 /// </summary>
 /// <param name="accountId">The account Id of the requestor. The account Id should own the ship fit being changed.</param>
 /// <param name="shipFitId">The id of the ship fit to be changed.</param>
 /// <param name="isActive">The required boolean state.</param>
 /// <returns>Returns true if the change was successful or false if not.</returns>
 public bool UpdateShipFitMonitoringState(int accountId, int shipFitId, bool isActive)
 {
     return(ShipFitManager.UpdateShipFitMonitoringState(accountId, shipFitId, isActive));
 }
        /// <summary>
        /// Deletes an account and all access codes, ship fits, sales agents and their contracts.
        /// </summary>
        /// <param name="accountId">The account Id being deleted.</param>
        /// <returns>Returns a validation result object.</returns>
        public IValidationResult DeleteAccount(int accountId)
        {
            IValidationResult validationResult = new ValidationResult();

            // Delete all account ship fits, components and related contracts.
            var accountShipFits = ShipFitManager.GetShipFitList(accountId);

            foreach (var shipFit in accountShipFits)
            {
                if (ShipFitManager.DeleteShipFit(accountId, shipFit.ShipFitId) == false)
                {
                    validationResult.AddError(shipFit.ShipFitId.ToString(), "Error while deleting ship fit: " + shipFit.ShipFitId.ToString());
                }
            }

            // Delete all account sales agents.
            var accountSalesAgents = SalesAgentManager.GetSalesAgents(accountId);

            foreach (var salesAgent in accountSalesAgents)
            {
                if (SalesAgentManager.DeleteSalesAgent(accountId, salesAgent.SalesAgentId) == false)
                {
                    validationResult.AddError(salesAgent.SalesAgentId.ToString(), "Error while deleting sales agent: " + salesAgent.SalesAgentId.ToString());
                }
            }

            // Delete all account doctrines.
            var accountDoctrines = ShipFitManager.GetDoctrineList(accountId);

            foreach (var doctrine in accountDoctrines)
            {
                if (ShipFitManager.DeleteDoctrine(accountId, doctrine.DoctrineId) == false)
                {
                    validationResult.AddError(doctrine.DoctrineId.ToString(), "Error while deleting doctrine: " + doctrine.DoctrineId.ToString());
                }
            }

            // Delete all account access codes.
            var accountAccessCodes = AccountManager.GetAccessCodes(accountId);

            foreach (var accessCode in accountAccessCodes)
            {
                if (AccountManager.DeleteAccessCode(accountId, accessCode.AccessCodeId) == false)
                {
                    validationResult.AddError(accessCode.AccessCodeId.ToString(), "Error while deleting access code: " + accessCode.AccessCodeId.ToString());
                }
            }

            // Delete all notification recipients.
            var accountNotificationRecipients = AccountManager.GetNotificationRecipients(accountId);

            foreach (var notificationRecipient in accountNotificationRecipients)
            {
                if (AccountManager.DeleteNotificationRecipient(accountId, notificationRecipient.NotificationRecipientId) == false)
                {
                    validationResult.AddError(notificationRecipient.NotificationRecipientId.ToString(), "Error while deleting notification recipient: " + notificationRecipient.NotificationRecipientId.ToString());
                }
            }

            // Delete the account.
            if (AccountManager.DeleteAccount(accountId) == false)
            {
                validationResult.AddError(accountId.ToString(), "Error while deleting account: " + accountId.ToString());
            }

            try
            {
                // Delete the account setting profile.
                var settingProfile = this.GetAccountSettingProfile(accountId);
                if (AccountManager.DeleteSettingProfile(accountId, settingProfile.SettingProfileId) == false)
                {
                    validationResult.AddError(settingProfile.SettingProfileId.ToString(), "Error while deleting setting profile: " + settingProfile.SettingProfileId.ToString());
                }
            }
            catch (System.ArgumentException e)
            {
                // The setting profile did not exist. Add an error to the validation result object.
                validationResult.AddError("SettingProfile.Exists" + accountId.ToString(), "The setting profile did not exist for account id: " + accountId.ToString());
            }
            catch (Exception)
            {
                throw;
            }

            return(validationResult);
        }
 /// <summary>
 /// Returns a list of all Doctrine Ships ship fits for a given account.
 /// </summary>
 /// <param name="accountId">The account for which the ship fits should be returned.</param>
 /// <returns>A list of ship fit objects.</returns>
 public IEnumerable <ShipFit> GetShipFitList(int accountId)
 {
     return(ShipFitManager.GetShipFitList(accountId));
 }
 /// <summary>
 /// Deletes a ship fit, its components and all related contracts.
 /// </summary>
 /// <param name="accountId">The account Id of the requestor. The account Id should own the ship fit being deleted.</param>
 /// <param name="shipFitId">The ship fit Id to be deleted.</param>
 /// <returns>Returns true if the deletion was successful or false if not.</returns>
 public bool DeleteShipFit(int accountId, int shipFitId)
 {
     return(ShipFitManager.DeleteShipFit(accountId, shipFitId));
 }
 /// <summary>
 /// Import a Doctrine Ships ship fitting.
 /// </summary>
 /// <param name="toParse">A ship fitting string in a supported format to be parsed.</param>
 /// <param name="accountId">The account for which the ship fit should be imported.</param>
 /// <returns>Returns a list of populated ship fit objects or an empty list if the process fails.</returns>
 public IEnumerable <ShipFit> ImportShipFit(string toParse, int accountId)
 {
     return(ShipFitManager.ImportShipFitEveXml(toParse, accountId));
 }