Ejemplo n.º 1
0
        public static void setupFileWatcher(WatchListControl list)
        {
            try
            {
                m_WatchFileChangedList = new ThreadSafeList<string>(100);

                FileInfo fi = new FileInfo(list.DataFileCompletePath);

                string fileName = fi.Name;
                string directory = fi.Directory.ToString();

                // Create a new FileSystemWatcher and set its properties.
                list.Watcher = new FileSystemWatcher();
                list.Watcher.Path = directory;
                list.Watcher.Filter = fileName; // filter out all but this one file, its all we want to watch
                /* Watch for changes in LastAccess and LastWrite times */
                //    wlItem.watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite;
                list.Watcher.NotifyFilter = NotifyFilters.LastWrite;

                // Add event handlers.
                list.Watcher.Changed += new FileSystemEventHandler(OnWatchFileChanged);
                // Begin watching.
                list.Watcher.EnableRaisingEvents = true;

            }
            catch (Exception ex)
            {
                ErrorLog.Trace(ex );
            }
        }
Ejemplo n.º 2
0
 public Chat(Client c, XmppClientConnection xmpp)
 {
     _client = c;
     Rooms = new ThreadSafeList<NewChatRoom>();
     _xmpp = xmpp;
     _xmpp.OnMessage += XmppOnOnMessage;
 }
Ejemplo n.º 3
0
 public Game()
 {
     Messages = new List<string>();
     Players = new ThreadSafeList<Player>();
     ActorList = new List<Actor>();
     BulletList = new List<Bullet>();
     Map = new Map();
 }
Ejemplo n.º 4
0
        public void ThreadSafeListCopyTest()
        {
            var list1 = new ThreadSafeList<QuoteData>();
            var list2 = new ThreadSafeList<int>();

            list1.AddRange(new[] {new QuoteData(1, 2, DateTime.Now), null}, 1000);
            list2.AddRange(new[] {1, 2, 3}, 1000);

            var found1 = list1.Find(x => true, x => new QuoteData(x), 1000);
            Assert.IsTrue(found1.ask == 2 && found1.bid == 1);
            var found2 = list1.Find(x => x == null, x => new QuoteData(x), 1000);
            Assert.IsNull(found2);
            found2 = list1.Find(x => x.ask == 100, x => new QuoteData(x), 1000);
            Assert.IsNull(found2);

            var found3 = list2.Find(x => x == 2, x => x, 1000);
            Assert.IsTrue(found3 == 2);
            found3 = list2.Find(x => x == 100, x => x, 1000);
            Assert.AreEqual(found3, default(int));
        }
Ejemplo n.º 5
0
        public PlayerSlotCollection(int numSlots)
        {
            SlotList = new ThreadSafeList<PlayerSlot>(numSlots);

            PlayerSlot previous = null;
            PlayerSlot current = null;
            for (int i = 0; i < numSlots; i++)
            {
                current = new PlayerSlot(i, SyncLock);

                if (previous != null)
                    previous.FillNextSlot(current);

                SlotList.Add(current);

                previous = current;
            }

            //-- Link the last slot to the first.
            current.FillNextSlot(SlotList[0]);
        }
Ejemplo n.º 6
0
 public MutableFace(Face face)
 {
     Vertices = new ThreadSafeList <MutableVertex>(face.Vertices.Select(x => new MutableVertex(x)));
     Texture  = face.Texture.Clone();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 静态构造函数
 /// </summary>
 static JobScheduler()
 {
     taskScheduler = new ThreadSafeList <Job>();
 }
Ejemplo n.º 8
0
Archivo: Users.cs Proyecto: timfplab/fp
 public Users()
 {
     Items = new ThreadSafeList <UserItem>();
 }
Ejemplo n.º 9
0
 public Computers()
 {
     itemsField = new ThreadSafeList <ComputersItem>();
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Create the grid
        /// </summary>
        private void DrawGrid()
        {
            HelixGrid = null;

            var newLines = new ThreadSafeList<Point3D>();

            for (int x = -10; x <= 10; x++)
            {
                newLines.Add(new Point3D(x, -10, -.001));
                newLines.Add(new Point3D(x, 10, -.001));
            }

            for (int y = -10; y <= 10; y++)
            {
                newLines.Add(new Point3D(-10, y, -.001));
                newLines.Add(new Point3D(10, y, -.001));
            }

            HelixGrid = newLines;
        }
Ejemplo n.º 11
0
 public AutoCopyItem(string ae)
 {
     SourceAE = ae;
     Datasets = new ThreadSafeList <string>();
 }
Ejemplo n.º 12
0
 public SyncProcessor(CommandHandler commandHandler, ThreadSafeList <CustomFileHash> changedFilesList)
 {
     _commandHandler   = commandHandler;
     _changedFilesList = changedFilesList;
 }
Ejemplo n.º 13
0
        public byte[][] getFilesToUpload()
        {
            this.checkAuthentication();
            this.checkTransactionIsEnabled();

            necessaryFiles = new ThreadSafeList<FBFile>(FBVersion.getNecessaryFilesToUpgrade(this.inSyncVersion, this.realFiles.filesAlreadyRepresented()));
            this.uploadedFiles = new PhysicFilesList();

            byte[][] ret = new byte[necessaryFiles.Count][];
            for (int i = 0; i < necessaryFiles.Count; ++i)
            {
                ret[i] = necessaryFiles.ElementAt(i).serialize();
            }
            return ret;
        }
Ejemplo n.º 14
0
 public OutPort(int number)
 {
     portNumber   = number;
     packetBuffer = new ThreadSafeList <MPLSPacket>();
 }
Ejemplo n.º 15
0
 public MPLSPack(ThreadSafeList <MPLSPacket> packets)
 {
     this.packets = packets;
 }
Ejemplo n.º 16
0
        private async void btnConnectAuto_Click(object sender, EventArgs e)
        {
            try
            {
                Context.InAutoMode = true;

                if (Helper.TraceEnabled)
                {
                    Logger.InitLogger(true);
                    _loggerTask = Task.Factory.StartNew(LoggerAction);
                }
                else
                {
                    Logger.InitLogger();
                    _loggerTask = null;
                }


                var changedFilesList      = new ThreadSafeList <CustomFileHash>();
                var commandResponseBuffer = new BufferBlock <byte[]>();

                var tcpClient = new TcpClient(txtHostAuto.Text, Int32.Parse(txtPortAuto.Text));
                _tcpCommunication = new TcpCommunication(tcpClient, commandResponseBuffer, changedFilesList);


                var connectionBytes = Encoding.UTF8.GetBytes(txtUsername.Text + ":" + txtUserpassword.Text + ":");
                _tcpCommunication.SendCommand(connectionBytes, 0, connectionBytes.Length);
                await _tcpCommunication.CommandResponseBuffer.OutputAvailableAsync();

                var response = _tcpCommunication.CommandResponseBuffer.Receive();
                var message  = Encoding.UTF8.GetString(response).Split(':');
                if (message[0].Equals("Error"))
                {
                    MessageBox.Show(message[1], @"Invalid user or password");
                    _tcpCommunication.Dispose();
                }
                else
                {
                    SwitchAutoUiState(UiConnectedState);
                    Context.CurrentUser = txtUsername.Text;
                    _commandHandler     = new CommandHandler(_tcpCommunication);

                    Logger.WriteInitialSyncBreakLine();
                    var filesForInitialSync = await DetermineFilesForInitialSync();

                    _syncProcessor = new SyncProcessor(_commandHandler, changedFilesList);
                    filesForInitialSync.ForEach(_syncProcessor.AddChangedFile);
                    await _syncProcessor.ChangedFileManager();

                    Logger.WriteSyncBreakLine();
                    changedFilesList.OnAdd += changedFilesList_OnAdd;
                    _myFsWatcher            = new MyFsWatcher(txtDefaultFolderAuto.Text, _syncProcessor);
                }
            }
            catch (FormatException fex)
            {
                var str = "Message: " + fex.Message +
                          "\nSource: " + fex.Source +
                          "\nStackTrace: " + fex.StackTrace;
                MessageBox.Show(str, @"Syncroniser - FormatException");
                SwitchAutoUiState(false);
                MessageBox.Show(fex.Message);
            }
            catch (Exception ex)
            {
                var str = "Message: " + ex.Message +
                          "\nSource: " + ex.Source +
                          "\nStackTrace: " + ex.StackTrace;
                MessageBox.Show(str, @"Syncroniser - Exception");
                SwitchAutoUiState(false);
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 17
0
Archivo: DVR.cs Proyecto: mutita/anpr
        // constructor
        public DVR(APPLICATION_DATA appData)
        {
            try
            {
                m_AppData = appData;
                m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
                m_Log = (ErrorLog)m_AppData.Logger;

                PauseFlag = new PAUSE_FLAG();

                PauseFlag.Pause = true;

                FileAccessControl = new FILE_SYSTEM_ACCESS(PauseFlag, m_AppData);

                try
                {
                    Paths = new PATHS(m_AppData.ThisComputerName, true, m_AppData);

                    m_AppData.PathManager = (object)Paths;
                }
                catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }

                m_EventLogFile = new EventLogFiles.EventLogFiles(m_AppData);

                //   PRE MOTION BUFFER LENGHT

                m_NumberOfFramesToPrePostBuffer = 30;      // this many frames before and after moton event, if too small, files may be erased before motion is detected because of processing lag

                ////////



                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveName].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveReady].boolean.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_FreeSpace].SnapshotDouble.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_UsedSpace].SnapshotDouble.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveHotSwap].StatString.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Drive].StatString.SetValue = "No drive ";

                m_FrameGenerator = (FrameGenerator)m_AppData.FrameGenerator;


                m_DriveManager = new DriveManager(m_AppData, OnExternalDriveChange, Paths.StorageDir);

                // alway use external storage

                if (m_AppData.RunninAsService)
                {
                    int count = 0;
                    Paths.Drive           = m_DriveManager.GetDrive(ref count);
                    PauseFlag.DriveExists = true;
                    if (count > 1)
                    {
                        PauseFlag.Pause = true;
                        m_Log.Log("Too many external drives on start", ErrorLog.LOG_TYPE.FATAL);
                        //m_MessageBoxMessage = "Too many external drives on start. Please connect only one external drive and re-start the LPR Service.";
                        //RunMessageBoxDialog();
                    }
                    else if (Paths.Drive == null)
                    {
                        PauseFlag.Pause = true;

                        m_Log.Log("External Drive not found", ErrorLog.LOG_TYPE.FATAL);
                        //  m_MessageBoxMessage = "External drive not found. Please connect one external drive";
                        PauseFlag.DriveExists = false;
                        // RunMessageBoxDialog();
                    }
                }



                m_ConsumerID = m_FrameGenerator.GetNewConsumerID();

                m_NewFrameQ         = new ThreadSafeQueue <FRAME>(240, "QueueOverruns_DVR_NewFrameQ", m_AppData);
                m_MotionDetectedQ   = new ThreadSafeQueue <FRAME>(240, "QueueOverruns_DVR_MotionDetectedQ", m_AppData);
                m_DirectyToStorageQ = new ThreadSafeQueue <FRAME>(240, "QueueOverruns_DVR_DirectyToStorageQ", m_AppData);
                m_NewLPRRecordQ     = new ThreadSafeQueue <FRAME>(m_LPRRecordQueLen, "QueueOverruns_DVR_NewLPRRecordQ", m_AppData);
                m_TempFileList      = new ThreadSafeList <TEMPFILES>(120);


                m_NumSourceChannels = (m_AppData.RunninAsService) ? m_AppData.MAX_PHYSICAL_CHANNELS : m_AppData.MAX_VIRTUAL_CHANNELS;

                m_PreMotionRecords = new PRE_MOTION_RECORDS[m_NumSourceChannels];

                m_DVRLoopThread = new Thread(DVRLoop);

                m_ReportDVRStats = new Thread(ReportDVRStatusLoop);

                m_TempFileCleanUpThread = new Thread(TempFilesCleanUpLoop);

                m_MaintainFileSystemSizeLimit = new Thread(MaintainFileSystemSizeLimitLoop);
            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
        }
Ejemplo n.º 18
0
        public TcpCommunication(TcpClient tcpClient, BufferBlock <byte[]> commandResponseBuffer, ThreadSafeList <CustomFileHash> changedFilesList)
        {
            try
            {
                _tcpClient            = tcpClient;
                _networkStream        = tcpClient.GetStream();
                CommandResponseBuffer = commandResponseBuffer;
                ChangedFilesList      = changedFilesList;

                Task.Factory.StartNew(AsyncReading());
            }
            catch (ArgumentNullException e)
            {
                throw new Exception("ArgumentNullException: " + e);
            }
            catch (SocketException e)
            {
                throw new Exception("SocketException: " + e);
            }
        }
Ejemplo n.º 19
0
            public CHANNEL(int idx)
            {
                index = idx;

                name = idx.ToString(); // default channel name

                singleton = new object();
                m_NewImageCallBackList = new ThreadSafeList<ConsumerNotificationInfo>(30);
                m_MotionDetectedCallBackList = new ThreadSafeList<ConsumerNotificationInfo>(30);
            }
Ejemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        public void GetServersFromIPs()
        {
            var lstDomains = new List <string>();

            if (!string.IsNullOrEmpty(Project.Domain))
            {
                lstDomains.Add(Project.Domain);
            }
            lstDomains.AddRange(Project.AlternativeDomains);

            var lstIPs = new ThreadSafeList <IPsItem>(Ips.Items.Where(IP => Project.Domain == "*" || relations.Items.Any(R => R.Ip.Ip == IP.Ip && lstDomains.Any(D => R.Domain.Domain.ToLower().EndsWith(D.ToLower())))));

            var po = new ParallelOptions();

            if (Program.cfgCurrent.ParallelDnsQueries != 0)
            {
                po.MaxDegreeOfParallelism = Program.cfgCurrent.ParallelDnsQueries;
            }
            Parallel.ForEach(lstIPs, ip =>
            {
                try
                {
                    ComputersItem ci;

                    if (computerIPs.Items.Any(C => C.Ip.Ip == ip.Ip))
                    {
                        ci = computerIPs.Items.First(C => C.Ip.Ip == ip.Ip).Computer;
                    }

                    else
                    {
                        if (computers.Items.Any(C => relations.Items.Where(R => R.Ip.Ip == ip.Ip).Select(D => D.Domain).Any(D => string.Equals(D.Domain, C.name, StringComparison.OrdinalIgnoreCase))))
                        {
                            ci      = computers.Items.First(C => relations.Items.Where(R => R.Ip.Ip == ip.Ip).Select(D => D.Domain).Any(D => string.Equals(D.Domain, C.name, StringComparison.OrdinalIgnoreCase)));
                            ci.name = string.Format("{0} [{1}]", ci.name, ip.Ip);
                            computerIPs.Items.Add(new ComputerIPsItem(ci, ip, ip.Source));
                        }

                        else
                        {
                            ci = new ComputersItem();
                            computers.Items.Add(ci);
                            ci.type = ComputersItem.Tipo.Server;
                            ci.os   = OperatingSystem.OS.Unknown;

                            var strFirstDomain = string.Empty;

                            try
                            {
                                strFirstDomain = relations.Items.First(R => R.Ip.Ip == ip.Ip && lstDomains.Any(D => R.Domain.Domain.ToLower().EndsWith(D.ToLower()))).Domain.Domain;
                            }
                            catch
                            {
                                strFirstDomain = "*";
                            }

                            ci.name = string.Format("{0} [{1}]", strFirstDomain, ip.Ip);

                            computerIPs.Items.Add(new ComputerIPsItem(ci, ip, ip.Source));
                        }
                    }

                    foreach (DomainsItem di in relations.Items.Where(R => R.Ip.Ip == ip.Ip).Select(D => D.Domain))
                    {
                        if (!computerDomains.Items.Any(C => C.Computer.name == ci.name && C.Domain.Domain == di.Domain))
                        {
                            computerDomains.Items.Add(new ComputerDomainsItem(ci, di, di.Source));
                        }

                        for (var fpI = 0; fpI < di.fingerPrinting.Count(); fpI++)
                        {
                            var fp = di.fingerPrinting[fpI];

                            if ((fp.os != OperatingSystem.OS.Unknown))
                            {
                                ci.os = fp.os;
                            }

                            foreach (var software in BannerAnalysis.GetSoftwareFromBanner(fp.Version).Where(software => !ci.Software.Items.Any(A => A.Name.ToLower() == software.ToLower())))
                            {
                                ci.Software.Items.Add(new ApplicationsItem(software, string.Format("{0} FingerPrinting Banner: {1}", di.Domain, fp.Version)));
                            }
                        }
                    }
                    if (ip.Information != null)
                    {
                        if (!string.IsNullOrEmpty(ip.Information.OS))
                        {
                            var os = OperatingSystemUtils.StringToOS(ip.Information.OS);

                            if (ci.os == OperatingSystem.OS.Unknown && os != OperatingSystem.OS.Unknown)
                            {
                                ci.os = os;
                            }
                        }

                        if (!string.IsNullOrEmpty(ip.Information.ServerBanner))
                        {
                            var os = OperatingSystemUtils.StringToOS(ip.Information.ServerBanner);
                            if (ci.os == OperatingSystem.OS.Unknown && os != OperatingSystem.OS.Unknown)
                            {
                                ci.os = os;
                            }

                            foreach (var software in BannerAnalysis.GetSoftwareFromBanner(ip.Information.ServerBanner).Where(software => !ci.Software.Items.Any(A => A.Name.ToLower() == software.ToLower())))
                            {
                                ci.Software.Items.Add(new ApplicationsItem(software, string.Format("{0} Shodan Banner: {1}", ip, ip.Information.ServerBanner)));
                            }
                        }
                    }
                }
                catch
                {
                }
            });
            OnChangeEvent(null);
        }
Ejemplo n.º 21
0
        public void Setup()
        {
            AddPlayers = new ThreadSafeList<Player>();
            RemovePlayers = new ThreadSafeList<Player>();
            Messages = new ThreadSafeList<string>();

            Game = new Engine.Game();
            if (LoadedMap != null) Game.Map = LoadedMap;
            else
            {
                Game.Map = new Map();
                Game.Map.CreateBasicMap(30, 30);
            }

            // Setup connections
            Server = new ServerManananger();
            Server.NewUserMethod = AddNewUser;
            Server.RemoveUserMethod = RemoveUser;
            Server.UserInputMethod = ReceiveUserInputs;
            ThreadPool.QueueUserWorkItem(o => Server.Start(HostIP));
            InGame = true;
        }
Ejemplo n.º 22
0
        public bool newTransaction(SerializedVersion newVersion)
        {
            this.checkAuthentication();

            if (this.transactionEnabled)
                throw new FaultException<ServiceErrorMessage>(new ServiceErrorMessage(ServiceErrorMessage.TRANSACTIONALREADYENABLED));

            FBVersion vers = FBVersion.deserialize(newVersion.encodedVersion);
            FBVersion current = FBVersion.deserialize(this.getCurrentVersion().encodedVersion);
            if (vers.Equals(current))
            {
                return false;
            }

            this.transactionEnabled = true;
            this.inSyncVersion = vers;

            String newDirPath = this.user.rootDirectory.FullName;
            newDirPath += "\\" + this.inSyncVersion.timestamp.ToString(directoryFormat, CultureInfo.InvariantCulture);
            this.transactDir = Directory.CreateDirectory(newDirPath);
            if (this.transactDir == null)
                throw new FaultException<ServiceErrorMessage>(new ServiceErrorMessage(ServiceErrorMessage.CREATEVERSIONDIRECTORYFAILED));

            necessaryFiles = new ThreadSafeList<FBFile>(FBVersion.getNecessaryFilesToUpgrade(this.inSyncVersion, this.realFiles.filesAlreadyRepresented()));

            return true;
        }
Ejemplo n.º 23
0
 public MapDataCollection()
 {
     Data = new ThreadSafeList <IMapData>();
 }
Ejemplo n.º 24
0
 public MutableSolid(Solid solid)
 {
     Faces = new ThreadSafeList <MutableFace>(solid.Faces.Select(x => new MutableFace(x)));
 }
Ejemplo n.º 25
0
        // auto detect insertion and de-insertion of the USB based 2255 frame grabbers
        //
        //  polling loop checks the OS for a list of connected 2255 devices.
        //
        //  if the detected device count is greater than the connected device count, try to open a new device
        //  if the detected device count is less than the connected device count, close the missing device.

        //  problem: the OS cannot tell me which device is connected/disconnected.
        //   so if we think we lost a device, then check each open device for time stamp at last received frame, and if
        //    its been a while since a frame was received, assume that is the missing frame grabber and close it.

        //  each frame grabber is associated with a device index which is used by the 2255 USB driver to identify a device.
        //  but we have no way of knowing which device index is assigned to a device by the driver except to
        //  attempt to open the device at each index until we get success on OpenDevice(index).  So a test open
        // function is in the S2255Device class which opens and then closes if the open was sucessful.

        //  the S2255Device class is a class which is designed to control a single instance of a 2255 physical device. So if
        //  there are two frame grabbers attached there should be two instances of the S2255Device class.

        unsafe public S2255Controller(PAL_NTSC_MODE mode, APPLICATION_DATA appData, bool [] enableChannels)
        {
            m_PAL_NSTC_mode     = mode;
            m_AppData           = appData;
            m_EabledSysChannels = enableChannels;

            m_Log = (ErrorLog)m_AppData.Logger;
            m_AppData.AddOnClosing(StopThreads, APPLICATION_DATA.CLOSE_ORDER.FIRST); // how to stop this object and its subthreads

            m_VideoStandard = (mode == PAL_NTSC_MODE.NTSC) ? 0 : 1;

            // allocate 2255Device instances
            m_S2255Devices = new ThreadSafeList <S2255Device>(MAX_S2255DEVICE_COUNT);     // max allowed number of connected frame grabbers

            m_DeviceHandlePool = new DeviceValuePoolManager(MAX_2255DEVICE_HANDLE_VALUE); // maximum value of device index that could be assigned by the USB driver

            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_1].StatString.SetValue = "No Device";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_2].StatString.SetValue = "No Device";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel1].StatString.SetValue  = "No Video Connected";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel2].StatString.SetValue  = "No Video Connected";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel3].StatString.SetValue  = "No Video Connected";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel4].StatString.SetValue  = "No Video Connected";


            m_UsedDeviceIndexes = new DeviceValuePoolManager(MAX_S2255DEVICE_COUNT);


            // current channel mapping:
            //   each S2255 device has four ports. a camera will be connected in parrallel to two ports.
            //   one port of the port pair will be setup as jpeg ecoded and the other is raw bitmap

            //  on device 0
            //   port 0 and 1 will be camera channel 0
            //   port 2 and 3 will be camera channel 1
            //  on device 1
            //   port 0 and 1 will be camera channel 2
            //   port 2 and 3 will be camera channel 3

            m_S2255DevicePortChannelMappsings = new S2255DevicePortChannelMappings[MAX_S2255DEVICE_COUNT];// set to 2

            int deviceCounter = 0;

            for (deviceCounter = 0; deviceCounter < m_S2255DevicePortChannelMappsings.Length; deviceCounter++)
            {
                m_S2255DevicePortChannelMappsings[deviceCounter] = new S2255DevicePortChannelMappings();
            }


            ////////////////    assumes MAX_S2255DEVICE_COUNT == 2 , doing port mappins by hand here

            deviceCounter = 0;

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[0] = 0;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[0]  = COMPRESSION_MODE.BITMAP;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[0]          = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[0]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[1] = 0;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[1]  = COMPRESSION_MODE.JPEG;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[1]          = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[1]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[2] = 1;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[2]  = COMPRESSION_MODE.BITMAP;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[2]          = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[2]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[3] = 1;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[3]  = COMPRESSION_MODE.JPEG;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[3]          = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[3]];


            deviceCounter = 1;

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[0] = 2;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[0]  = COMPRESSION_MODE.BITMAP;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[0]          = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[0]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[1] = 2;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[1]  = COMPRESSION_MODE.JPEG;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[1]          = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[1]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[2] = 3;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[2]  = COMPRESSION_MODE.BITMAP;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[2]          = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[2]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[3] = 3;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[3]  = COMPRESSION_MODE.JPEG;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[3]          = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[3]];
        }
Ejemplo n.º 26
0
 public IPs()
 {
     itemsField = new ThreadSafeList <IPsItem>();
 }
Ejemplo n.º 27
0
 private ServiceState()
 {
     AllLogs = new ThreadSafeList<RotatedLog>();
     LastKnownLogHashes = new ThreadSafeDictionary<string, string>();
     HashesOfPendingLogs = new ThreadSafeQueue<string>();
 }
Ejemplo n.º 28
0
 /// <summary>
 ///     constructor, se le pasa una lista de IPs que será sobre las que consultará a Shodan
 /// </summary>
 /// <param name="lstIPs"></param>
 public ShodanRecognition(string secretKey, ThreadSafeList <string> lstIPs)
 {
     ShodanAPIKey = secretKey;
     this.lstIPs  = lstIPs;
 }
Ejemplo n.º 29
0
        /// <summary>
        ///     Extract existing folders from a given list of URLs
        /// </summary>
        /// <param name="lsturls"></param>
        /// <returns></returns>
        private static ThreadSafeList <string> _ExtractFoldersRuntime(IEnumerable <string> lsturls)
        {
            var folders        = new ThreadSafeList <string>();
            var foldersBackups = new ThreadSafeList <string>();

            try
            {
                foreach (var url in lsturls)
                {
                    if (!String.IsNullOrWhiteSpace(url))
                    {
                        var u = new Uri(url);
                        if (u.ToString().EndsWith("//"))
                        {
                            var auxSingleUrl = new ThreadSafeList <string> {
                                u.ToString().Remove(u.ToString().Length - 1, 1)
                            };
                            return(_ExtractFoldersRuntime(auxSingleUrl));
                        }

                        var offSetProtocol = url.IndexOf("://", StringComparison.Ordinal);
                        var protocol       = url.Substring(0, offSetProtocol);

                        var foldersSplit = u.AbsolutePath.Split('/');
                        var path         = string.Empty;

                        for (var i = 0; i < foldersSplit.Length; i++)
                        {
                            if (i + 1 != foldersSplit.Length)
                            {
                                path += foldersSplit[i] + "/";
                            }
                            if (folders.Contains(protocol + "://" + u.Host + path) || path.Contains("."))
                            {
                                continue;
                            }
                            folders.Add(protocol + "://" + u.Host + path);

                            // ToDo use a list provided by the user
                            string[] compressExt = { ".zip", ".rar", ".tar", ".gz", ".tar.gz" };
                            var      path1       = path;
                            foreach (
                                var extension in
                                compressExt.Where(
                                    extension =>
                                    protocol + "://" + u.Host + path1.Substring(0, path1.Length - 1) !=
                                    protocol + "://" + u.Host)
                                .Where(
                                    extension =>
                                    !foldersBackups.Contains(protocol + "://" + u.Host +
                                                             path1.Substring(0, path1.Length - 1) +
                                                             extension)))
                            {
                                foldersBackups.Add(protocol + "://" + u.Host + path.Substring(0, path.Length - 1) +
                                                   extension);
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            return(foldersBackups);
        }
        static public void AsociateFingerPrinting(object sender, EventArgs e)
        {
            // Añade al DomainItem del dominio la información del fingerprinting
            if (sender == null)
            {
                return;
            }
            DomainsItem domain = null;

            if (sender is HTTP)
            {
                HTTP http = (HTTP)sender;

                domain = Program.data.GetDomain(http.Host);
                if (domain != null)
                {
                    domain.fingerPrinting.Add(http);
                }
                else
                {
                    string ip = http.Host;
                    if (ip == null)
                    {
                        return;
                    }
                    ThreadSafeList <DomainsItem> dominiosAsociados = Program.data.GetResolutionDomains(ip);
                    foreach (DomainsItem dAsociado in dominiosAsociados)
                    {
                        dAsociado.fingerPrinting.Add(http);
                    }
                }
            }
            else if (sender is SMTP)
            {
                SMTP smtp = (SMTP)sender;

                domain = Program.data.GetDomain(smtp.Host);
                {
                    domain.fingerPrinting.Add(smtp);
                }
            }
            else if (sender is FTP)
            {
                FTP ftp = (FTP)sender;

                domain = Program.data.GetDomain(ftp.Host);
                {
                    domain.fingerPrinting.Add(ftp);
                }
            }
            else if (sender is DNS)
            {
                DNS dns = (DNS)sender;

                domain = Program.data.GetDomain(dns.Host);
                {
                    domain.fingerPrinting.Add(dns);
                }
            }

            // Actualiza la información de los servidores existentes
            ActualizaSOServidores(domain);
        }
Ejemplo n.º 31
0
        // constructor
        public DVR(APPLICATION_DATA appData)
        {
            try
            {
                m_AppData = appData;
                m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
                m_Log = (ErrorLog)m_AppData.Logger;

                PauseFlag = new PAUSE_FLAG();

                PauseFlag.Pause = true;

                FileAccessControl = new FILE_SYSTEM_ACCESS(PauseFlag, m_AppData);

                try
                {
                    Paths = new PATHS(m_AppData.ThisComputerName, true, m_AppData);

                    m_AppData.PathManager = (object)Paths;
                }
                catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }

                m_EventLogFile = new EventLogFiles.EventLogFiles(m_AppData);

                //   PRE MOTION BUFFER LENGHT

                m_NumberOfFramesToPrePostBuffer =    30;   // this many frames before and after moton event, if too small, files may be erased before motion is detected because of processing lag

                ////////

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveName].StatString.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveReady].boolean.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_FreeSpace].SnapshotDouble.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_UsedSpace].SnapshotDouble.RegisterForUse(true);
                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.DVR.DVR_DriveHotSwap].StatString.RegisterForUse(true);

                m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_Drive].StatString.SetValue = "No drive ";

                m_FrameGenerator = (FrameGenerator)m_AppData.FrameGenerator;

                m_DriveManager = new DriveManager(m_AppData, OnExternalDriveChange, Paths.StorageDir);

                // alway use external storage

                if ( m_AppData.RunninAsService)
                {

                    int count = 0;
                    Paths.Drive = m_DriveManager.GetDrive(ref count);
                    PauseFlag.DriveExists = true;
                    if (count > 1)
                    {
                        PauseFlag.Pause = true;
                        m_Log.Log("Too many external drives on start", ErrorLog.LOG_TYPE.FATAL);
                        //m_MessageBoxMessage = "Too many external drives on start. Please connect only one external drive and re-start the LPR Service.";
                        //RunMessageBoxDialog();

                    }
                    else if (Paths.Drive == null)
                    {
                        PauseFlag.Pause = true;

                        m_Log.Log("External Drive not found", ErrorLog.LOG_TYPE.FATAL);
                      //  m_MessageBoxMessage = "External drive not found. Please connect one external drive";
                        PauseFlag.DriveExists = false;
                       // RunMessageBoxDialog();
                    }

                }

                m_ConsumerID = m_FrameGenerator.GetNewConsumerID();

                m_NewFrameQ = new ThreadSafeQueue<FRAME>(240, "QueueOverruns_DVR_NewFrameQ", m_AppData);
                m_MotionDetectedQ = new ThreadSafeQueue<FRAME>(240, "QueueOverruns_DVR_MotionDetectedQ", m_AppData);
                m_DirectyToStorageQ = new ThreadSafeQueue<FRAME>(240, "QueueOverruns_DVR_DirectyToStorageQ", m_AppData);
                m_NewLPRRecordQ = new ThreadSafeQueue<FRAME>(m_LPRRecordQueLen, "QueueOverruns_DVR_NewLPRRecordQ", m_AppData);
                m_TempFileList = new ThreadSafeList<TEMPFILES>(120);

                m_NumSourceChannels = (m_AppData.RunninAsService) ? m_AppData.MAX_PHYSICAL_CHANNELS : m_AppData.MAX_VIRTUAL_CHANNELS;

                m_PreMotionRecords = new PRE_MOTION_RECORDS[m_NumSourceChannels];

                m_DVRLoopThread = new Thread(DVRLoop);

                m_ReportDVRStats = new Thread(ReportDVRStatusLoop);

                m_TempFileCleanUpThread = new Thread(TempFilesCleanUpLoop);

                m_MaintainFileSystemSizeLimit = new Thread(MaintainFileSystemSizeLimitLoop);

            }
            catch (Exception ex) { m_Log.Trace(ex, ErrorLog.LOG_TYPE.FATAL); }
        }
Ejemplo n.º 32
0
 public Ficheros()
 {
     itemsField = new ThreadSafeList <FilesItem>();
 }
Ejemplo n.º 33
0
 public HiveConnectionTracker()
 {
     records = new ThreadSafeList<HiveConnectionRecord>();
 }
Ejemplo n.º 34
0
        // auto detect insertion and de-insertion of the USB based 2255 frame grabbers
        //
        //  polling loop checks the OS for a list of connected 2255 devices.
        //
        //  if the detected device count is greater than the connected device count, try to open a new device
        //  if the detected device count is less than the connected device count, close the missing device.
        //  problem: the OS cannot tell me which device is connected/disconnected.
        //   so if we think we lost a device, then check each open device for time stamp at last received frame, and if
        //    its been a while since a frame was received, assume that is the missing frame grabber and close it.
        //  each frame grabber is associated with a device index which is used by the 2255 USB driver to identify a device.
        //  but we have no way of knowing which device index is assigned to a device by the driver except to
        //  attempt to open the device at each index until we get success on OpenDevice(index).  So a test open
        // function is in the S2255Device class which opens and then closes if the open was sucessful.
        //  the S2255Device class is a class which is designed to control a single instance of a 2255 physical device. So if
        //  there are two frame grabbers attached there should be two instances of the S2255Device class.
        public unsafe S2255Controller(PAL_NTSC_MODE mode, APPLICATION_DATA appData, bool [] enableChannels)
        {
            m_PAL_NSTC_mode = mode;
            m_AppData = appData;
            m_EabledSysChannels = enableChannels;

            m_Log = (ErrorLog)m_AppData.Logger;
            m_AppData.AddOnClosing(StopThreads, APPLICATION_DATA.CLOSE_ORDER.FIRST); // how to stop this object and its subthreads

            m_VideoStandard = (mode == PAL_NTSC_MODE.NTSC) ? 0 : 1;

            // allocate 2255Device instances
            m_S2255Devices = new ThreadSafeList<S2255Device>(MAX_S2255DEVICE_COUNT); // max allowed number of connected frame grabbers

            m_DeviceHandlePool = new DeviceValuePoolManager(MAX_2255DEVICE_HANDLE_VALUE); // maximum value of device index that could be assigned by the USB driver

            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_1].StatString.SetValue = "No Device";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_frameGrabber_2].StatString.SetValue = "No Device";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel1].StatString.SetValue = "No Video Connected";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel2].StatString.SetValue = "No Video Connected";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel3].StatString.SetValue = "No Video Connected";
            m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.System.System_videoChannel4].StatString.SetValue = "No Video Connected";

            m_UsedDeviceIndexes = new DeviceValuePoolManager(MAX_S2255DEVICE_COUNT);

            // current channel mapping:
            //   each S2255 device has four ports. a camera will be connected in parrallel to two ports.
            //   one port of the port pair will be setup as jpeg ecoded and the other is raw bitmap

            //  on device 0
            //   port 0 and 1 will be camera channel 0
            //   port 2 and 3 will be camera channel 1
            //  on device 1
            //   port 0 and 1 will be camera channel 2
            //   port 2 and 3 will be camera channel 3

            m_S2255DevicePortChannelMappsings = new S2255DevicePortChannelMappings[MAX_S2255DEVICE_COUNT];// set to 2

            int deviceCounter = 0;
            for (deviceCounter = 0; deviceCounter < m_S2255DevicePortChannelMappsings.Length; deviceCounter++)
            {
                m_S2255DevicePortChannelMappsings[deviceCounter] = new S2255DevicePortChannelMappings();
            }

            ////////////////    assumes MAX_S2255DEVICE_COUNT == 2 , doing port mappins by hand here

            deviceCounter = 0;

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[0] = 0;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[0] = COMPRESSION_MODE.BITMAP;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[0] = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[0]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[1] = 0;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[1] = COMPRESSION_MODE.JPEG;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[1] = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[1]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[2] = 1;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[2] = COMPRESSION_MODE.BITMAP;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[2] = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[2]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[3] = 1;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[3] = COMPRESSION_MODE.JPEG;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[3] = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[3]];

            deviceCounter = 1;

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[0] = 2;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[0] = COMPRESSION_MODE.BITMAP;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[0] = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[0]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[1] = 2;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[1] = COMPRESSION_MODE.JPEG;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[1] = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[1]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[2] = 3;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[2] = COMPRESSION_MODE.BITMAP;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[2] = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[2]];

            m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[3] = 3;
            m_S2255DevicePortChannelMappsings[deviceCounter].compressionMode[3] = COMPRESSION_MODE.JPEG;
            m_S2255DevicePortChannelMappsings[deviceCounter].enabled[3] = m_EabledSysChannels[m_S2255DevicePortChannelMappsings[deviceCounter].globalChannIndex[3]];
        }
Ejemplo n.º 35
0
 public MutableFace(IEnumerable <Vector3> vertices, Primitives.Texture texture)
 {
     Vertices = new ThreadSafeList <MutableVertex>(vertices.Select(x => new MutableVertex(x)));
     Texture  = texture;
 }
Ejemplo n.º 36
0
 public Domains()
 {
     itemsField = new ThreadSafeList <DomainsItem>();
 }
Ejemplo n.º 37
0
        /// <summary>
        /// A utility method for merging multiple meshes into one.
        /// </summary>
        /// <param name="meshes"></param>
        /// <returns></returns>
        public static MeshGeometry3D MergeMeshes(ThreadSafeList<MeshGeometry3D> meshes)
        {
            if (meshes.Count == 0)
                return null;

            int offset = 0;

            var builder = new MeshBuilder();

            foreach (MeshGeometry3D m in meshes)
            {
                foreach (var pos in m.Positions)
                {
                    builder.Positions.Add(pos);
                }
                foreach (var index in m.TriangleIndices)
                {
                    builder.TriangleIndices.Add(index + offset);
                }
                foreach (var norm in m.Normals)
                {
                    builder.Normals.Add(norm);
                }
                foreach (var tc in m.TextureCoordinates)
                {
                    builder.TextureCoordinates.Add(tc);
                }

                offset += m.Positions.Count;
            }

            return builder.ToMesh(false);
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Process Network nodes.
        /// </summary>
        static private void NodeNetworkProcess()
        {
            if (Program.data == null)
            {
                return;
            }

            var nServers = 0;

            var tnPCServers = Program.FormMainInstance.TreeView.Nodes[TreeViewKeys.KProject.ToString()].Nodes[TreeViewKeys.KPCServers.ToString()];

            if (tnPCServers != null)
            {
                var lst = new ThreadSafeList <ComputersItem>(Program.data.computers.Items);
                foreach (var computer in lst)
                {
                    Application.DoEvents();

                    TreeNode tn = null;
                    switch (computer.type)
                    {
                    case ComputersItem.Tipo.ClientPC:
                    {
                        tn = tnPCServers.Nodes["Clients"].Nodes[computer.name];
                        if (tn == null)
                        {
                            var insertAtIndex = Program.FormMainInstance.SearchTextInNodes(tnPCServers.Nodes["Clients"].Nodes, computer.name);
                            tn = tnPCServers.Nodes["Clients"].Nodes.Insert(insertAtIndex, computer.name, computer.name);
                            tn.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                        }
                        else
                        {
                            tn.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                        }
                    }
                    break;

                    case ComputersItem.Tipo.Server:
                    {
                        //Si no tiene una IP asociada añadir al nodo de servidores desconocidos
                        if (!Program.data.computerIPs.Items.Any(C => C.Computer.name == computer.name))
                        {
                            Object x = Program.FormMainInstance.TreeView;
                            if (tnPCServers.Nodes["Servers"].Nodes["Unlocated Servers"].Nodes[computer.name] != null)
                            {
                                tn = tnPCServers.Nodes["Servers"].Nodes["Unlocated Servers"].Nodes[computer.name];
                            }
                            else
                            {
                                int insertAtIndex = Program.FormMainInstance.SearchTextInNodes(tnPCServers.Nodes["Servers"].Nodes["Unlocated Servers"].Nodes, computer.name);
                                tn = tnPCServers.Nodes["Servers"].Nodes["Unlocated Servers"].Nodes.Insert(insertAtIndex, computer.name, computer.name);
                                tn.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                            }
                            if (tn == null)
                            {
                                return;
                            }
                        }
                        else         //Como tiene una IP asociada insertar en su rango
                        {
                            string strIP = Program.data.computerIPs.Items.First(C => C.Computer.name == computer.name).Ip.Ip;

                            if (Program.data.Project.IsIpInNetrange(strIP) == false)
                            {
                                continue;
                            }

                            bool found = false;
                            foreach (RelationsItem relation in Program.data.relations.Items.Where(S => S.Ip.Ip == strIP))
                            {
                                if (relation.Domain.Domain.Contains(Program.data.Project.Domain) == true)
                                {
                                    found = true;
                                }

                                foreach (string auxDom in Program.data.Project.AlternativeDomains)
                                {
                                    if (relation.Domain.Domain.Contains(auxDom))
                                    {
                                        found = true;
                                    }
                                }
                            }

                            if ((found == false) && (DNSUtil.IsIPv4(strIP)))
                            {
                                if (Program.data.IsIpInLimitRange(strIP))
                                {
                                    found = true;
                                }
                            }

                            if (found == false)
                            {
                                continue;
                            }


                            //Comprobar que existe el rango
                            if (DNSUtil.IsIPv4(strIP))
                            {
                                byte[] IPBytes = DNSUtil.IPToByte(strIP);
                                //Dependiendo de la calse de Ip que sea tiene que dibujarla a una profundidad u otra
                                //IP de clase A
                                if (IPBytes[0] >= 1 && IPBytes[0] < 128)
                                {
                                    TreeNode tnIP    = null;
                                    string   iprange = string.Format("{0}.0.0.0", IPBytes[0]);

                                    if (tnPCServers.Nodes["Servers"].Nodes[iprange] != null)
                                    {
                                        tnIP = tnPCServers.Nodes["Servers"].Nodes[iprange];
                                    }
                                    else
                                    {
                                        tnIP = tnPCServers.Nodes["Servers"].Nodes.Insert(Program.FormMainInstance.SearchTextInNodes(tnPCServers.Nodes["Servers"].Nodes, iprange), iprange, iprange);
                                        tnIP.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                                        tnIP.ImageIndex       = tnIP.SelectedImageIndex = 18;
                                        tnIP.Tag = "iprange";
                                    }
                                    if (tnIP == null)
                                    {
                                        return;
                                    }
                                    iprange = string.Format("{0}.{1}.0.0", IPBytes[0], IPBytes[1]);
                                    if (tnIP.Nodes[iprange] != null)
                                    {
                                        tnIP = tnIP.Nodes[iprange];
                                    }
                                    else
                                    {
                                        tnIP = tnIP.Nodes.Insert(Program.FormMainInstance.SearchTextInNodes(tnIP.Nodes, iprange), iprange, iprange);
                                        tnIP.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                                        tnIP.ImageIndex       = tnIP.SelectedImageIndex = 18;
                                        tnIP.Tag = "iprange";
                                    }
                                    if (tnIP == null)
                                    {
                                        return;
                                    }
                                    iprange = string.Format("{0}.{1}.{2}.0", IPBytes[0], IPBytes[1], IPBytes[2]);
                                    if (tnIP.Nodes[iprange] != null)
                                    {
                                        tnIP = tnIP.Nodes[iprange];
                                    }
                                    else
                                    {
                                        tnIP = tnIP.Nodes.Insert(Program.FormMainInstance.SearchTextInNodes(tnIP.Nodes, iprange), iprange, iprange);
                                        tnIP.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                                        tnIP.ImageIndex       = tnIP.SelectedImageIndex = 18;
                                        tnIP.Tag = "iprange";
                                    }
                                    iprange = string.Format("{0}.{1}.{2}.{3}", IPBytes[0], IPBytes[1], IPBytes[2], IPBytes[3]);
                                    if (tnIP.Nodes[iprange] != null)
                                    {
                                        tn = tnIP.Nodes[iprange];
                                    }
                                    else
                                    {
                                        tn = tnIP.Nodes.Insert(Program.FormMainInstance.SearchTextInNodes(tnIP.Nodes, iprange), iprange, computer.name);
                                        tn.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                                    }
                                    if (tn == null)
                                    {
                                        return;
                                    }
                                }
                                //IP de clase B
                                else if (IPBytes[0] >= 128 && IPBytes[0] < 192)
                                {
                                    TreeNode tnIP    = null;
                                    string   iprange = string.Format("{0}.{1}.0.0", IPBytes[0], IPBytes[1]);
                                    if (tnPCServers.Nodes["Servers"].Nodes[iprange] != null)
                                    {
                                        tnIP = tnPCServers.Nodes["Servers"].Nodes[iprange];
                                    }
                                    else
                                    {
                                        tnIP = tnPCServers.Nodes["Servers"].Nodes.Insert(Program.FormMainInstance.SearchTextInNodes(tnPCServers.Nodes["Servers"].Nodes, iprange), iprange, iprange);
                                        tnIP.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                                        tnIP.ImageIndex       = tnIP.SelectedImageIndex = 18;
                                        tnIP.Tag = "iprange";
                                    }
                                    if (tnIP == null)
                                    {
                                        return;
                                    }
                                    iprange = string.Format("{0}.{1}.{2}.0", IPBytes[0], IPBytes[1], IPBytes[2]);
                                    if (tnIP.Nodes[iprange] != null)
                                    {
                                        tnIP = tnIP.Nodes[iprange];
                                    }
                                    else
                                    {
                                        tnIP = tnIP.Nodes.Insert(Program.FormMainInstance.SearchTextInNodes(tnIP.Nodes, iprange), iprange, iprange);
                                        tnIP.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                                        tnIP.ImageIndex       = tnIP.SelectedImageIndex = 18;
                                        tnIP.Tag = "iprange";
                                    }
                                    iprange = string.Format("{0}.{1}.{2}.{3}", IPBytes[0], IPBytes[1], IPBytes[2], IPBytes[3]);
                                    if (tnIP.Nodes[iprange] != null)
                                    {
                                        tn = tnIP.Nodes[iprange];
                                    }
                                    else
                                    {
                                        tn = tnIP.Nodes.Insert(Program.FormMainInstance.SearchTextInNodes(tnIP.Nodes, iprange), iprange, computer.name);
                                        tn.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                                    }
                                }
                                //IP de clase C
                                else if (IPBytes[0] >= 192 && IPBytes[0] < 240)
                                {
                                    TreeNode tnIP    = null;
                                    string   iprange = string.Format("{0}.{1}.{2}.0", IPBytes[0], IPBytes[1], IPBytes[2]);
                                    if (tnPCServers.Nodes["Servers"].Nodes[iprange] != null)
                                    {
                                        tnIP = tnPCServers.Nodes["Servers"].Nodes[iprange];
                                    }
                                    else
                                    {
                                        tnIP = tnPCServers.Nodes["Servers"].Nodes.Insert(Program.FormMainInstance.SearchTextInNodes(tnPCServers.Nodes["Servers"].Nodes, iprange), iprange, iprange);
                                        tnIP.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                                        tnIP.ImageIndex       = tnIP.SelectedImageIndex = 18;
                                        tnIP.Tag = "iprange";
                                    }
                                    if (tnIP == null)
                                    {
                                        return;
                                    }
                                    iprange = string.Format("{0}.{1}.{2}.{3}", IPBytes[0], IPBytes[1], IPBytes[2], IPBytes[3]);
                                    if (tnIP.Nodes[iprange] != null)
                                    {
                                        tn = tnIP.Nodes[iprange];
                                    }
                                    else
                                    {
                                        tn = tnIP.Nodes.Insert(Program.FormMainInstance.SearchTextInNodes(tnIP.Nodes, iprange), iprange, computer.name);
                                        tn.ContextMenuStrip = Program.FormMainInstance.contextMenu;
                                    }
                                }

                                nServers++;
                            }
                            else
                            {
                                //ipv6
                            }
                        }
                    }
                    break;
                    }

                    Program.FormMainInstance.TreeView.Invoke(new MethodInvoker(delegate
                    {
                        if (tn == null)
                        {
                            return;
                        }
                        tn.Tag = computer;


                        if (computer.os != OperatingSystem.OS.Unknown)
                        {
                            tn.ImageIndex = tn.SelectedImageIndex = OperatingSystemUtils.OSToIconNumber(computer.os);
                        }
                        else
                        {
                            tn.ImageIndex = tn.SelectedImageIndex = computer.type == ComputersItem.Tipo.ClientPC ? 111 : 45;
                        }

                        var computersDomain = Program.data.computerDomains.Items;

                        foreach (var cdi in computersDomain.Where(x => x.Computer == computer))
                        {
                            if (cdi.Domain == null)
                            {
                                continue;
                            }

                            if (!(tn.Nodes.ContainsKey(cdi.Domain.Domain)))
                            {
                                var newTn  = new TreeNode(cdi.Domain.Domain);
                                newTn.Text = cdi.Domain.Domain;
                                newTn.Name = cdi.Domain.Domain;
                                newTn.Tag  = cdi;

                                if (cdi.Domain.os == OperatingSystem.OS.Unknown)
                                {
                                    newTn.SelectedImageIndex = newTn.ImageIndex = 90;
                                }
                                else
                                {
                                    newTn.SelectedImageIndex = newTn.ImageIndex = OperatingSystemUtils.OSToIconNumber(cdi.Domain.os);
                                }

                                tn.Nodes.Add(newTn);
                            }
                        }

                        foreach (var cdi in Program.data.computerDomains.Items)
                        {
                            if (cdi.Domain == null)
                            {
                                return;
                            }

                            var oldTn = tn.Nodes[cdi.Domain.Domain];

                            if (oldTn == null)
                            {
                                continue;
                            }

                            if (cdi.Domain == null)
                            {
                                continue;
                            }

                            oldTn.ImageIndex         = OperatingSystemUtils.OSToIconNumber(cdi.Domain.os);
                            oldTn.SelectedImageIndex = oldTn.ImageIndex;

                            OperatingSystem.OS lastOsDom = OperatingSystem.OS.Unknown;
                            var networkDevice            = false;

                            lastOsDom = OperatingSystem.OS.Unknown;
                            foreach (ComputerDomainsItem cdiDom in from TreeNode tnDom in tn.Nodes where tnDom.Tag is ComputerDomainsItem select(ComputerDomainsItem) tnDom.Tag)
                            {
                                if ((cdiDom.Domain.os != lastOsDom) && (cdiDom.Domain.os != OperatingSystem.OS.Unknown) && (lastOsDom != OperatingSystem.OS.Unknown))
                                {
                                    networkDevice = true;
                                    break;
                                }
                                if (cdiDom.Domain.os != OperatingSystem.OS.Unknown)
                                {
                                    lastOsDom = cdiDom.Domain.os;
                                }
                            }

                            if (networkDevice)
                            {
                                tn.ImageIndex = tn.SelectedImageIndex = 100;
                            }
                            else
                            if (lastOsDom != OperatingSystem.OS.Unknown)
                            {
                                tn.ImageIndex = tn.SelectedImageIndex = OperatingSystemUtils.OSToIconNumber(lastOsDom);
                            }
                        }

                        if (computer.Users.Items.Count > 0)
                        {
                            TreeNode tnUsers;
                            if (tn.Nodes["Users"] == null)
                            {
                                tnUsers            = tn.Nodes.Add("Users", "Users");
                                tnUsers.ImageIndex = tnUsers.SelectedImageIndex = 14;
                            }
                            else
                            {
                                tnUsers = tn.Nodes["Users"];
                            }
                            tnUsers.Tag = computer.Users;
                        }
                        else if (tn.Nodes["Users"] != null)
                        {
                            tn.Nodes["Users"].Remove();
                        }

                        if (computer.Description.Items.Count > 0)
                        {
                            TreeNode tnDescription;
                            if (tn.Nodes["Description"] == null)
                            {
                                tnDescription = tn.Nodes.Add("Description", "Description");
                            }
                            else
                            {
                                tnDescription = tn.Nodes["Description"];
                            }
                            tnDescription.Tag = computer.Description;
                        }
                        else if (tn.Nodes["Description"] != null)
                        {
                            tn.Nodes["Description"].Remove();
                        }

                        if (computer.RemotePasswords.Items.Count > 0)
                        {
                            TreeNode tnPasswords;
                            if (tn.Nodes["Passwords"] == null)
                            {
                                tnPasswords            = tn.Nodes.Add("Passwords", "Passwords");
                                tnPasswords.ImageIndex = tnPasswords.SelectedImageIndex = 121;
                            }
                            else
                            {
                                tnPasswords = tn.Nodes["Passwords"];
                            }
                            tnPasswords.Tag = computer.RemotePasswords;
                        }
                        else if (tn.Nodes["Passwords"] != null)
                        {
                            tn.Nodes["Passwords"].Remove();
                        }


                        if (computer.Folders.Items.Count > 0)
                        {
                            TreeNode tnFolders;
                            if (tn.Nodes["Folders"] == null)
                            {
                                tnFolders            = tn.Nodes.Add("Folders", "Folders");
                                tnFolders.ImageIndex = tnFolders.SelectedImageIndex = 117;
                            }
                            else
                            {
                                tnFolders = tn.Nodes["Folders"];
                            }
                            tnFolders.Tag = computer.Folders;
                        }
                        else if (tn.Nodes["Folders"] != null)
                        {
                            tn.Nodes["Folders"].Remove();
                        }
                        if (computer.Printers.Items.Count > 0)
                        {
                            TreeNode tnPrinters;
                            if (tn.Nodes["Printers"] == null)
                            {
                                tnPrinters            = tn.Nodes.Add("Printers", "Printers");
                                tnPrinters.ImageIndex = tnPrinters.SelectedImageIndex = 118;
                            }
                            else
                            {
                                tnPrinters = tn.Nodes["Printers"];
                            }
                            tnPrinters.Tag = computer.Printers;
                        }
                        else if (tn.Nodes["Printers"] != null)
                        {
                            tn.Nodes["Printers"].Remove();
                        }
                        if (computer.RemoteUsers.Items.Count > 0)
                        {
                            TreeNode tnRemoteUsers;
                            if (tn.Nodes["Users with access"] == null)
                            {
                                tnRemoteUsers            = tn.Nodes.Add("Users with access", "Users with access");
                                tnRemoteUsers.ImageIndex = tnRemoteUsers.SelectedImageIndex = 43;
                            }
                            else
                            {
                                tnRemoteUsers = tn.Nodes["Users with access"];
                            }
                            tnRemoteUsers.Tag = computer.RemoteUsers;
                        }
                        else if (tn.Nodes["Users with access"] != null)
                        {
                            tn.Nodes["Users with access"].Remove();
                        }
                        if (computer.RemoteFolders.Items.Count > 0)
                        {
                            TreeNode tnRemoteFolders;
                            if (tn.Nodes["Remote Folders"] == null)
                            {
                                tnRemoteFolders            = tn.Nodes.Add("Remote Folders", "Remote Folders");
                                tnRemoteFolders.ImageIndex = tnRemoteFolders.SelectedImageIndex = 42;
                            }
                            else
                            {
                                tnRemoteFolders = tn.Nodes["Remote Folders"];
                            }
                            tnRemoteFolders.Tag = computer.RemoteFolders;
                        }
                        else if (tn.Nodes["Remote Folders"] != null)
                        {
                            tn.Nodes["Remote Folders"].Remove();
                        }
                        if (computer.RemotePrinters.Items.Count > 0)
                        {
                            TreeNode tnRemotePrinters;
                            if (tn.Nodes["Remote Printers"] == null)
                            {
                                tnRemotePrinters            = tn.Nodes.Add("Remote Printers", "Remote Printers");
                                tnRemotePrinters.ImageIndex = tnRemotePrinters.SelectedImageIndex = 44;
                            }
                            else
                            {
                                tnRemotePrinters = tn.Nodes["Remote Printers"];
                            }
                            tnRemotePrinters.Tag = computer.RemotePrinters;
                        }
                        else if (tn.Nodes["Remote Printers"] != null)
                        {
                            tn.Nodes["Remote Printers"].Remove();
                        }
                    }));
                }
            }

            if (tnPCServers != null)
            {
                for (var i = tnPCServers.Nodes["Clients"].Nodes.Count; i > 0; i--)
                {
                    var tn = tnPCServers.Nodes["Clients"].Nodes[i - 1];
                    if (!Program.data.computers.Items.Any(C => C.type == ComputersItem.Tipo.ClientPC && C.name.ToLower() == tn.Text.ToLower()))
                    {
                        Program.FormMainInstance.TreeView.Invoke(new MethodInvoker(delegate
                        {
                            tn.Remove();
                        }));
                    }
                }

                Program.FormMainInstance.DeleteNodesServers(tnPCServers.Nodes["Servers"].Nodes);
                Program.FormMainInstance.TreeView.Invoke(new MethodInvoker(delegate
                {
                    tnPCServers.Nodes["Clients"].Text = string.Format("Clients ({0})", tnPCServers.Nodes["Clients"].Nodes.Count);
                }));
                tnPCServers.Nodes["Servers"].Text = string.Format("Servers ({0})", nServers);
            }
        }
Ejemplo n.º 39
0
 public Relations()
 {
     itemsField = new ThreadSafeList <RelationsItem>();
 }
        /// <summary>
        /// Creates a new <see cref="MemoryPool"/>.
        /// </summary>
        /// <param name="pageSize">The desired page size. Must be between 4KB and 256KB</param>
        /// <param name="maximumBufferSize">The desired maximum size of the allocation. Note: could be less if there is not enough system memory.</param>
        /// <param name="utilizationLevel">Specifies the desired utilization level of the allocated space.</param>
        public MemoryPool(int pageSize = 64 * 1024, long maximumBufferSize = -1, TargetUtilizationLevels utilizationLevel = TargetUtilizationLevels.Low)
        {
            if (pageSize < 4096 || pageSize > 256 * 1024)
                throw new ArgumentOutOfRangeException("pageSize", "Page size must be between 4KB and 256KB and a power of 2");

            if (!BitMath.IsPowerOfTwo((uint)pageSize))
                throw new ArgumentOutOfRangeException("pageSize", "Page size must be between 4KB and 256KB and a power of 2");

            m_syncRoot = new object();
            m_syncAllocate = new object();
            PageSize = pageSize;
            PageMask = PageSize - 1;
            PageShiftBits = BitMath.CountBitsSet((uint)PageMask);

            m_pageList = new MemoryPoolPageList(PageSize, maximumBufferSize);
            m_requestCollectionEvent = new ThreadSafeList<WeakEventHandler<CollectionEventArgs>>();
            SetTargetUtilizationLevel(utilizationLevel);
        }
Ejemplo n.º 41
0
 static BrickListCache()
 {
     ChangedParts = new HashSet <int>();
     Source       = CacheSource.None;
     Bricks       = new ThreadSafeList <BrickInfo>();
 }
Ejemplo n.º 42
0
        public static void RemakeXmpp()
        {
            if (Xmpp != null)
            {
                Xmpp.OnXmppConnectionStateChanged -= XmppOnOnXmppConnectionStateChanged;
                Xmpp.Close();
                Xmpp = null;
            }
            Xmpp = new XmppClientConnection(ServerPath);
            //#else
            //            Xmpp = new XmppClientConnection();
            //            Xmpp.ConnectServer = "127.0.0.1";
            //            Xmpp.AutoResolveConnectServer = false;
            //#endif

            Xmpp.RegisterAccount = false;
            Xmpp.AutoAgents = true;
            Xmpp.AutoPresence = true;
            Xmpp.AutoRoster = true;
            Xmpp.Username = XmppUsername;
            Xmpp.Password = XmppPassword;//Don't commit real password
            Xmpp.Priority = 1;
            Xmpp.OnLogin += XmppOnOnLogin;
            Xmpp.OnMessage += XmppOnOnMessage;
            Xmpp.OnIq += XmppOnOnIq;
            Xmpp.OnError += XmppOnOnError;
            Xmpp.OnAuthError += new XmppElementHandler(Xmpp_OnAuthError);
            Xmpp.OnReadXml += XmppOnOnReadXml;
            Xmpp.OnPresence += XmppOnOnPresence;
            Xmpp.OnWriteXml += XmppOnOnWriteXml;
            Xmpp.OnStreamError += XmppOnOnStreamError;
            Xmpp.KeepAlive = true;
            Xmpp.KeepAliveInterval = 60;
            Xmpp.OnAgentStart += XmppOnOnAgentStart;
            Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
            _userList = new ThreadSafeList<Jid>();
            Xmpp.Open();
        }
Ejemplo n.º 43
0
 public Applications()
 {
     Items = new ThreadSafeList<ApplicationsItem>();
 }
Ejemplo n.º 44
-1
        static GameBot()
        {
            //#if(DEBUG)
            Xmpp = new XmppClientConnection("skylabsonline.com");
            //#else
            //            Xmpp = new XmppClientConnection();
            //            Xmpp.ConnectServer = "127.0.0.1";
            //            Xmpp.AutoResolveConnectServer = false;
            //#endif

            Xmpp.RegisterAccount = false;
            Xmpp.AutoAgents = true;
            Xmpp.AutoPresence = true;
            Xmpp.AutoRoster = true;
            Xmpp.Username = "******";
            Xmpp.Password = "******";//Don't commit real password

            Xmpp.Priority = 1;
            Xmpp.OnLogin += XmppOnOnLogin;
            Xmpp.OnMessage += XmppOnOnMessage;
            Xmpp.OnIq += XmppOnOnIq;
            Xmpp.OnError += XmppOnOnError;
            Xmpp.OnAuthError += new XmppElementHandler(Xmpp_OnAuthError);
            Xmpp.OnReadXml += XmppOnOnReadXml;
            Xmpp.OnPresence += XmppOnOnPresence;
            Xmpp.OnWriteXml += XmppOnOnWriteXml;
            Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
            _userList = new ThreadSafeList<Jid>();
            Xmpp.Open();
        }