public static Response<List<OpenLawOffice.Common.Models.Matters.Matter>> ListMatters(string contactFilter, string titleFilter, 
            string caseNumberFilter, string jurisdictionFilter, bool activeFilter = true)
        {
            JsonWebClient web;
            OpenLawOffice.Common.Net.Response<List<OpenLawOffice.Common.Models.Matters.Matter>> response;

            web = new JsonWebClient();
            response = web.Request<List<OpenLawOffice.Common.Models.Matters.Matter>>(
                Globals.ThisAddIn.Settings.ServerUrl + "JsonInterface/Matters?contactFilter=" + contactFilter + "&titleFilter=" + titleFilter +
                "&caseNumberFilter=" + caseNumberFilter + "&jurisdictionFilter=" + jurisdictionFilter + "&activeFilter=" + activeFilter.ToString(), "GET");

            if (response != null && response.Successful)
                return new Response<List<Common.Models.Matters.Matter>>()
                {
                    Package = response.Package,
                    RequestReceived = response.RequestReceived,
                    ResponseSent = response.ResponseSent,
                    Error = response.Error,
                    Successful = response.Successful
                };

            if (Globals.ThisAddIn.CanLog)
                LogManager.GetCurrentClassLogger().Error("Error: " + response.Error);

            return null;
        }
        public Response<dynamic> CloseSession()
        {
            JsonWebClient web;
            Response<bool> result;
            string url;
            Response<dynamic> resp;
            AuthPackage authPackage;

            if (string.IsNullOrEmpty(Globals.ThisAddIn.Settings.ServerUrl))
                throw new InvalidOperationException("Invalid Server URL");
            if (string.IsNullOrEmpty(Globals.ThisAddIn.Settings.Username))
                throw new InvalidOperationException("Invalid Username");

            authPackage = new AuthPackage()
            {
                AppName = "OpenLawOffice.Word",
                MachineId = Globals.ThisAddIn.Settings.MachineId,
                Username = Globals.ThisAddIn.Settings.Username.Trim()
            };

            web = new JsonWebClient();
            url = Globals.ThisAddIn.Settings.ServerUrl + "JsonInterface/CloseSession";

            if (Globals.ThisAddIn.CanLog)
                LogManager.GetCurrentClassLogger().Debug("Sending authentication request to: " + url);

            result = web.Request<AuthPackage, bool>(url, "POST", authPackage);
            resp = new Common.Net.Response<dynamic>();

            if (result == null)
            {
                if (Globals.ThisAddIn.CanLog)
                    LogManager.GetCurrentClassLogger().Info("Error closing session.");

                resp.RequestReceived = result.RequestReceived;
                resp.ResponseSent = result.ResponseSent;
                resp.Successful = result.Successful;
                resp.Package = new
                {
                    Error = web.GetResult<bool>().Error,
                    Server = Globals.ThisAddIn.Settings.ServerUrl.Trim()
                };
            }
            else
            {
                resp.RequestReceived = result.RequestReceived;
                resp.ResponseSent = result.ResponseSent;
                resp.Successful = result.Successful;
                resp.Package = null;

                _isConnected = false;
                Token = null;

                if (Globals.ThisAddIn.CanLog)
                    LogManager.GetCurrentClassLogger().Debug("Session closed successfully.");
            }

            return resp;
        }
Exemple #3
0
        private async void buttonStringGet_click_1(object sender, RoutedEventArgs e)
        {
            JsonWebAsync.JsonWebClient client = new JsonWebClient();
            var resp = await client.DoRequestAsync("http://dev.codigo.labplc.mx/EventarioWeb/eventos/1.json");

            string result = resp.ReadToEnd();

            resultText.Text = result;
        }
        public BaseSpaceClient(IClientSettings settings, IRequestOptions defaultOptions = null)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            Settings = settings;
            WebClient = new JsonWebClient(settings, defaultOptions);
        }
 public GitHubApiClient(IBranchesProvider branchesProvider,
     CommitMapper commitMapper,
     ICredentialsProvider credentialsProvider,
     JsonWebClient jsonWebClient)
 {
     _branchesProvider = branchesProvider;
     _credentialsProvider = credentialsProvider;
     _commitMapper = commitMapper;
     _jsonWebClient = jsonWebClient;
     _currentUserName = _credentialsProvider.GetUserName();
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="uriString"></param>
        public IotaClient(string uriString)
        {
            _jsonWebClient          = new JsonWebClient();
            _jsonSerializerSettings = new JsonSerializerSettings
            {
                MissingMemberHandling = MissingMemberHandling.Ignore,
                NullValueHandling     = NullValueHandling.Ignore,
                DefaultValueHandling  = DefaultValueHandling.Include,
                ContractResolver      = new CamelCasePropertyNamesContractResolver()
            };

            UriString = uriString;
        }
Exemple #7
0
        public async Task TestDelete()
        {
            var ws = new TestWebServer();

            ws.Start();

            while (!ws.IsStarted)
            {
            }

            Console.WriteLine(JsonConvert.SerializeObject(await JsonWebClient.DeleteAsync <object>($"{TestWebServer.TestHost}?key1=test&key2=try")));

            ws.Stop();
        }
Exemple #8
0
        public ActionResult Index()
        {
            if (Request.Url.AbsoluteUri.Contains(@"Home/Index"))
            {
                return(Redirect("/"));
            }
            ViewBag.Title = "Home Page";
            var model = new IndexViewModel();
            var abc   = new Abc {
                a = 1, b = new Bclass(2.2), c = "Drei"
            };

            using (JsonWebClient client = new JsonWebClient())
                model.results.Add("Result1",
                                  client.UploadObject(url(@"Home/EchoAOfABC"), abc));

            using (JsonWebClient client = new JsonWebClient())
            {
                Cba r = client.UpDownloadObject <Cba>(url(@"Home/EchoAbcAsCba"), abc);
                model.results.Add("Result2",
                                  $"Result has type {r.GetType()} and values {r}");
            }

            // Download
            model.results.Add("Download one Abc:",
                              JsonWebClient.DownloadObject <Abc>(url(@"DownloadCheck/DownloadOneAbc")).ToString());
            model.results.Add("Download a DateTime:",
                              JsonWebClient.DownloadObject <DateTime>(url(@"DownloadCheck/DownloadServerDateTime"), "PATCH").ToString("u"));


            //UpDownload
            var abc3 = new Abc()
            {
                a = 11, b = new Bclass(2.2), c = "Drei und Dreißig"
            };
            var cba3 = new Cba()
            {
                a = 333, b = new Bclass(2.22), c = "Hundertelf"
            };
            var transportList = new List <object>();

            transportList.Add(abc3);
            transportList.Add(cba3);

            model.results.Add("UpDownload two objects, the secound is:",
                              JsonWebClient.UpDownloadObject <Cba>(transportList, url(@"UpDownloadCheck/UpDownloadOneCbaFromAbc")).ToString());


            return(View(model));
        }
Exemple #9
0
        private async Task <bool> RefreshDlLevelListAsync()
        {
            try
            {
                JsonWebClient  client = new JsonWebClient();
                List <LevelDl> resp   = await client.DoRequestJsonAsync <List <LevelDl> >(QUIZZ_APP_INIT_BASE_URL + "/" + QUIZZ_APP_SERVICE_LEVELS_LIST + "/" + QUIZZ_APP_MEDIA_TYPE_IDENTIFIER);

                this.toDlLevels           = resp;
                this.LastDlLevelsListTime = DateTime.Now;
                return(this.toDlLevels != null);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error retrieving packs to dl list !!", ex);
                return(false);
            }
        }
Exemple #10
0
        private async Task <bool> RefreshInitInfosAsync(bool updateIndicatorOfAllPacks)
        {
            try
            {
                JsonWebClient client = new JsonWebClient();
                InitInfosRep  resp   = await client.DoRequestJsonAsync <InitInfosRep>(QUIZZ_APP_INIT_BASE_URL + "/" + QUIZZ_APP_SERVICE_INFO + "/" + QUIZZ_APP_MEDIA_TYPE_IDENTIFIER);

                this.LastInitInfosRep     = resp;
                this.LastInitInfosRepTime = DateTime.Now;

                // Inject dificulties
                if (this.LastInitInfosRep == null)
                {
                    return(false);
                }

                var difficulties = this.LastInitInfosRep.Difficulties.Where(m => m.Language.Value.Equals(LanguagesUtils.GetCurrentLanguageOnQuizzAppFormat(), StringComparison.InvariantCultureIgnoreCase)).ToList();
                using (var dbHelper = new GameDBHelper(MAIN_DATABASE_PATH, MAIN_PACKS_FOLDER_PATH))
                {
                    var installedDifficulties = dbHelper.GetDifficulties();
                    foreach (var item in difficulties)
                    {
                        if (!installedDifficulties.ContainsKey(item.Difficulty.Id))
                        {
                            dbHelper.AddDifficulty(item);
                        }
                    }

                    var toto = dbHelper.GetDifficulties();
                }



                //if (updateIndicatorOfAllPacks)
                //    this.UpdateIndicatorNewOfPacks();

                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error doing 'init' on server!!", ex);
                return(false);
            }
        }
        public static Response<List<OpenLawOffice.Common.Models.Forms.FormFieldMatter>> GetFormDataForMatter(Guid matterId)
        {
            JsonWebClient web;
            OpenLawOffice.Common.Net.Response<List<OpenLawOffice.Common.Models.Forms.FormFieldMatter>> response;

            web = new JsonWebClient();
            response = web.Request<List<OpenLawOffice.Common.Models.Forms.FormFieldMatter>>(
                Globals.ThisAddIn.Settings.ServerUrl + "JsonInterface/GetFormDataForMatter/" + matterId.ToString(), "GET");

            if (response != null && response.Successful)
                return new Response<List<Common.Models.Forms.FormFieldMatter>>()
                {
                    Package = response.Package,
                    RequestReceived = response.RequestReceived,
                    ResponseSent = response.ResponseSent,
                    Error = response.Error,
                    Successful = response.Successful
                };

            if (Globals.ThisAddIn.CanLog)
                LogManager.GetCurrentClassLogger().Error("Error: " + response.Error);

            return null;
        }
        public Response<dynamic> Authenticate(string password)
        {
            JsonWebClient web;
            AuthPackage authPackage;
            Response<Guid> result;
            string authUrl;
            Response<dynamic> resp;
            Common.Encryption enc;
            Common.Encryption.Package encPackage;

            enc = new Common.Encryption();
            enc.Key = Globals.ThisAddIn.Settings.Key;
            enc.GenerateIV();
            encPackage = new Common.Encryption.Package()
            {
                Input = password.Trim()
            };
            encPackage = enc.Encrypt(encPackage);

            authPackage = new AuthPackage()
            {
                AppName = "OpenLawOffice.Word",
                MachineId = Globals.ThisAddIn.Settings.MachineId,
                Username = Globals.ThisAddIn.Settings.Username.Trim(),
                IV = enc.IV,
                Password = encPackage.Output
            };

            if (string.IsNullOrEmpty(Globals.ThisAddIn.Settings.ServerUrl))
                throw new InvalidOperationException("Invalid Server URL");
            if (string.IsNullOrEmpty(Globals.ThisAddIn.Settings.Username))
                throw new InvalidOperationException("Invalid Username");

            web = new JsonWebClient();
            authUrl = Globals.ThisAddIn.Settings.ServerUrl + "JsonInterface/Authenticate";

            if (Globals.ThisAddIn.CanLog)
                LogManager.GetCurrentClassLogger().Debug("Sending authentication request to: " + authUrl);

            result = web.Request<AuthPackage, Guid>(authUrl, "POST", authPackage);
            resp = new Common.Net.Response<dynamic>();

            if (result == null)
            {
                string error;

                if (Globals.ThisAddIn.CanLog)
                    LogManager.GetCurrentClassLogger().Info("Login error for user: "******"User logged in successfully: " + authPackage.Username);
                    else
                        LogManager.GetCurrentClassLogger().Debug("Failed login for: " + authPackage.Username);
                }
            }

            return resp;
        }