| | |
| | | public static long ConvertDateTimeLong () |
| | | { |
| | | System.DateTime startTime = TimeZoneInfo.ConvertTimeToUtc (new System.DateTime (2020, 1, 1)); |
| | | long l = (long)(Math.Round ((DateTime.Now - startTime).TotalSeconds, 1) * 10); |
| | | long l = (long)(Math.Round ((DateTime.Now - startTime).TotalMilliseconds, 1) / 10); |
| | | if (l <= LastTime) l = LastTime + 1; |
| | | LastTime = l; |
| | | return l; |
| | |
| | | hdlLinkSceneList.Add (mHDLLinkScene); |
| | | } |
| | | } |
| | | //2.上传场景 |
| | | //2.1不存在,需要新上传的 |
| | | |
| | | //全量同步场景 |
| | | res = UploadSceneList (hdlLinkSceneList); |
| | | //2.2已存在,需要更新的 |
| | | //if (res) { |
| | | // var updateLinkSceneList = new List<HDLLinkScene> (); |
| | | // res = UploadSceneList (updateLinkSceneList); |
| | | //} |
| | | |
| | | |
| | | } catch (Exception ex){ |
| | | Utlis.WriteLine ("catch :" + ex.ToString ()); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// 全量同步场景 |
| | | /// </summary> |
| | | /// <param name="mScene"></param> |
| | | bool UploadSceneList (List<HDLLinkScene> hdlLinkSceneList) |
| | | { |
| | | var res = false; |
| | | try { |
| | | var revertObj = HttpServerRequest.Current.AddScene (hdlLinkSceneList); |
| | | var revertObj = HttpServerRequest.Current.SecneSyncList (hdlLinkSceneList); |
| | | if (revertObj.Code == StateCode.SUCCESS) { |
| | | res = true; |
| | | } else { |
| | |
| | | var commonNew = Newtonsoft.Json.JsonConvert.DeserializeObject<LightDimming> (jsonInfo); |
| | | var mSceneFunction = new SceneFunction (); |
| | | mSceneFunction.sid = function.sid; |
| | | //1.Brightness |
| | | //1.on_off |
| | | var status = new List<SceneFunctionStatus> (); |
| | | status.Add (new SceneFunctionStatus () { |
| | | key = FunctionAttributeKey.OnOff, |
| | | value = commonNew.CurrentBrightness > 0 ? "on" : "off", |
| | | }); |
| | | //2.Brightness |
| | | status.Add (new SceneFunctionStatus () { |
| | | key = FunctionAttributeKey.Brightness, |
| | | value = commonNew.CurrentBrightness.ToString(), |
| | | }); |
| | | //2.Delay |
| | | //3.Delay |
| | | status.Add (new SceneFunctionStatus () { |
| | | key = FunctionAttributeKey.Delay, |
| | | value = (commonNew.DelayTimeHeight * 256 + commonNew.DelayTimeLow).ToString (), |
| | |
| | | var commonNew = Newtonsoft.Json.JsonConvert.DeserializeObject<LightLogic> (jsonInfo); |
| | | var mSceneFunction = new SceneFunction (); |
| | | mSceneFunction.sid = function.sid; |
| | | //1.Brightness |
| | | //1.on_off |
| | | var status = new List<SceneFunctionStatus> (); |
| | | status.Add (new SceneFunctionStatus () { |
| | | key = FunctionAttributeKey.OnOff, |
| | | value = commonNew.CurrentBrightness > 0 ? "on" : "off", |
| | | }); |
| | | //2.Brightness |
| | | status.Add (new SceneFunctionStatus () { |
| | | key = FunctionAttributeKey.Brightness, |
| | | value = commonNew.CurrentBrightness.ToString (), |
| | | }); |
| | | //2.Delay |
| | | //3.Delay |
| | | status.Add (new SceneFunctionStatus () { |
| | | key = FunctionAttributeKey.Delay, |
| | | value = (commonNew.DelayTimeHeigh * 256 + commonNew.DelayTimeLow).ToString (), |
| | | }); |
| | | |
| | | //3.rgb |
| | | //4.rgb |
| | | status.Add (new SceneFunctionStatus () { |
| | | key = FunctionAttributeKey.RGB, |
| | | value = commonNew.RStatus + "," + commonNew.GStatus + "," + commonNew.BStatus, |
| | |
| | | var commonNew = Newtonsoft.Json.JsonConvert.DeserializeObject<LightSwitch> (jsonInfo); |
| | | var mSceneFunction = new SceneFunction (); |
| | | mSceneFunction.sid = function.sid; |
| | | //1.Brightness |
| | | //1.OnOff |
| | | var status = new List<SceneFunctionStatus> (); |
| | | status.Add (new SceneFunctionStatus () { |
| | | key = FunctionAttributeKey.OnOff, |
| | |
| | | |
| | | functionLists.AddRange (ConvertToSidListToIotCloud (tmpOid.oid, tmp)); |
| | | |
| | | Utlis.WriteLine ("新的模块,新的的OID:" + tmpOid.addresses + " deviceType:" + tmpOid.deviceType); |
| | | //Utlis.WriteLine ("新的模块,新的的OID:" + tmpOid.addresses + " deviceType:" + tmpOid.deviceType); |
| | | } else { |
| | | //3.2存在则取之前的oid |
| | | functionLists.AddRange (ConvertToSidListToIotCloud (deviceOid.oid, tmp)); |
| | | Utlis.WriteLine ("相同的模块,取之前的OID:" + deviceOid.addresses + " deviceType:" + deviceOid.deviceType); |
| | | //Utlis.WriteLine ("相同的模块,取之前的OID:" + deviceOid.addresses + " deviceType:" + deviceOid.deviceType); |
| | | } |
| | | |
| | | } |