Beispiel #1
0
        public void TestJsonDataSourceFindByKey(string key, dynamic val)
        {
            // Setup
            var jsonDataSource = new JsonDataSource <Person>();

            // Perform
            var people = jsonDataSource.Find(key, val);

            // Assertions
            Assert.NotNull(people);

            switch (key)
            {
            case "Age":
                Assert.Equal(3, people.Count);
                Assert.Equal(val, people[0].Age);
                Assert.Equal(val, people[1].Age);
                Assert.Equal(val, people[2].Age);
                break;

            case "Id":
                Assert.Equal(3, people.Count);
                Assert.Equal(val, people[0].Id);
                Assert.Equal(val, people[1].Id);
                Assert.Equal(val, people[2].Id);
                break;

            case "Gender":
                Assert.Equal(2, people.Count);
                Assert.Equal(val, people[0].Gender);
                Assert.Equal(val, people[1].Gender);
                break;
            }
        }
Beispiel #2
0
        public void TestJsonDataSourceAllByKey(string key)
        {
            // Setup
            var jsonDataSource = new JsonDataSource <Person>();

            // Perform
            var people = jsonDataSource.All(key);

            // Assertions
            Assert.NotNull(people);

            switch (key)
            {
            case "Age":
                Assert.Equal(4, people.Count);
                Assert.Equal(3, people["66"].Count);
                Assert.Equal(1, people["12"].Count);
                Assert.Equal(2, people["23"].Count);
                break;

            case "Id":
                Assert.Equal(5, people.Count);
                Assert.Equal(3, people["31"].Count);
                Assert.Equal(1, people["53"].Count);
                Assert.Equal(1, people["62"].Count);
                break;

            case "Gender":
                Assert.Equal(3, people.Count);
                Assert.Equal(3, people["Unknown"].Count);
                Assert.Equal(2, people["Male"].Count);
                Assert.Equal(2, people["Female"].Count);
                break;
            }
        }
Beispiel #3
0
 void UpdateData()
 {
     DataSource = new JsonDataSource()
     {
         Source = JsonSource.FromUri(new Uri("https://s3.amazonaws.com/utdmakerspace/events.json"))
     };
 }
Beispiel #4
0
    public void OnGet()
    {
        // Create a SQL data source.
        // MsSqlConnectionParameters parameters = new MsSqlConnectionParameters("localhost",
        //     "dbName", "userName", "password", MsSqlAuthorizationType.SqlServer);
        // SqlDataSource dataSource = new SqlDataSource(parameters);
        // SelectQuery query = SelectQueryFluentBuilder.AddTable("Products").SelectAllColumnsFromTable().Build("Products");
        // dataSource.Queries.Add(query);
        // dataSource.RebuildResultSchema();

        // Create a JSON data source.
        JsonDataSource jsonDataSource = new JsonDataSource();

        jsonDataSource.JsonSource = new UriJsonSource(new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"));
        jsonDataSource.Fill();


        DesignerModel = new ReportDesignerModel
        {
            Report      = new XtraReport(),
            DataSources = new Dictionary <string, object>()
        };
        // DesignerModel.DataSources.Add("BookStoreDb", dataSource);
        DesignerModel.DataSources.Add("JsonDataSource", jsonDataSource);
    }
Beispiel #5
0
        public MainPage()
        {
            InitializeComponent();

            using (WebClient wc = new WebClient())
            {
                _json = wc.DownloadString("https://services.odata.org/V3/Northwind/Northwind.svc/Products?$format=json");
            }

            JObject o = JObject.Parse(_json);

            if (o != null)
            {
                List <JToken> tokens = o.Children().ToList();
                JToken        token1 = tokens[1];
                var           value  = token1.Value <JProperty>();
                _json = value.First.ToString();
            }

            JsonDataSource   jsonDataSource   = new JsonDataSource();
            StringJsonSource stringJsonSource = new StringJsonSource();

            stringJsonSource.Json = _json;
            jsonDataSource.Source = stringJsonSource;
            this.DataSource       = jsonDataSource;
        }
Beispiel #6
0
        public void JsonDataSourceComplex()
        {
            var jsonDataSource = new JsonDataSource();

            var json = @"[
	{
		'Name': 'Kristen Perez',
		'Address': 'Ap #325-3386 Ac Av.',
		'Phone': '(016977) 7108',
		'Title': 'Lorem Ipsum Dolor Incorporated',
		'Email': '*****@*****.**',
		'List' : [
          'Foo', 'Bar', 'Baz'
        ]
	},
	{
		'Name': 'Murphy Cote',
		'Address': '906-6938 Porttitor Ave',
		'Phone': '076 9223 8954',
		'Title': 'Vulputate Industries',
		'Email': '*****@*****.**',
        'List' : [ { 'Second' : 'Thing' } ]
	},
	{
		'Name': 'Nicole Valdez',
		'Address': '485-9530 Ut Rd.',
		'Phone': '0800 364 0760',
		'Title': 'Diam At Ltd',
		'Email': '*****@*****.**'
	}
]";

            jsonDataSource.Source = json;
            Debug.WriteLine(jsonDataSource);
        }
Beispiel #7
0
 public GenericListDataPage(string dataSource)
 {
     DataSource = new JsonDataSource()
     {
         Source = JsonSource.FromUri(new Uri(dataSource))
     };
     InitializeComponent();
 }
Beispiel #8
0
        protected JsonDataSource CreateDataSourceFromText()
        {
            JsonDataSource jsonDataSource = new JsonDataSource();

            jsonDataSource.JsonSource = new CustomJsonSource(jsonData);
            jsonDataSource.Fill();
            return(jsonDataSource);
        }
Beispiel #9
0
        static JsonDataSource CreateJsonDataSource(string urlString)
        {
            var jsonDataSource = new JsonDataSource();

            jsonDataSource.JsonSource = new UriJsonSource(new Uri(urlString));
            jsonDataSource.Fill();
            return(jsonDataSource);
        }
        private JsonDataSource CreateDataSourceFromFile()
        {
            var jsonDataSource = new JsonDataSource();
            //Specify the a JSON file's name
            Uri fileUri = new Uri(@"file:///../../../../customers.txt");

            jsonDataSource.JsonSource = new UriJsonSource(fileUri);
            return(jsonDataSource);
        }
        public TaskDataSource(CrmServiceClient crmServiceClient, string currentDirectory, CommandLineArgs arguments)
        {
            this.crmServiceClient = crmServiceClient;
            this.currentDirectory = currentDirectory;
            this.arguments        = arguments;
            var jsonFile = Path.Combine(currentDirectory, arguments.Json);

            this.json = SimpleJson.DeserializeObject <Json>(File.ReadAllText(jsonFile))
                        .datasources.FirstOrDefault(x => x.profile == arguments.Profile);
        }
Beispiel #12
0
        protected virtual JsonCustomerService SetUpSystemUnderTest()
        {
            var jsonFile = new Mock <IJsonAccess>();

            jsonFile.Setup(x => x.LoadAsync())
            .ReturnsAsync(JObject.Parse(Utils.GetDatabaseSeedJson()));
            var dataSource = new JsonDataSource(jsonFile.Object);

            return(new JsonCustomerService(dataSource));
        }
Beispiel #13
0
        public static JsonDataSource CreateDataSourceFromFile()
        {
            var jsonDataSource = new JsonDataSource();
            // Specify the JSON file name.
            Uri fileUri = new Uri("customers.json", UriKind.RelativeOrAbsolute);

            jsonDataSource.JsonSource = new UriJsonSource(fileUri);
            // Populate the data source with data.
            jsonDataSource.Fill();
            return(jsonDataSource);
        }
Beispiel #14
0
    private void Awake()
    {
        dl  = ServiceLocator.Get <DataLoader>();
        dtl = ServiceLocator.Get <DataToLoad>();


        iSource  = dl.LoadedDataSources[dtl.GetLevelToLoad()];
        jSonData = iSource as JsonDataSource;

        InitializeValues();
    }
Beispiel #15
0
        public static void Do()
        {
            BsonClassMap.RegisterClassMap <ClimateEntry>().AutoMap();
            BsonClassMap.RegisterClassMap <CityDto>().AutoMap();
            var client = new MongoClient();
            var db     = client.GetDatabase("climate");
            var cities = db.GetCollection <CityDto>("cities");
            var source = new JsonDataSource();

            cities.InsertMany(source.Cities);
        }
        private JsonDataSource CreateDataSourceFromText()
        {
            var jsonDataSource = new JsonDataSource();

            //Specify a string with JSON content
            string json = "{\"Customers\":[{\"Id\":\"ALFKI\",\"CompanyName\":\"Alfreds Futterkiste\",\"ContactName\":\"Maria Anders\",\"ContactTitle\":\"Sales Representative\",\"Address\":\"Obere Str. 57\",\"City\":\"Berlin\",\"PostalCode\":\"12209\",\"Country\":\"Germany\",\"Phone\":\"030-0074321\",\"Fax\":\"030-0076545\"}],\"ResponseStatus\":{}}";

            // Specify the object that retrieves JSON data
            jsonDataSource.JsonSource = new CustomJsonSource(json);
            return(jsonDataSource);
        }
        public void JsonDataStringException()
        {
            Document doc = new Document(MyDir + "Reporting engine template - JSON data destination.docx");

            JsonDataLoadOptions options = new JsonDataLoadOptions();

            options.SimpleValueParseMode = JsonSimpleValueParseMode.Strict;

            JsonDataSource dataSource = new JsonDataSource(MyDir + "List of people.json", options);

            Assert.Throws <InvalidOperationException>(() => BuildReport(doc, dataSource, "persons"));
        }
Beispiel #18
0
        public IActionResult Login(LoginViewModel users)
        {
            IDataSource jsonData = new JsonDataSource();

            _userData               = new UserData();
            _userData.DataSource    = jsonData;
            _userData.UserViewModel = users;

            var checkLogin = _userData.CheckLoginUser();

            return(View());
        }
Beispiel #19
0
        public void TestJsonDataSourceAll()
        {
            // Setup
            var jsonDataSource = new JsonDataSource <Person>();

            // Perform
            var people = jsonDataSource.All();

            // Assertions
            Assert.NotNull(people);
            Assert.Equal(7, people.Count);
        }
Beispiel #20
0
    // Use this for initialization
    void Awake()
    {
        dl  = ServiceLocator.Get <DataLoader>();
        dtl = ServiceLocator.Get <DataToLoad>();

        iSource  = dl.LoadedDataSources[dtl.GetLevelToLoad()];
        jSonData = iSource as JsonDataSource;

        InitializeValues();

        source = GetComponent <AudioSource>();

        piecePrefabDict = new Dictionary <PieceType, GameObject>();

        for (int i = 0; i < piecePrefabs.Length; ++i)
        {
            if (!piecePrefabDict.ContainsKey(piecePrefabs[i].type))
            {
                piecePrefabDict.Add(piecePrefabs[i].type, piecePrefabs[i].prefab);
            }
        }

        for (int x = 0; x < xDim; ++x)
        {
            for (int y = 0; y < yDim; ++y)
            {
                GameObject backgroung = Instantiate(backGroundPrefab, GetWorldPosition(x, y) * 9.5f, Quaternion.identity);
                backgroung.transform.parent = transform;
            }
        }

        pieces = new GamePiece [xDim, yDim];

        for (int i = 0; i < initialPieces.Length; i++)
        {
            if (initialPieces[i].x >= 0 && initialPieces[i].x < xDim && initialPieces[i].y >= 0 && initialPieces[i].y < yDim)
            {
                SpawnNewPiece(initialPieces[i].x, initialPieces[i].y, initialPieces[i].type);
            }
        }


        for (int x = 0; x < xDim; ++x)
        {
            for (int y = 0; y < yDim; ++y)
            {
                if (pieces[x, y] == null)
                {
                    SpawnNewPiece(x, y, PieceType.EMPTY);
                }
            }
        }
    }
Beispiel #21
0
        public void TestJsonDataSourceFirstOrDefault(string key, dynamic val)
        {
            // Setup
            var jsonDataSource = new JsonDataSource <Person>();

            // Perform
            var person = jsonDataSource.FirstOrDefault(key, val);

            // Assertions
            Assert.NotNull(person);
            Assert.Equal(val, person.Id);
        }
Beispiel #22
0
        public void JsonDataString()
        {
            Document doc = new Document(MyDir + "Reporting engine template - XML data destination.docx");

            JsonDataSource dataSource = new JsonDataSource(MyDir + "List of people.json");

            BuildReport(doc, dataSource, "persons");

            doc.Save(ArtifactsDir + "ReportingEngine.JsonDataString.docx");

            Assert.IsTrue(DocumentHelper.CompareDocs(ArtifactsDir + "ReportingEngine.JsonDataString.docx",
                                                     GoldsDir + "ReportingEngine.DataSource Gold.docx"));
        }
Beispiel #23
0
        private JsonDataSource CreateDataSourceFromWeb()
        {
            var jsonDataSource = new JsonDataSource();

            //Specify the data source location
            jsonDataSource.JsonSource = new UriJsonSource(new Uri("https://srframework.vercel.app/SRFeature.json"));
            // jsonDataSource.JsonSource = new UriJsonSource(new Uri("http://northwind.servicestack.net/customers.json"));

            jsonDataSource.Fill();
            //jsonDataSource.FillAsync();
            DataJsonSource = jsonDataSource;
            return(jsonDataSource);
        }
        public void JsonDataString()
        {
            Document doc = new Document(MyDir + "ReportingEngine.DataSource.docx");

            JsonDataSource dataSource = new JsonDataSource(MyDir + "JsonData.json");

            BuildReport(doc, dataSource, "persons");

            doc.Save(ArtifactsDir + "ReportingEngine.JsonDataString.docx");

            Assert.IsTrue(DocumentHelper.CompareDocs(ArtifactsDir + "ReportingEngine.JsonDataString.docx",
                                                     GoldsDir + "ReportingEngine.DataSource Gold.docx"));
        }
Beispiel #25
0
        public void JsonDataWithNestedElements()
        {
            Document doc = new Document(MyDir + "Reporting engine template - Data destination with nested elements.docx");

            JsonDataSource dataSource = new JsonDataSource(MyDir + "Nested elements.json");

            BuildReport(doc, dataSource, "managers");

            doc.Save(ArtifactsDir + "ReportingEngine.JsonDataWithNestedElements.docx");

            Assert.IsTrue(DocumentHelper.CompareDocs(ArtifactsDir + "ReportingEngine.JsonDataWithNestedElements.docx",
                                                     GoldsDir + "ReportingEngine.DataSourceWithNestedElements Gold.docx"));
        }
Beispiel #26
0
    private void Awake()
    {
        dl  = ServiceLocator.Get <DataLoader>();
        dtl = ServiceLocator.Get <DataToLoad>();


        iSource  = dl.LoadedDataSources[dtl.GetLevelToLoad()];
        jSonData = iSource as JsonDataSource;

        InitializeValues();

        levelAS    = GetComponent <AudioSource>();
        gamePlayAS = GameObject.Find("GameplayMusic").GetComponent <AudioSource>();
    }
Beispiel #27
0
 private void Awake()
 {
     dataLoader = ServiceLocator.Get <DataLoader>();
     if (App.Instance.hasGameLoaded)
     {
         towerData = dataLoader.GetDataSourceById(dataSourceId) as JsonDataSource;
         name      = System.Convert.ToString(towerData.DataDictionary["Name"]);
     }
     audioSource  = GetComponent <AudioSource>();
     audioManager = ServiceLocator.Get <AudioManager>();
     fullHealth   = MaxHealth / 2.0f;
     InvokeRepeating("UpdateTarget", 0f, 0.1f);
     animator = GetComponent <Animator>();
 }
        public void JsonDataStream()
        {
            Document doc = new Document(MyDir + "ReportingEngine.DataSource.docx");

            using (FileStream stream = File.OpenRead(MyDir + "JsonData.json"))
            {
                JsonDataSource dataSource = new JsonDataSource(stream);
                BuildReport(doc, dataSource, "persons");
            }

            doc.Save(ArtifactsDir + "ReportingEngine.JsonDataStream.docx");

            Assert.IsTrue(DocumentHelper.CompareDocs(ArtifactsDir + "ReportingEngine.JsonDataStream.docx",
                                                     GoldsDir + "ReportingEngine.DataSource Gold.docx"));
        }
        private void CreateReportDataSourceWithAuthenticationInCodeButton_Click(object sender, EventArgs e)
        {
            // XtraReport1 does not have assigned data sources
            var report = new XtraReport1();

            // Create JsonDataSource in code
            JsonDataSource jsonDataSource = CreateReportDataSourceWithAuthenticationInCode();

            // Retrieve data to populate the Report Designer's Field List
            jsonDataSource.Fill();

            report.DataSource = jsonDataSource;
            report.DataMember = "Customers";

            new DevExpress.XtraReports.UI.ReportDesignTool(report).ShowDesigner();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string apiUrl = WebConfigurationManager.AppSettings["api_url"];
            // string df = Request.QueryString["from"];
            // string dt = Request.QueryString["to"];
            string df   = "20190101";
            string dt   = "20200503";
            int    d    = Convert.ToInt32(Request.QueryString["d"]);
            string type = Request.QueryString["type"];

            if (string.IsNullOrEmpty(type))
            {
                type = "easafcl16";
            }
            string prms           = Request.QueryString["prms"];
            int    reportId       = -1;
            int    airlineId      = -1;
            int    flightStatusId = -1;
            int    employeeId     = 297;

            JsonDataSource dataSource = null;

            switch (type)
            {
            case "easafcl16":
                var rptEASAFCL16 = new RptFlight();
                dataSource            = new JsonDataSource();
                dataSource.JsonSource = new UriJsonSource(new Uri(apiUrl + "odata/crew/flights/app2/?id=" + employeeId + "&df=" + df + "&dt=" + dt + "&status=" + flightStatusId + "&airline=" + airlineId + "&report=" + reportId));
                dataSource.Fill();
                rptEASAFCL16.DataSource = dataSource;
                ASPxWebDocumentViewer1.OpenReport(rptEASAFCL16);
                break;

            default:
                break;
            }
            // var report = new RptTwoPageLogBook();

            // var jsonDataSource = new JsonDataSource();

            // jsonDataSource.JsonSource = new UriJsonSource(new Uri("http://fleet.flypersia.aero/api.airpocket/odata/fuel/report/?$top=2020&dt=2020-01-12T00:00:00&df=2020-01-12T00:00:00&%24orderby=STDDay%2CSTDLocal&%24filter=(FlightId%20gt%200)"));

            // jsonDataSource.Fill();

            //report.DataSource = jsonDataSource;
        }
Beispiel #31
0
		public void JsonDataSourceComplex ()
		{
			var jsonDataSource = new JsonDataSource ();

			var json = @"[
	{
		'Name': 'Kristen Perez',
		'Address': 'Ap #325-3386 Ac Av.',
		'Phone': '(016977) 7108',
		'Title': 'Lorem Ipsum Dolor Incorporated',
		'Email': '*****@*****.**',
		'List' : [
          'Foo', 'Bar', 'Baz'
        ]
	},
	{
		'Name': 'Murphy Cote',
		'Address': '906-6938 Porttitor Ave',
		'Phone': '076 9223 8954',
		'Title': 'Vulputate Industries',
		'Email': '*****@*****.**',
        'List' : [ { 'Second' : 'Thing' } ]
	},
	{
		'Name': 'Nicole Valdez',
		'Address': '485-9530 Ut Rd.',
		'Phone': '0800 364 0760',
		'Title': 'Diam At Ltd',
		'Email': '*****@*****.**'
	}
]";
			jsonDataSource.Source = json;
			Debug.WriteLine (jsonDataSource);
		}