public void AddSyncData(string id, SyncData syncData)
 {
     if (ContainsScreen(id))
     {
         var data = _syncInfoTable[id].SyncDatas.Find(s => s.SyncType == syncData.SyncType);
         if (data == null)
         {
             _syncInfoTable[id].SyncDatas.Add(syncData);
         }
         else
         {
             _logService.Debug(string.Format("<-{0}->:ThreadID={1}", "AddSyncData", System.Threading.Thread.GetDomainID().ToString()));
             UpdateSyncData(id, syncData);
         }
     }
     else
     {
         var syncInformation = new SyncInformation();
         syncInformation.Sn = id;
         syncInformation.SyncDatas = new List<SyncData>() { syncData };
         _syncInfoTable.Add(id, syncInformation);
     }
 }
Ejemplo n.º 2
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);
             }
         }
     }
 }
 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);
     }
 }
 public void UpdateSyncData(string sn, SyncData syncData)
 {
     _logService.Debug(string.Format("<-{0}->:ThreadID={1}", "UpdateSyncData", System.Threading.Thread.GetDomainID().ToString()));
     _syncInformationManager.UpdateSyncData(GetScreenId(AppDataConfig.CurrentMAC, sn), syncData);
 }
        public bool UpdateSyncData(string id, SyncData syncData)
        {
            _logService.Debug(string.Format("<-{0}->:ThreadID={1}", "UpdateSyncData", System.Threading.Thread.GetDomainID().ToString()));
            if (ContainsScreen(id))
            {
                SyncData configSyncData = null;
                try
                {
                    configSyncData = _syncInfoTable[id].SyncDatas.FirstOrDefault(d => d.SyncType == syncData.SyncType);
                }
                catch (Exception ex)
                {
                    _logService.Error(string.Format("ExistCatch:<-{0}->:{1},\nThreadID={2}", "UpdateSyncData", "_syncInfoTable[id].SyncDatas.FirstOrDefault error,info:" + ex.ToString(), System.Threading.Thread.GetDomainID().ToString()));
                    return false;
                }
                if (configSyncData == null)
                {
                    _logService.Error(string.Format("<-{0}->:{1}", "UpdateSyncData", "无指定的更新项."));
                    return false;
                }

                _syncInfoTable[id].SyncDatas.Remove(configSyncData);
                _syncInfoTable[id].SyncDatas.Add(syncData);
                return true;
            }
            else
            {
                _logService.Error(string.Format("<-{0}->:{1}", "UpdateSyncData", "无指定的更新项."));
                return false;
            }
        }
 public void RemoveSyncData(string id, SyncData syncData)
 {
     if (ContainsScreen(id))
     {
         _syncInfoTable[id].SyncDatas.Remove(syncData);
     }
 }