private async void ObterJsonAsync(object sender, EventArgs e)
        {
            RootService RootService = new RootService();
            ApiService  apiService  = new ApiService();


            resultText.Text = "Carregando dados...";

            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert("Mensagem", connection.Message, "Ok");

                return;
            }

            Response response = new Response();

            response = await RootService.GetAllUrl(UrlApiEntry.Text);


            if (response.IsSuccess)
            {
                resultText.Text = response.Result.ToString();
            }
            else
            {
                resultText.Text = response.Message.ToString();
            }
        }
예제 #2
0
        // GET: Root
        public ActionResult Index()
        {
            var service = new RootService();
            var model   = service.GetRoots();

            return(View(model));
        }
예제 #3
0
        public void StartService(ServiceType serviceType)
        {
            // Start the services,
            lock (serverManagerLock) {
                IService service = serviceFactory.CreateService(address, serviceType, connector);
                if (service == null)
                {
                    throw new ApplicationException("Unable to create service of tyoe  " + serviceType);
                }

                service.Start();

                if (serviceType == ServiceType.Manager)
                {
                    manager = (ManagerService)service;
                }
                else if (serviceType == ServiceType.Root)
                {
                    root = (RootService)service;
                }
                else if (serviceType == ServiceType.Block)
                {
                    block = (BlockService)service;
                }
            }
        }
예제 #4
0
        //Get Delete
        public ActionResult Delete(int id)
        {
            var service = new RootService();
            var model   = service.GetRootById(id);

            return(View(model));
        }
예제 #5
0
        public ImmuClient(string immudbUrl)
        {
            this.channel     = GrpcChannel.ForAddress(immudbUrl);
            this.instance    = new ImmuService.ImmuServiceClient(channel);
            this.rootService = new RootService(this.instance);

            this.rootService.Init();
        }
예제 #6
0
        private Service DoCreateService(IServiceAddress serviceAddress, ServiceType serviceType, IServiceConnector connector)
        {
            Service service = null;

            if (serviceType == ServiceType.Manager)
            {
                if (manager == null)
                {
                    string npath = Path.Combine(basePath, "manager");
                    if (!Directory.Exists(npath))
                    {
                        Directory.CreateDirectory(npath);
                    }

                    manager = new FileSystemManagerService(connector, basePath, npath, serviceAddress);
                }

                service = manager;
            }
            else if (serviceType == ServiceType.Root)
            {
                if (root == null)
                {
                    string npath = Path.Combine(basePath, "root");
                    if (!Directory.Exists(npath))
                    {
                        Directory.CreateDirectory(npath);
                    }

                    root = new FileSystemRootService(connector, serviceAddress, npath);
                }

                service = root;
            }
            else if (serviceType == ServiceType.Block)
            {
                if (block == null)
                {
                    string npath = Path.Combine(basePath, "block");
                    if (!Directory.Exists(npath))
                    {
                        Directory.CreateDirectory(npath);
                    }

                    block = new FileSystemBlockService(connector, npath);
                }

                service = block;
            }

            if (service != null)
            {
                service.Started += ServiceStarted;
                service.Stopped += ServiceStopped;
            }

            return(service);
        }
예제 #7
0
        private async void LoadContaApagar()
        {
            RootService RootService = new RootService();

            this.IsRefreshing = true;

            var connection = await this.apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert("Mensagem", connection.Message, "Ok");

                return;
            }

            if (this.service == "Contas a receber")
            {
                this.url           = Application.Current.Resources["UrlAPI"].ToString();
                this.urlPrefix     = Application.Current.Resources["UrlPrefix"].ToString();
                this.prefixControl = Application.Current.Resources["UrlPrefixControllerContaReceber"].ToString();
                this.action        = "emp=99&fil=01";
            }
            else
            {
                this.url           = Application.Current.Resources["UrlAPI"].ToString();
                this.urlPrefix     = Application.Current.Resources["UrlPrefix"].ToString();
                this.prefixControl = Application.Current.Resources["UrlPrefixControllerContaApagar"].ToString();
                this.action        = "emp=99&fil=01";
            }

            var response = await RootService.GetAll(this.url, this.urlPrefix, this.prefixControl, this.action);

            var test = await RootService.GetAll(this.url, this.urlPrefix, this.prefixControl, this.action);

            var         list     = (Root)response.Result;
            List <Root> ListRoot = new List <Root>();

            ListRoot.Add(list);

            if (!response.IsSuccess)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert("Mensagem", "Tempo de resposta do servidor inesperado Tente novamente", "Ok");

                return;
            }

            this.ContaApagar = new ObservableCollection <Root>(ListRoot);
            this.Titulo      = list.titulo.ToString();
            this.Dados       = new ObservableCollection <Dados>(list.dados);

            this.Filtros = new ObservableCollection <string>(list.fitros.valores);

            this.IsRefreshing = false;
        }
예제 #8
0
        private async void SelectItemDetalhe(object sender, ItemTappedEventArgs e)
        {
            var item = e.Item as Dados;

            try
            {
                if (item == null)
                {
                    return;
                }
                else
                {
                    RootService rootService = new RootService();
                    var         response    = await rootService.GetAllUrl(item.urlFilhos);

                    var list = (Root)response.Result;
                    this.Title = list.titulo;
                    List <Dados> listDados = new List <Dados>();
                    if (list != null)
                    {
                        string       fornecedor  = "";
                        string       empresa     = "";
                        string       periodo     = "";
                        string       prefixo     = "";
                        List <Dados> dadosFiltro = new List <Dados>();
                        foreach (Dados dado in list.dados)
                        {
                            decimal total = Convert.ToDecimal(dado.total);
                            dado.total = total.ToString("N2");
                            fornecedor = dado.fornecedor;
                            empresa    = dado.natureza;
                            periodo    = dado.id;
                            prefixo    = dado.prefixo;
                            dadosFiltro.Add(dado);
                        }

                        if (prefixo == null)
                        {
                            await Navigation.PushAsync(new Teste(dadosFiltro, empresa, periodo));
                        }
                        else
                        {
                            await Navigation.PushAsync(new DetalhePage(dadosFiltro, fornecedor, periodo, this.Title));
                        }

                        ((ListView)sender).SelectedItem = null;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #9
0
        public ActionResult Create(RootCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = new RootService();

            service.CreateRoot(model);

            return(RedirectToAction("Index"));
        }
예제 #10
0
        public static SafeGetResponse Call(ImmuService.ImmuServiceClient immuS, RootService rs, SafeGetOptions request)
        {
            var root  = rs.GetRoot();
            var index = new Immudb.Schema.Index
            {
                Index_ = root.Index
            };

            var protoReq = new SafeGetOptions(request)
            {
                RootIndex = index
            };

            var msg      = immuS.SafeGet(protoReq);
            var verified = Proofs.Verify(msg.Proof, ItemUtils.GetHash(msg.Item), root);

            if (verified)
            {
                var toCache = new Root
                {
                    Index = msg.Proof.At,
                    Root_ = msg.Proof.Root
                };

                try
                {
                    rs.SetRoot(toCache);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            var i = msg.Item;

            var timestampBytes = i.Value.Take(8).ToArray();

            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(timestampBytes);
            }

            return(new SafeGetResponse
            {
                Index = i.Index,
                Key = i.Key,
                Value = ByteString.CopyFrom(i.Value.Skip(8).ToArray()),
                Timestamp = BitConverter.ToInt64(timestampBytes),
                Verified = verified
            });
        }
예제 #11
0
        public ActionResult Edit(int id)
        {
            var service = new RootService();
            var detail  = service.GetRootById(id);
            var model   =
                new RootListItem
            {
                Id          = detail.Id,
                RootName    = detail.RootName,
                NotesOnRoot = detail.NotesOnRoot
            };

            return(View(model));
        }
예제 #12
0
        public ActionResult DeletePost(int id)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var service = new RootService();

            service.DeleteRoot(id);

            TempData["SaveResult"] = "Your note was deleted";

            return(RedirectToAction("Index"));
        }
예제 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAdvertiseServicesWhenAsked() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void ShouldAdvertiseServicesWhenAsked()
            {
                UriInfo uriInfo = mock(typeof(UriInfo));
                URI     uri     = new URI("http://example.org:7474/");

                when(uriInfo.BaseUri).thenReturn(uri);

                RootService svc = new RootService(new CommunityNeoServer(Config.defaults(stringMap((new HttpConnector("http", HttpConnector.Encryption.NONE)).type.name(), "HTTP", (new HttpConnector("http", HttpConnector.Encryption.NONE)).enabled.name(), "true")), GraphDatabaseDependencies.newDependencies().userLogProvider(NullLogProvider.Instance).monitors(new Monitors())));

                EntityOutputFormat output            = new EntityOutputFormat(new JsonFormat(), null, null);
                Response           serviceDefinition = svc.GetServiceDefinition(uriInfo, output);

                assertEquals(200, serviceDefinition.Status);
                IDictionary <string, object> result = (IDictionary <string, object>)output.ResultAsMap["services"];

                assertThat(result["console"].ToString(), containsString(string.Format("{0}server/console", uri.ToString())));
                assertThat(result["jmx"].ToString(), containsString(string.Format("{0}server/jmx", uri.ToString())));
            }
예제 #14
0
 public void StopService(ServiceType serviceType)
 {
     lock (serverManagerLock) {
         if (serviceType == ServiceType.Manager && manager != null)
         {
             manager.Stop();
             manager = null;
         }
         else if (serviceType == ServiceType.Root && root != null)
         {
             root.Stop();
             root = null;
         }
         else if (serviceType == ServiceType.Block && block != null)
         {
             block.Stop();
             block = null;
         }
     }
 }
예제 #15
0
        public PeriodoPage(Funcionalidade _func)
        {
            InitializeComponent();
            BindingContext = new RootViewModel(_func.Nome);;
            this.func      = _func;

            try
            {
                FlowListView.Init();
                ObterRootRaiz = new Command <string>(
                    async(string urlFilhos) =>
                {
                    if (urlFilhos != null)
                    {
                        RootService rootService = new RootService();
                        var response            = await rootService.GetAllUrl(urlFilhos);
                        var list = (Root)response.Result;
                        List <Dados> listDados = new List <Dados>();
                        if (list != null)
                        {
                            string natureza          = "";
                            string periodo           = "";
                            List <Dados> dadosFiltro = new List <Dados>();
                            foreach (Dados dado in list.dados)
                            {
                                decimal total = Convert.ToDecimal(dado.total);
                                dado.total    = total.ToString("N2");
                                periodo       = dado.id;
                                dadosFiltro.Add(dado);
                                dadosFiltro.Add(dado);
                            }
                            await Navigation.PushAsync(new Teste(dadosFiltro, natureza, periodo));
                        }
                    }
                });
            }
            catch (Exception e)
            {
                throw;
            }
        }
예제 #16
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (manager != null)
                {
                    manager.Dispose();
                    manager = null;
                }
                if (root != null)
                {
                    root.Dispose();
                    root = null;
                }
                if (block != null)
                {
                    block.Dispose();
                    block = null;
                }
            }

            base.Dispose(disposing);
        }
예제 #17
0
        protected override void OnStop()
        {
            if (configTimer != null)
            {
                configTimer.Dispose();
                configTimer = null;
            }

            if (manager != null)
            {
                manager.Dispose();
                manager = null;
            }
            if (root != null)
            {
                root.Dispose();
                root = null;
            }
            if (block != null)
            {
                block.Dispose();
                block = null;
            }
        }
예제 #18
0
        public ActionResult Edit(int id, RootListItem model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.Id != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = new RootService();

            if (service.UpdateRoot(model))
            {
                TempData["SaveResult"] = "Your note was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your note could not be updated.");
            return(View(model));
        }
예제 #19
0
        public async Task Greeting(IDialogContext context, LuisResult result)
        {
            await context.PostAsync(RootService.GetReply(RootReply.Greeting));

            context.Wait(this.MessageReceived);
        }
예제 #20
0
 public MemoryPathAccess(RootService service, string pathName)
     : base(service, pathName)
 {
 }
예제 #21
0
 // Use this for initialization
 void Awake()
 {
     service = new RootService();
     // lifeInsurance = new RootService.LifeInsurance(1000000);
 }
예제 #22
0
        public static SafeSetResponse Call(ImmuService.ImmuServiceClient immuS, RootService rs, SafeSetOptions request)
        {
            var root = rs.GetRoot();

            var index = new Immudb.Schema.Index
            {
                Index_ = root.Index
            };

            var valueB        = new byte[8 + request.Kv.Value.Length];
            var buffTimestamp = BitConverter.GetBytes(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());

            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(buffTimestamp);
            }

            buffTimestamp.CopyTo(valueB, 0);
            request.Kv.Value.CopyTo(valueB, 8);

            var sso = new SafeSetOptions
            {
                Kv = new KeyValue
                {
                    Key   = request.Kv.Key,
                    Value = ByteString.CopyFrom(valueB)
                },
                RootIndex = index
            };

            var msg = immuS.SafeSet(sso);

            var item = new Item
            {
                Key   = sso.Kv.Key,
                Value = sso.Kv.Value,
                Index = msg.Index
            };

            if (!ItemUtils.GetHash(item).SequenceEqual(msg.Leaf.ToByteArray()))
            {
                throw new Exception("Proof does not match the given item.");
            }

            bool verified = Proofs.Verify(msg, msg.Leaf.ToByteArray(), root);

            if (verified)
            {
                var toCache = new Root
                {
                    Index = msg.Index,
                    Root_ = msg.Root
                };

                try
                {
                    rs.SetRoot(toCache);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            return(new SafeSetResponse
            {
                Index = msg.Index,
                Leaf = msg.Leaf,
                Root = msg.Root,
                At = msg.At,
                InclusionPath = msg.InclusionPath,
                ConsistencyPath = msg.ConsistencyPath,
                Verified = verified
            });
        }