public void Test_Holiday_Update_From_Url()
        {
            string url = "http://data.ntpc.gov.tw/api/v1/rest/datastore/382000000A-000077-002";

            ISourceGraber <SourceHoliday> sourceGraber = new HttpSourceGraber <SourceHoliday>(url);
            IUnitOfWork unitOfWork = EFUnitOfWorkFactory.GetUnitOfWork <HolidayEntities>();

            IGenericDataAccess <TWHoliday> dataAccess = new GenericDataAccess <TWHoliday>(unitOfWork);
            HolidayMaintainer maintanier = new HolidayMaintainer(sourceGraber, dataAccess);
            var source = maintanier.AddHolidayFromSource();

            Assert.AreEqual(true, source);
        }
        public void Test_Holiday_Update_From_File()
        {
            string filePath = Path.Combine(Directory.GetCurrentDirectory(), @"Source/Holiday.json");

            ISourceGraber <SourceHoliday> sourceGraber = new FileSourceGraber <SourceHoliday>(filePath);

            IUnitOfWork unitOfWork = EFUnitOfWorkFactory.GetUnitOfWork <HolidayEntities>();

            IGenericDataAccess <TWHoliday> dataAccess = new GenericDataAccess <TWHoliday>(unitOfWork);
            HolidayMaintainer maintanier = new HolidayMaintainer(sourceGraber, dataAccess);
            var source = maintanier.AddHolidayFromSource();

            Assert.AreEqual(true, source);
        }
Esempio n. 3
0
        public IHttpActionResult CheckDateIsHoliday([FromBody] DateModel value)
        {
            DateTime    time       = value.Time;
            IUnitOfWork unitOfWork = EFUnitOfWorkFactory.GetUnitOfWork <HolidayEntities>();

            IGenericDataAccess <TWHoliday> dataAccess = new GenericDataAccess <TWHoliday>(unitOfWork);
            HolidayMaintainer maintanier = new HolidayMaintainer(dataAccess);
            bool result = maintanier.CheckDateIsHoliday(time);
            var  resp   = new RespModel()
            {
                IsHoliday = result
            };

            return(Json(resp));
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start update holiday");

            string filePath = Path.Combine(Directory.GetCurrentDirectory(), @"Source/Holiday.json");

            ISourceGraber <SourceHoliday> sourceGraber = new FileSourceGraber <SourceHoliday>(filePath);

            IUnitOfWork unitOfWork = EFUnitOfWorkFactory.GetUnitOfWork <HolidayEntities>();

            IGenericDataAccess <TWHoliday> dataAccess = new GenericDataAccess <TWHoliday>(unitOfWork);
            HolidayMaintainer maintanier = new HolidayMaintainer(sourceGraber, dataAccess);
            var source = maintanier.AddHolidayFromSource();

            if (source)
            {
                Console.WriteLine("Update Holiday success");
            }

            Console.WriteLine("Update Holiday fail");
        }