Exemple #1
0
        /// <summary>
        /// 更新缓存
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <bool> UpdateAsync()
        {
            return(await Task.Run(async() =>
            {
                //更新缓存
                Data.LoginInfo = ServiceContext.Session.LoginInfo;

                var storeResult = await ServiceContext.StoreService.GetList();
                if (storeResult.IsSuccess)
                {
                    Data.StoreList = storeResult.Data;
                }
                if (Data.StoreList?.Count > 0)
                {
                    var deviceResult = await ServiceContext.DeviceService.GetList();
                    Data.DeviceList = deviceResult.Data;
                }
                //更新监控
                //Data.CameraList = YsAction.GetCameraList();
                foreach (var device in Data.DeviceList)
                {
                    if (device.DeviceType == 1)
                    {
                        device.CameraList = YsAction.GetCameraList(device.Info);
                    }
                }
                Data.LastUpdateTime = DateTime.Now;
                Save();
                return true;
            }));
        }
Exemple #2
0
        public FullCamera(string cameraId, IntPtr sessionId, int level, string safeKey)
        {
            InitializeComponent();

            this.cameraId  = cameraId;
            this.sessionId = sessionId;
            this.level     = level;
            this.safeKey   = safeKey;
            var pictureBox = new PictureBox();

            pictureBox.BackColor         = Color.Black;
            pictureBox.Name              = "picFull";
            pictureBox.Dock              = DockStyle.Fill;
            pictureBox.SizeMode          = PictureBoxSizeMode.Zoom;
            pictureBox.MouseDoubleClick += (s, e) =>
            {
                Closed();
            };
            Controls.Add(pictureBox);

            var play = YsAction.Play(pictureBox.Handle, sessionId, cameraId, level, safeKey);

            if (!play)
            {
                SM("全屏播放失败!");
            }
        }
Exemple #3
0
        private void picbox_MouseDoubleClick(object sender, EventArgs e)
        {
            PictureBox picb1 = sender as PictureBox;            //取出点击的控件sender

            if (picb1.IsNull())
            {
                EM("请重试");
                return;
            }
            var index    = Convert.ToInt32(picb1.Tag);
            var cameraId = PlayCameraId[index];

            if (string.IsNullOrEmpty(cameraId))
            {
                EM("无视频");
                return;
            }
            YsAction.Stop(SessionId[index]);            //关闭当前所有正在播放的该摄像头
            var frm = new FullCamera(cameraId, SessionId[index], 3, _context.CacheContext.Data.SafeKye);

            frm.FormClosed += async(s, args) =>
            {
                await PlayAsync(index);
            };
            frm.ShowDialog();
        }
Exemple #4
0
        void M()
        {
            T("InitSdk", YsAction.InitSdk());
            T(YsAction.GetAccessToken());
            var _list = YsAction.GetCameraList("C04104941");

            _list = YsAction.GetCameraList();
            T("DisposeSdk", YsAction.DisposeSdk());
        }
Exemple #5
0
        private void picbox_MouseClick(object sender, MouseEventArgs e)
        {
            var pictureBox = sender as PictureBox; //取出点击的控件sender

            if (pictureBox == null)                //点击则非空,否则为空
            {
                return;
            }
            var cameraId = pictureBox.Tag.ToString();
            var camera   = _context.CacheContext.Data.DeviceList.SelectMany(m => m.CameraList).FirstOrDefault(m => m.CameraId == cameraId);

            if (camera.IsNull())
            {
                EM("不存在的设备!");
                return;
            }
            if (camera.Status != 1)
            {
                EM("设备不在线,无法播放!");
                return;
            }
            if (PlayCameraId.Contains(cameraId))
            {
                IS("该视频已经在播放中,请勿重复点击!");
                return;
            }
            handle[j] = picbox[j].Handle;                 //赋予句柄
            if (a == 1 && d == 1)                         //全部容器都在播放
            {
                bool close = YsAction.Stop(SessionId[j]); //关闭最开始打开的画面
            }
            PlayCameraId[j] = cameraId;
            PlayAsync(j);
            if (j < c - 1)
            {
                j++;
            }
            else if (j == c - 1)
            {
                j = 0;
                d = 1;
            }
        }
Exemple #6
0
 /// <summary>
 /// 播放
 /// </summary>
 /// <param name="index"></param>
 void Play(int index = 0)
 {
     SessionId[index] = YsAction.AllocSession();
     if (SessionId[index] != null)
     {
         picbox[index].Image = Resources.load2;
         try
         {
             var play = YsAction.Play(handle[index], SessionId[index], PlayCameraId[index], 2, _context.CacheContext.Data.SafeKye);
             if (play == true)
             {
                 a = 1;
             }
         }
         catch (Exception ex)
         {
             EM(ex.Message);
         }
     }
     else
     {
         IS("申请会话异常!");
     }
 }
Exemple #7
0
        /// <summary>
        /// 是否可以启动窗体
        /// 暂无运行的窗体  &&  没有需要更新的版本  && 网络
        /// </summary>
        /// <returns></returns>
        static bool CanRun()
        {
            bool      canRun;
            Attribute guid_attr = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(GuidAttribute));
            string    guid      = ((GuidAttribute)guid_attr).Value;

            _mutex = new System.Threading.Mutex(true, guid, out canRun);
            if (!canRun)
            {
                MessageBox.Show("已经在运行了!", AppInfo.AssemblyTitle,
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                canRun = IsConnect();
                if (!canRun)
                {
                    MessageBox.Show("网络异常,请检查网络是否连接!", AppInfo.AssemblyTitle,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    canRun = YsAction.InitSdk();
                    if (!canRun)
                    {
                        MessageBox.Show("监控提供商链接失败,请联系软件开发者!", AppInfo.AssemblyTitle,
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        canRun = CheckUpdateTask().Result == null;
                    }
                }
            }
            return(canRun);
        }
Exemple #8
0
 void Closed()
 {
     YsAction.Stop(sessionId);
     Close();
 }