CrabtreeOn,印度客户定制APP,迁移2.0平台版本
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using System;
using System.Collections.Generic;
 
namespace Shared
{
 
 
    #region ■ 场景列表相关___________________________
 
    #endregion
 
    /// <summary>
    /// 
    /// </summary>
    public class HDLLinkScene
    {
        /// <summary>
        /// 场景sid
        /// </summary>
        public string sid = "";
        /// <summary>
        /// 场景名称
        /// </summary>
        public string name = "";
        /// <summary>
        /// 网关ID
        /// </summary>
        public string gatewayId = "";
        /// <summary>
        /// 云端oss存储图片的路径
        /// </summary>
        public string image = "";
        /// <summary>
        /// 所属房间列表
        /// </summary>
        public List<string> roomIds = new List<string> ();
        /// <summary>
        /// 延时
        /// </summary>
        public string delay = "0";
        /// <summary>
        /// 场景分组
        /// </summary>
        public string group = "1";
        /// <summary>
        /// 场景类型
        /// </summary>
        public SceneType sceneType = SceneType.OrdinaryScenes;
        /// <summary>
        /// 收藏标记
        /// </summary>
        public bool collect = false;
        /// <summary>
        /// 场景功能列表
        /// </summary>
        public List<SceneFunction> functions = new List<SceneFunction> ();
        /// <summary>
        /// 场景推送配置列表
        /// </summary>
        public List<ScenePushConfig> pushConfigs = new List<ScenePushConfig> ();
 
        /// <summary>
        /// 生成逻辑sid方法
        /// </summary>
        public string NewSid ()
        {
            string sceneId = "";
            try {
                string sOidBeginsWith = "000101";//厂商 + 通讯方式
                DateTime dt = DateTime.Now;
                DateTime startTime = TimeZoneInfo.ConvertTimeToUtc (new DateTime (2020, 1, 1));
                long m = (long)((dt - startTime).TotalMilliseconds / 10);
                string sTimeSpan = "00000000";
 
                byte [] arry = new byte [4];
                arry [0] = (byte)(m & 0xFF);
                arry [1] = (byte)((m & 0xFF00) >> 8);
                arry [2] = (byte)((m & 0xFF0000) >> 16);
                arry [3] = (byte)((m >> 24) & 0xFF);
                sTimeSpan = arry [0].ToString ("X2") + arry [1].ToString ("X2") + arry [2].ToString ("X2") + arry [3].ToString ("X2");
 
 
                if (sTimeSpan.Length > 8) {
                    sTimeSpan = sTimeSpan.Substring (0, 8);
                } else {
                    sTimeSpan = "00000000";
                }
 
                sceneId = sOidBeginsWith + sTimeSpan;
 
                sceneId += "0A";
                sceneId += "0A01";
                int maxId = 1;
 
                Random random = new Random (Guid.NewGuid ().GetHashCode ());
                maxId = random.Next (1000);
 
                //for (int i = 0; i < FunctionList.List.scenes.Count; i++) {
                //    string s = FunctionList.List.scenes [i].sid.Substring (20, 4);
                //    int iThisSceneId = Convert.ToInt16 (s, 16);
                //    if (iThisSceneId > maxId)
                //        maxId = iThisSceneId;
                //}
 
                sceneId += (maxId + 1).ToString ("X4");
                sceneId += "0000";
            } catch {
                return sceneId;
            }
            return sceneId;
        }
    }
 
 
    /// <summary>
    /// 场景功能对象
    /// </summary>
    public class SceneFunction
    {
        public string sid = "";
 
        public List<SceneFunctionStatus> status = new List<SceneFunctionStatus> ();
        /// <summary>
        /// 功能延时
        /// </summary>
        public string delay = "0";
 
        //Function _localFunction;
        ///// <summary>
        ///// 本地对应的功能
        ///// </summary>
        //[Newtonsoft.Json.JsonIgnore]
        //public Function localFunction {
        //    get {
        //        if (_localFunction == null) {
        //            _localFunction = ConvertFunctionObject ();
        //        }
        //        return _localFunction;
        //    }
        //}
 
        ///// <summary>
        ///// 转换成功能对象
        ///// </summary>
        ///// <returns></returns>
        //Function ConvertFunctionObject ()
        //{
        //    var localFunction = FunctionList.List.GetDeviceFunctionList ().Find ((obj) => obj.sid == sid);
        //    return localFunction;
        //}
 
    }
 
    /// <summary>
    /// 场景功能属性
    /// </summary>
    public class SceneFunctionStatus
    {
        public string key = "";
        public string value = "";
    }
    /// <summary>
    /// 场景推送配置
    /// </summary>
    public class ScenePushConfig
    {
        /// <summary>
        /// 推送方式
        /// </summary>
        public string pushMethod = "";
        /// <summary>
        /// 推送内容
        /// </summary>
        public string pushContent = "";
        /// <summary>
        /// 推送目标集合
        /// </summary>
        public List<string> pushTarget = new List<string> ();
    }
}