private void SplitCollection() { if (ChangeTracker.LiveMonitors.Count <= 0) { return; } SyncList <IMatchVw> lMatches = Matches.ToSyncList(); int iMatchIdx = 0; int page = -1; for (int i = 0; i < LiveMonitorsCollectionList.Count; i++) { if (lmViewModels[i].rotating || lmViewModels[i].LiveOddsVisibility == Visibility.Collapsed) { continue; } LiveMonitorViewModel lmvm = null; Dispatcher.Invoke(() => { lmvm = ChangeTracker.LiveMonitors[i].Window.DataContext as LiveMonitorViewModel; }); Debug.Assert(lmvm != null); double dblItemHeight = lmvm != null && lmvm.ItemHeight > 0.0d ? lmvm.ItemHeight : ITEM_DEFAULT_HEIGHT; double dblHeaderItemHeight = lmvm != null && lmvm.HeaderItemHeight > 0.0d ? lmvm.HeaderItemHeight : ITEM_WITH_HEADER_DEFAULT_HEIGHT; Dispatcher.Invoke(() => { SyncObservableCollection <IMatchVw> socMonitor = LiveMonitorsCollectionList[i]; double dblCurrentMonitorFilledHeight = 0; SyncList <IMatchVw> lMatchesTemp = new SyncList <IMatchVw>(); IMatchVw matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null; string currentSport = ""; bool isPreLiveOld = false; while (matchVw != null) { var isPreLive = matchVw.LiveBetStatus == eMatchStatus.NotStarted || !matchVw.IsLiveBet; if (matchVw.SportDescriptor != currentSport) { matchVw.IsHeaderForLiveMonitor = true; currentSport = matchVw.SportDescriptor; } else if (page != i) { matchVw.IsHeaderForLiveMonitor = true; page = i; } else if (isPreLive && !isPreLiveOld) { matchVw.IsHeaderForLiveMonitor = true; isPreLiveOld = isPreLive; } else { if (dblCurrentMonitorFilledHeight + dblItemHeight <= LiveMonitorHeights[i]) { matchVw.IsHeaderForLiveMonitor = false; } } currentSport = matchVw.SportDescriptor; page = i; isPreLiveOld = isPreLive; dblCurrentMonitorFilledHeight += matchVw.IsHeaderForLiveMonitor ? dblHeaderItemHeight : dblItemHeight; if (dblCurrentMonitorFilledHeight > LiveMonitorHeights[i]) { page = i; break; } else { lMatchesTemp.Add(matchVw); } iMatchIdx++; matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null; } //Debug.Assert(ChangeTracker.LiveMonitors[i].threadId == socMonitor.threadid); //Debug.Assert(Thread.CurrentThread == socMonitor.threadid); socMonitor.ApplyChanges(lMatchesTemp); }); } }
public void Rotate() { if (ChangeTracker.LiveMonitors.Count <= 0) { return; } if (this.rotationCounter >= 1000) { rotationCounter = 0; } this.rotationCounter++; LiveMonitorViewModel lmvm = null; SyncList <IMatchVw> lMatches = Matches.ToSyncList(); for (int i = 0; i < LiveMonitorsCollectionList.Count; i++) { if (!lmViewModels[i].rotating || lmViewModels[i].LiveOddsVisibility == Visibility.Collapsed) { continue; } //check interval if (this.rotationCounter % lmViewModels[i].rotationInterval != 0 && this.rotationCounter != 0) { continue; } lmvm = ChangeTracker.LiveMonitors[i].DataContext as LiveMonitorViewModel; Debug.Assert(lmvm != null); double dblItemHeight = lmvm != null && lmvm.ItemHeight > 0.0d ? lmvm.ItemHeight : ITEM_DEFAULT_HEIGHT; double dblHeaderItemHeight = lmvm != null && lmvm.HeaderItemHeight > 0.0d ? lmvm.HeaderItemHeight : ITEM_WITH_HEADER_DEFAULT_HEIGHT; if (LiveMonitorRotationCounters[i] >= lMatches.Count) { LiveMonitorRotationCounters[i] = LiveMonitorRotationCounters[i] - lMatches.Count; } int iMatchIdx = LiveMonitorRotationCounters[i]; if (iMatchIdx >= lMatches.Count) { iMatchIdx = 0; } IMatchVw matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null; SyncObservableCollection <IMatchVw> socMonitor = LiveMonitorsCollectionList[i]; double dblCurrentMonitorFilledHeight = 0; SyncList <IMatchVw> lMatchesTemp = new SyncList <IMatchVw>(); string oldSport = ""; bool isPreLiveOld = false; while (matchVw != null) { if (matchVw == null || lMatchesTemp.Contains(matchVw)) { break; } string currentSport = matchVw.SportDescriptor; var isPreLive = matchVw.LiveBetStatus == eMatchStatus.NotStarted || !matchVw.IsLiveBet; if (!string.IsNullOrEmpty(currentSport)) { if (currentSport != oldSport) { matchVw.IsHeaderForRotation = true; } else if (isPreLive && !isPreLiveOld) { matchVw.IsHeaderForRotation = true; } else { matchVw.IsHeaderForRotation = false; } oldSport = currentSport; isPreLiveOld = isPreLive; } dblCurrentMonitorFilledHeight += matchVw.IsHeaderForRotation ? dblHeaderItemHeight : dblItemHeight; if (dblCurrentMonitorFilledHeight > lmViewModels[i].LiveOddsHeight) //lmViewModels[i].LiveOddsHeight) { break; } else { lMatchesTemp.Add(matchVw); } iMatchIdx++; if (iMatchIdx >= lMatches.Count) { iMatchIdx = 0; } matchVw = lMatches.Count > iMatchIdx ? lMatches[iMatchIdx] : null; LiveMonitorRotationCounters[i]++; } Dispatcher.Invoke(() => { socMonitor.ApplyChanges(lMatchesTemp); //damn thing does not applay normally changes for collections with duplicate matches with it... }); } }
public void AddThief(GameObject player) { aliveThieves.Add(player); }
[SyncVar] private bool inUse; // clients cannot use a storage if it is already in use public void AddItem(StoredItem i) { items.Add(i); }
public static void Generate( string computerName, SyncList<DprNetworkInfo> result ) { Helpers.AssertNotNull( result, @"result SyncList cannot be null" ); Helpers.AssertString( computerName, @"Computer name cannot be empty" ); var networkInfoList = new List<DprNetworkInfo>( ); try { WmiHelpers.ForEach( computerName, @"SELECT * FROM Win32_NetworkAdapterConfiguration", obj => { var ci = new DprNetworkInfo( computerName ); ci.DefaultIpGateway = WmiHelpers.GetStringArray( obj, @"DefaultIPGateway" ); ci.Description = WmiHelpers.GetString( obj, @"Description" ); ci.DhcpEnabled = WmiHelpers.GetBoolean( obj, @"DHCPEnabled" ); ci.DhcpLeaseExpires = WmiHelpers.GetNullableDate( obj, @"DHCPLeaseExpires", true ); ci.DhcpLeaseObtained = WmiHelpers.GetNullableDate( obj, @"DHCPLeaseObtained", true ); ci.DhcpServer = WmiHelpers.GetString( obj, @"DHCPServer" ); ci.DnsDomain = WmiHelpers.GetString( obj, @"DNSDomain" ); ci.DnsDomainSuffixSearchOrder = WmiHelpers.GetStringArray( obj, @"DNSDomainSuffixSearchOrder" ); ci.DnsEnabledForWinsResolution = WmiHelpers.GetNullableBoolean( obj, @"DNSEnabledForWINSResolution" ); ci.DnsHostName = WmiHelpers.GetString( obj, @"DNSHostName" ); ci.DnsServerSearchOrder = WmiHelpers.GetStringArray( obj, @"DNSServerSearchOrder" ); ci.DomainDnsRegistrationEnabled = WmiHelpers.GetNullableBoolean( obj, @"DomainDNSRegistrationEnabled" ); ci.FullDnsRegistrationEnabled = WmiHelpers.GetNullableBoolean( obj, @"FullDNSRegistrationEnabled" ); ci.Index = WmiHelpers.GetUInt( obj, @"Index" ); ci.InterfaceIndex = WmiHelpers.GetUInt( obj, @"InterfaceIndex" ); ci.IpAddress = WmiHelpers.GetStringArray( obj, @"IPAddress" ); ci.IpConnectionMetric = WmiHelpers.GetNullableUInt( obj, @"IPConnectionMetric" ); ci.IpEnabled = WmiHelpers.GetNullableBoolean( obj, @"IPEnabled" ); ci.MacAddress = WmiHelpers.GetString( obj, @"MACAddress" ); ci.SettingId = WmiHelpers.GetString( obj, @"SettingID" ); ci.WinsEnableLmHostsLookup = WmiHelpers.GetNullableBoolean( obj, @"WINSEnableLMHostsLookup" ); ci.WinsHostLookupFile = WmiHelpers.GetString( obj, @"WINSHostLookupFile" ); ci.WinsPrimaryServer = WmiHelpers.GetString( obj, @"WINSPrimaryServer" ); ci.WinsSecondaryServer = WmiHelpers.GetString( obj, @"WINSSecondaryServer" ); ci.WinsScopeId = WmiHelpers.GetString( obj, @"WINSScopeID" ); networkInfoList.Add( ci ); return true; }, true, false ); } catch( UnauthorizedAccessException ) { result.Add( new DprNetworkInfo( computerName, ConnectionStatuses.AuthorizationError ) ); return; } catch( Exception ) { result.Add( new DprNetworkInfo( computerName, ConnectionStatuses.Error ) ); return; } result.AddRange( networkInfoList ); ValidateUniqueness( result ); }
public static void Generate( string computerName, SyncList.SyncList<DprCurrentUsers> result ) { Helpers.AssertNotNull( result, @"result SyncList cannot be null" ); Helpers.AssertString( computerName, @"Computer name cannot be empty" ); switch( GetNetworkUsers( computerName, ref result ) ) { case Win32.Error.Success: break; case Win32.Error.ErrorMoreData: break; case Win32.Error.ErrorAccessDenied: GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"DprCurrentUsers - Generate - Access Denied for {0}", computerName ); result.Add( new DprCurrentUsers( computerName, ConnectionStatuses.AccessDenied ) ); //return; break; default: GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"DprCurrentUsers - Generate - Unknown Error for {0}", computerName ); result.Add( new DprCurrentUsers( computerName, ConnectionStatuses.Error ) ); //return; break; } GetLocallyLoggedOnUsers( computerName, result ); ValidateUniqueness( result ); }
// Host game function called by the player // Function needs to create a new match in the set of matches // Then add the player to it, and return the port number that the player moves to // Return 0 if it fails public int HostGame(int id, GameObject p) { matches.Add(new Match(id.ToString(), p, matches.Count + 7778)); Debug.Log($"Match ID: {matches[0].matchID.ToString()}"); return(matches.Count + 7777); }
public void VerifySelectedOdds(SortableObservableCollection <ITipItemVw> socSelectedOdds, SyncHashSet <ITipItemVw> hsOddsToRemove = null) { CheckTime ct = new CheckTime(true, "VerifySelectedOdds(TipCount={0})", socSelectedOdds.Count); ExcpHelper.ThrowIf <ArgumentNullException>(socSelectedOdds == null, "VerifySelectedOdds(NULL) ERROR"); lock (_verifyLocker) { ct.AddEvent("Lock Entered"); if (hsOddsToRemove != null) { hsOddsToRemove.Clear(); } else { hsOddsToRemove = new SyncHashSet <ITipItemVw>(); } SyncList <ITipItemVw> lTipItems = socSelectedOdds.ToSyncList(); foreach (TipItemVw tiv in lTipItems) { // Check if selected odd is not expired if (!CheckOdd(tiv.Odd)) { hsOddsToRemove.Add(tiv); } // Check if selected odd is not yet in current collection (m_lSelectedOdds) else if (!m_lSelectedOdds.Contains(tiv.Odd)) { m_lSelectedOdds.Add(tiv.Odd); tiv.Odd.BetDomain.Match.SetSelected(tiv.Odd, true); } } ct.AddEvent("Check Completed"); // Remove from socSelectedOdds and m_lSelectedOdds for (int i = 0; i < lTipItems.Count;) { var tiv = lTipItems[i]; if (hsOddsToRemove.Contains(tiv)) { // This Odd is expired lTipItems.Remove(tiv); socSelectedOdds.Remove(tiv); m_lSelectedOdds.Remove(tiv.Odd); tiv.Odd.BetDomain.Match.SetSelected(tiv.Odd, false); } else { i++; } } ct.AddEvent("Remove from List Completed"); // Remove from m_lSelectedOdd those items were not removed in previous cycle for (int i = 0; i < m_lSelectedOdds.Count;) { IOddLn odd = m_lSelectedOdds[i]; TipItemVw tiv = new TipItemVw(odd); if (!lTipItems.Contains(tiv)) { m_lSelectedOdds.Remove(odd); tiv.Odd.BetDomain.Match.SetSelected(tiv.Odd, false); } else { i++; } } ct.AddEvent("Remove from List2 Completed"); } ct.Info(m_logger); }
// public bool ShouldHide { get { return IsHidden( ); } } // // private bool IsHidden( bool shown = false ) { // return !shown && SystemComponent; // } public static void Generate(string computerName, SyncList <DprComputerSoftware> result) { Debug.Assert(null != result, @"result SyncList cannot be null"); Helpers.AssertString(computerName, @"Computer name cannot be empty"); var softwareList = new List <DprComputerSoftware>(); try { string[] regPaths = { @"SOFTWARE\Wow6432node\Microsoft\Windows\CurrentVersion\Uninstall", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" }; foreach (var currentPath in regPaths) { using (var regKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, computerName).OpenSubKey(currentPath, false)) { if (null == regKey) { continue; } foreach (var currentGuid in regKey.GetSubKeyNames( ).Where(currentValue => currentValue.StartsWith(@"{")).Where(currentGuid => !HasGuid(softwareList, currentGuid))) { using (var curReg = regKey.OpenSubKey(currentGuid, false)) { if (null == curReg || !string.IsNullOrEmpty(RegistryHelpers.GetString(curReg, @"ParentKeyName"))) { continue; } var currentProduct = new DprComputerSoftware(computerName) { Guid = currentGuid, Name = RegistryHelpers.GetString(curReg, @"DisplayName"), Publisher = RegistryHelpers.GetString(curReg, @"Publisher"), Version = RegistryHelpers.GetString(curReg, @"DisplayVersion"), InstallDate = RegistryHelpers.GetDateTime(curReg, @"InstallDate"), CanRemove = 0 == RegistryHelpers.GetDword(curReg, @"NoRemove", 0), //SystemComponent = 1 == RegistryHelpers.GetDword( curReg, @"SystemComponent", 0 ) }; { var estSize = RegistryHelpers.GetDword(curReg, @"EstimatedSize"); if (null != estSize) { currentProduct.Size = (float)Math.Round((float)estSize / 1024.0, 2, MidpointRounding.AwayFromZero); } } currentProduct.HelpLink = RegistryHelpers.GetString(curReg, @"HelpLink"); currentProduct.UrlInfoAbout = RegistryHelpers.GetString(curReg, @"UrlInfoAbout"); if (currentProduct.Valid( )) { softwareList.Add(currentProduct); } } } } } } catch (System.IO.IOException) { result.Add(new DprComputerSoftware(computerName, ConnectionStatuses.ConnectionError)); softwareList.Clear( ); } catch (UnauthorizedAccessException) { result.Add(new DprComputerSoftware(computerName, ConnectionStatuses.AuthorizationError)); softwareList.Clear( ); } catch (System.Security.SecurityException) { result.Add(new DprComputerSoftware(computerName, ConnectionStatuses.AuthorizationError)); softwareList.Clear( ); } result.AddRange(softwareList); ValidateUniqueness(result); }
void ChangeVector3Vars(Vector3 newValue) { _SyncVector3Vars.Add(newValue); }
private void CmdAddNewItem(Item item) { // _syncListString.Add(s); _syncListItem.Add(item); }
// public bool ShouldHide { get { return IsHidden( ); } } // // private bool IsHidden( bool shown = false ) { // return !shown && SystemComponent; // } public static void Generate( string computerName, SyncList<DprComputerSoftware> result ) { Debug.Assert( null != result, @"result SyncList cannot be null" ); Helpers.AssertString( computerName, @"Computer name cannot be empty" ); var softwareList = new List<DprComputerSoftware>(); try { string[] regPaths = { @"SOFTWARE\Wow6432node\Microsoft\Windows\CurrentVersion\Uninstall", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" }; foreach( var currentPath in regPaths ) { using( var regKey = RegistryKey.OpenRemoteBaseKey( RegistryHive.LocalMachine, computerName ).OpenSubKey( currentPath, false ) ) { if( null == regKey ) { continue; } foreach( var currentGuid in regKey.GetSubKeyNames( ).Where( currentValue => currentValue.StartsWith( @"{" ) ).Where( currentGuid => !HasGuid( softwareList, currentGuid ) ) ) { using( var curReg = regKey.OpenSubKey( currentGuid, false ) ) { if( null == curReg || !string.IsNullOrEmpty( RegistryHelpers.GetString( curReg, @"ParentKeyName" ) ) ) { continue; } var currentProduct = new DprComputerSoftware( computerName ) { Guid = currentGuid, Name = RegistryHelpers.GetString( curReg, @"DisplayName" ), Publisher = RegistryHelpers.GetString( curReg, @"Publisher" ), Version = RegistryHelpers.GetString( curReg, @"DisplayVersion" ), InstallDate = RegistryHelpers.GetDateTime( curReg, @"InstallDate" ), CanRemove = 0 == RegistryHelpers.GetDword( curReg, @"NoRemove", 0 ), //SystemComponent = 1 == RegistryHelpers.GetDword( curReg, @"SystemComponent", 0 ) }; { var estSize = RegistryHelpers.GetDword( curReg, @"EstimatedSize" ); if( null != estSize ) { currentProduct.Size = (float)Math.Round( (float)estSize / 1024.0, 2, MidpointRounding.AwayFromZero ); } } currentProduct.HelpLink = RegistryHelpers.GetString( curReg, @"HelpLink" ); currentProduct.UrlInfoAbout = RegistryHelpers.GetString( curReg, @"UrlInfoAbout" ); if( currentProduct.Valid( ) ) { softwareList.Add( currentProduct ); } } } } } } catch( System.IO.IOException ) { result.Add( new DprComputerSoftware( computerName, ConnectionStatuses.ConnectionError ) ); softwareList.Clear( ); } catch( UnauthorizedAccessException ) { result.Add( new DprComputerSoftware( computerName, ConnectionStatuses.AuthorizationError ) ); softwareList.Clear( ); } catch( System.Security.SecurityException ) { result.Add( new DprComputerSoftware( computerName, ConnectionStatuses.AuthorizationError ) ); softwareList.Clear( ); } result.AddRange( softwareList ); ValidateUniqueness( result ); }
public static void Generate( string computerName, SyncList.SyncList<DprComputerInfo> result ) { Helpers.AssertNotNull( result, @"result SyncList cannot be null" ); Helpers.AssertString( computerName, @"Computer name cannot be empty" ); var ci = new DprComputerInfo( computerName ) { LocalSystemDateTime = DateTime.Now }; try { WmiHelpers.ForEach( computerName, @"SELECT * FROM Win32_OperatingSystem WHERE Primary=TRUE", obj => { ci.LastBootTime = WmiHelpers.GetNullableDate( obj, @"LastBootUpTime" ); ci.SystemTime = WmiHelpers.GetNullableDate( obj, @"LocalDateTime" ); ci.Version = WmiHelpers.GetString( obj, @"Caption" ); ci.Architecture = WmiHelpers.GetString( obj, @"OSArchitecture" ); ci.InstallDate = WmiHelpers.GetNullableDate( obj, @"InstallDate" ); return true; } ); WmiHelpers.ForEach( computerName, @"SELECT * FROM Win32_BIOS", obj => { ci.Manufacturer = WmiHelpers.GetString( obj, @"Manufacturer" ); ci.HwReleaseDate = WmiHelpers.GetNullableDate( obj, @"ReleaseDate" ); ci.SerialNumber = WmiHelpers.GetString( obj, @"SerialNumber" ); ci.BiosVersion = WmiHelpers.GetString( obj, @"SMBIOSBIOSVersion" ); return true; } ); WmiHelpers.ForEach( computerName, @"SELECT * FROM Win32_ComputerSystem", obj => { ci.Model = WmiHelpers.GetString( obj, @"Model" ); ci.TotalPhysicalMemory = WmiHelpers.GetUInt( obj, @"TotalPhysicalMemory" ); return true; } ); } catch( UnauthorizedAccessException uae ) { GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"Exception - {0} - {1}", uae.TargetSite, uae.Message ); ci.ConnectionStatus = ConnectionStatuses.AuthorizationError; } catch( Exception ex ) { GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"Exception - {0} - {1}", ex.TargetSite, ex.Message ); ci.ConnectionStatus = ConnectionStatuses.Error; } result.Add( ci ); ValidateUniqueness( result ); }
public void WritingToReadOnlyThrows() { Assert.Throws <InvalidOperationException>(() => { clientSyncList.Add("fail"); }); }
protected override void OnAttach() { Script.Add().Value = "var cube = World.RootSlot.FindInChildren(\"Cube\");"; Script.Add().Value = "var cube1 = World.RootSlot.FindInChildren(\"Cube1\");"; Script.Add().Value = "function InitPort(){AddOut(\"floatQ\");}"; Script.Add().Value = ""; Script.Add().Value = "function Update(){"; Script.Add().Value = "if(cube1.Parent == World.RootSlot){"; Script.Add().Value = "OutFloatQ(0, cube.GlobalRotation);"; Script.Add().Value = "cube1.Rotation_Field.Value = cube.GlobalRotation;"; Script.Add().Value = "}"; Script.Add().Value = "}"; //Script.Add().Value = "function Run(){t++;}"; //World.RootSlot.FindInChildren("Cube").GlobalPosition RefreshOld = false; RefreshPortsOld = false; loadJS(); InitPorts(); }
public void TestAdd() { serverSyncList.Add("yay"); SerializeDeltaTo(serverSyncList, clientSyncList); Assert.That(clientSyncList, Is.EquivalentTo(new[] { "Hello", "World", "!", "yay" })); }
private void cmdAddPlayer(int playerId) { activePlayers.Add(playerId); printList(); }