示例#1
0
 public void Logout()
 {
     try {
         NvrUserSession?.StopSession();
     } catch (Exception e) {
         Console.WriteLine(e.Message + "\n" + e.StackTrace);
     } finally {
         NvrUserSession?.Dispose();
         NvrUserSession = null;
     }
 }
示例#2
0
        public async Task LoginAsync(NvrSessionInfo sessionInfo)
        {
            string sdkLogDir = System.Reflection.Assembly.GetEntryAssembly().Location + @"_NvrSdkLogs\";

            NvrUserSession = new NvrUserSession(sessionInfo, sdkLogDir, true);

            await Task.Factory.StartNew(() => {
                try {
                    NvrUserSession.StartSession();
                } catch (NvrSdkException ex) {
                    throw new SystemException($"StartSession failed: NvrException Code[{ex.SdkErrorCode}]: {ex.Message}", ex);
                } catch (Exception ex) {
                    throw new SystemException("StartSession failed: " + ex.Message, ex);
                }
            }, TaskCreationOptions.AttachedToParent);
        }