コード例 #1
0
 private void UpdateLedConfigSyncCollection()
 {
     //if (string.IsNullOrEmpty(AppDataConfig.CurrentMAC))
     //{
     //    return;
     //}
     for (int screenIndex = 0; screenIndex < LedList.Count; screenIndex++)
     {
         string id = GetScreenId(AppDataConfig.CurrentMAC, LedList[screenIndex].SerialNumber);
         if (_syncInformationManager.ContainsScreen(id))
         {
             continue;
         }
         else
         {
             foreach (int type in Enum.GetValues(typeof(SyncType)))
             {
                 var summary = new SyncSummary();
                 summary.SyncMark = "-1";
                 summary.Type = (SyncType)Enum.Parse(typeof(SyncType), type.ToString());
                 var syncData = new SyncData()
                 {
                     SyncType = (SyncType)Enum.Parse(typeof(SyncType), type.ToString()),
                     SyncParam = SyncFlag.Synchronized,
                     SyncContent = string.Empty,
                     Datestamp = "-1"
                 };
                 _syncInformationManager.AddSyncData(id, syncData);
             }
         }
     }
 }
コード例 #2
0
        public void HeartbeatWithCareServer(object obj)
        {
            if (LedList == null)
                return;
            List<Led> ledList = new List<Led>();
            lock (LedList)
            {
                ledList = LedList.Select(t => (Led)t.Clone()).ToList();
            }
            isBlocked = 0;

            UpdateLedConfigSyncData();

            foreach (var led in ledList)
            {
                HeartbeatRequest request;
                string id = GetScreenId(AppDataConfig.CurrentMAC, led.SerialNumber);

                if (_syncInformationManager.ContainsScreen(id))
                {
                    var syncInfos = new List<SyncSummary>();
                    var currentSyncInformation = _syncInformationManager.GetSyncInformation(id);
                    foreach (var syncData in currentSyncInformation.SyncDatas)
                    {
                        var info = new SyncSummary();
                        info.SyncMark = syncData.Datestamp;
                        info.Type = syncData.SyncType;
                        syncInfos.Add(info);
                    }
                    request = new HeartbeatRequest()
                    {
                        Identifier = id,
                        SystemVersion = AppDataConfig.CurrentMonitorVersion,
                        Timestamp = SystemHelper.GetUtcTicksByDateTime(DateTime.Now).ToString(),
                        SyncInfos = syncInfos
                    };
                }
                else
                {
                    var syncInfos = new List<SyncSummary>();
                    foreach (int type in Enum.GetValues(typeof(SyncType)))
                    {
                        var info = new SyncSummary();
                        info.SyncMark = "-1";
                        info.Type = (SyncType)Enum.Parse(typeof(SyncType), type.ToString());
                        syncInfos.Add(info);
                        _syncInformationManager.AddSyncData(id, new SyncData() { SyncType = info.Type, SyncParam = SyncFlag.Synchronized, SyncContent = string.Empty, Datestamp = "-1" });
                    }
                    request = new HeartbeatRequest()
                    {
                        Identifier = id,
                        SystemVersion = AppDataConfig.CurrentMonitorVersion,
                        Timestamp = SystemHelper.GetUtcTicksByDateTime(DateTime.Now).ToString(),
                        SyncInfos = syncInfos
                    };
                }

                RestFulClient.Instance.Post("api/index/heartbeat", request, response =>
                {
                    HeartbeatResponse(response);
                });
            }
        }
コード例 #3
0
 public void InitializeSyncDataBy(string id)
 {
     foreach (int type in Enum.GetValues(typeof(SyncType)))
     {
         var summary = new SyncSummary();
         summary.SyncMark = "-1";
         summary.Type = (SyncType)Enum.Parse(typeof(SyncType), type.ToString());
         var syncData = new SyncData()
         {
             SyncType = (SyncType)Enum.Parse(typeof(SyncType), type.ToString()),
             SyncParam = SyncFlag.Synchronized,
             SyncContent = string.Empty,
             Datestamp = "-1"
         };
         AddSyncData(id, syncData);
     }
 }