服务端的TigerApi 框架,基于.NET6 2024 版本
Rodney Chen
6 天以前 756e6c531d49a4565e47949120cb33bae431566e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Tiger.Business.MESTests
{
    [TestClass()]
    public class MesTests
    {
        [TestMethod()]
        public void CommonTest()
        {
            var dic = new Dictionary<string, string>();
            dic.Add("1", "11");
            dic.Add("2", "222");
            var dicStr = dic.ToJson();
 
            var ai = new ActiveInfo() { ExpiryDate = DateTime.Now };
            var aiStr = ai.ToJson();
 
            var date = new DateTime(2021,1,2);
            
            var firstDay = new DateTime(date.Year, 1, 1);
            int daysOffset = firstDay.DayOfWeek.GetValue() > 3 ? (firstDay.DayOfWeek.GetValue() - 7) : 0;
            int year = date.Year + ((date - firstDay).TotalDays + daysOffset < 0 ? -1 : 0);
            int week = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Sunday);
            var str = $"{year.ToString().Substring(2, 2)}{week:00}";
            ;
        }
 
        public class ActiveInfo
        {
            public string Mac { get; set; }
            public DateTime? ExpiryDate { get; set; }
        }
    }
}