Beispiel #1
0
        public IActionResult About()
        {
            List <holidayModel> holidays = new List <holidayModel>();
            var request = (HttpWebRequest)WebRequest.Create("https://holidayapi.com/v1/holidays?pretty&key=bb4b77e1-0cc2-47d9-872e-483b2449ba44&country=DE&year=2020");

            request.Method = "GET";
            using (var response = (HttpWebResponse)request.GetResponse())
            {
                using (var stream = response.GetResponseStream())
                {
                    using (var sr = new StreamReader(stream))
                    {
                        var content = sr.ReadToEnd();

                        dynamic holidayInfo = JsonConvert.DeserializeObject(content);
                        var     holidayName = holidayInfo.holidays[0].name;

                        foreach (var holiday in holidayInfo.holidays)
                        {
                            holidayModel hm = new holidayModel();
                            hm.Name     = holiday.name;
                            hm.Date     = holiday.date;
                            hm.Observed = holiday.observed;
                            // hm.Weekday = holiday.weekday.date.name;
                            holidays.Add(hm);
                        }
                    }
                }
            }
            ViewBag.h = holidays;
            return(View());
        }
Beispiel #2
0
        public holidayMasterModel master(holidayModel value)
        {
            holidayMasterModel result = new holidayMasterModel();

            try
            {
                using (var context = new StandardCanEntities())
                {
                    if (String.IsNullOrEmpty(value.user_id))
                    {
                        throw new Exception("Unauthorized Access");
                    }
                    var userId = JwtHelper.GetUserIdFromToken(value.user_id);
                    if (String.IsNullOrEmpty(userId))
                    {
                        throw new Exception("Unauthorized Access");
                    }

                    string sql = "select		convert(nvarchar(4), year(mhd_date)) code ";
                    sql        += " , convert(nvarchar(4), year(mhd_date)) [text] ";
                    sql        += " from MAS_HOLIDAY ";
                    sql        += " group by    year(mhd_date) ";
                    sql        += " order by    year(mhd_date) ";
                    result.year = context.Database.SqlQuery <dropdown>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(result);
        }
        // POST api/<controller>
        public HttpResponseMessage Post([FromBody] holidayModel value)
        {
            if (value == null)
            {
                return(null);
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            holidayService      service  = new holidayService();
            HttpResponseMessage response = null;
            Object result = null;

            switch (value.method)
            {
            case "master":
                result = service.master(value);
                break;

            case "search":
                result = service.search(value);
                break;

            case "calendarHoliday":
                result = service.calendarHoliday(value);
                break;

            case "getHoliday":
                result = service.getHoliday(value);
                break;

            case "getSchedule":
                result = service.getSchedule(value);
                break;

            default:
                break;
            }


            string json = js.Serialize(result);

            response         = Request.CreateResponse(HttpStatusCode.OK);
            response.Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
            return(response);
        }
Beispiel #4
0
 public IEnumerable <sp_mb_get_holiday_Result> getHoliday(holidayModel value)
 {
     try
     {
         //if (String.IsNullOrEmpty(value.user_id))
         //{
         //    throw new Exception("Unauthorized Access");
         //}
         //var userId = JwtHelper.GetUserIdFromToken(value.user_id);
         //if (String.IsNullOrEmpty(userId))
         //{
         //    throw new Exception("Unauthorized Access");
         //}
         StandardCanEntities context = new StandardCanEntities();
         IEnumerable <sp_mb_get_holiday_Result> result = context.sp_mb_get_holiday().AsEnumerable();
         return(result);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Beispiel #5
0
 public IEnumerable <sp_holiday_search_Result> search(holidayModel value)
 {
     try
     {
         if (String.IsNullOrEmpty(value.user_id))
         {
             throw new Exception("Unauthorized Access");
         }
         var userId = JwtHelper.GetUserIdFromToken(value.user_id);
         if (String.IsNullOrEmpty(userId))
         {
             throw new Exception("Unauthorized Access");
         }
         StandardCanEntities context = new StandardCanEntities();
         IEnumerable <sp_holiday_search_Result> result = context.sp_holiday_search(value.year).AsEnumerable();
         return(result);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Beispiel #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string url = string.Format("https://fangjia.51240.com/{0}__fangjia/", DateTime.Now.Year);

            timerGetYearHoliday.Enabled = true;
            HtmlNodeCollection aa = GetHtmlNode(url, "//table");

            if (aa != null)
            {
                List <holidayModel> mylist  = new List <holidayModel>();
                holidayModel        mymodel = null;
                Regex           regex       = new Regex(@"<td>((\w|[、()()~])*)</td>", RegexOptions.IgnoreCase);
                MatchCollection matchlist   = regex.Matches(aa[0].InnerHtml);
                for (int i = 0; i < matchlist.Count; i += 3)
                {
                    mymodel      = new holidayModel();
                    mymodel.休息   = matchlist[i].Groups[1].Value;
                    mymodel.调休   = matchlist[i + 1].Groups[1].Value;
                    mymodel.放假天数 = matchlist[i + 2].Groups[1].Value;
                    mylist.Add(mymodel);
                }
                dataGridView1.DataSource = mylist;
            }
        }