关联摄像头

This commit is contained in:
2023-02-01 16:23:55 +08:00
parent 1d18cfbbf1
commit 9cd1860db1
16 changed files with 829 additions and 69 deletions
@@ -1,6 +1,8 @@
using BLL;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
@@ -9,6 +11,20 @@ namespace FineUIPro.Web.ProjectData
{
public partial class ProjectList : PageBase
{
/// <summary>
/// 定义项
/// </summary>
public string URLToken
{
get
{
return (string)ViewState["URLToken"];
}
set
{
ViewState["URLToken"] = value;
}
}
#region
/// <summary>
/// 加载页面
@@ -116,6 +132,47 @@ namespace FineUIPro.Web.ProjectData
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectSetView.aspx?ProjectId={0}", Grid1.SelectedRowID, "查看 - ")));
}
/// <summary>
/// 关联摄像头
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMonitor_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Grid1.SelectedRowID))
{
string url = ConfigurationManager.AppSettings["Video_URL"];
string username = ConfigurationManager.AppSettings["Video_USER"];
string password = ConfigurationManager.AppSettings["Video_PW"];
if (string.IsNullOrEmpty(URLToken))
{
String res = BLL.CommonService.CreateGetHttpResponse(url + "api/v1/login?username=" + username + "&password=" + Funs.EncryptionPassword(password));
Dictionary<string, string> dicres = JsonConvert.DeserializeObject<Dictionary<string, string>>(res);
URLToken = dicres["URLToken"];
}
var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == Grid1.SelectedRowID);
string resUserInfor = BLL.CommonService.CreateGetHttpResponse(url + "api/v1/user/info?token=" + URLToken + "&username=" + project.ProjectCode);
if ("user not found".Equals(resUserInfor) || "远程服务器返回错误: (400) 错误的请求。".Equals(resUserInfor))
{
string resUserSave = BLL.CommonService.CreateGetHttpResponse(url + "api/v1/user/save?token=" + URLToken + "&ID=0&Username=" + project.ProjectCode + "&Role=操作员,观众&Enable=true");
Dictionary<string, string> dicUserSave = JsonConvert.DeserializeObject<Dictionary<string, string>>(resUserSave);
project.MonitorId = dicUserSave["ID"];
string newPassWord = Funs.EncryptionPassword(DateTime.Now.Ticks.ToString());
newPassWord = newPassWord.Substring(newPassWord.Length - 9, 8);
string resResPS = BLL.CommonService.CreateGetHttpResponse(url + "api/v1/user/resetpassword?token=" + URLToken + "&id=" + dicUserSave["ID"] + "&password="+ newPassWord);
project.MonitorPW = newPassWord;
Funs.DB.SubmitChanges();
}
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectMonitorList.aspx?ProjectCode={0}&Id={1}&URLToken={2}", project.ProjectCode, project.MonitorId, URLToken, "查看 - ")));
}
else
{
ShowNotify("请选择项目进入!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 查看