Example #1
0
        public void GetMarketTest()
        {
            OpenDataService service = new OpenDataService();
            var             result  = service.GetMarket(1, 10);

            Assert.IsTrue(result.JObjCodeTrue());
            var jresult = JsonConvert.DeserializeObject(result);
        }
Example #2
0
        public void GetCommunityNotitceTitles_Test()
        {
            OpenDataService service = new OpenDataService();
            var             result  = service.GetCommunityNoticeByPage("汪弄社区", 2, 20);

            //var introduction = JsonConvert.DeserializeObject(result);
            Assert.IsTrue(result.JObjCodeTrue());
        }
Example #3
0
        public void GetBikeLocationCountTest()
        {
            OpenDataService service = new OpenDataService();
            var             result  = service.GetBikeLocationCount();

            Assert.IsTrue(result.JObjCodeTrue());
            Assert.AreNotEqual(result.JobjMessageConvert <int>(), 0);
        }
Example #4
0
        public void GetCommunityFCCount_Test()
        {
            OpenDataService service = new OpenDataService();
            var             result  = service.GetCommunityFCCount("联南社区");

            //var introduction = JsonConvert.DeserializeObject(result);
            Assert.IsTrue(result.JObjCodeTrue());
        }
Example #5
0
        public List <OpenProductionUnitViewModel> GetById(int Id)
        {
            var db = new ApplicationDbContext();
            var openDataService = new OpenDataService(db);

            var one = openDataService.One(Id);

            return(one.ToList());
        }
Example #6
0
        public List <OpenMeasureViewModel> GetMeasures(int Id)
        {
            var db = new ApplicationDbContext();
            var openDataService = new OpenDataService(db);

            var measures = openDataService.GetMeasures(Id);

            return(measures.ToList());
        }
Example #7
0
        public List <SecureProductionUnitViewModel> GetByUser(string User)
        {
            var db = new ApplicationDbContext();
            var openDataService = new OpenDataService(db);

            var byUser = openDataService.GetByUser(User);

            return(byUser.ToList());
        }
Example #8
0
        public List <OpenProductionUnitViewModel> GetAll()
        {
            var db = new ApplicationDbContext();
            var openDataService = new OpenDataService(db);

            var all = openDataService.GetAll();

            return(all.ToList());
        }
Example #9
0
        public void GetCommunityIntroduction_Test()
        {
            OpenDataService service = new OpenDataService();
            var             result  = service.GetCommunityIntroduction("华兴社区");
            //var introduction = JsonConvert.DeserializeObject(result);
            var jobj = JObject.Parse(result);

            Assert.AreEqual(jobj["Code"], 1);
            if ((int)jobj["Code"] == 1)
            {
                var msg      = jobj["Message"];
                var telbook1 = msg["TelBook"].Value <string>();
            }
        }
        public async Task LoadData(string keyword = null)
        {
            OpenDataService openDataService = new OpenDataService();
            var             content         = await openDataService.Get();

            OpenDataItems.Clear();
            foreach (var item in content)
            {
                if (string.IsNullOrEmpty(keyword) == false)
                {
                    if (item.連絡電話?.Contains(keyword) == false)
                    {
                        continue;
                    }
                }
                OpenDataItems.Add(item);
            }
        }
Example #11
0
        static void Main(string[] args)
        {
            string domain = "";
            string category = "";
            string type = "";
            string filename = "catalog.csv";
            OpenDataService odServices = new OpenDataService();

            foreach (string arg in args)
            {
                if (arg == "-h")
                {
                    Console.WriteLine(
                        "SoCat: Get Socrata Catalog - Help\n" +
                        "---------------------------------\n\n" +
                        "Proper usage:\n\n" +
                        "socat [-d:domain] [-c:category] [-t:type] [-f:filename]\n\n" +
                        "Ex. socat -d:data.ny.gov -c:transportation -t:map -f:myfile.csv\n\n" +
                        "domain: either data.ny.gov or health.data.ny.gov\n" +
                        "category: valid category (education, health, transportation, etc.)\n" +
                        "type: valid type (tabular, map, chart, etc.)\n" +
                        "filename: valid output path and filename ending with .csv\n\n" +
                        "Notes:\n" +
                        "- If the category or type contains more than one word, enclose it in \"\",\n" +
                        "  like this: socat -c:\"energy & environment\"\n" +
                        "- If you don't specify a filename, output will be written to catalog.csv in\n" +
                        "  the same location as this program.");
                    return;
                }
                if (arg.StartsWith("-d:") && arg.Length > 3)
                {
                    domain = arg.Substring(3).Trim();
                }
                else if (arg.StartsWith("-c:") && arg.Length > 3)
                {
                    category = arg.Substring(3).Trim();
                }
                else if (arg.StartsWith("-t:") && arg.Length > 3)
                {
                    type = arg.Substring(3).Trim();
                }
                else if (arg.StartsWith("-f:") && arg.Length > 3)
                {
                    filename = arg.Substring(3).Trim();
                }
                else
                {
                    Console.WriteLine("Invalid arguments.  Type \"socat -h\" for help.");
                    return;
                }
            }

            Console.WriteLine(
                "SoCat: Get Socrata Catalog\n" +
                "--------------------------\n\n" +
                "Domain: {0}\n" +
                "Category: {1}\n" +
                "Type: {2}\n\n" +
                "Getting catalog...please wait.\n",
                (domain == "" ? "Not specified" : domain),
                (category == "" ? "Not specified" : category),
                (type == "" ? "Not specified" : type));

            var catalog = odServices.getCatalog();

            if (domain != "")
            {
                catalog = catalog.Where(p => String.Equals(p.Domain, domain,
                    StringComparison.OrdinalIgnoreCase)).ToList<CatalogItem>();
            }

            if (category != "")
            {
                catalog = catalog.Where(p => String.Equals(p.Category, category,
                    StringComparison.OrdinalIgnoreCase)).ToList<CatalogItem>();
            }

            if (type != "")
            {
                catalog = catalog.Where(p => String.Equals(p.Type, type,
                    StringComparison.OrdinalIgnoreCase)).ToList<CatalogItem>();
            }

            try
            {
                using (CsvFileWriter writer = new CsvFileWriter(filename))
                {
                    CsvRow row = new CsvRow();
                    row.Add("Id");
                    row.Add("Name");
                    row.Add("Type");
                    row.Add("Description");
                    row.Add("URL");
                    row.Add("Category");
                    row.Add("Keywords");
                    row.Add("Agency");
                    row.Add("Contact Information");
                    row.Add("Time Period");
                    row.Add("Coverage");
                    row.Add("Posting Frequency");
                    row.Add("Created At");
                    row.Add("Updated At");
                    row.Add("Domain");
                    row.Add("View Count");
                    row.Add("Download Count");
                    row.Add("Row Count");
                    row.Add("Rows Updated At");
                    writer.WriteRow(row);

                    foreach (var item in catalog)
                    {
                        row = new CsvRow();
                        row.Add(String.Format("{0}", item.Id));
                        row.Add(String.Format("{0}", item.Name));
                        row.Add(String.Format("{0}", item.Type));
                        row.Add(String.Format("{0}", item.Description));
                        row.Add(String.Format("{0}", item.Url));
                        row.Add(String.Format("{0}", item.Category));
                        row.Add(String.Format("{0}", item.Keywords));
                        row.Add(String.Format("{0}", item.Agency));
                        row.Add(String.Format("{0}", item.ContactInformation));
                        row.Add(String.Format("{0}", item.TimePeriod));
                        row.Add(String.Format("{0}", item.Coverage));
                        row.Add(String.Format("{0}", item.PostingFrequency));
                        row.Add(String.Format("{0:MM/dd/yyyy HH:mm:ss}", item.CreatedAt));
                        row.Add(String.Format("{0:MM/dd/yyyy HH:mm:ss}", item.UpdatedAt));
                        row.Add(String.Format("{0}", item.Domain));
                        row.Add(String.Format("{0}", item.ViewCount));
                        row.Add(String.Format("{0}", item.DownloadCount));
                        // Get row count and rows last updated for Tabular items only
                        if (item.Type == "Tabular")
                        {
                            row.Add(String.Format("{0}", item.RowCount));
                            row.Add(String.Format("{0:MM/dd/yyyy HH:mm:ss}", item.RowsUpdatedAt));
                        }
                        else
                        {
                            row.Add("");
                            row.Add("");
                        }
                        writer.WriteRow(row);
                    }
                }

                Console.WriteLine("\n{0} catalog items written to {1}\n", catalog.Count, filename);
            }
            catch (UnauthorizedAccessException e)
            {
                Console.WriteLine("Cannot write to: " + filename);
            }
        }
 protected override void Initialize(System.Web.Routing.RequestContext requestContext)
 {
     base.Initialize(requestContext);
     _OpenDataService   = new OpenDataService(LanguageRequest, User);
     _MWQMSampleService = new MWQMSampleService(LanguageRequest, User);
 }