Ejemplo n.º 1
0
        // GET api/scan/5
        public ScanOrder Get(string id)
        {
            AuleaseEntities db = new AuleaseEntities();

            string SR;

            IEnumerable <SystemGroup> SystemGroups;

            if (id.ToUpper().StartsWith("SR"))
            {
                // SR Number
                SR           = id.ToUpper();
                SystemGroups = db.SystemGroups.Where(n => n.PO.PONumber == id).Distinct();
            }
            else
            {
                // Order Number
                if (db.Components.Any(n => n.OrderNumber == id))
                {
                    SR           = db.Components.Where(n => n.OrderNumber == id).SelectMany(n => n.Leases).Select(n => n.SystemGroup).FirstOrDefault().PO.PONumber;
                    SystemGroups = db.Components.Where(n => n.OrderNumber == id).ToList().SelectMany(n => n.Leases).Select(n => n.SystemGroup).Distinct();
                }
                else
                {
                    var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
                    {
                        Content      = new StringContent("Invalid Order Number"),
                        ReasonPhrase = "No Order Number found in the database"
                    };
                    throw new HttpResponseException(resp);
                }
            }

            IEnumerable <ScanSystem> orders = SystemGroups.Select(n => new ScanSystem
            {
                SystemGroupId = n.Id,
                Components    = n.Leases.OrderBy(o => o.Component.TypeId).ThenBy(o => o.Id).Select(o => new ScanComponents
                {
                    ComponentId   = o.Component.Id,
                    SerialNumber  = o.Component.SerialNumber,
                    LeaseTag      = o.Component.LeaseTag,
                    Type          = o.Component.Type.Name,
                    Make          = o.Component.Make.Name,
                    Model         = o.Component.Model.Name,
                    StatementName = o.StatementName
                })
            });

            ScanOrder order = new ScanOrder();

            order.orders = orders;
            order.SR     = SR;

            return(order);
        }
Ejemplo n.º 2
0
        public bool SetTagValue(string groupName, string tagName, string value)
        {
            var output = false;

            if (SystemGroups.ContainsKey(groupName))
            {
                output = SystemGroups[groupName].SetTagValue(tagName, value);
            }

            return(output);
        }
Ejemplo n.º 3
0
        public async ValueTask <string> GetTagValueAsync(string groupName, string tagName)
        {
            var output = string.Empty;

            if (SystemGroups.ContainsKey(groupName))
            {
                output = await SystemGroups[groupName].GetTagValueAsync(tagName).ConfigureAwait(false);
            }

            return(output);
        }
Ejemplo n.º 4
0
        public string GetTagValue(string groupName, string tagName)
        {
            var output = string.Empty;

            if (SystemGroups.ContainsKey(groupName))
            {
                output = SystemGroups[groupName].GetTagValue(tagName);
            }

            return(output);
        }
Ejemplo n.º 5
0
        public async ValueTask <bool> SetTagValueAsync(string groupName, string tagName, string value)
        {
            //_logger.LogTrace("SetTagValueAsync: " + groupName + " " + tagName + " " + value);
            var output = false;

            if (SystemGroups.ContainsKey(groupName))
            {
                output = await SystemGroups[groupName].SetTagValueAsync(tagName, value).ConfigureAwait(false);
            }

            return(output);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates the database in the context given, granting the administrative
        /// control to the user identified by the given name and password.
        /// </summary>
        /// <param name="adminName">The name of the administrator.</param>
        /// <param name="adminPassword">The password used to identify the administrator.</param>
        /// <exception cref="DatabaseSystemException">
        /// If the database context is configured to be in read-only model, if it was not possible
        /// to commit the initial information or if another unhanded error occurred while
        /// creating the database.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// If either one of <paramref name="adminName"/> or <paramref name="adminPassword"/>
        /// are <c>null</c> or empty.
        /// </exception>
        /// <remarks>
        /// <para>
        /// The properties used to create the database are extracted from
        /// the underlying context (<see cref="DatabaseContext" />).
        /// </para>
        /// <para>
        /// This method does not automatically open the database: to make it accessible
        /// a call to <see cref="Open" /> is required.
        /// </para>
        /// </remarks>
        /// <seealso cref="IDatabaseContext.Configuration" />
        public void Create(string adminName, string adminPassword)
        {
            if (Context.ReadOnly())
            {
                throw new DatabaseSystemException("Cannot create database in read-only mode.");
            }

            if (String.IsNullOrEmpty(adminName))
            {
                throw new ArgumentNullException("adminName");
            }
            if (String.IsNullOrEmpty(adminPassword))
            {
                throw new ArgumentNullException("adminPassword");
            }

            try {
                // Create the conglomerate
                TableComposite.Create();

                using (var session = this.CreateInitialSystemSession()) {
                    using (var context = session.CreateQuery()) {
                        try {
                            session.CurrentSchema(SystemSchema.Name);

                            // Create the schema information tables
                            CreateSchemata(context);

                            // The system tables that are present in every conglomerate.
                            SystemSchema.CreateTables(context);
                            SystemGroups.Create(context);

                            context.CreatePublicUser();

                            // Create the system views
                            InformationSchema.CreateViews(context);
                            InformationSchema.GrantToPublic(context);

                            this.CreateAdminUser(context, adminName, adminPassword);

                            SetCurrentDataVersion(context);

                            // Set all default system procedures.
                            // TODO: SystemSchema.SetupSystemFunctions(session, username);

                            OnDatabaseCreate(context);

                            try {
                                // Close and commit this transaction.
                                session.Commit();
                            } catch (TransactionException e) {
                                throw new DatabaseSystemException("Could not commit the initial information", e);
                            }
                        } catch (DatabaseSystemException) {
                            throw;
                        } catch (Exception ex) {
                            throw new DatabaseSystemException("An error occurred while creating the database.", ex);
                        }
                    }
                }

                // Close the conglomerate.
                TableComposite.Close();
            } catch (DatabaseSystemException) {
                throw;
            } catch (Exception e) {
                throw new DatabaseSystemException("An error occurred while creating the database.", e);
            }
        }
Ejemplo n.º 7
0
        public void LoadGroup()
        {
            //var result =
            try
            {
                foreach (var tagGroupReady in _tagGroupReady.GetAllTagGroupReady())
                {
                    #region [Connection]

                    TagGroupEventBus.Add(tagGroupReady.Name + "_Connection",
                                         new EventBusRabbitMqRpc(PersistentConnection, _loggerFactory, new ConnectionStatusRpcHandler(_loggerFactory, _componentContext),
                                                                 null, _exchangeDeclareParameters, _queueDeclareParameters, "BusinessQueueConnection_" + tagGroupReady.Name, CancellationToken.None));

                    ((IEventBusRpcClient)TagGroupEventBus[tagGroupReady.Name + "_Connection"])
                    .SubscribeRpcClient <ConnectionStatusIntegrationEventReply, ConnectionStatusRpcClientHandler>(tagGroupReady.Name + ".automation.connection.client.com");

                    TagGroupEventBus.Add(tagGroupReady.Name + "_Connection_Server",
                                         new EventBusRabbitMqRpcServer(PersistentConnection, _loggerFactory, new ConnectionStatusRpcServerHandler(_loggerFactory, _componentContext),
                                                                       null, _exchangeDeclareParameters, _queueDeclareParameters, "BusinessQueueServerRead_" + tagGroupReady.Name, CancellationToken.None));

                    ((IEventBusRpcServer)TagGroupEventBus[tagGroupReady.Name + "_Connection_Server"])
                    .SubscribeRpcServer <TagReadIntegrationEvent, TagReadIntegrationEventReply, TagReadRpcServerHandler>(tagGroupReady.Name + ".automation.connection.server");

                    #endregion

                    TagGroupEventBus.Add(tagGroupReady.Name + "_Invoke",
                                         new EventBusRabbitMqQueue(PersistentConnection, _loggerFactory, new TagInvokeEventHandler(_loggerFactory, _componentContext),
                                                                   null, _exchangeDeclareParameters, _queueDeclareParameters, "BusinessQueueInvoke_" + tagGroupReady.Name, CancellationToken.None));

                    #region [Read]

                    TagGroupEventBus.Add(tagGroupReady.Name + "_Read",
                                         new EventBusRabbitMqRpcClient(PersistentConnection, _loggerFactory, new TagReadRpcClientHandler(_loggerFactory, _componentContext),
                                                                       null, _exchangeDeclareParameters, _queueDeclareParameters, "BusinessQueueRead_" + tagGroupReady.Name, CancellationToken.None));

                    ((IEventBusRpcClient)TagGroupEventBus[tagGroupReady.Name + "_Read"])
                    .SubscribeRpcClient <TagReadIntegrationEventReply, TagReadRpcClientHandler>(tagGroupReady.Name + ".automation.read.client.com");

                    TagGroupEventBus.Add(tagGroupReady.Name + "_Read_Server",
                                         new EventBusRabbitMqRpcServer(PersistentConnection, _loggerFactory, new TagReadRpcServerHandler(_loggerFactory, _componentContext),
                                                                       null, _exchangeDeclareParameters, _queueDeclareParameters, "BusinessQueueServerRead_" + tagGroupReady.Name, CancellationToken.None));

                    ((IEventBusRpcServer)TagGroupEventBus[tagGroupReady.Name + "_Read_Server"])
                    .SubscribeRpcServer <TagReadIntegrationEvent, TagReadIntegrationEventReply, TagReadRpcServerHandler>(tagGroupReady.Name + ".automation.read.server");

                    #endregion

                    #region [Write]

                    TagGroupEventBus.Add(tagGroupReady.Name + "_Write",
                                         new EventBusRabbitMqRpcClient(PersistentConnection, _loggerFactory, new TagWriteRpcHandler(_loggerFactory, _componentContext),
                                                                       null, _exchangeDeclareParameters, _queueDeclareParameters, "BusinessQueueWrite_" + tagGroupReady.Name, CancellationToken.None));

                    ((IEventBusRpcClient)TagGroupEventBus[tagGroupReady.Name + "_Write"])
                    .SubscribeRpcClient <TagWriteIntegrationEventReply, TagWriteRpcClientHandler>(tagGroupReady.Name + ".automation.write.client.com");

                    TagGroupEventBus.Add(tagGroupReady.Name + "_Write_Server",
                                         new EventBusRabbitMqRpcServer(PersistentConnection, _loggerFactory, new TagWriteRpcServerHandler(_loggerFactory, _componentContext),
                                                                       null, _exchangeDeclareParameters, _queueDeclareParameters, "BusinessQueueServerWrite_" + tagGroupReady.Name, CancellationToken.None));

                    ((IEventBusRpcServer)TagGroupEventBus[tagGroupReady.Name + "_Write_Server"])
                    .SubscribeRpcServer <TagWriteIntegrationEvent, TagWriteIntegrationEventReply, TagWriteRpcServerHandler>(tagGroupReady.Name + ".automation.write.server");

                    #endregion

                    if (SystemGroups.ContainsKey(tagGroupReady.Name))
                    {
                        continue;
                    }
                    tagGroupReady.AddLoggerFactory(_loggerFactory);
                    SystemGroups.Add(tagGroupReady.Name, tagGroupReady.GetTagGroup(/*_connectionFactory,*/ _notifierMediatorService));

                    SystemGroups[tagGroupReady.Name]
                    .Initiate(_allTagGroupAllConnection.GetAllTagGroupAllConnection()
                              .Where(tags => tags.TagGroupName.Equals(tagGroupReady.Name))
                              .ToList());

                    //tagGroupReady.Initiate(_allTagGroupAllConnection.AllTagGroupAllConnections
                    //    .Where(tags => tags.TagGroupName.Equals(tagGroupReady.Name)).ToList());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("LoadGroup: " + ex.Message + " - " + ex.StackTrace);
            }
        }
Ejemplo n.º 8
0
 public bool GetConnectionWriteStatus(string groupName, string connectionName)
 {
     return(SystemGroups.ContainsKey(groupName) && SystemGroups[groupName].GetConnectionStatusWrite(connectionName));
 }