Esempio n. 1
0
        public LiveCapture(Core core, string host, UInt32 remoteIdent, MainWindow main)
        {
            InitializeComponent();

            m_Core = core;
            m_Main = main;

            this.DoubleBuffered = true;
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);

            Icon = global::renderdocui.Properties.Resources.icon;

            m_Connection  = null;
            m_Host        = host;
            m_RemoteIdent = remoteIdent;

            childProcessLabel.Visible = false;
            childProcesses.Visible    = false;

            m_ConnectThread = null;

            Text = (m_Host.Length > 0 ? (m_Host + " - ") : "") + "Connecting...";
            connectionStatus.Text = "Connecting...";
            connectionIcon.Image  = global::renderdocui.Properties.Resources.hourglass;

            thumbs            = new ImageList();
            thumbs.ColorDepth = ColorDepth.Depth24Bit;

            thumbs.ImageSize        = new Size(256, 144);
            captures.TileSize       = new Size(400, 160);
            captures.LargeImageList = thumbs;

            captures.Columns.AddRange(new ColumnHeader[] { new ColumnHeader(), new ColumnHeader(), new ColumnHeader() });
        }
Esempio n. 2
0
        private void CreateDB(string databaseName, DatabaseOptions databaseOptions, bool useSingleFile)
        {
            this.DataBaseStartedAt  = DateTime.UtcNow;
            this.DataBaseName       = databaseName;
            this.DatabaseOptions    = databaseOptions;
            this.UseInMemoryStorage = databaseOptions?.UseInMemoryStorage ?? false;

            this.databaseService = new DatabaseService(databaseOptions.StorageDirectory, databaseName, new JsonSerializationFactory(this.Logger), databaseOptions.StorageIO, this.Logger, false, databaseOptions.StorageName);
            if (this.DatabaseOptions == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(databaseOptions.RunAsServerWithAddress))
            {
                RemoteAccess = new RemoteAccess();
                RemoteAccess.RunServer(databaseOptions.RunAsServerWithAddress);
            }

            this.RemoteServerAdrress = databaseOptions.UseRemoteServerAdrressForClientRequests;
            this.databaseService.DataBaseSettings.EnableCaching = this.DatabaseOptions.EnableCaching;
            this.databaseService.DataBaseSettings.EnableFasterCachingButWithLeakyUpdates = this.DatabaseOptions.EnableFasterCachingButWithLeakyUpdates;
            this.databaseService.DataBaseSettings.MaxResponseTime           = this.DatabaseOptions.MaxResponseTime;
            this.databaseService.DataBaseSettings.PrettifyDocuments         = this.DatabaseOptions.PrettifyDocuments;
            this.databaseService.DataBaseSettings.DontWaitForWrites         = this.DatabaseOptions.DontWaitForWrites;
            this.databaseService.DataBaseSettings.DontWaitForWritesOnCreate = this.DatabaseOptions.DontWaitForWritesOnCreate;
        }
        private CapturePipeline()
        {
            using (var l_RemoteAccess = new RemoteAccess())
            {
                VideoWidth = l_RemoteAccess.TextureDesc.Width;

                VideoHeight = l_RemoteAccess.TextureDesc.Height;
            }
        }
Esempio n. 4
0
        public void CheckIsRemoteNotReady()
        {
            var remoteService = MockRepository.Mock <IService>();
            var disconnected  = 0;

            var ra = new RemoteAccess <IService>(() => remoteService, () => ++ disconnected);

            Assert.Throws <ApplicationException>(() => ra.CheckIsRemoteReady(_ => throw new ApplicationException("not ready yet"), 1));

            Assert.AreEqual(1, disconnected);
        }
Esempio n. 5
0
        public void PerformActionExceptionDisconnect()
        {
            var remoteService = MockRepository.Mock <IService>();

            remoteService.Stub(_ => _.MethodException()).Throws <ArgumentException>();
            var disconnected = false;

            var ra = new RemoteAccess <IService>(() => remoteService, () => disconnected = true);

            Assert.Throws <ArgumentException>(() => ra.Perform(_ => _.MethodException()));

            Assert.IsTrue(disconnected);
        }
Esempio n. 6
0
        public string LoadRawDocument <T>(string id, string documentName = null, bool includeDeleted = false)
        {
            if (RunAsHttpClient)
            {
                var databaseName = PecanDatabaseUtilityObj.DetermineDatabaseName <PecanDocument <T>, T>(documentName);
                var resultStr    = RemoteAccess.MakeRequest <string>(RemoteServerAdrress, $"Load?id={id}&database={databaseName}&includeDeleted={includeDeleted}");
                return(resultStr);
            }

            this.Logger?.Trace(this.GetType().Name, $"Load json document {id} from dynamic . Supplied document name {documentName} - {this.GetContextDescription()}");
            string result = this.LoadDocument <T, string>(id, documentName, includeDeleted, true).DocumentEntity;

            return(result);
        }
Esempio n. 7
0
        public void PerformFunction()
        {
            var remoteService = MockRepository.Mock <IService>();

            remoteService.Stub(_ => _.Method2()).Repeat.Once().Return("from remote service");
            var disconnected = false;

            var ra = new RemoteAccess <IService>(() => remoteService, () => disconnected = true);

            var result = ra.Perform(_ => _.Method2());

            Assert.IsFalse(disconnected);
            Assert.AreEqual("from remote service", result);
            remoteService.VerifyAllExpectations();
        }
Esempio n. 8
0
        public void PerformAction()
        {
            var remoteService = MockRepository.Mock <IService>();

            remoteService.Stub(_ => _.Method()).Repeat.Once();
            var disconnected = false;

            var ra = new RemoteAccess <IService>(() => remoteService, () => disconnected = true);

            ra.Perform(_ => _.Method());

            Assert.IsFalse(disconnected);

            remoteService.VerifyAllExpectations();
        }
Esempio n. 9
0
        public string GetETagFor <T>(string id, string documentName = null)
        {
            if (RunAsHttpClient)
            {
                var databaseName = PecanDatabaseUtilityObj.DetermineDatabaseName <PecanDocument <T>, T>(documentName);
                var resultStr    = RemoteAccess.MakeRequest <string>(RemoteServerAdrress, $"GetETagFor?id={id}&database={databaseName}");
                return(resultStr);
            }
            this.Logger?.Trace(this.GetType().Name, $"Get etag for document {documentName} with id {id}  Supplied document name {documentName} - {this.GetContextDescription()}");

            PecanDocument <T> result = this.LoadDocument <T>(id, documentName);

            this.Logger?.Trace(this.GetType().Name, $"Get etag {result?.ETag} from document {documentName} with id {id}  Supplied document name {documentName} - {this.GetContextDescription()}");

            return(result.ETag);
        }
Esempio n. 10
0
        public T Load <T>(string id, string documentName = null, bool includeDeleted = false)
        {
            if (RunAsHttpClient)
            {
                var databaseName = PecanDatabaseUtilityObj.DetermineDatabaseName <PecanDocument <T>, T>(documentName);
                var resultStr    = RemoteAccess.MakeRequest <string>(RemoteServerAdrress, $"Load?id={id}&database={databaseName}");
                var resultData   = string.IsNullOrEmpty(resultStr) ? default(T) : JsonConvert.DeserializeObject <T>(resultStr);
                return(resultData);
            }

            this.Logger?.Trace(this.GetType().Name, $"Load document {id} of {typeof(T).Name}. Supplied document name {documentName} - {this.GetContextDescription()}");

            PecanDocument <T> result = this.LoadDocument <T>(id, documentName, includeDeleted);

            return(result.DocumentEntity);
        }
Esempio n. 11
0
		public RemoteAccessViewModel(RemoteAccess remoteAccess)
		{
			AddCommand = new RelayCommand(OnAdd);
			RemoveCommand = new RelayCommand(OnRemove, CanRemove);

			ServiceFactory.Events.GetEvent<RemoteAccessTypeChecked>().Unsubscribe(OnRemoteAccessTypeChecked);
			ServiceFactory.Events.GetEvent<RemoteAccessTypeChecked>().Subscribe(OnRemoteAccessTypeChecked);

			RemoteAccessTypes = new List<RemoteAccessTypeViewModel>();
			foreach (RemoteAccessType remoteAccessType in Enum.GetValues(typeof(RemoteAccessType)))
			{
				RemoteAccessTypes.Add(new RemoteAccessTypeViewModel(remoteAccessType));
			}
			RemoteAccessTypes.Find(x => x.RemoteAccessType == remoteAccess.RemoteAccessType).IsActive = true;

			HostNameOrAddressList = new ObservableCollection<string>(remoteAccess.HostNameOrAddressList);
			SelectedHostNameOrAddress = HostNameOrAddressList.FirstOrDefault();
		}
Esempio n. 12
0
        public void CheckIsRemoteReady()
        {
            var remoteService = MockRepository.Mock <IService>();
            var disconnected  = 0;

            var attempts = 0;

            var ra = new RemoteAccess <IService>(() => remoteService, () => ++ disconnected);

            ra.CheckIsRemoteReady(_ => { if (++attempts < 5)
                                         {
                                             throw new ApplicationException("not ready yet");
                                         }
                                  });

            Assert.AreEqual(5, attempts);
            Assert.AreEqual(4, disconnected);
        }
Esempio n. 13
0
        public string Save <T>(string documentName, T document, string id = null)
        {
            if (RunAsHttpClient)
            {
                var databaseName = PecanDatabaseUtilityObj.DetermineDatabaseName <PecanDocument <T>, T>(documentName);
                var data         = JsonConvert.SerializeObject(document);
                var resultStr    = RemoteAccess.MakeRequest <string>(RemoteServerAdrress, $"Save?data={data}&database={databaseName}");
                return(resultStr);
            }

            this.Logger?.Trace(this.GetType().Name, $"STORING NEW Document with id {id} of {documentName} type {typeof(T).Name}. Supplied document name {documentName} - {this.GetContextDescription()}");

            if (IsAnonymousObject <T>())
            {
                this.Logger?.Trace(this.GetType().Name, $"STORING NEW Document determined to be anonymous with id {id} of {documentName} type {typeof(T).Name}. Supplied document name {documentName} - {this.GetContextDescription()}");

                StorageDatabase <PecanDocument <object>, object> handle = this.GetDatabaseServiceHandle <object>(documentName);
                var data = new PecanDocument <object>
                {
                    DocumentEntity = document.ToDynamic()
                };

                PecanDocument <object> result = handle.Create(data, false, id);

                this.Logger?.Trace(this.GetType().Name, $"STORING NEW successfully obtained final Order id {result?.Id} after the storing Document with id {id} of {documentName} type {typeof(T).Name}. Supplied document name {documentName} - {this.GetContextDescription()}");

                return(result.Id);
            }
            else
            {
                this.Logger?.Trace(this.GetType().Name, $"STORING NEW storing Document determined to be NOT anonymous with id {id} of {documentName} type {typeof(T).Name}. Supplied document name {documentName} - {this.GetContextDescription()}");

                StorageDatabase <PecanDocument <T>, T> handle = this.GetDatabaseServiceHandle <T>(documentName);
                var data = new PecanDocument <T>
                {
                    DocumentEntity = document
                };

                PecanDocument <T> result = handle.Create(data, false, id);
                this.Logger?.Trace(this.GetType().Name, $"STORING NEW successfully obtained final Order id {result?.Id} after the storing Document with id {id} of {documentName} type {typeof(T).Name}. Supplied document name {documentName} - {this.GetContextDescription()}");

                return(result.Id);
            }
        }
Esempio n. 14
0
 /// <summary>
 /// To access entry from cache, 1st lookup in the cache/dlinked using the key, if found remove from the current location,
 /// and move it to the top of the cache/dlinked. If not found return -1;
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public T GetCacheEntry(K key)
 {
     if (CashDictionary.ContainsKey(key))
     {
         CacheEntry <K, T> cachEntry = CashDictionary[key];
         //if the element is the only element in the cache OR If it at the top of the cacheList then return the element
         if (Count == 1 || Head == cachEntry)
         {
             return(cachEntry.Value);
         }
         RemoveNode(cachEntry);
         AddTopNode(cachEntry);
         return(cachEntry.Value);
     }
     else
     {
         //get it directly from db or any remote storage/ actual data.
         RemoteAccess <T> ActualData = new RemoteAccess <T>();
         return(ActualData.GetActualData());
     }
 }
Esempio n. 15
0
        private void ConnectionThreadEntry()
        {
            try
            {
                string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

                m_Connection = StaticExports.CreateRemoteAccessConnection(m_Host, m_RemoteIdent, username, true);

                if (m_Connection.Connected)
                {
                    string api = "...";
                    if (m_Connection.API.Length > 0)
                    {
                        api = m_Connection.API;
                    }
                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        if (m_Connection.PID == 0)
                        {
                            connectionStatus.Text = String.Format("Connection established to {0} ({1})", m_Connection.Target, api);
                            Text = String.Format("{0} ({1})", m_Connection.Target, api);
                        }
                        else
                        {
                            connectionStatus.Text = String.Format("Connection established to {0} [PID {1}] ({2})",
                                                                  m_Connection.Target, m_Connection.PID, api);
                            Text = String.Format("{0} [PID {1}] ({2})", m_Connection.Target, m_Connection.PID, api);
                        }
                        connectionIcon.Image = global::renderdocui.Properties.Resources.connect;
                    });
                }
                else
                {
                    throw new ApplicationException();
                }

                while (m_Connection.Connected)
                {
                    m_Connection.ReceiveMessage();

                    if (m_TriggerCapture)
                    {
                        m_Connection.TriggerCapture();
                        m_TriggerCapture = false;
                    }

                    if (m_QueueCapture)
                    {
                        m_Connection.QueueCapture((uint)m_CaptureFrameNum);
                        m_QueueCapture    = false;
                        m_CaptureFrameNum = 0;
                    }

                    if (m_Disconnect)
                    {
                        m_Connection.Shutdown();
                        m_Connection = null;
                        return;
                    }

                    if (m_Connection.InfoUpdated)
                    {
                        this.BeginInvoke((MethodInvoker) delegate
                        {
                            connectionStatus.Text = String.Format("Connection established to {0} ({1})", m_Connection.Target, m_Connection.API);
                            Text = String.Format("{0} ({1})", m_Connection.Target, m_Connection.API);
                            connectionIcon.Image = global::renderdocui.Properties.Resources.connect;
                        });

                        m_Connection.InfoUpdated = false;
                    }

                    if (m_Connection.CaptureExists)
                    {
                        uint     capID     = m_Connection.CaptureFile.ID;
                        DateTime timestamp = new DateTime(1970, 1, 1, 0, 0, 0);
                        timestamp = timestamp.AddSeconds(m_Connection.CaptureFile.timestamp).ToLocalTime();
                        byte[] thumb = m_Connection.CaptureFile.thumbnail;
                        string path  = m_Connection.CaptureFile.localpath;

                        if (path.Length == 0 || File.Exists(path))
                        {
                            this.BeginInvoke((MethodInvoker) delegate
                            {
                                CaptureAdded(capID, m_Connection.Target, m_Connection.API, thumb, timestamp);
                                if (path.Length > 0)
                                {
                                    CaptureRetrieved(capID, path);
                                }
                            });
                            m_Connection.CaptureExists = false;

                            if (path.Length == 0)
                            {
                                m_Connection.CopyCapture(capID, m_Core.TempLogFilename("remotecopy_" + m_Connection.Target));
                            }
                        }
                    }

                    if (m_Connection.CaptureCopied)
                    {
                        uint   capID = m_Connection.CaptureFile.ID;
                        string path  = m_Connection.CaptureFile.localpath;

                        this.BeginInvoke((MethodInvoker) delegate
                        {
                            CaptureRetrieved(capID, path);
                        });
                        m_Connection.CaptureCopied = false;
                    }

                    if (m_Connection.ChildAdded)
                    {
                        if (m_Connection.NewChild.PID != 0)
                        {
                            try
                            {
                                ChildProcess c = new ChildProcess();
                                c.PID   = (int)m_Connection.NewChild.PID;
                                c.ident = m_Connection.NewChild.ident;
                                c.name  = Process.GetProcessById((int)m_Connection.NewChild.PID).ProcessName;

                                lock (m_Children)
                                {
                                    m_Children.Add(c);
                                }
                            }
                            catch (Exception)
                            {
                                // process expired/doesn't exist anymore
                            }
                        }

                        m_Connection.ChildAdded = false;
                    }
                }

                this.BeginInvoke((MethodInvoker) delegate
                {
                    connectionStatus.Text = "Connection closed";
                    connectionIcon.Image  = global::renderdocui.Properties.Resources.disconnect;

                    ConnectionClosed();
                });
            }
            catch (ApplicationException)
            {
                this.BeginInvoke((MethodInvoker) delegate
                {
                    Text = (m_Host.Length > 0 ? (m_Host + " - ") : "") + "Connection failed";
                    connectionStatus.Text = "Connection failed";
                    connectionIcon.Image  = global::renderdocui.Properties.Resources.delete;

                    ConnectionClosed();
                });
            }
        }
Esempio n. 16
0
		public RemoteAccess GetModel()
		{
			var remoteAccess = new RemoteAccess();
			remoteAccess.RemoteAccessType = RemoteAccessTypes.Find(x => x.IsActive).RemoteAccessType;
			if (remoteAccess.RemoteAccessType == RemoteAccessType.SelectivelyAllowed)
				remoteAccess.HostNameOrAddressList = new List<string>(HostNameOrAddressList.ToList());

			return remoteAccess;
		}
        public void Stop()
        {
            m_RemoteAccess.Dispose();

            m_RemoteAccess = null;
        }
 public void Start()
 {
     m_RemoteAccess = new RemoteAccess();
 }