CrabtreeOn,印度客户定制APP,迁移2.0平台版本
JLChen
2021-02-24 50b7b7a486f56fab27c83b59eb45673c6d9f0935
Crabtree/SmartHome/HDL/Common/HDLLinkScene.cs
@@ -3,17 +3,20 @@
namespace Shared
{
    #region ■ 场景列表相关___________________________
    #endregion
    /// <summary>
    /// 
    /// </summary>
    public class HDLLinkScene
    public class HDLLinkSceneBase
    {
        /// <summary>
        /// 场景sid
        /// </summary>
        public string userSceneId;
        /// <summary>
        /// 场景sid
        /// </summary>
@@ -51,6 +54,23 @@
        /// </summary>
        public bool collect = false;
        /// <summary>
        /// 修改时间
        /// </summary>
        public string modifyTime;
        /// <summary>
        /// 创建时间
        /// </summary>
        public string createTime;
    }
    /// <summary>
    ///
    /// </summary>
    public class HDLLinkScene: HDLLinkSceneBase
    {
        /// <summary>
        /// 场景功能列表
        /// </summary>
        public List<SceneFunction> functions = new List<SceneFunction> ();
@@ -59,56 +79,7 @@
        /// </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;
        }
    }