Exemplo n.º 1
0
        public MockDataStore()
        {
            items = new List <Item>();

            Task.Run(async() =>
            {
                int registros = await App.Database.GetNumRows();

                if (registros == 0)
                {
                    await DownloadAtendimentosAsync(0);
                }
                else
                {
                    List <Item> LastDBAtendimento = await App.Database.MaxId();
                    LastId LastServerAtendimento  = await LastServerIdAsync();

                    if (LastServerAtendimento.id > LastDBAtendimento[0].id)
                    {
                        await DownloadAtendimentosAsync(LastDBAtendimento[0].id);
                        await CarregarViaBancolocalAsync();
                    }
                    else
                    {
                        await CarregarViaBancolocalAsync();
                    }
                }
            }).Wait();
        }
Exemplo n.º 2
0
        public void TestMethod2()
        {
            var manufacturer = "Honda";
            var model        = "Civic";
            var airCon       = true;
            var alloys       = true;

            LastId lastId = LastId.getInstance();

            Order  order  = Order.getInstance(0, manufacturer, model, airCon, alloys, lastId);
            Dealer dealer = Dealer.getInstance(manufacturer);

            var response = order.fulfillOrder(dealer);

            Assert.IsNotNull(response);


            manufacturer = "Ford";
            model        = "Focus";
            airCon       = false;
            alloys       = false;

            order    = Order.getInstance(0, manufacturer, model, airCon, alloys, lastId);
            dealer   = Dealer.getInstance(manufacturer);
            response = order.fulfillOrder(dealer);

            Assert.IsNotNull(response);
        }
Exemplo n.º 3
0
        async Task <LastId> LastServerIdAsync()
        {
            var dados = await ws.QuerySelect("controldesk.mb_guiaslista_atendimentos_id");

            LastId info = null;

            foreach (var item in dados)
            {
                info = JsonConvert.DeserializeObject <LastId>(item.ToString());
            }
            return(info);
        }
Exemplo n.º 4
0
        virtual public Task SendAsync(ArraySegment <byte> buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
        {
            var json = Encoding.UTF8.GetString(buffer.Array, 0, buffer.Count);

            LastPacket = JToken.Parse(json);
            LastId     = LastPacket["id"]?.Value <int>();

            if (_isFirstSend)
            {
                _isFirstSend = false;
                if (IsChat)
                {
                    JoinedChat.Set();
                    if (_isAuthenticated)
                    {
                        InjectPacket("{'type':'reply','error':null,'id':<MSGID>,'data':{'authenticated':true,'roles':[]}}"
                                     .Replace("'", "\"")
                                     .Replace("<MSGID>", LastId.ToString())
                                     );
                    }
                    else
                    {
                        InjectPacket("{'type':'reply','error':null,'id':<MSGID>,'data':null}"
                                     .Replace("'", "\"")
                                     .Replace("<MSGID>", LastId.ToString())
                                     );
                    }
                }
                else
                {
                    JoinedConstallation.Set();
                    if (_isAuthenticated)
                    {
                        InjectPacket("{'type':'reply','error':null,'id':<MSGID>,'data':{'authenticated':true,'roles':['Owner','User']}}".Replace("'", "\"").Replace("<MSGID>", LastId.ToString()));
                    }
                    else
                    {
                        InjectPacket("{'id':<MSGID>,'type':'reply','result':null,'error':null}".Replace("'", "\"").Replace("<MSGID>", LastId.ToString()));
                    }
                }
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 5
0
            public Dictionary <string, string> ToDictionary()
            {
                var options = new Dictionary <string, string>();

                if (UnreadOnly)
                {
                    options.Add("unreadOnly", "true");
                }
                if (Limit.HasValue)
                {
                    options.Add("limit", Limit.ToString());
                }
                if (LastId.HasValue)
                {
                    options.Add("lastId", LastId.ToString());
                }
                if (AllUsers)
                {
                    options.Add("allUsers", "true");
                }
                return(options);
            }
            public Dictionary <string, string> ToDictionary()
            {
                var options = new Dictionary <string, string>();

                if (!string.IsNullOrEmpty(UserId))
                {
                    options.Add("userId", UserId);
                }
                if (LastId.HasValue)
                {
                    options.Add("lastId", LastId.ToString());
                }
                if (Limit.HasValue)
                {
                    options.Add("limit", Limit.ToString());
                }
                if (SortOrder == ListSortOrder.Ascending)
                {
                    options.Add("sortOrder", "asc");
                }
                return(options);
            }