Ejemplo n.º 1
0
 public void RegionLoaded(Scene scene)
 {
     InventoryService = m_scene.InventoryService;
     AssetService = m_scene.AssetService;
     UserAccountService = m_scene.UserAccountService;
     AvatarService = m_scene.AvatarService;
 }
Ejemplo n.º 2
0
        public void Startup()
        {
            _orderRepository = new TestOrderRepository();
            _catalogRepository = new TestCatalogRepository();
            _addressValidation = new TestAddressValidator();
            _shippingRepository = new TestShippingRepository();
            _shippingService = new SimpleShippingService(_shippingRepository);
            _taxRepository = new TestTaxRepository();
            _taxService = new RegionalSalesTaxService(_taxRepository);
            _orderService = new OrderService(_orderRepository,_catalogRepository,_shippingRepository,_shippingService);
            _personalizationRepository = new TestPersonalizationRepository();
            _personalizationService = new PersonalizationService(_personalizationRepository,_orderRepository, _orderService,_catalogRepository);
            _catalogService = new CatalogService(_catalogRepository,_orderService);
            _paymentService = new FakePaymentService();
            _incentiveRepository = new TestIncentiveRepository();
            _incentiveService = new IncentiveService(_incentiveRepository);

            //this service throws the sent mailers into a collection
            //and does not use SMTP
            _mailerService = new TestMailerService();
            _inventoryRepository = new TestInventoryRepository();
            _inventoryService = new InventoryService(_inventoryRepository,_catalogService);
            _mailerRepository = new TestMailerRepository();
            _pipeline=new DefaultPipeline(
                _addressValidation,_paymentService,
                _orderService,_mailerService,
                _inventoryService
                );


        }
Ejemplo n.º 3
0
        public BasicReportModule(IRegionManager regionManager, BasicReportView basicReportView,
            IWorkPeriodService workPeriodService, IPrinterService printerService, ICacheService cacheService,
            IInventoryService inventoryService, IUserService userService, IAutomationService automationService,
            IApplicationState applicationState, ILogService logService, ISettingService settingService)
            : base(regionManager, AppScreens.ReportView)
        {
            ReportContext.PrinterService = printerService;
            ReportContext.WorkPeriodService = workPeriodService;
            ReportContext.InventoryService = inventoryService;
            ReportContext.UserService = userService;
            ReportContext.ApplicationState = applicationState;
            ReportContext.CacheService = cacheService;
            ReportContext.LogService = logService;
            ReportContext.SettingService = settingService;

            _userService = userService;

            _regionManager = regionManager;
            _basicReportView = basicReportView;
            SetNavigationCommand(Resources.Reports, Resources.Common, "Images/Ppt.png", 60);

            PermissionRegistry.RegisterPermission(PermissionNames.OpenReports, PermissionCategories.Navigation, Resources.CanDisplayReports);
            PermissionRegistry.RegisterPermission(PermissionNames.ChangeReportDate, PermissionCategories.Report, Resources.CanChangeReportFilter);

            //todo refactor
            automationService.RegisterParameterSource("ReportName", () => ReportContext.Reports.Select(x => x.Header));

        }
        public InventoryServiceInConnector(IConfigSource config, IHttpServer server, string configName) :
                base(config, server, configName)
        {
            if (configName != string.Empty)
                m_ConfigName = configName;
    
            IConfig serverConfig = config.Configs[m_ConfigName];
            if (serverConfig == null)
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));

            string inventoryService = serverConfig.GetString("LocalServiceModule",
                    String.Empty);

            if (inventoryService == String.Empty)
                throw new Exception("No LocalServiceModule in config file");

            Object[] args = new Object[] { config };
            m_InventoryService =
                    ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args);

            m_userserver_url = serverConfig.GetString("UserServerURI", String.Empty);
            m_doLookup = serverConfig.GetBoolean("SessionAuthentication", false);

            AddHttpHandlers(server);
            m_log.Debug("[INVENTORY HANDLER]: handlers initialized");
        }
 public WarehouseInventoryViewModel(IInventoryService inventoryService, ICacheService cacheService, IApplicationState applicationState)
 {
     _inventoryService = inventoryService;
     _cacheService = cacheService;
     _applicationState = applicationState;
     WarehouseButtonSelectedCommand = new CaptionCommand<Warehouse>("", OnWarehouseSelected);
 }
Ejemplo n.º 6
0
 public SalesService(IFinancialService financialService,
     IInventoryService inventoryService,
     IRepository<SalesOrderHeader> salesOrderRepo,
     IRepository<SalesInvoiceHeader> salesInvoiceRepo,
     IRepository<SalesReceiptHeader> salesReceiptRepo,
     IRepository<Customer> customerRepo,
     IRepository<Account> accountRepo,
     IRepository<Item> itemRepo,
     IRepository<Measurement> measurementRepo,
     IRepository<SequenceNumber> sequenceNumberRepo,
     IRepository<PaymentTerm> paymentTermRepo,
     IRepository<SalesDeliveryHeader> salesDeliveryRepo,
     IRepository<Bank> bankRepo,
     IRepository<GeneralLedgerSetting> generalLedgerSetting,
     IRepository<Contact> contactRepo)
     : base(sequenceNumberRepo, generalLedgerSetting, paymentTermRepo, bankRepo)
 {
     _financialService = financialService;
     _inventoryService = inventoryService;
     _salesOrderRepo = salesOrderRepo;
     _salesInvoiceRepo = salesInvoiceRepo;
     _salesReceiptRepo = salesReceiptRepo;
     _customerRepo = customerRepo;
     _accountRepo = accountRepo;
     _itemRepo = itemRepo;
     _measurementRepo = measurementRepo;
     _sequenceNumberRepo = sequenceNumberRepo;
     _paymentTermRepo = paymentTermRepo;
     _salesDeliveryRepo = salesDeliveryRepo;
     _bankRepo = bankRepo;
     _genetalLedgerSetting = generalLedgerSetting;
     _contactRepo = contactRepo;
 }
        public WebFetchInvDescServerConnector(IConfigSource config, IHttpServer server, string configName) :
                base(config, server, configName)
        {
            if (configName != String.Empty)
                m_ConfigName = configName;

            IConfig serverConfig = config.Configs[m_ConfigName];
            if (serverConfig == null)
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));

            string invService = serverConfig.GetString("InventoryService", String.Empty);

            if (invService == String.Empty)
                throw new Exception("No InventoryService in config file");

            Object[] args = new Object[] { config };
            m_InventoryService =
                    ServerUtils.LoadPlugin<IInventoryService>(invService, args);

            if (m_InventoryService == null)
                throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName));

            string libService = serverConfig.GetString("LibraryService", String.Empty);
            m_LibraryService =
                    ServerUtils.LoadPlugin<ILibraryService>(libService, args);

            WebFetchInvDescHandler webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService);
            IRequestHandler reqHandler = new RestStreamHandler("POST", "/CAPS/WebFetchInvDesc/" /*+ UUID.Random()*/, webFetchHandler.FetchInventoryDescendentsRequest);
            server.AddStreamHandler(reqHandler);
        }
        public FetchInventory2ServerConnector(IConfigSource config, IHttpServer server, string configName)
            : base(config, server, configName)
        {
            if (configName != String.Empty)
                m_ConfigName = configName;

            IConfig serverConfig = config.Configs[m_ConfigName];
            if (serverConfig == null)
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));

            string invService = serverConfig.GetString("InventoryService", String.Empty);

            if (invService == String.Empty)
                throw new Exception("No InventoryService in config file");

            Object[] args = new Object[] { config };
            m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);

            if (m_InventoryService == null)
                throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName));

            FetchInventory2Handler fiHandler = new FetchInventory2Handler(m_InventoryService);
            IRequestHandler reqHandler
                = new RestStreamHandler("POST", "/CAPS/FetchInventory/", fiHandler.FetchInventoryRequest);
            server.AddStreamHandler(reqHandler);
        }
Ejemplo n.º 9
0
        public BasicReportModule(IRegionManager regionManager, BasicReportView basicReportView,
            IWorkPeriodService workPeriodService, IPrinterService printerService,
            IInventoryService inventoryService, IUserService userService,
            IApplicationState applicationState, IAutomationService automationService, ILogService logService)
            : base(regionManager, AppScreens.ReportView)
        {
            ReportContext.PrinterService = printerService;
            ReportContext.WorkPeriodService = workPeriodService;
            ReportContext.InventoryService = inventoryService;
            ReportContext.UserService = userService;
            ReportContext.ApplicationState = applicationState;
            ReportContext.LogService = logService;

            _userService = userService;

            _regionManager = regionManager;
            _basicReportView = basicReportView;
            SetNavigationCommand(Resources.Reports, Resources.Common, "Images/Ppt.png", 60);

            PermissionRegistry.RegisterPermission(PermissionNames.OpenReports, PermissionCategories.Navigation, Resources.CanDisplayReports);
            PermissionRegistry.RegisterPermission(PermissionNames.ChangeReportDate, PermissionCategories.Report, Resources.CanChangeReportFilter);

            automationService.RegisterActionType("SaveReportToFile", Resources.SaveReportToFile, new { ReportName = "", FileName = "" });
            automationService.RegisterActionType(ActionNames.PrintReport, Resources.PrintReport, new { ReportName = "" });
            automationService.RegisterParameterSoruce("ReportName", () => ReportContext.Reports.Select(x => x.Header));

            EventServiceFactory.EventService.GetEvent<GenericEvent<IActionData>>().Subscribe(x =>
            {
                if (x.Value.Action.ActionType == "SaveReportToFile")
                {
                    var reportName = x.Value.GetAsString("ReportName");
                    var fileName = x.Value.GetAsString("FileName");
                    if (!string.IsNullOrEmpty(reportName))
                    {
                        var report = ReportContext.Reports.FirstOrDefault(y => y.Header == reportName);
                        if (report != null)
                        {
                            ReportContext.CurrentWorkPeriod = ReportContext.ApplicationState.CurrentWorkPeriod;
                            var document = report.GetReportDocument();
                            ReportViewModelBase.SaveAsXps(fileName, document);
                        }
                    }
                }

                if (x.Value.Action.ActionType == ActionNames.PrintReport)
                {
                    var reportName = x.Value.GetAsString("ReportName");
                    if (!string.IsNullOrEmpty(reportName))
                    {
                        var report = ReportContext.Reports.FirstOrDefault(y => y.Header == reportName);
                        if (report != null)
                        {
                            ReportContext.CurrentWorkPeriod = ReportContext.ApplicationState.CurrentWorkPeriod;
                            var document = report.GetReportDocument();
                            ReportContext.PrinterService.PrintReport(document, ReportContext.ApplicationState.CurrentTerminal.ReportPrinter);
                        }
                    }
                }
            });
        }
Ejemplo n.º 10
0
 public void Setup()
 {
     MefBootstrapper.ComposeParts();
     WorkPeriodService = MefBootstrapper.Resolve<IWorkPeriodService>();
     InventoryService = MefBootstrapper.Resolve<IInventoryService>();
     ApplicationState = MefBootstrapper.Resolve<IApplicationState>();
 }
Ejemplo n.º 11
0
 public OrdersController(
     IQuartetClientFactory                       clientFactory,
     IMappingService<Order,    OrderViewModel>   orderMapping,
     IMappingService<Customer, HCardViewModel>   hcardMapping,
     IMappingService<Address,  AddressViewModel> addressMapping,
     IMailingService                             mailingService,
     IInvoicingService                           invoicingService,
     IFeaturesConfigService                      featuresConfigService,
     IAppSettings                                appSettings,
     IConsultantContext                          consultantContext,
     IConsultantDataServiceClientFactory         consultantDataServiceClientFactory,
     IPromotionService                           promotionService,
     IProductCatalogClientFactory                productCatalogClientFactory,
     IInventoryService                           inventoryService,
     ISubsidiaryAccessor                         subsidiaryAccessor
 )
 {
     _clientFactory                      = clientFactory;
     _orderMapping                       = orderMapping;
     _hcardMapping                       = hcardMapping;
     _addressMapping                     = addressMapping;
     _mailingService                     = mailingService;
     _invoicingService                   = invoicingService;
     _featuresConfigService              = featuresConfigService;
     _appSettings                        = appSettings;
     _consultantContext                  = consultantContext;
     _consultantDataServiceClientFactory = consultantDataServiceClientFactory;
     _promotionService                   = promotionService;
     _productCatalogClientFactory        = productCatalogClientFactory;
     _inventoryService                   = inventoryService;
     _subsidiaryAccessor                 = subsidiaryAccessor;
 }
Ejemplo n.º 12
0
        public InventoryModule(IRegionManager regionManager, ICacheService cacheService, IUserService userService, IInventoryService inventoryService,
            WarehouseInventoryView resourceInventoryView, WarehouseInventoryViewModel resourceInventoryViewModel, ILogService logService)
            : base(regionManager, AppScreens.InventoryView)
        {
            _regionManager = regionManager;
            _cacheService = cacheService;
            _userService = userService;
            _inventoryService = inventoryService;
            _warehouseInventoryView = resourceInventoryView;
            _warehouseInventoryViewModel = resourceInventoryViewModel;
            _logService = logService;

            AddDashboardCommand<EntityCollectionViewModelBase<WarehouseTypeViewModel, WarehouseType>>(Resources.WarehouseType.ToPlural(), Resources.Inventory, 35);
            AddDashboardCommand<EntityCollectionViewModelBase<WarehouseViewModel, Warehouse>>(Resources.Warehouse.ToPlural(), Resources.Inventory, 35);
            AddDashboardCommand<EntityCollectionViewModelBase<TransactionTypeViewModel, InventoryTransactionType>>(Resources.TransactionType.ToPlural(), Resources.Inventory, 35);
            AddDashboardCommand<EntityCollectionViewModelBase<TransactionDocumentTypeViewModel, InventoryTransactionDocumentType>>(Resources.DocumentType.ToPlural(), Resources.Inventory, 35);
            AddDashboardCommand<TransactionDocumentListViewModel>(Resources.Transaction.ToPlural(), Resources.Inventory, 35);

            AddDashboardCommand<EntityCollectionViewModelBase<InventoryItemViewModel, InventoryItem>>(Resources.InventoryItems, Resources.Inventory, 35);
            AddDashboardCommand<RecipeListViewModel>(Resources.Recipes, Resources.Inventory, 35);
            AddDashboardCommand<PeriodicConsumptionListViewModel>(Resources.EndOfDayRecords, Resources.Inventory, 36);

            SetNavigationCommand(Resources.Warehouses, Resources.Common, "Images/box.png", 40);

            EventServiceFactory.EventService.GetEvent<GenericEvent<Entity>>().Subscribe(OnResourceEvent);
            EventServiceFactory.EventService.GetEvent<GenericEvent<Warehouse>>().Subscribe(OnWarehouseEvent);

            PermissionRegistry.RegisterPermission(PermissionNames.OpenInventory, PermissionCategories.Navigation, string.Format(Resources.CanNavigate_f, Resources.Inventory));
        }
Ejemplo n.º 13
0
 public PurchasingService(IFinancialService financialService,
     IInventoryService inventoryService,
     IRepository<PurchaseOrderHeader> purchaseOrderRepo,
     IRepository<PurchaseInvoiceHeader> purchaseInvoiceRepo,
     IRepository<PurchaseReceiptHeader> purchaseReceiptRepo,
     IRepository<Vendor> vendorRepo,
     IRepository<Account> accountRepo,
     IRepository<Item> itemRepo,
     IRepository<Measurement> measurementRepo,
     IRepository<SequenceNumber> sequenceNumberRepo,
     IRepository<VendorPayment> vendorPaymentRepo,
     IRepository<GeneralLedgerSetting> generalLedgerSettingRepo,
     IRepository<PaymentTerm> paymentTermRepo,
     IRepository<Bank> bankRepo
     )
     : base(sequenceNumberRepo, generalLedgerSettingRepo, paymentTermRepo, bankRepo)
 {
     _financialService = financialService;
     _inventoryService = inventoryService;
     _purchaseOrderRepo = purchaseOrderRepo;
     _purchaseInvoiceRepo = purchaseInvoiceRepo;
     _purchaseReceiptRepo = purchaseReceiptRepo;
     _vendorRepo = vendorRepo;
     _accountRepo = accountRepo;
     _itemRepo = itemRepo;
     _measurementRepo = measurementRepo;
     _sequenceNumberRepo = sequenceNumberRepo;
     _vendorPaymentRepo = vendorPaymentRepo;
     _generalLedgerSettingRepo = generalLedgerSettingRepo;
     _paymentTermRepo = paymentTermRepo;
     _bankRepo = bankRepo;
 }
        private void ConnectToServices(Action onConnectionCallback)
        {
            if (_retryCount < 4)
            {
                try
                {
                    _corporateInventoryService =
                        new ChannelFactory<IInventoryService>("CorporateOfficeInventoryService").CreateChannel();

                    _webSiteInventoryChannel =
                        new ChannelFactory<IInventoryService>("WebSiteInventoryService");

                    _storeInventoryService = _webSiteInventoryChannel.CreateChannel();

                    _retryCount = 0;

                    if (onConnectionCallback != null)
                        onConnectionCallback();
                }
                catch
                {
                    _retryCount += 1;
                    Thread.Sleep(2000);
                }
            }
        }
Ejemplo n.º 15
0
 public FinancialService(IInventoryService inventoryService, 
     IRepository<GeneralLedgerHeader> generalLedgerRepository,
     IRepository<GeneralLedgerLine> generalLedgerLineRepository,
     IRepository<Account> accountRepo,
     IRepository<Tax> taxRepo,
     IRepository<JournalEntryHeader> journalEntryRepo,
     IRepository<FiscalYear> fiscalYearRepo,
     IRepository<TaxGroup> taxGroupRepo,
     IRepository<ItemTaxGroup> itemTaxGroupRepo,
     IRepository<PaymentTerm> paymentTermRepo,
     IRepository<Bank> bankRepo,
     IRepository<Item> itemRepo,
     IRepository<GeneralLedgerSetting> glSettingRepo
     )
     :base(null, null, paymentTermRepo, bankRepo)
 {
     _inventoryService = inventoryService;
     _generalLedgerRepository = generalLedgerRepository;
     _accountRepo = accountRepo;
     _taxRepo = taxRepo;
     _journalEntryRepo = journalEntryRepo;
     _generalLedgerLineRepository = generalLedgerLineRepository;
     _fiscalYearRepo = fiscalYearRepo;
     _taxGroupRepo = taxGroupRepo;
     _itemTaxGroupRepo = itemTaxGroupRepo;
     _paymentTermRepo = paymentTermRepo;
     _bankRepo = bankRepo;
     _itemRepo = itemRepo;
     _glSettingRepo = glSettingRepo;
 }
        public XInventoryInConnector(IConfigSource config, IHttpServer server, string configName) :
                base(config, server, configName)
        {
            if (configName != String.Empty)
                m_ConfigName = configName;

            m_log.DebugFormat("[XInventoryInConnector]: Starting with config name {0}", m_ConfigName);

            IConfig serverConfig = config.Configs[m_ConfigName];
            if (serverConfig == null)
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));

            string inventoryService = serverConfig.GetString("LocalServiceModule",
                    String.Empty);

            if (inventoryService == String.Empty)
                throw new Exception("No InventoryService in config file");

            Object[] args = new Object[] { config, m_ConfigName };
            m_InventoryService =
                    ServerUtils.LoadPlugin<IInventoryService>(inventoryService, args);

            IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);

            server.AddStreamHandler(new XInventoryConnectorPostHandler(m_InventoryService, auth));
        }
Ejemplo n.º 17
0
 public SalesViewModelBuilder(IInventoryService inventoryService,
     IFinancialService financialService,
     ISalesService salesService)
 {
     _inventoryService = inventoryService;
     _financialService = financialService;
     _salesService = salesService;
 }
Ejemplo n.º 18
0
 public ReportsController(ISalesService salesService,
     IInventoryService inventoryService,
     IFinancialService financialService)
 {
     _salesService = salesService;
     _inventoryService = inventoryService;
     _financialService = financialService;
 }
Ejemplo n.º 19
0
 public PurchasingController(IInventoryService inventoryService,
     IFinancialService financialService,
     IPurchasingService purchasingService)
 {
     _inventoryService = inventoryService;
     _financialService = financialService;
     _purchasingService = purchasingService;
 }
Ejemplo n.º 20
0
 public TransactionViewModel(InventoryTransaction model, IWorkspace workspace, IInventoryService inventoryService, ICacheService cacheService)
 {
     _workspace = workspace;
     _inventoryService = inventoryService;
     _cacheService = cacheService;
     Model = model;
     UpdateWarehouses();
 }
Ejemplo n.º 21
0
 public AdministrationController(IInventoryService inventoryService,
     ISalesService salesService,
     IAdministrationService administrationService)
 {
     _inventoryService = inventoryService;
     _salesService = salesService;
     _administrationService = administrationService;
 }
Ejemplo n.º 22
0
 public InventoryConnectorPostHandler(string url, IInventoryService service, string SessionID,
                                      IRegistryCore registry)
     : base("POST", url)
 {
     m_InventoryService = service;
     m_SessionID = SessionID;
     m_registry = registry;
 }
Ejemplo n.º 23
0
        public UserAccountService(IConfigSource config)
            : base(config)
        {
            IConfig userConfig = config.Configs["UserAccountService"];
            if (userConfig == null)
                throw new Exception("No UserAccountService configuration");

            string gridServiceDll = userConfig.GetString("GridService", string.Empty);
            if (gridServiceDll != string.Empty)
                m_GridService = LoadPlugin<IGridService>(gridServiceDll, new Object[] { config });

            string authServiceDll = userConfig.GetString("AuthenticationService", string.Empty);
            if (authServiceDll != string.Empty)
                m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config });

            string presenceServiceDll = userConfig.GetString("GridUserService", string.Empty);
            if (presenceServiceDll != string.Empty)
                m_GridUserService = LoadPlugin<IGridUserService>(presenceServiceDll, new Object[] { config });

            string invServiceDll = userConfig.GetString("InventoryService", string.Empty);
            if (invServiceDll != string.Empty)
                m_InventoryService = LoadPlugin<IInventoryService>(invServiceDll, new Object[] { config });

            string avatarServiceDll = userConfig.GetString("AvatarService", string.Empty);
            if (avatarServiceDll != string.Empty)
                m_AvatarService = LoadPlugin<IAvatarService>(avatarServiceDll, new Object[] { config });

            m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false);

            // In case there are several instances of this class in the same process,
            // the console commands are only registered for the root instance
            if (m_RootInstance == null && MainConsole.Instance != null)
            {
                m_RootInstance = this;
                MainConsole.Instance.Commands.AddCommand("Users", false,
                        "create user",
                        "create user [<first> [<last> [<pass> [<email> [<user id>]]]]]",
                        "Create a new user", HandleCreateUser);

                MainConsole.Instance.Commands.AddCommand("Users", false,
                        "reset user password",
                        "reset user password [<first> [<last> [<password>]]]",
                        "Reset a user password", HandleResetUserPassword);

                MainConsole.Instance.Commands.AddCommand("Users", false,
                        "set user level",
                        "set user level [<first> [<last> [<level>]]]",
                        "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, "
                            + "this account will be treated as god-moded. "
                            + "It will also affect the 'login level' command. ",
                        HandleSetUserLevel);

                MainConsole.Instance.Commands.AddCommand("Users", false,
                        "show account",
                        "show account <first> <last>",
                        "Show account details for the given user", HandleShowAccount);
            }
        }
Ejemplo n.º 24
0
 public LoginSwitch( UserLoginService service,
                     IInterServiceInventoryServices interInventoryService,
                     IInventoryService inventoryService,
                     IGridService gridService,
                     UserConfig config)
 {
     m_UserLoginService = service;
     m_RealXtendLogin = new RealXtendLogin(service, interInventoryService, inventoryService, this, gridService, config);
 }
Ejemplo n.º 25
0
 public void Start(IConfigSource config, IRegistryCore registry)
 {
     m_GridService = registry.RequestModuleInterface<IGridService>();
     m_AuthenticationService = registry.RequestModuleInterface<IAuthenticationService>();
     m_InventoryService = registry.RequestModuleInterface<IInventoryService>();
     m_Database = DataManager.RequestPlugin<IUserAccountData>();
     if (m_Database == null)
         throw new Exception("Could not find a storage interface in the given module");
 }
Ejemplo n.º 26
0
        public void IncomingCapsRequest (UUID agentID, Framework.Services.GridRegion region, ISimulationBase simbase, ref OSDMap capURLs)
        {
            m_agentID = agentID;
            m_moneyModule = simbase.ApplicationRegistry.RequestModuleInterface<IMoneyModule> ();
            m_assetService = simbase.ApplicationRegistry.RequestModuleInterface<IAssetService> ();
            m_inventoryService = simbase.ApplicationRegistry.RequestModuleInterface<IInventoryService> ();
            m_libraryService = simbase.ApplicationRegistry.RequestModuleInterface<ILibraryService> ();
            m_inventoryData = Framework.Utilities.DataManager.RequestPlugin<IInventoryData> ();

            HttpServerHandle method;
            string uri;

            method = (path, request, httpRequest, httpResponse) => HandleFetchInventoryDescendents (request, m_agentID);
            uri = "/CAPS/FetchInventoryDescendents/" + UUID.Random () + "/";
            capURLs ["WebFetchInventoryDescendents"] = MainServer.Instance.ServerURI + uri;
            capURLs ["FetchInventoryDescendents"] = MainServer.Instance.ServerURI + uri;
            capURLs ["FetchInventoryDescendents2"] = MainServer.Instance.ServerURI + uri;
            m_uris.Add (uri);
            MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", uri, method));

            method = (path, request, httpRequest, httpResponse) => HandleFetchLibDescendents (request, m_agentID);
            uri = "/CAPS/FetchLibDescendents/" + UUID.Random () + "/";
            capURLs ["FetchLibDescendents"] = MainServer.Instance.ServerURI + uri;
            capURLs ["FetchLibDescendents2"] = MainServer.Instance.ServerURI + uri;
            m_uris.Add (uri);
            MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", uri, method));

            method = (path, request, httpRequest, httpResponse) => HandleFetchInventory (request, m_agentID);
            uri = "/CAPS/FetchInventory/" + UUID.Random () + "/";
            capURLs ["FetchInventory"] = MainServer.Instance.ServerURI + uri;
            capURLs ["FetchInventory2"] = MainServer.Instance.ServerURI + uri;
            m_uris.Add (uri);
            MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", uri, method));

            method = (path, request, httpRequest, httpResponse) => HandleFetchLib (request, m_agentID);
            uri = "/CAPS/FetchLib/" + UUID.Random () + "/";
            capURLs ["FetchLib"] = MainServer.Instance.ServerURI + uri;
            capURLs ["FetchLib2"] = MainServer.Instance.ServerURI + uri;
            m_uris.Add (uri);
            MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", uri, method));


            uri = "/CAPS/NewFileAgentInventory/" + UUID.Random () + "/";
            capURLs ["NewFileAgentInventory"] = MainServer.Instance.ServerURI + uri;
            m_uris.Add (uri);
            MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", uri, NewAgentInventoryRequest));

            uri = "/CAPS/NewFileAgentInventoryVariablePrice/" + UUID.Random () + "/";
            capURLs ["NewFileAgentInventoryVariablePrice"] = MainServer.Instance.ServerURI + uri;
            m_uris.Add (uri);
            MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", uri, NewAgentInventoryRequestVariablePrice));

            uri = "/CAPS/CreateInventoryCategory/" + UUID.Random () + "/";
            capURLs ["CreateInventoryCategory"] = MainServer.Instance.ServerURI + uri;
            m_uris.Add (uri);
            MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", uri, CreateInventoryCategory));
        }
Ejemplo n.º 27
0
        public void RegisterCaps(IRegionClientCapsService service)
        {
            m_service = service;
            m_assetService = service.Registry.RequestModuleInterface<IAssetService>();
            m_inventoryService = service.Registry.RequestModuleInterface<IInventoryService>();
            m_libraryService = service.Registry.RequestModuleInterface<ILibraryService>();

            RestBytesMethod method = delegate(string request, string path, string param,
                                                                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                return HandleWebFetchInventoryDescendents(request, m_service.AgentID);
            };
            service.AddStreamHandler("WebFetchInventoryDescendents",
                new RestBytesStreamHandler("POST", service.CreateCAPS("WebFetchInventoryDescendents", ""),
                                                      method));

            method = delegate(string request, string path, string param,
                                                                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                return HandleFetchLibDescendents(request, m_service.AgentID);
            };
            service.AddStreamHandler("FetchLibDescendents",
                new RestBytesStreamHandler("POST", service.CreateCAPS("FetchLibDescendents", ""),
                                                      method));

            method = delegate(string request, string path, string param,
                                                                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                return HandleFetchInventory(request, m_service.AgentID);
            };
            service.AddStreamHandler("FetchInventory",
                new RestBytesStreamHandler("POST", service.CreateCAPS("FetchInventory", ""),
                                                      method));

            method = delegate(string request, string path, string param,
                                                                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                return HandleFetchLib(request, m_service.AgentID);
            };
            service.AddStreamHandler("FetchLib",
                new RestBytesStreamHandler("POST", service.CreateCAPS("FetchLib", ""),
                                                      method));

            service.AddStreamHandler("NewFileAgentInventory",
                new RestStreamHandler("POST", service.CreateCAPS("NewFileAgentInventory", m_newInventory),
                                                      NewAgentInventoryRequest));

            /*method = delegate(string request, string path, string param,
                                                                OSHttpRequest httpRequest, OSHttpResponse httpResponse)
            {
                return HandleInventoryItemCreate(request, m_service.AgentID);
            };
            service.AddStreamHandler("InventoryItemCreate",
                new RestBytesStreamHandler("POST", service.CreateCAPS("InventoryItemCreate", ""),
                                                      method));*/
        }
Ejemplo n.º 28
0
        public SalesController(IInventoryService inventoryService,
            IFinancialService financialService,
            ISalesService salesService)
        {
            _inventoryService = inventoryService;
            _financialService = financialService;
            _salesService = salesService;

            _viewModelBuilder = new Web.Models.ViewModels.Sales.SalesViewModelBuilder(inventoryService, financialService, salesService);
        }
        /// <summary>
        /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder
        /// </summary>        
        ///
        /// This method does not handle paths that contain multiple delimitors
        ///
        /// FIXME: We do not yet handle situations where folders have the same name.  We could handle this by some
        /// XPath like expression
        ///
        /// FIXME: Delimitors which occur in names themselves are not currently escapable.
        ///
        /// <param name="inventoryService">
        /// Inventory service to query
        /// </param>
        /// <param name="userId">
        /// User id to search
        /// </param>
        /// <param name="path">
        /// The path to the required folder.  
        /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
        /// </param>
        /// <returns>null if the folder is not found</returns>
        public static InventoryFolderBase FindFolderByPath(
            IInventoryService inventoryService, UUID userId, string path)
        {
            InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);

            if (null == rootFolder)
                return null;

            return FindFolderByPath(inventoryService, rootFolder, path);
        }        
Ejemplo n.º 30
0
        /// <summary>
        /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder
        /// </summary>
        /// <remarks>
        /// This method does not handle paths that contain multiple delimitors
        ///
        /// FIXME: We have no way of distinguishing folders with the same path
        ///
        /// FIXME: Delimitors which occur in names themselves are not currently escapable.
        /// </remarks>
        /// <param name="inventoryService">
        /// Inventory service to query
        /// </param>
        /// <param name="userId">
        /// User id to search
        /// </param>
        /// <param name="path">
        /// The path to the required folder.
        /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
        /// </param>
        /// <returns>The folder found.  Please note that if there are multiple folders with the same name then an 
        /// unspecified one will be returned.  If no such folder eixsts then null is returned</returns>
        public static InventoryFolderBase FindFolderByPath(
            IInventoryService inventoryService, UUID userId, string path)
        {
            List<InventoryFolderBase> folders = FindFoldersByPath(inventoryService, userId, path);

            if (folders.Count == 0)
                return null;
            else
                return folders[0];
        }
 public InventoryWorkperiodProcessor(IInventoryService inventoryService)
 {
     _inventoryService = inventoryService;
 }
Ejemplo n.º 32
0
 public InventoryController(IInventoryService inventoryService, AppDbContext dbContext, IConfiguration config)
 {
     _dbContext        = dbContext;
     _inventoryService = inventoryService;
     Configuration     = config;
 }
Ejemplo n.º 33
0
 public RecipeItemViewModel(RecipeItem model, IWorkspace workspace, IInventoryService inventoryService)
 {
     Model             = model;
     _workspace        = workspace;
     _inventoryService = inventoryService;
 }
Ejemplo n.º 34
0
 public InventoryController(IInventoryService inventoryService, IErpPackLogService packLogService)
 {
     _inventoryService = inventoryService;
     _packLogService   = packLogService;
 }
Ejemplo n.º 35
0
        public UserAccountService(IConfigSource config)
            : base(config)
        {
            IConfig userConfig = config.Configs["UserAccountService"];

            if (userConfig == null)
            {
                throw new Exception("No UserAccountService configuration");
            }

            string gridServiceDll = userConfig.GetString("GridService", string.Empty);

            if (gridServiceDll != string.Empty)
            {
                m_GridService = LoadPlugin <IGridService>(gridServiceDll, new Object[] { config });
            }

            string authServiceDll = userConfig.GetString("AuthenticationService", string.Empty);

            if (authServiceDll != string.Empty)
            {
                m_AuthenticationService = LoadPlugin <IAuthenticationService>(authServiceDll, new Object[] { config });
            }

            string presenceServiceDll = userConfig.GetString("GridUserService", string.Empty);

            if (presenceServiceDll != string.Empty)
            {
                m_GridUserService = LoadPlugin <IGridUserService>(presenceServiceDll, new Object[] { config });
            }

            string invServiceDll = userConfig.GetString("InventoryService", string.Empty);

            if (invServiceDll != string.Empty)
            {
                m_InventoryService = LoadPlugin <IInventoryService>(invServiceDll, new Object[] { config });
            }

            string avatarServiceDll = userConfig.GetString("AvatarService", string.Empty);

            if (avatarServiceDll != string.Empty)
            {
                m_AvatarService = LoadPlugin <IAvatarService>(avatarServiceDll, new Object[] { config });
            }

            m_CreateDefaultAvatarEntries = userConfig.GetBoolean("CreateDefaultAvatarEntries", false);

            // In case there are several instances of this class in the same process,
            // the console commands are only registered for the root instance
            if (m_RootInstance == null && MainConsole.Instance != null)
            {
                m_RootInstance = this;
                MainConsole.Instance.Commands.AddCommand("UserService", false,
                                                         "create user",
                                                         "create user [<first> [<last> [<pass> [<email> [<user id>]]]]]",
                                                         "Create a new user", HandleCreateUser);

                MainConsole.Instance.Commands.AddCommand("UserService", false,
                                                         "reset user password",
                                                         "reset user password [<first> [<last> [<password>]]]",
                                                         "Reset a user password", HandleResetUserPassword);

                MainConsole.Instance.Commands.AddCommand("UserService", false,
                                                         "set user level",
                                                         "set user level [<first> [<last> [<level>]]]",
                                                         "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, "
                                                         + "this account will be treated as god-moded. "
                                                         + "It will also affect the 'login level' command. ",
                                                         HandleSetUserLevel);

                MainConsole.Instance.Commands.AddCommand("UserService", false,
                                                         "show account",
                                                         "show account <first> <last>",
                                                         "Show account details for the given user", HandleShowAccount);
            }
        }
Ejemplo n.º 36
0
 public void SetUp()
 {
     _vendinMachineDataBaseMock = new Mock <IVendinMachineDataBase>();
     _inventoryService          = new InventoryService(_vendinMachineDataBaseMock.Object);
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Inventory constructor with mapper and inventory service dependancy injection
 /// </summary>
 /// <param name="inventoryService"></param>
 /// <param name="mapper"></param>
 public InventoryController(IInventoryService inventoryService, IInventoryMapper mapper)
 {
     _inventoryService = inventoryService;
     _mapper           = mapper;
 }
 public DefaultInventoryService(IInventoryService inventoryService, IWarehouseRepository warehouseRepository)
 {
     _inventoryService    = inventoryService;
     _warehouseRepository = warehouseRepository;
 }
Ejemplo n.º 39
0
        public ReturnOrderPageViewModel(INavigationService navigationService,
                                        IGlobalService globalService,
                                        IDialogService dialogService,
                                        IAllocationService allocationService,
                                        IAdvanceReceiptService advanceReceiptService,
                                        IReceiptCashService receiptCashService,
                                        ICostContractService costContractService,
                                        ICostExpenditureService costExpenditureService,
                                        IInventoryService inventoryService,
                                        IPurchaseBillService purchaseBillService,
                                        IReturnReservationBillService returnReservationBillService,
                                        IReturnBillService returnBillService,
                                        ISaleReservationBillService saleReservationBillService,
                                        ISaleBillService saleBillService
                                        ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "退货订单";


            this.BillType = BillTypeEnum.ReturnReservationBill;

            this.Load = ReactiveCommand.Create(async() =>
            {
                ItemTreshold = 1;
                PageCounter  = 0;

                try
                {
                    Bills?.Clear();
                    int?terminalId     = Filter.TerminalId;
                    int?businessUserId = Filter.BusinessUserId;
                    string billNumber  = Filter.SerchKey;
                    DateTime?startTime = Filter.StartTime ?? DateTime.Now.AddMonths(-1);
                    DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                    int?makeuserId = Settings.UserId;
                    if (Filter.BusinessUserId == Settings.UserId)
                    {
                        businessUserId = 0;
                    }
                    int?wareHouseId     = 0;
                    int?deliveryUserId  = 0;
                    string terminalName = "";
                    string remark       = "";
                    int?districtId      = 0;
                    //获取未审核
                    bool?auditedStatus     = false;
                    bool?sortByAuditedTime = true;
                    bool?showReverse       = null;
                    bool?showReturn        = null;
                    bool?alreadyChange     = null;


                    var pending = new List <ReturnReservationBillModel>();


                    var result = await _returnReservationBillService.GetReturnReservationBillsAsync(makeuserId, terminalId, terminalName, businessUserId, deliveryUserId, wareHouseId, districtId, billNumber, remark, startTime, endTime, auditedStatus, sortByAuditedTime, showReverse, showReturn, alreadyChange, 0, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm    = s;
                            sm.IsLast = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            return(sm);
                        }).Where(s => s.MakeUserId == Settings.UserId || s.BusinessUserId == Settings.UserId).ToList();
                    }
                    if (pending.Any())
                    {
                        Bills = new System.Collections.ObjectModel.ObservableCollection <ReturnReservationBillModel>(pending);
                    }
                    UpdateTitle();
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            });


            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            int?terminalId     = Filter.TerminalId;
                            int?businessUserId = Filter.BusinessUserId;
                            string billNumber  = Filter.SerchKey;
                            DateTime?startTime = Filter.StartTime ?? DateTime.Now.AddMonths(-1);
                            DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                            int?makeuserId = Settings.UserId;
                            if (Filter.BusinessUserId == Settings.UserId)
                            {
                                businessUserId = 0;
                            }
                            int?wareHouseId     = 0;
                            int?deliveryUserId  = 0;
                            string terminalName = "";
                            string remark       = "";
                            int?districtId      = 0;
                            //获取未审核
                            bool?auditedStatus     = false;
                            bool?sortByAuditedTime = true;
                            bool?showReverse       = null;
                            bool?showReturn        = null;
                            bool?alreadyChange     = null;

                            var items = await _returnReservationBillService.GetReturnReservationBillsAsync(makeuserId, terminalId, terminalName, businessUserId, deliveryUserId, wareHouseId, districtId, billNumber, remark, startTime, endTime, auditedStatus, sortByAuditedTime, showReverse, showReturn, alreadyChange, pageIdex, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());
                            if (items != null)
                            {
                                foreach (var item in items)
                                {
                                    if (Bills.Count(s => s.Id == item.Id) == 0)
                                    {
                                        Bills.Add(item);
                                    }
                                }

                                foreach (var s in Bills)
                                {
                                    s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                                }
                            }
                            UpdateTitle();
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));
            //选择单据
            this.SelectedCommand = ReactiveCommand.Create <ReturnReservationBillModel>(async x =>
            {
                if (x != null)
                {
                    await NavigateAsync(nameof(ReturnOrderBillPage), ("Bill", x), ("IsSubmitBill", true));
                }
            });

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.SUBMIT30:
                    {
                        Filter.StartTime = dtime.AddMonths(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case Enums.MenuEnum.CLEARHISTORY:    //清空一个月历史单据
                    {
                        ClearHistory(() => _globalService.UpdateHistoryBillStatusAsync((int)this.BillType));
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_VIEW_KEY, 2));

            this.BindBusyCommand(Load);
        }
Ejemplo n.º 40
0
 public Warehouse(IInventoryService invService, ILogger logger)
 {
     _logger           = logger;
     _inventoryService = invService;
 }
Ejemplo n.º 41
0
        public void RegionLoaded(Scene s)
        {
            if (!m_Enabled)
            {
                return;
            }

            if (s_processedRequestsStat == null)
            {
                s_processedRequestsStat =
                    new Stat(
                        "ProcessedFetchInventoryRequests",
                        "Number of processed fetch inventory requests",
                        "These have not necessarily yet been dispatched back to the requester.",
                        "",
                        "inventory",
                        "httpfetch",
                        StatType.Pull,
                        MeasuresOfInterest.AverageChangeOverTime,
                        stat => { stat.Value = ProcessedRequestsCount; },
                        StatVerbosity.Debug);
            }

            if (s_queuedRequestsStat == null)
            {
                s_queuedRequestsStat =
                    new Stat(
                        "QueuedFetchInventoryRequests",
                        "Number of fetch inventory requests queued for processing",
                        "",
                        "",
                        "inventory",
                        "httpfetch",
                        StatType.Pull,
                        MeasuresOfInterest.AverageChangeOverTime,
                        stat => { stat.Value = m_queue.Count(); },
                        StatVerbosity.Debug);
            }

            StatsManager.RegisterStat(s_processedRequestsStat);
            StatsManager.RegisterStat(s_queuedRequestsStat);

            m_InventoryService = Scene.InventoryService;
            m_LibraryService   = Scene.LibraryService;

            // We'll reuse the same handler for all requests.
            m_webFetchHandler = new FetchInvDescHandler(m_InventoryService, m_LibraryService, Scene);

            Scene.EventManager.OnRegisterCaps += RegisterCaps;

            m_NumberScenes++;

            int nworkers = 2; // was 2

            if (ProcessQueuedRequestsAsync && m_workerThreads == null)
            {
                m_workerThreads = new Thread[nworkers];

                for (uint i = 0; i < nworkers; i++)
                {
                    m_workerThreads[i] = WorkManager.StartThread(DoInventoryRequests,
                                                                 String.Format("InventoryWorkerThread{0}", i),
                                                                 ThreadPriority.Normal,
                                                                 true,
                                                                 true,
                                                                 null,
                                                                 int.MaxValue);
                }
            }
        }
Ejemplo n.º 42
0
 public void FinishedStartup()
 {
     m_assetService = m_registry.RequestModuleInterface <IAssetService>();
     m_invService   = m_registry.RequestModuleInterface <IInventoryService>();
 }
Ejemplo n.º 43
0
 public InventoryCommands(IInventoryService inventoryService, IUserRepository userRepository, ISlackWebApi slack)
 {
     _inventoryService = inventoryService;
     _userRepository   = userRepository;
     _slack            = slack;
 }
Ejemplo n.º 44
0
 public InventoryController(IInventoryService inventoryService)
 {
     _inventoryService = inventoryService;
 }
Ejemplo n.º 45
0
 public HomeController(ILogger <HomeController> logger, ApplicationDbContext context, Kiemtra kiemtra, ISaleService iSaleService, ISaleItem iSaleItem, IInventoryService inventoryService, IPurchaseOrderService iPurchaseOrderService, IPurchaseOrderItem iPurchaseOrderItem)
 {
     _logger                    = logger;
     _context                   = context;
     this.kiemtra               = kiemtra;
     this.iSaleService          = iSaleService;
     this.iSaleItem             = iSaleItem;
     this.inventoryService      = inventoryService;
     this.iPurchaseOrderService = iPurchaseOrderService;
     this.iPurchaseOrderItem    = iPurchaseOrderItem;
 }
        public void obtain_proxy_from_container_using_service_contract()
        {
            IInventoryService proxy = ObjectBase.Container.GetExportedValue <IInventoryService>();

            Assert.IsTrue(proxy is InventoryClient);
        }
Ejemplo n.º 47
0
        private UUID CreateCallingCard(UUID userID, UUID creatorID, UUID folderID, bool isGod)
        {
            IUserAccountService userv = m_Scenes[0].UserAccountService;

            if (userv == null)
            {
                return(UUID.Zero);
            }

            UserAccount info = userv.GetUserAccount(UUID.Zero, creatorID);

            if (info == null)
            {
                return(UUID.Zero);
            }

            IInventoryService inv = m_Scenes[0].InventoryService;

            if (inv == null)
            {
                return(UUID.Zero);
            }

            if (folderID == UUID.Zero)
            {
                InventoryFolderBase folder = inv.GetFolderForType(userID,
                                                                  AssetType.CallingCard);

                if (folder == null) // Nowhere to put it
                {
                    return(UUID.Zero);
                }

                folderID = folder.ID;
            }

            m_log.DebugFormat("[XCALLINGCARD]: Creating calling card for {0} in inventory of {1}", info.Name, userID);

            InventoryItemBase item = new InventoryItemBase();

            item.AssetID         = UUID.Zero;
            item.AssetType       = (int)AssetType.CallingCard;
            item.BasePermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify);
            if (isGod)
            {
                item.BasePermissions = (uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Move);
            }

            item.EveryOnePermissions = (uint)PermissionMask.None;
            item.CurrentPermissions  = item.BasePermissions;
            item.NextPermissions     = (uint)(PermissionMask.Copy | PermissionMask.Modify);

            item.ID         = UUID.Random();
            item.CreatorId  = creatorID.ToString();
            item.Owner      = userID;
            item.GroupID    = UUID.Zero;
            item.GroupOwned = false;
            item.Folder     = folderID;

            item.CreationDate = Util.UnixTimeSinceEpoch();
            item.InvType      = (int)InventoryType.CallingCard;
            item.Flags        = 0;

            item.Name        = info.Name;
            item.Description = "";

            item.SalePrice = 10;
            item.SaleType  = (byte)SaleType.Not;

            inv.AddItem(item);

            IClientAPI client = FindClientObject(userID);

            if (client != null)
            {
                client.SendBulkUpdateInventory(item);
            }

            return(item.ID);
        }
 public InventoryController(IWorkContextAccessor workContextAccessor, IStorefrontUrlBuilder urlBuilder, IInventoryService inventoryService)
     : base(workContextAccessor, urlBuilder)
 {
     _inventoryService = inventoryService;
 }
        void OnInstantMessage(IClientAPI client, GridInstantMessage im)
        {
            //MainConsole.Instance.InfoFormat("[Inventory transfer]: OnInstantMessage {0}", im.dialog);
            IScene clientScene = FindClientScene(client.AgentId);

            if (clientScene == null)
            {
                // Something seriously wrong here.
                MainConsole.Instance.DebugFormat("[Inventory transfer]: Cannot find originating user scene");
                return;
            }

            if (im.Dialog == (byte)InstantMessageDialog.InventoryOffered)
            {
                //MainConsole.Instance.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0]));

                if (im.BinaryBucket.Length < 17)   // Invalid
                {
                    MainConsole.Instance.DebugFormat("[Inventory transfer]: Invalid length {0} for asset type {1}",
                                                     im.BinaryBucket.Length, ((AssetType)im.BinaryBucket [0]));
                    return;
                }

                UUID           recipientID        = im.ToAgentID;
                IScenePresence recipientUser      = null;
                IScene         recipientUserScene = FindClientScene(recipientID);
                if (recipientUserScene != null)
                {
                    recipientUser = recipientUserScene.GetScenePresence(recipientID);
                }

                UUID copyID;

                // give the item to the recipient, assuming they will accept it
                // First byte is the asset type
                AssetType assetType = (AssetType)im.BinaryBucket [0];

                if (assetType == AssetType.Folder)
                {
                    var folderID = new UUID(im.BinaryBucket, 1);
                    if (im.SessionID == folderID)
                    {
                        // this must be an offline message being processed. just pass it through
                        if (m_TransferModule != null)
                        {
                            m_TransferModule.SendInstantMessage(im);
                        }
                        return;
                    }

                    MainConsole.Instance.DebugFormat(
                        "[Inventory transfer]: Inserting original folder {0} into agent {1}'s inventory",
                        folderID, im.ToAgentID);


                    clientScene.InventoryService.GiveInventoryFolderAsync(
                        recipientID,
                        client.AgentId,
                        folderID,
                        UUID.Zero,
                        (folder) => {
                        if (folder == null)
                        {
                            client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false);
                            return;
                        }

                        // The outgoing binary bucket should contain only the byte which signals an asset folder is
                        // being copied and the following bytes for the copied folder's UUID
                        copyID = folder.ID;
                        byte [] copyIDBytes = copyID.GetBytes();
                        im.BinaryBucket     = new byte [1 + copyIDBytes.Length];
                        im.BinaryBucket [0] = (byte)AssetType.Folder;
                        Array.Copy(copyIDBytes, 0, im.BinaryBucket, 1, copyIDBytes.Length);
                        im.SessionID = copyID;

                        if (moneyService != null)
                        {
                            moneyService.Transfer(im.ToAgentID, im.FromAgentID, 0,
                                                  "Inworld inventory folder transfer", TransactionType.GiveInventory);
                        }

                        if (recipientUser != null)
                        {
                            // user is on this region... update them
                            recipientUser.ControllingClient.SendBulkUpdateInventory(folder);
                            recipientUser.ControllingClient.SendInstantMessage(im);
                        }
                        else if (m_TransferModule != null)
                        {
                            // user is not in this region or not online... let them know
                            m_TransferModule.SendInstantMessage(im);
                        }
                    });
                }
                else
                {
                    // Inventory item
                    // First byte of the array is probably the item type
                    // Next 16 bytes are the UUID

                    var itemID = new UUID(im.BinaryBucket, 1);
                    if (im.SessionID == itemID)
                    {
                        // this must be an offline message being processed. just pass it through
                        if (m_TransferModule != null)
                        {
                            m_TransferModule.SendInstantMessage(im);
                        }
                        return;
                    }


                    MainConsole.Instance.DebugFormat(
                        "[Inventory transfer]: (giving) Inserting item {0} into agent {1}'s inventory",
                        itemID, im.ToAgentID);

                    clientScene.InventoryService.GiveInventoryItemAsync(
                        im.ToAgentID,
                        im.FromAgentID,
                        itemID,
                        UUID.Zero,
                        false,
                        (itemCopy) => {
                        if (itemCopy == null)
                        {
                            MainConsole.Instance.DebugFormat(
                                "[Inventory transfer]: (giving) Unable to find item {0} to give to agent {1}'s inventory",
                                itemID, im.ToAgentID);
                            client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
                            return;
                        }

                        copyID = itemCopy.ID;
                        Array.Copy(copyID.GetBytes(), 0, im.BinaryBucket, 1, 16);
                        im.SessionID = itemCopy.ID;

                        if (moneyService != null)
                        {
                            moneyService.Transfer(im.ToAgentID, im.FromAgentID, 0,
                                                  "Inworld inventory item transfer", TransactionType.GiveInventory);
                        }

                        if (recipientUser != null)
                        {
                            // user is on this region...
                            recipientUser.ControllingClient.SendBulkUpdateInventory(itemCopy);
                            recipientUser.ControllingClient.SendInstantMessage(im);
                        }
                        else if (m_TransferModule != null)
                        {
                            // user is not present on this region or offline... let them know
                            m_TransferModule.SendInstantMessage(im);
                        }
                    });
                }
            }
            else if (im.Dialog == (byte)InstantMessageDialog.InventoryAccepted)
            {
                IScenePresence user = clientScene.GetScenePresence(im.ToAgentID);
                MainConsole.Instance.DebugFormat("[Inventory transfer]: Acceptance message received");

                if (user != null)    // Local
                {
                    user.ControllingClient.SendInstantMessage(im);
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im);
                    }
                }
            }
            else if (im.Dialog == (byte)InstantMessageDialog.InventoryDeclined)
            {
                // Here, the recipient is local and we can assume that the
                // inventory is loaded. Courtesy of the above bulk update,
                // It will have been pushed to the client, too
                //
                IInventoryService invService = clientScene.InventoryService;
                MainConsole.Instance.DebugFormat("[Inventory transfer]: Declined message received");

                InventoryFolderBase trashFolder =
                    invService.GetFolderForType(client.AgentId, InventoryType.Unknown, FolderType.Trash);

                UUID inventoryID = im.SessionID; // The inventory item/folder, back from it's trip

                InventoryItemBase   item   = invService.GetItem(client.AgentId, inventoryID);
                InventoryFolderBase folder = null;

                // cannot delete if we do not have  somewhere to put it
                if (trashFolder != null)
                {
                    // Deleting an item
                    if (item != null)
                    {
                        item.Folder = trashFolder.ID;

                        var uuids = new List <UUID> {
                            item.ID
                        };
                        invService.DeleteItems(item.Owner, uuids);          // delete the item from the client's inventory

                        ILLClientInventory inventory = client.Scene.RequestModuleInterface <ILLClientInventory> ();
                        if (inventory != null)
                        {
                            inventory.AddInventoryItemAsync(client, item);  // send an inventory update to the client
                        }
                    }
                    else
                    {
                        // deleting a folder
                        folder = new InventoryFolderBase(inventoryID, client.AgentId);
                        folder = invService.GetFolder(folder);

                        if (folder != null)
                        {
                            folder.ParentID = trashFolder.ID;
                            invService.MoveFolder(folder);
                            client.SendBulkUpdateInventory(folder);
                        }
                    }
                }

                if ((item == null && folder == null) | trashFolder == null)
                {
                    string reason = string.Empty;

                    if (trashFolder == null)
                    {
                        reason += " Trash folder not found.";
                    }
                    if (item == null)
                    {
                        reason += " Item not found.";
                    }
                    if (folder == null)
                    {
                        reason += " Folder not found.";
                    }

                    client.SendAgentAlertMessage("Unable to delete received inventory" + reason, false);
                }

                if (moneyService != null)
                {
                    moneyService.Transfer(im.ToAgentID, im.FromAgentID, 0,
                                          "Inworld inventory transfer declined", TransactionType.GiveInventory);
                }

                IScenePresence user = clientScene.GetScenePresence(im.ToAgentID);

                if (user != null)    // Local
                {
                    user.ControllingClient.SendInstantMessage(im);
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im);
                    }
                }
            }
        }
Ejemplo n.º 50
0
 public ReservationApiController(IInventoryService inventoryService, IRentalService rentalservice)
 {
     _inventoryService = inventoryService;
     _rentalservice    = rentalservice;
 }
Ejemplo n.º 51
0
 /// <summary>
 /// Get the inventory items that match the path name.
 /// </summary>
 /// <param name="inventoryService"></param>
 /// <param name="userId"></param>
 /// <param name="path"></param>
 /// <returns>An empty list if no matching items were found.</returns>
 public static List <InventoryItemBase> GetInventoryItems(IInventoryService inventoryService, UUID userId, string path)
 {
     return(InventoryArchiveUtils.FindItemsByPath(inventoryService, userId, path));
 }
Ejemplo n.º 52
0
 public QuickOrderService(IContentLoader contentLoader, IInventoryService inventoryService)
 {
     _contentLoader    = contentLoader;
     _inventoryService = inventoryService;
 }
Ejemplo n.º 53
0
 /// <summary>
 /// Create inventory folders starting from the user's root folder.
 /// </summary>
 /// <param name="inventoryService"></param>
 /// <param name="userId"></param>
 /// <param name="path">
 /// The folders to create.  Multiple folders can be specified on a path delimited by the PATH_DELIMITER
 /// </param>
 /// <param name="useExistingFolders">
 /// If true, then folders in the path which already the same name are
 /// used.  This applies to the terminal folder as well.
 /// If false, then all folders in the path are created, even if there is already a folder at a particular
 /// level with the same name.
 /// </param>
 /// <returns>
 /// The folder created.  If the path contains multiple folders then the last one created is returned.
 /// Will return null if the root folder could not be found.
 /// </returns>
 public static InventoryFolderBase CreateInventoryFolder(
     IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders)
 {
     return(CreateInventoryFolder(inventoryService, userId, UUID.Random(), path, useExistingFolders));
 }
Ejemplo n.º 54
0
 public InventoryController(IInventoryService inventoryService, ILogger <InventoryController> logger)
 {
     _inventoryService = inventoryService;
     _logger           = logger;
 }
Ejemplo n.º 55
0
        public UnCostExpenditurePageViewModel(INavigationService navigationService,
                                              IGlobalService globalService,
                                              IDialogService dialogService,
                                              IAllocationService allocationService,
                                              IAdvanceReceiptService advanceReceiptService,
                                              IReceiptCashService receiptCashService,
                                              ICostContractService costContractService,
                                              ICostExpenditureService costExpenditureService,
                                              IInventoryService inventoryService,
                                              IPurchaseBillService purchaseBillService,
                                              IReturnReservationBillService returnReservationBillService,
                                              IReturnBillService returnBillService,
                                              ISaleReservationBillService saleReservationBillService,
                                              ISaleBillService saleBillService
                                              ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "费用支出(0)";

            this.Bills = new ObservableCollection <CostExpenditureBillModel>();

            //载入未签收费用支出单据
            this.Load = ReactiveCommand.Create(async() =>
            {
                var pending = new List <CostExpenditureBillModel>();
                try
                {
                    DateTime?startTime = Filter.StartTime;
                    DateTime?endTime   = Filter.EndTime;
                    int?customerId     = Filter.TerminalId;
                    int?employeeId     = Filter.BusinessUserId;
                    int?makeuserId     = Settings.UserId;

                    string billNumber = "";
                    //获取已审核
                    bool?auditedStatus     = true;
                    bool?showReverse       = null;
                    bool sortByAuditedTime = false;
                    int pagenumber         = 0;
                    int pageSize           = 20;

                    var result = await _costExpenditureService.GetCostExpendituresAsync(makeuserId,
                                                                                        customerId,
                                                                                        "",
                                                                                        employeeId,
                                                                                        billNumber,
                                                                                        auditedStatus,
                                                                                        startTime,
                                                                                        endTime,
                                                                                        showReverse,
                                                                                        sortByAuditedTime,
                                                                                        0,
                                                                                        pagenumber,
                                                                                        pageSize, this.ForceRefresh, new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm       = s;
                            sm.IsLast    = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            sm.SumAmount = s.Items?.Sum(i => i.Amount) ?? 0;

                            return(sm);
                        }).ToList();

                        TotalAmount = pending.Select(b => b.SumAmount).Sum();
                        Title       = $"费用支出({pending.Count})";

                        if (pending != null && pending.Any())
                        {
                            Bills = new ObservableCollection <CostExpenditureBillModel>(pending);
                        }
                    }
                }
                catch (System.Exception) { }
            });

            //费用支出单签收
            this.SelecterCommand = ReactiveCommand.CreateFromTask <CostExpenditureBillModel>(async(item) =>
            {
                if (item != null)
                {
                    using (UserDialogs.Instance.Loading("稍等..."))
                    {
                        await this.NavigateAsync("CostExpenditureBillPage",
                                                 ("Reference", this.PageName),
                                                 ("DispatchItemModel", null),
                                                 ("Bill", item));
                    }
                }
                item = null;
            });

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_DEV_KEY, 1));


            this.BindBusyCommand(Load);
        }
Ejemplo n.º 56
0
        private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
        {
//            m_log.DebugFormat(
//                "[INVENTORY TRANSFER]: {0} IM type received from client {1}. From={2} ({3}), To={4}",
//                (InstantMessageDialog)im.dialog, client.Name,
//                im.fromAgentID, im.fromAgentName, im.toAgentID);

            Scene scene = FindClientScene(client.AgentId);

            if (scene == null) // Something seriously wrong here.
            {
                return;
            }

            if (im.dialog == (byte)InstantMessageDialog.InventoryOffered)
            {
                //m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0]));

                if (im.binaryBucket.Length < 17) // Invalid
                {
                    return;
                }

                UUID          receipientID = new UUID(im.toAgentID);
                ScenePresence user         = scene.GetScenePresence(receipientID);
                UUID          copyID;

                // First byte is the asset type
                AssetType assetType = (AssetType)im.binaryBucket[0];

                if (AssetType.Folder == assetType)
                {
                    UUID folderID = new UUID(im.binaryBucket, 1);

                    m_log.DebugFormat(
                        "[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory",
                        folderID, new UUID(im.toAgentID));

                    InventoryFolderBase folderCopy
                        = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero);

                    if (folderCopy == null)
                    {
                        client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false);
                        return;
                    }

                    // The outgoing binary bucket should contain only the byte which signals an asset folder is
                    // being copied and the following bytes for the copied folder's UUID
                    copyID = folderCopy.ID;
                    byte[] copyIDBytes = copyID.GetBytes();
                    im.binaryBucket    = new byte[1 + copyIDBytes.Length];
                    im.binaryBucket[0] = (byte)AssetType.Folder;
                    Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length);

                    if (user != null)
                    {
                        user.ControllingClient.SendBulkUpdateInventory(folderCopy);
                    }

                    // HACK!!
                    // Insert the ID of the copied folder into the IM so that we know which item to move to trash if it
                    // is rejected.
                    // XXX: This is probably a misuse of the session ID slot.
                    im.imSessionID = copyID.Guid;
                }
                else
                {
                    // First byte of the array is probably the item type
                    // Next 16 bytes are the UUID

                    UUID itemID = new UUID(im.binaryBucket, 1);

                    m_log.DebugFormat("[INVENTORY TRANSFER]: (giving) Inserting item {0} " +
                                      "into agent {1}'s inventory",
                                      itemID, new UUID(im.toAgentID));

                    InventoryItemBase itemCopy = scene.GiveInventoryItem(
                        new UUID(im.toAgentID),
                        client.AgentId, itemID);

                    if (itemCopy == null)
                    {
                        client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
                        return;
                    }

                    copyID = itemCopy.ID;
                    Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16);

                    if (user != null)
                    {
                        user.ControllingClient.SendBulkUpdateInventory(itemCopy);
                    }

                    // HACK!!
                    // Insert the ID of the copied item into the IM so that we know which item to move to trash if it
                    // is rejected.
                    // XXX: This is probably a misuse of the session ID slot.
                    im.imSessionID = copyID.Guid;
                }

                // Send the IM to the recipient. The item is already
                // in their inventory, so it will not be lost if
                // they are offline.
                //
                if (user != null)
                {
                    user.ControllingClient.SendInstantMessage(im);
                    return;
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im, delegate(bool success)
                        {
                            if (!success)
                            {
                                client.SendAlertMessage("User not online. Inventory has been saved");
                            }
                        });
                    }
                }
            }
            else if (im.dialog == (byte)InstantMessageDialog.InventoryAccepted)
            {
                ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));

                if (user != null) // Local
                {
                    user.ControllingClient.SendInstantMessage(im);
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im, delegate(bool success) {
                            // justincc - FIXME: Comment out for now.  This code was added in commit db91044 Mon Aug 22 2011
                            // and is apparently supposed to fix bulk inventory updates after accepting items.  But
                            // instead it appears to cause two copies of an accepted folder for the receiving user in
                            // at least some cases.  Folder/item update is already done when the offer is made (see code above)

//                            // Send BulkUpdateInventory
//                            IInventoryService invService = scene.InventoryService;
//                            UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip
//
//                            InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId);
//                            folder = invService.GetFolder(folder);
//
//                            ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID));
//
//                            // If the user has left the scene by the time the message comes back then we can't send
//                            // them the update.
//                            if (fromUser != null)
//                                fromUser.ControllingClient.SendBulkUpdateInventory(folder);
                        });
                    }
                }
            }

            // XXX: This code was placed here to try and accomodate RLV which moves given folders named #RLV/~<name>
            // to the requested folder, which in this case is #RLV.  However, it is the viewer that appears to be
            // response from renaming the #RLV/~example folder to ~example.  For some reason this is not yet
            // happening, possibly because we are not sending the correct inventory update messages with the correct
            // transaction IDs
            else if (im.dialog == (byte)InstantMessageDialog.TaskInventoryAccepted)
            {
                UUID destinationFolderID = UUID.Zero;

                if (im.binaryBucket != null && im.binaryBucket.Length >= 16)
                {
                    destinationFolderID = new UUID(im.binaryBucket, 0);
                }

                if (destinationFolderID != UUID.Zero)
                {
                    InventoryFolderBase destinationFolder = new InventoryFolderBase(destinationFolderID, client.AgentId);
                    if (destinationFolder == null)
                    {
                        m_log.WarnFormat(
                            "[INVENTORY TRANSFER]: TaskInventoryAccepted message from {0} in {1} specified folder {2} which does not exist",
                            client.Name, scene.Name, destinationFolderID);

                        return;
                    }

                    IInventoryService invService = scene.InventoryService;

                    UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip

                    InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId);
                    item = invService.GetItem(item);
                    InventoryFolderBase folder  = null;
                    UUID?previousParentFolderID = null;

                    if (item != null) // It's an item
                    {
                        previousParentFolderID = item.Folder;
                        item.Folder            = destinationFolderID;

                        invService.DeleteItems(item.Owner, new List <UUID>()
                        {
                            item.ID
                        });
                        scene.AddInventoryItem(client, item);
                    }
                    else
                    {
                        folder = new InventoryFolderBase(inventoryID, client.AgentId);
                        folder = invService.GetFolder(folder);

                        if (folder != null) // It's a folder
                        {
                            previousParentFolderID = folder.ParentID;
                            folder.ParentID        = destinationFolderID;
                            invService.MoveFolder(folder);
                        }
                    }

                    // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code).
                    if (previousParentFolderID != null)
                    {
                        InventoryFolderBase previousParentFolder
                            = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId);
                        previousParentFolder = invService.GetFolder(previousParentFolder);
                        scene.SendInventoryUpdate(client, previousParentFolder, true, true);

                        scene.SendInventoryUpdate(client, destinationFolder, true, true);
                    }
                }
            }
            else if (
                im.dialog == (byte)InstantMessageDialog.InventoryDeclined ||
                im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined)
            {
                // Here, the recipient is local and we can assume that the
                // inventory is loaded. Courtesy of the above bulk update,
                // It will have been pushed to the client, too
                //
                IInventoryService invService = scene.InventoryService;

                InventoryFolderBase trashFolder =
                    invService.GetFolderForType(client.AgentId, AssetType.TrashFolder);

                UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip

                InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId);
                item = invService.GetItem(item);
                InventoryFolderBase folder  = null;
                UUID?previousParentFolderID = null;

                if (item != null && trashFolder != null)
                {
                    previousParentFolderID = item.Folder;
                    item.Folder            = trashFolder.ID;

                    // Diva comment: can't we just update this item???
                    List <UUID> uuids = new List <UUID>();
                    uuids.Add(item.ID);
                    invService.DeleteItems(item.Owner, uuids);
                    scene.AddInventoryItem(client, item);
                }
                else
                {
                    folder = new InventoryFolderBase(inventoryID, client.AgentId);
                    folder = invService.GetFolder(folder);

                    if (folder != null & trashFolder != null)
                    {
                        previousParentFolderID = folder.ParentID;
                        folder.ParentID        = trashFolder.ID;
                        invService.MoveFolder(folder);
                    }
                }

                if ((null == item && null == folder) | null == trashFolder)
                {
                    string reason = String.Empty;

                    if (trashFolder == null)
                    {
                        reason += " Trash folder not found.";
                    }
                    if (item == null)
                    {
                        reason += " Item not found.";
                    }
                    if (folder == null)
                    {
                        reason += " Folder not found.";
                    }

                    client.SendAgentAlertMessage("Unable to delete " +
                                                 "received inventory" + reason, false);
                }
                // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code).
                else if (previousParentFolderID != null)
                {
                    InventoryFolderBase previousParentFolder
                        = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId);
                    previousParentFolder = invService.GetFolder(previousParentFolder);
                    scene.SendInventoryUpdate(client, previousParentFolder, true, true);

                    scene.SendInventoryUpdate(client, trashFolder, true, true);
                }

                if (im.dialog == (byte)InstantMessageDialog.InventoryDeclined)
                {
                    ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));

                    if (user != null) // Local
                    {
                        user.ControllingClient.SendInstantMessage(im);
                    }
                    else
                    {
                        if (m_TransferModule != null)
                        {
                            m_TransferModule.SendInstantMessage(im, delegate(bool success) { });
                        }
                    }
                }
            }
        }
Ejemplo n.º 57
0
 public FetchInventory2Handler(IInventoryService invService, UUID agentId)
 {
     m_inventoryService = invService;
     m_agentID          = agentId;
 }
Ejemplo n.º 58
0
 public InventoryController(ILogger <InventoryController> logger, IInventoryService inventoryService)
 {
     _logger           = logger;
     _inventoryService = inventoryService;
 }
Ejemplo n.º 59
0
        private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
        {
            m_log.InfoFormat(
                "[INVENTORY TRANSFER]: {0} IM type received from {1}",
                (InstantMessageDialog)im.dialog, client.Name);

            Scene scene = FindClientScene(client.AgentId);

            if (scene == null) // Something seriously wrong here.
            {
                return;
            }


            if (im.dialog == (byte)InstantMessageDialog.InventoryOffered)
            {
                //m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0]));

                if (im.binaryBucket.Length < 17) // Invalid
                {
                    return;
                }

                UUID          receipientID = new UUID(im.toAgentID);
                ScenePresence user         = scene.GetScenePresence(receipientID);
                UUID          copyID;

                // First byte is the asset type
                AssetType assetType = (AssetType)im.binaryBucket[0];

                if (AssetType.Folder == assetType)
                {
                    UUID folderID = new UUID(im.binaryBucket, 1);

                    m_log.DebugFormat("[INVENTORY TRANSFER]: Inserting original folder {0} " +
                                      "into agent {1}'s inventory",
                                      folderID, new UUID(im.toAgentID));

                    InventoryFolderBase folderCopy
                        = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero);

                    if (folderCopy == null)
                    {
                        client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false);
                        return;
                    }

                    // The outgoing binary bucket should contain only the byte which signals an asset folder is
                    // being copied and the following bytes for the copied folder's UUID
                    copyID = folderCopy.ID;
                    byte[] copyIDBytes = copyID.GetBytes();
                    im.binaryBucket    = new byte[1 + copyIDBytes.Length];
                    im.binaryBucket[0] = (byte)AssetType.Folder;
                    Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length);

                    if (user != null)
                    {
                        user.ControllingClient.SendBulkUpdateInventory(folderCopy);
                    }

                    // HACK!!
                    im.imSessionID = folderID.Guid;
                }
                else
                {
                    // First byte of the array is probably the item type
                    // Next 16 bytes are the UUID

                    UUID itemID = new UUID(im.binaryBucket, 1);

                    m_log.DebugFormat("[INVENTORY TRANSFER]: (giving) Inserting item {0} " +
                                      "into agent {1}'s inventory",
                                      itemID, new UUID(im.toAgentID));

                    InventoryItemBase itemCopy = scene.GiveInventoryItem(
                        new UUID(im.toAgentID),
                        client.AgentId, itemID);

                    if (itemCopy == null)
                    {
                        client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
                        return;
                    }

                    copyID = itemCopy.ID;
                    Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16);

                    if (user != null)
                    {
                        user.ControllingClient.SendBulkUpdateInventory(itemCopy);
                    }

                    // HACK!!
                    im.imSessionID = itemID.Guid;
                }

                // Send the IM to the recipient. The item is already
                // in their inventory, so it will not be lost if
                // they are offline.
                //
                if (user != null)
                {
                    user.ControllingClient.SendInstantMessage(im);
                    return;
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im, delegate(bool success)
                        {
                            if (!success)
                            {
                                client.SendAlertMessage("User not online. Inventory has been saved");
                            }
                        });
                    }
                }
            }
            else if (im.dialog == (byte)InstantMessageDialog.InventoryAccepted)
            {
                ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));

                if (user != null) // Local
                {
                    user.ControllingClient.SendInstantMessage(im);
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im, delegate(bool success) {});
                    }
                }
            }
            else if (im.dialog == (byte)InstantMessageDialog.InventoryDeclined)
            {
                // Here, the recipient is local and we can assume that the
                // inventory is loaded. Courtesy of the above bulk update,
                // It will have been pushed to the client, too
                //
                IInventoryService invService = scene.InventoryService;

                InventoryFolderBase trashFolder =
                    invService.GetFolderForType(client.AgentId, AssetType.TrashFolder);

                UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip

                InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId);
                item = invService.GetItem(item);
                InventoryFolderBase folder = null;

                if (item != null && trashFolder != null)
                {
                    item.Folder = trashFolder.ID;

                    // Diva comment: can't we just update this item???
                    List <UUID> uuids = new List <UUID>();
                    uuids.Add(item.ID);
                    invService.DeleteItems(item.Owner, uuids);
                    scene.AddInventoryItem(client, item);
                }
                else
                {
                    folder = new InventoryFolderBase(inventoryID, client.AgentId);
                    folder = invService.GetFolder(folder);

                    if (folder != null & trashFolder != null)
                    {
                        folder.ParentID = trashFolder.ID;
                        invService.MoveFolder(folder);
                    }
                }

                if ((null == item && null == folder) | null == trashFolder)
                {
                    string reason = String.Empty;

                    if (trashFolder == null)
                    {
                        reason += " Trash folder not found.";
                    }
                    if (item == null)
                    {
                        reason += " Item not found.";
                    }
                    if (folder == null)
                    {
                        reason += " Folder not found.";
                    }

                    client.SendAgentAlertMessage("Unable to delete " +
                                                 "received inventory" + reason, false);
                }

                ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));

                if (user != null) // Local
                {
                    user.ControllingClient.SendInstantMessage(im);
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im, delegate(bool success) {});
                    }
                }
            }
        }
        public static async Task <PackageInventoryModel> LoadAsync(
            IInventoryService inventoryService,
            PackageInventoryType inventoryType,
            IProjectExplorerNode node,
            CancellationToken token)
        {
            IEnumerable <GuestOsInfo> inventory;

            try
            {
                if (node is IProjectExplorerInstanceNode vmNode)
                {
                    var info = await inventoryService.GetInstanceInventoryAsync(
                        vmNode.Instance,
                        token)
                               .ConfigureAwait(false);

                    inventory = info != null
                        ? new GuestOsInfo[] { info }
                        : Enumerable.Empty <GuestOsInfo>();
                }
                else if (node is IProjectExplorerZoneNode zoneNode)
                {
                    inventory = await inventoryService.ListZoneInventoryAsync(
                        new ZoneLocator(zoneNode.Zone.ProjectId, zoneNode.Zone.Name),
                        OperatingSystems.Windows,
                        token)
                                .ConfigureAwait(false);
                }
                else if (node is IProjectExplorerProjectNode projectNode)
                {
                    inventory = await inventoryService.ListProjectInventoryAsync(
                        projectNode.Project.ProjectId,
                        OperatingSystems.Windows,
                        token)
                                .ConfigureAwait(false);
                }
                else
                {
                    // Unknown/unsupported node.
                    return(null);
                }
            }
            catch (Exception e) when(e.Unwrap() is GoogleApiException apiEx &&
                                     apiEx.IsConstraintViolation())
            {
                //
                // Reading OS inventory data can fail because of a
                // `compute.disableGuestAttributesAccess` constraint.
                //
                ApplicationTraceSources.Default.TraceWarning(
                    "Failed to load OS inventory data: {0}", e);

                inventory = Enumerable.Empty <GuestOsInfo>();
            }

            return(PackageInventoryModel.FromInventory(
                       node.DisplayName,
                       inventoryType,
                       inventory));
        }