public MainWindow()
        {
            InitializeComponent();
            hopEntries = new SyncList<HopEntry>(this);

            dgvTracert.DataSource = hopEntries;
        }
Esempio n. 2
0
 public Dispatcher(bool autoStart)
 {
     workList = new SyncList<Work>();
     addWorkEvent = new ManualResetEvent(false);
     addWorkLock = new object();
     if (autoStart)
         Start();
 }
Esempio n. 3
0
        public MainForm()
        {
            InitializeComponent();

            ConfigurationSupport.LoadConfig();

            if (!ConfigurationSupport.showGMTClock)
            {
                this.timerGMTClock.Enabled = false;
                this.toolStripClock.Visible = false;
            }

            SnortStatList = new SyncList<SnortStatus>(this);
            EventListES = new SyncList<SguilEvent>(this);
            SensorStatList = new SyncList<SensorStatus>(this);
            RTEventLists = new List<SyncList<SguilEvent>>();
            dgvList = new List<DataGridView>();

            dgvList.Add(this.RealTimeEvents0DataGridView);
            dgvList.Add(this.RealTimeEvents1DataGridView);
            dgvList.Add(this.RealTimeEvents2DataGridView);

            for (int i = 0; i < 2; i++)
            {
                RTEventLists.Add(new SyncList<SguilEvent>(this));
                dgvList[i].AutoGenerateColumns = false;
                dgvList[i].DataSource = RTEventLists[i];
            }

            this.dgvESEvents.AutoGenerateColumns = false;
            this.dgvESEvents.DataSource = EventListES;
            this.SnortStatisticsDataGridView.AutoGenerateColumns = false;
            this.SnortStatisticsDataGridView.DataSource = SnortStatList;
            this.SensorStatsDataGridView.AutoGenerateColumns = false;
            this.SensorStatsDataGridView.Columns["agntLast"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.SensorStatsDataGridView.Columns["agntStatus"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            this.SensorStatsDataGridView.DataSource = SensorStatList;
            this.tlPacket.Controls.Add(this.tlHdrUDP, 1, 3);
            this.tlPacket.Controls.Add(this.tlHdrICMP, 1, 3);
            this.tlHdrUDP.Hide();
            this.tlHdrICMP.Hide();
            this.packetDataHexRichTextBoxSyncronized.BindScroll(this.packetDataAsciiRichTextBoxSyncronized);
        }
Esempio n. 4
0
		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 );
		}
Esempio n. 5
0
		private static void GetLocallyLoggedOnUsers( string computerName, SyncList.SyncList<DprCurrentUsers> result ) {
			var usersList = new List<DprCurrentUsers>( );
			using( var regHku = RegistryKey.OpenRemoteBaseKey( RegistryHive.Users, string.Empty ) ) {
				foreach( var currentSid in regHku.GetSubKeyNames( ).Where( IsSid ) ) {
					var cu = new DprCurrentUsers( computerName ) { Sid = currentSid };
					try {
						if( Win32.WellKnownSids.ContainsKey( currentSid ) ) {
							cu.Domain = computerName;	// Local account
							cu.UserName = Win32.WellKnownSids[currentSid];
						} else {
							GetUserAccountFromSid( ref cu );
						}
						cu.ProfileFolder = RegistryHelpers.GetString( computerName, RegistryHive.LocalMachine, string.Format( @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\{0}", currentSid ), @"ProfileImagePath" );
						cu.LastLogon = GetUsersLogonTimestamp( cu );					
					} catch( Exception ex ) {
						GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"Exception - {0} - {1}", ex.TargetSite, ex.Message );
						cu = new DprCurrentUsers( computerName, ConnectionStatuses.Error ) { Sid = currentSid };
					}
					cu.LogonType = LogonTypes.Local;
					usersList.Add( cu );
				}
			}
			result.AddRange( usersList );
		}
Esempio n. 6
0
 public Enumerator(SyncList <T> list)
 {
     this.list = list;
     index     = -1;
     Current   = default;
 }
Esempio n. 7
0
        private void CheckForChanges()
        {
            Globals global = null;

            try
            {
                global = db.Find <Globals>(1);
            }
            catch (SQLiteException e)
            {
            }
            if (global == null)
            {
                // this mean there was no files downloaded (as there is none on the account)
                global    = new Globals();
                global.Id = 1;
                global.CurrentRevision = 0;
                db.Insert(global);
            }
            var request = newReq("/rest/sync/changes");

            SetUpRequest(request);
            request.AddParameter("rev", global.CurrentRevision);

            var response = client.Execute <SyncList>(request);

            if (response.ResponseStatus == ResponseStatus.Completed)
            {
                SyncList        list  = response.Data;
                List <DiskItem> items = list.Items;

                if (list.LatestRevision > global.CurrentRevision)
                {
                    global.CurrentRevision = list.LatestRevision;
                    db.Update(global);

                    foreach (DiskItem i in items)
                    {
                        if (DoesThisNeedUpdating(i))
                        {
                            switch (i.Action)
                            {
                            case "ADD":
                                NewFileAdded(i);
                                break;

                            case "DELETE":
                                DeleteDiskItem(i);
                                break;

                            case "UPDATED":
                                UpdateDiskItem(i);
                                break;

                            case "RENAME":
                                DiskItemRenamed(i);
                                break;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 8
0
 public void SyncAccess(SyncList <int> .Operation op, int index, int oldItem, int newItem)
 {
     //Do anything special when the synclist changes on the client
 }
Esempio n. 9
0
        private void ThreadedSyncAndScan(object sender, DoWorkEventArgs e)
        {
            // Get the BackgroundWorker that raised this event.
            BackgroundWorker worker = sender as BackgroundWorker;

            Dictionary <string, SyncItem> serverhashes;

            //get the server hashlist
            AddTextToConsole("Getting server hashes (" + Settings.HashServer + ")" + Environment.NewLine);
            try
            {
                serverhashes = Http.GetHashList();
            }
            catch (Exception ex)
            {
                AddTextToConsole("Error Reading Remote Hashes:" + ex.Message + Environment.NewLine);
                return;
            }

            //hash all teh local files.
            AddTextToConsole("Checking Local hashes" + Environment.NewLine);
            SyncList LocalData = new SyncList(Settings.LocalDirectory);

            List <string> FilesToDownload = new List <string>();

            LocalData.saveSyncList(Settings.HashCache);
            //get the delta list
            foreach (KeyValuePair <string, SyncItem> kvp in serverhashes)
            {
                //ignore metadata.
                if (kvp.Key == "__Server" || kvp.Key == "__DateGeneratedUTC")
                {
                    ;
                }
                else
                {
                    //Queue downloads
                    if (!LocalData.HashList.ContainsKey(kvp.Key))
                    {
                        //downlaod files that dont exist.
                        FilesToDownload.Add(kvp.Key);
                    }
                    else
                    {
                        if (kvp.Value.Hash != LocalData.HashList[kvp.Key].Hash)
                        {
                            //download files the dont mathc the hash
                            FilesToDownload.Add(kvp.Key);
                        }
                        else
                        {
                            //if we get here the file exist and is right.
                            //get it out of the hash list so we dont delrte it.
                            LocalData.HashList.Remove(kvp.Key);
                        }
                    }
                }
            }

            //Remove Files if set to
            if (Settings.RemoveLocalFileIfNoRemoteFile)
            {
                AddTextToConsole("Generating list of local files to remove" + Environment.NewLine);
                bool shouldDelete = true;
                //ensure we didnt delte everything accidentally.
                if (LocalData.HashList.Count > Settings.numFilesToRemoveWithNoWarning)
                {
                    shouldDelete = false;
                    if (MessageBox.Show(LocalData.HashList.Count + " Files Are flagged for deletion." + Environment.NewLine + " Delete them?", "Continue?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        shouldDelete = true;
                        AddTextToConsole("Deleting Files" + Environment.NewLine);
                    }
                    else
                    {
                        AddTextToConsole("Files Will NOT be Removed" + Environment.NewLine);
                    }
                }


                //remove files
                if (shouldDelete && LocalData.HashList.Count > 0)
                {
                    foreach (KeyValuePair <string, SyncItem> kvp in LocalData.HashList)
                    {
                        AddTextToConsole("  " + kvp.Key + Environment.NewLine);

                        File.Delete(Settings.LocalDirectory + kvp.Key);
                    }
                }
            }



            //DOWNLOADS
            AddTextToConsole("Need to download: " + FilesToDownload.Count + " from " + Settings.DownloadType + Environment.NewLine);
            ErrorCount = 0;



            int tasklimit = 10;

            int nextFile = 0;
            GetObjectRequest request;
            AmazonS3Client   s3 = new  AmazonS3Client(Settings.s3IDKey, Settings.s3SecretKey);

            while (nextFile < FilesToDownload.Count || DownloadCount > 0)
            {
                if (DownloadCount < tasklimit && nextFile < FilesToDownload.Count)
                {
                    request            = new GetObjectRequest();
                    request.BucketName = Settings.s3Bucket;
                    request.Key        = FilesToDownload[nextFile].Substring(1); //use substring so we elminate the /
                    request.Timeout    = 1000;                                   //wait 1 minute for a  response.
                    AddTextToConsole("  " + (nextFile + 1) + "/" + FilesToDownload.Count + " " + request.Key + Environment.NewLine);

                    s3.BeginGetObject(request, DownloadFile, s3);
                    nextFile++;
                    DownloadCount++;
                    worker.ReportProgress((int)(((float)nextFile) / ((float)FilesToDownload.Count) * 100.0f));
                }
            }



            if (nextFile - ErrorCount < FilesToDownload.Count)
            {
                AddTextToConsole("WARNING: NOT ALL FILES WERE SUCCESSFULLY DOWNLOADED" + Environment.NewLine + Environment.NewLine);
            }
            AddTextToConsole("Download queue processed. Check log for any errors" + Environment.NewLine);
        }
        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 SetMonitors(bool result)
        {
            lock (locker)
            {
                MonitorTemplates deserializedFeed = null;
                try
                {
                    if (!lmViewModelsDefault.Equals(lmViewModels))
                    {
                        lmViewModels = new SyncList <LiveMonitorViewModel>(lmViewModelsDefault);
                    }

                    foreach (LiveMonitorViewModel lv in lmViewModels)
                    {
                        lv.liveOddsPage = 1000;
                    }

                    string number    = StationRepository.StationNumber;
                    string templates = WsdlRepository.GetContentManagementData(StationRepository.StationNumber);
                    deserializedFeed = JsonConvert.DeserializeObject <MonitorTemplates>(templates);

                    var screens = Screen.AllScreens.Where(s => !s.Primary).ToList();
                    for (int i = 0; i < ChangeTracker.LiveMonitors.Count; i++)
                    {
                        string index = screens[i].DeviceName.Substring(screens[i].DeviceName.Length - 1, 1);
                        lmViewModels[i].LiveOddsVisibility = Visibility.Collapsed;

                        lmViewModels[i].HeaderTextVisibility = Visibility.Collapsed;
                        lmViewModels[i].BannerVisibility     = Visibility.Collapsed;
                        lmViewModels[i].rotating             = false;
                        lmViewModels[i].rotationInterval     = 10;
                        lmViewModels[i].MonitorWidth         = screens[i].WorkingArea.Width;
                        lmViewModels[i].MonitorHeight        = screens[i].WorkingArea.Height;

                        MonitorTemplate temp = deserializedFeed.monitorTemplates.Where(x => x.monitorPosition == index).FirstOrDefault();
                        if (temp == null)
                        {
                            Mediator.SendMessage(i + "|" + Visibility.Collapsed.ToString(), MsgTag.ChangeVisibility);

                            Dispatcher.Invoke(() =>
                            {
                                if (!lmViewModels[i].IsClosed)
                                {
                                    lmViewModels[i].ViewWindow.Visibility = Visibility.Visible;
                                }
                            });
                            lmViewModels[i].HeaderTextVisibility = Visibility.Collapsed;
                            lmViewModels[i].BannerVisibility     = Visibility.Collapsed;
                            lmViewModels[i].rotating             = false;
                            lmViewModels[i].rotationInterval     = 10;
                            lmViewModels[i].MonitorWidth         = screens[i].WorkingArea.Width;
                            lmViewModels[i].MonitorHeight        = screens[i].WorkingArea.Height;

                            lmViewModels[i].LiveOddsRow        = 0;
                            lmViewModels[i].LiveOddsVisibility = Visibility.Visible;
                            lmViewModels[i].LiveOddsHeight     = screens[i].WorkingArea.Height;
                            lmViewModels[i].liveOddsPage       = i + 1001;
                        }
                        else
                        {
                            string            templateId = temp.templateId;
                            AvailableTemplate template   = deserializedFeed.availableTemplates.Where(x => x.templateId == templateId).FirstOrDefault();
                            if (template != null)
                            {
                                for (int y = 0; y < template.content.Count(); y++)
                                {
                                    string type = template.content.ElementAt(y).contentType;
                                    if (type == "VFL")
                                    {
                                        Dispatcher.Invoke(() =>
                                        {
                                            if (!lmViewModels[i].IsClosed)
                                            {
                                                lmViewModels[i].ViewWindow.Visibility = Visibility.Collapsed;
                                            }
                                        });

                                        Mediator.SendMessage(i + "|" + Visibility.Visible.ToString(), MsgTag.ChangeVisibility);

                                        Mediator.SendMessage(i + "|" + SetVFLAddress(screens[i], 0), MsgTag.SetUpBrowser);
                                    }
                                    else if (type == "VHC")
                                    {
                                        Dispatcher.Invoke(() =>
                                        {
                                            if (!lmViewModels[i].IsClosed)
                                            {
                                                lmViewModels[i].ViewWindow.Visibility = Visibility.Collapsed;
                                            }
                                        });

                                        Mediator.SendMessage(i + "|" + Visibility.Visible.ToString(),
                                                             MsgTag.ChangeVisibility);
                                        Mediator.SendMessage(i + "|" + SetVHCAddress(screens[i]), MsgTag.SetUpBrowser);
                                    }
                                    else
                                    {
                                        Mediator.SendMessage(i + "|" + Visibility.Collapsed.ToString(), MsgTag.ChangeVisibility);


                                        Dispatcher.Invoke(() =>
                                        {
                                            if (!lmViewModels[i].IsClosed)
                                            {
                                                lmViewModels[i].ViewWindow.Visibility = Visibility.Visible;
                                            }
                                        });
                                        //lmViewModels[i].HeaderTextVisibility = Visibility.Collapsed;
                                        //lmViewModels[i].BannerVisibility = Visibility.Collapsed;
                                        //lmViewModels[i].rotating = false;
                                        //lmViewModels[i].rotationInterval = 10;
                                        //lmViewModels[i].MonitorWidth = screens[i].WorkingArea.Width;
                                        //lmViewModels[i].MonitorHeight = screens[i].WorkingArea.Height;

                                        if (type == "HEADER_TEXT")
                                        {
                                            lmViewModels[i].HeaderRow            = y;
                                            lmViewModels[i].HeaderTextVisibility = Visibility.Visible;
                                            double dd  = Int64.Parse(template.content.ElementAt(y).size);
                                            double sc  = screens[i].WorkingArea.Height;
                                            double res = dd * sc / 100;
                                            lmViewModels[i].HeaderTextHeight = res;
                                            lmViewModels[i].HeaderText       = template.content.ElementAt(y).data;
                                        }
                                        else if (type == "LIVE_ODDS")
                                        {
                                            lmViewModels[i].LiveOddsRow        = y;
                                            lmViewModels[i].LiveOddsVisibility = Visibility.Visible;
                                            double desiredHeight = Int64.Parse(template.content.ElementAt(y).size) *
                                                                   screens[i].WorkingArea.Height / 100;
                                            ;
                                            if (desiredHeight != lmViewModels[i].LiveOddsHeight)
                                            {
                                                Dispatcher.Invoke(() =>
                                                {
                                                    LiveMonitorsCollectionList[i].Clear();
                                                });

                                                lmViewModels[i].LiveOddsHeight = desiredHeight;
                                            }

                                            if (template.content.ElementAt(y).data.ToLowerInvariant().Contains("page"))
                                            {
                                                string page =
                                                    template.content.ElementAt(y)
                                                    .data.Substring(template.content.ElementAt(y).data.Length - 1, 1);
                                                lmViewModels[i].liveOddsPage     = Int16.Parse(page);
                                                lmViewModels[i].rotating         = false;
                                                lmViewModels[i].rotationInterval = 10;
                                            }
                                            else if (
                                                template.content.ElementAt(y)
                                                .data.ToLowerInvariant()
                                                .Contains("rotating"))
                                            {
                                                //if(!lmViewModels[i].rotating)
                                                //    LiveMonitorRotationCounters[i] = 0;

                                                lmViewModels[i].rotating         = true;
                                                lmViewModels[i].rotationInterval =
                                                    Int16.Parse(template.content.ElementAt(y).additParams);
                                            }
                                        }
                                        else if (type == "BANNER")
                                        {
                                            double dd  = Int64.Parse(template.content.ElementAt(y).size);
                                            double sc  = screens[i].WorkingArea.Height;
                                            double res = dd * sc / 100;

                                            lmViewModels[i].BannerRow        = y;
                                            lmViewModels[i].BannerVisibility = Visibility.Visible;
                                            lmViewModels[i].BannerHeight     = res;
                                            lmViewModels[i].BannerLink       = template.content.ElementAt(y).data;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    LiveMonitorViewModel vm         = lmViewModels.Where(x => x.liveOddsPage != 1000).FirstOrDefault();
                    LiveMonitorViewModel vmRotating = lmViewModels.Where(x => x.rotating).FirstOrDefault();
                    if (vm != null || vmRotating != null)
                    {
                        lmViewModels = new SyncList <LiveMonitorViewModel>(lmViewModels.OrderBy(x => x.liveOddsPage).ToList());
                        LiveMonitorHeights.Clear();
                        for (int i = 0; i < lmViewModels.Count; i++)
                        {
                            LiveMonitorHeights.Add(lmViewModels[i].LiveOddsHeight);
                            lmViewModels[i].MatchesCollection = LiveMonitorsCollectionList[i];
                        }
                    }
                    else
                    {
                        ResetMonitorsHeight();
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Esempio n. 12
0
 public Logger()
 {
     LogList     = new SyncList <LogItem>(SynchonizeInvoke);
     VisibleList = new SyncList <LogItem>(SynchonizeInvoke);
 }
Esempio n. 13
0
		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 );			
		}
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
 void OnJoinedListUpdate(SyncList <int> .Operation op, int itemIndex, int oldItem, int newItem)
 {
     Debug.LogWarning("Joined list changed");
     Debug.LogWarning(op.ToString());
 }
Esempio n. 16
0
 public Accessor(SyncList <T> sync)
 {
     this.sync = sync;
     index     = 0;
 }
// 		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 );
		}
Esempio n. 18
0
 public Form1()
 {
     InitializeComponent();
     _List = new SyncList <object>(this);
 }
 public static bool Prefix(Scp268 __instance)
 {
     if (NetworkServer.active && ((PlayerEffect)__instance).Enabled)
     {
         __instance.curTime += Time.deltaTime;
         Player player = Player.Get(((PlayerEffect)__instance).Hub);
         if (!(TrackingAndMethods.PlayersWithSubclasses.ContainsKey(player) && TrackingAndMethods.PlayersWithSubclasses[player].Abilities.Contains(AbilityType.InvisibleUntilInteract)) && __instance.curTime > 15f)
         {
             ((PlayerEffect)__instance).ServerDisable();
         }
         bool flag = false;
         using (SyncList <Inventory.SyncItemInfo> .SyncListEnumerator enumerator = ((PlayerEffect)__instance).Hub.inventory.items.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 if (enumerator.Current.id != ItemType.SCP268)
                 {
                     continue;
                 }
                 flag = true;
             }
         }
         //if (!flag)
         //{
         //    //((PlayerEffect)__instance).ServerDisable();
         //}
     }
     if (((PlayerEffect)__instance).Hub.inventory.isLocalPlayer)
     {
         if (((PlayerEffect)__instance).Enabled)
         {
             __instance.animationTime += Time.deltaTime;
             if (__instance.animationTime > 1f)
             {
                 __instance.animationTime = 1f;
             }
         }
         else
         {
             __instance.animationTime -= Time.deltaTime * 2f;
             if (__instance.animationTime < 0f)
             {
                 __instance.animationTime = 0f;
             }
         }
         if (__instance.prevAnim != __instance.animationTime)
         {
             bool flag2;
             __instance.prevAnim = __instance.animationTime;
             CameraFilterPack_Colors_Adjust_ColorRGB effect = ((PlayerEffect)__instance).Hub.gfxController.CustomCameraEffects[1].Effect as CameraFilterPack_Colors_Adjust_ColorRGB;
             effect.enabled = flag2 = __instance.animationTime > 0f;
             CameraFilterPack_TV_Vignetting vignetting1 = ((PlayerEffect)__instance).Hub.gfxController.CustomCameraEffects[0].Effect as CameraFilterPack_TV_Vignetting;
             vignetting1.enabled         = flag2;
             vignetting1.Vignetting      = vignetting1.VignettingFull = __instance.animationTime;
             vignetting1.VignettingColor = (Color) new Color32(0, 1, 2, 0xff);
             effect.Blue       = __instance.animationTime * 0.98f;
             effect.Brightness = __instance.animationTime * -0.97f;
             effect.Red        = effect.Green = __instance.animationTime * 0.97f;
         }
     }
     return(false);
 }
Esempio n. 20
0
		private static Win32.Error GetNetworkUsers( string computerName, ref SyncList.SyncList<DprCurrentUsers> result ) {
			Win32.Error res;
			var er = 0;
			var tr = 0;
			var resume = 0;
			var buffer = IntPtr.Zero;
			var usersList = new List<DprCurrentUsers>( );
			do {
				try {
					res = (Win32.Error)Win32.NetSessionEnum( computerName, null, null, 502, out buffer, -1, ref er, ref tr, ref resume );
					if( res == Win32.Error.ErrorMoreData || res == Win32.Error.Success ) {
						var bufferPtrInt = buffer.ToInt32( );
						for( var i = 0; i < er; i++ ) {
							var sessionInfo = (Win32.SessionInfo502)Marshal.PtrToStructure( new IntPtr( bufferPtrInt ), typeof( Win32.SessionInfo502 ) );
							var cu = new DprCurrentUsers( computerName ) {
								UserName = sessionInfo.userName, LastLogon = DateTime.Now.AddSeconds( -sessionInfo.logonDuration ), LogonType = LogonTypes.Share
							};
							usersList.Add( cu );
							bufferPtrInt += Marshal.SizeOf( typeof( Win32.SessionInfo502 ) );
						}

					} else {
						switch( res ) {
						case Win32.Error.ErrorAccessDenied:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Access Denied: {0}", computerName );
							break;
						case Win32.Error.ErrorNotEnoughMemory:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Not Enough Memory: {0}", computerName );
							break;
						case Win32.Error.ErrorBadNetpath:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Bad Network Path: {0}", computerName );
							break;
						case Win32.Error.ErrorNetworkBusy:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Network Busy: {0}", computerName );
							break;
						case Win32.Error.ErrorInvalidParameter:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Invalid Parameter: {0}", computerName );
							break;
						case Win32.Error.ErrorInsufficientBuffer:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Insufficient Buff: {0}", computerName );
							break;
						case Win32.Error.ErrorInvalidLevel:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Invalid Level: {0}", computerName );
							break;
						case Win32.Error.ErrorExtendedError:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Exended Error: {0}", computerName );
							break;
						case Win32.Error.ErrorNoNetwork:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: No Network: {0}", computerName );
							break;
						case Win32.Error.ErrorInvalidHandleState:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Invalid Handle State: {0}", computerName );
							break;
						case Win32.Error.NerrBase:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: NERR_BASE: {0}", computerName );
							break;
						case Win32.Error.NerrUnknownDevDir:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Unknown Device Directory: {0}", computerName );
							break;
						case Win32.Error.NerrDuplicateShare:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Duplicate Share: {0}", computerName );
							break;
						case Win32.Error.NerrBufTooSmall:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: Buffer too small: {0}", computerName );
							break;
						case Win32.Error.ErrorNoBrowserServersFound:
							GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"GetNetworkUsers: No Browser Servers Found: {0}", computerName );
							break;
						}
						return res;
					}
				} finally {
					if( IntPtr.Zero != buffer ) {
						Win32.NetApiBufferFree( buffer );
					}
				}
			} while( res == Win32.Error.ErrorMoreData );
			result.AddRange( usersList );
			return Win32.Error.Success;
		}
Esempio n. 21
0
 public SubItem()
 {
     SubItems = new SyncList <SubItem>();
 }
Esempio n. 22
0
		public static void ValidateUniqueness( SyncList.SyncList<DprCurrentUsers> rows ) {
			var guids = new HashSet<Guid>( );
			foreach( var item in rows ) {
				Helpers.Assert( !guids.Contains( item.RowGuid ), @"RowGuid's must be unique" );
				guids.Add( item.RowGuid );
			}
		}
Esempio n. 23
0
 public Core()
 {
     Items = new SyncList <MyItem>;
 }
Esempio n. 24
0
	private void UpdateFromServer(SyncList<string>.Operation op, int index)
	{
		RefreshPlayerListText();
	}
//      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);
        }
Esempio n. 26
0
 private void ItemChanged(SyncList <Item> .Operation op, int itemIndex)
 {
     OnItemChanged?.Invoke(op, itemIndex);
 }
Esempio n. 27
0
 public Enumerator(SyncList <T> list)
 {
     _list   = list;
     _index  = -1;
     Current = default;
 }
        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);
                });
            }
        }
 void NetPlayerDatasChanged(SyncList <NetPlayerData> .Operation op, int itemIndex)
 {
     Debug.Log("NetPlayerDatas changed:" + op);
 }
Esempio n. 30
0
 void Test(SyncList <int> .Operation op, int itemIndex)
 {
     Debug.Log("Score " + itemIndex + " changed: " + op);
 }
Esempio n. 31
0
        public static void Main(string[] args)
        {
            Dictionary <string, SyncItem> serverhashes = null;
            SyncList LocalData = null;

            Console.WriteLine("Startup.  ");

            //read teh settings file
            Settings.ReadConfigFile(Settings.CONFIG_FILE_CLIENT);

            Console.WriteLine("Getting file list");
            //get the server hashlist
            try {
                serverhashes = Http.GetHashList();
            } catch (Exception ex) {
                Console.WriteLine("Something went wrong gettin'  our remote hashes. Oops.\n" + ex.Message);
                return;
            }

            Console.WriteLine("getting local files");
            //hash all teh local files.
            try {
                LocalData = new SyncList(Settings.LocalDirectory);
                Console.WriteLine("hashed:" + LocalData.HashList.Count);

                LocalData.saveSyncList(Settings.HashCache);
            } catch (Exception ex) {
                Console.WriteLine("Problems readin' local directory. Oops\n" + ex.Message);
                return;
            }


            List <string> FilesToDownload = new List <string> ();

            //get the delta list
            foreach (KeyValuePair <string, SyncItem> kvp in serverhashes)
            {
                //ignore metadata.
                if (kvp.Key == "__Server" || kvp.Key == "__DateGeneratedUTC")
                {
                    ;
                }
                else
                {
                    //Queue downloads
                    if (!LocalData.HashList.ContainsKey(kvp.Key))
                    {
                        //downlaod files that dont exist.
                        FilesToDownload.Add(kvp.Key);
                        Console.WriteLine("New File: " + kvp.Key);
                    }
                    else
                    {
                        if (kvp.Value.Hash != LocalData.HashList [kvp.Key].Hash)
                        {
                            //download files the dont mathc the hash
                            FilesToDownload.Add(kvp.Key);
                            Console.WriteLine(String.Format("hash mismatch: {0}  ;local{2}, remote {1}", kvp.Key, kvp.Value.Hash, LocalData.HashList [kvp.Key].Hash));
                        }
                        else
                        {
                            //if we get here the file exist and is right.
                            //get it out of the hash list so we dont delrte it.
                            bool okay = LocalData.HashList.Remove(kvp.Key);
                            //Console.WriteLine ("File OK: " + kvp.Key+ "okay"+okay);
                        }
                    }
                }
            }

            //Remove Files if set to
            if (Settings.RemoveLocalFileIfNoRemoteFile)
            {
                bool shouldDelete = true;
                //ensure we didnt delte everything accidentally.
                if (LocalData.HashList.Count > Settings.numFilesToRemoveWithNoWarning)
                {
                    shouldDelete = false;
                    Console.Write(LocalData.HashList.Count + " Files Are flagged for deletion, Remove them (Y/N)");
                    char key = (char)Console.Read();

                    if (key == 'Y' || key == 'y')
                    {
                        shouldDelete = true;
                    }
                }


                //remove files
                if (shouldDelete)
                {
                    foreach (KeyValuePair <string, SyncItem> kvp in LocalData.HashList)
                    {
                        File.Delete(Settings.LocalDirectory + kvp.Key);
                        Console.WriteLine("removed: " + kvp.Key);
                    }
                }
            }

            //DOWNLOADS
            Console.WriteLine("Need to download: " + FilesToDownload.Count + " from " + Settings.DownloadType);
            int progress = 0;



            int tasklimit = 10;

            int nextFile = 0;
            GetObjectRequest request;
            AmazonS3Client   s3 = new  AmazonS3Client(Settings.s3IDKey, Settings.s3SecretKey);

            while (nextFile < FilesToDownload.Count || DownloadCount > 0)
            {
                if (DownloadCount < tasklimit && nextFile < FilesToDownload.Count)
                {
                    request            = new GetObjectRequest();
                    request.BucketName = Settings.s3Bucket;
                    request.Key        = FilesToDownload[nextFile].Substring(1); //use substring so we elminate the /
                    request.Timeout    = 1000;                                   //wait 1 minute for a  response.
                    Console.WriteLine(nextFile + "/" + FilesToDownload.Count + " " + request.Key);

                    s3.BeginGetObject(request, DownloadFile, s3);
                    nextFile++;
                    DownloadCount++;
                }
            }



            Console.WriteLine("Downloaded " + (nextFile - ErrorCount) + "/" + FilesToDownload.Count + " File");

            if (nextFile - ErrorCount != FilesToDownload.Count)
            {
                Console.WriteLine("WARNING: NOT ALL FILES WERE SUCCESSFULLY DOWNLOADED");
                Console.WriteLine("         YOU SHOULD RUN THIS TOOL AGAIN.");
            }
            Console.WriteLine("Press any key to close.");
            Console.ReadKey();
        }
Esempio n. 32
0
 public void SyncSprites(SyncList <int> .Operation op, int index)
 {
     clothingSlots[index].Reference = syncEquipSprites[index];
 }
Esempio n. 33
0
 private void OnAllowedWeaponsChanged(SyncList <string> .Operation op, int itemindex, string olditem, string newitem)
 {
     Debug.Log($"Allowed weapon {newitem}");
 }
 private void OnConnectedPlayersChanged(SyncList <string> .Operation op, int itemindex)
 {
     PlayersSelection.ClearOptions();
     PlayersSelection.AddOptions(m_ConnectedPlayerNames.ToArray());
 }
Esempio n. 35
0
		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 );
		}
Esempio n. 36
0
 private void OnInventoryUpdate(SyncList <int> .Operation op, int itemIndex, int oldItem, int newItem)
 {
     // TODO: Update UI
 }
Esempio n. 37
0
        private static bool Prefix(Generator079 __instance, GameObject person, PlayerInteract.Generator079Operations command)
        {
            try
            {
                API.Features.Player player = API.Features.Player.Get(person);

                switch (command)
                {
                case PlayerInteract.Generator079Operations.Door:
                    bool isAllowed = true;

                    switch (__instance.isDoorOpen)
                    {
                    case false:
                        var openingEventArgs = new OpeningGeneratorEventArgs(player, __instance, isAllowed);

                        Player.OnOpeningGenerator(openingEventArgs);

                        isAllowed = openingEventArgs.IsAllowed;
                        break;

                    case true:
                        var closingEventArgs = new ClosingGeneratorEventArgs(player, __instance, isAllowed);

                        Player.OnClosingGenerator(closingEventArgs);

                        isAllowed = closingEventArgs.IsAllowed;
                        break;
                    }

                    if (isAllowed)
                    {
                        __instance.OpenClose(person);
                    }
                    else
                    {
                        __instance.RpcDenied();
                    }
                    break;

                case PlayerInteract.Generator079Operations.Tablet:
                    if (__instance.isTabletConnected || !__instance.isDoorOpen || (__instance._localTime <= 0.0 || Generator079.mainGenerator.forcedOvercharge))
                    {
                        break;
                    }
                    Inventory component = person.GetComponent <Inventory>();
                    using (SyncList <Inventory.SyncItemInfo> .SyncListEnumerator enumerator = component.items.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Inventory.SyncItemInfo current = enumerator.Current;
                            if (current.id == ItemType.WeaponManagerTablet)
                            {
                                var insertingEventArgs = new InsertingGeneratorTabletEventArgs(player, __instance);

                                Player.OnInsertingGeneratorTablet(insertingEventArgs);

                                if (insertingEventArgs.IsAllowed)
                                {
                                    component.items.Remove(current);
                                    __instance.NetworkisTabletConnected = true;
                                }

                                break;
                            }
                        }

                        break;
                    }

                case PlayerInteract.Generator079Operations.Cancel:
                    var ejectingEventArgs = new EjectingGeneratorTabletEventArgs(player, __instance);

                    Player.OnEjectingGeneratorTablet(ejectingEventArgs);

                    if (ejectingEventArgs.IsAllowed)
                    {
                        __instance.EjectTablet();
                    }

                    break;
                }

                return(false);
            }
            catch (Exception exception)
            {
                API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.InsertingGeneratorTablet: {exception}\n{exception.StackTrace}");

                return(true);
            }
        }
Esempio n. 38
0
 private void OnChatUpdated(SyncList <ChatMessageNew> .Operation op, int itemIndex, ChatMessageNew item)
 {
     chatline.text += "[" + item.sender + "] - " + item.messsage + "\n";
 }
Esempio n. 39
0
        public void SearchMatches(SyncList <IMatchVw> lMatchesToSync, string sSearch, string sLanguage, DelegateFilterMatches dfm)
        {
            CheckTime ct = new CheckTime(false, "SearchMatches('{0}', '{1}') entered", sSearch, sLanguage);

            lock (m_oReadLocker)
            {
                if (lMatchesToSync != null)
                {
                    HashSet <IMatchVw> hsMatches   = new HashSet <IMatchVw>();
                    SyncList <MatchLn> lAllMatches = m_diAll.Matches.ToSyncList();

                    if (!string.IsNullOrEmpty(sSearch))
                    {
                        ct.AddEvent("Search by string in {0} matches", lAllMatches.Count);

                        IdentityList ilGroups      = new IdentityList();
                        IdentityList ilCompetitors = new IdentityList();

                        m_diAll.TaggedStrings.SearchRelatedStrings(sSearch, sLanguage, ilGroups, ilCompetitors);

                        int  iCode     = 0;
                        bool bIsNumber = int.TryParse(sSearch, out iCode) && 0 < iCode && iCode < MAX_MATCH_CODE;

                        if (ilCompetitors.Count > 0 || bIsNumber)
                        {
                            foreach (var mtch in lAllMatches)
                            {
#if DEBUG || TRACE_ID_FROM_FILE
                                if (TraceHelper.TraceFromFileLongValues("MatchIds.txt", (long)mtch.MatchId, new TraceHelper.DelegateLongFromRegistryFound(MatchIdFromFileFound), mtch))
                                {
                                    // Put breakpoint here to catch certain match by mtch.MatchId
                                }
#endif
                                string sCode = mtch.Code.Value.ToString("G");

                                if (sCode.IndexOf(sSearch, StringComparison.OrdinalIgnoreCase) >= 0 || ilCompetitors.Contains(mtch.HomeCompetitorId.Value) || ilCompetitors.Contains(mtch.AwayCompetitorId.Value))
                                {
                                    SearchMatchImp(hsMatches, lMatchesToSync, mtch, dfm);
                                }
                                //else
                                //{
                                //    SyncList<GroupLn> lGroups = LineSr.Instance.AllObjects.MatchesToGroups.GetMatchGroups(mtch.MatchId);

                                //    foreach (GroupLn group in lGroups)
                                //    {
                                //        if (ilGroups.Contains(group.GroupId))
                                //        {
                                //            SearchMatchImp(hsMatches, lMatchesToSync, mtch, dfm);
                                //        }
                                //    }
                                //}
                            }
                        }
                    }
                    else
                    {
                        ct.AddEvent("Search directly in {0} matches", lAllMatches.Count);

                        foreach (var mtch in lAllMatches)
                        {
#if DEBUG || TRACE_ID_FROM_FILE
                            if (TraceHelper.TraceFromFileLongValues("MatchIds.txt", (long)mtch.MatchId, new TraceHelper.DelegateLongFromRegistryFound(MatchIdFromFileFound), mtch))
                            {
                                // Put breakpoint here to catch certain match by mtch.MatchId
                            }
#endif
                            SearchMatchImp(hsMatches, lMatchesToSync, mtch, dfm);
                        }
                    }

                    ct.AddEvent("Search Completed");

                    for (int i = 0; i < lMatchesToSync.Count;)
                    {
                        IMatchVw matchView = lMatchesToSync[i];

                        if (!hsMatches.Contains(matchView))
                        {
                            lMatchesToSync.RemoveAt(i);
                        }
                        else
                        {
                            i++;
                        }
                    }

                    ct.AddEvent("Remove Completed");
                }
            }

            ct.AddEvent("Completed (Found {0} match(es))", lMatchesToSync.Count);
            ct.Info(m_logger);
        }