Exemple #1
0
        public Response Post(SocketClientHomeModel theModel)
        {
            if (theModel != null)
            {
                string EndpointGuid = string.IsNullOrEmpty(theModel.Guid) ? Guid.NewGuid().ToString() : theModel.Guid;

                Core.Instance.Update(new SocketClientProperties[] {
                    new SocketClientProperties
                    {
                        Guid         = EndpointGuid,
                        LoggingLevel = theModel.LoggingLevel,
                    }
                });

                return(new Response
                {
                    StatusCode = System.Net.HttpStatusCode.Moved,
                    Location = new Uri(Context.Referrer, Context.Referrer.AbsolutePath + "?id=" + EndpointGuid)
                });
            }

            return(new Response
            {
                StatusCode = System.Net.HttpStatusCode.Moved,
                Location = Context.Referrer
            });
        }
Exemple #2
0
        public Response Get(string id)
        {
            SocketClientComponent SocketEndpoint = null;

            if (!string.IsNullOrEmpty(id))
            {
                SocketEndpoint = Core.Instance.SocketClients.FirstOrDefault(t => t.Guid == id);

                if (SocketEndpoint == null)
                {
                    return(new Response
                    {
                        Template = Templates.SettingsNotFound
                    });
                }
            }

            SocketClientHomeModel Model;

            Subscription[] Subscriptions = null;

            if (SocketEndpoint != null)
            {
                Model = new SocketClientHomeModel
                {
                    Guid              = SocketEndpoint.Guid,
                    LoggingLevel      = SocketEndpoint.LoggingLevel,
                    TraceLog          = SocketEndpoint.TraceLog,
                    Connected         = SocketEndpoint.Connected,
                    ConnectionInError = SocketEndpoint.ConnectionInError
                };
                Subscriptions = new Subscription[] { new Subscription {
                                                         Id = SocketEndpoint.LogEventId
                                                     } };
            }
            else
            {
                string Guid = System.Guid.NewGuid().ToString();

                Model = new SocketClientHomeModel
                {
                    Guid              = string.Empty,
                    LoggingLevel      = 0,
                    TraceLog          = string.Empty,
                    Connected         = false,
                    ConnectionInError = false
                };

                Subscriptions = new Subscription[0];
            }

            return(new Response
            {
                Model = Model,
                Template = Templates.SettingsSocketClientHome,
                Subscriptions = Subscriptions
            });
        }