diff --git a/DataBase/版本日志/SGGLDB_2026-05-12-lc.sql b/DataBase/版本日志/SGGLDB_2026-05-12-lc.sql new file mode 100644 index 0000000..b9b2505 --- /dev/null +++ b/DataBase/版本日志/SGGLDB_2026-05-12-lc.sql @@ -0,0 +1,30 @@ +INSERT INTO [dbo].[Sys_Menu] ([MenuId], [MenuName], [Icon], [Url], [SortIndex], [SuperMenu], [MenuType], [IsOffice], [IsEnd], [IsUsed]) VALUES (N'E4DC0A35-C585-4C4F-8F79-10F528892314', N'Ŀ豸', NULL, N'ProjectData/ProjectDevices.aspx', '86', N'0', N'Menu_ProjectSet', '0', '1', '1'); +INSERT INTO [dbo].[Sys_ButtonToMenu] ([ButtonToMenuId], [MenuId], [ButtonName], [SortIndex]) VALUES (N'1E3A5ADC-BAA7-45BC-AAF9-012A024F4752', N'E4DC0A35-C585-4C4F-8F79-10F528892314', N'', '4'); +INSERT INTO [dbo].[Sys_ButtonToMenu] ([ButtonToMenuId], [MenuId], [ButtonName], [SortIndex]) VALUES (N'37E51622-FB4E-40F4-8D37-603EE626DB7F', N'E4DC0A35-C585-4C4F-8F79-10F528892314', N'', '1'); +INSERT INTO [dbo].[Sys_ButtonToMenu] ([ButtonToMenuId], [MenuId], [ButtonName], [SortIndex]) VALUES (N'6EBFA308-581A-4260-9ECA-7E30283EF9EA', N'E4DC0A35-C585-4C4F-8F79-10F528892314', N'ɾ', '3'); +INSERT INTO [dbo].[Sys_ButtonToMenu] ([ButtonToMenuId], [MenuId], [ButtonName], [SortIndex]) VALUES (N'939F4F2D-F03B-4DBD-963C-D55196535D8C', N'E4DC0A35-C585-4C4F-8F79-10F528892314', N'޸', '2'); + +Alter TABLE [dbo].[SitePerson_Person] add + [YunMouState] [nvarchar](50) NULL + +CREATE TABLE [dbo].[Project_Devices]( + [DeviceId] [nvarchar](50) NOT NULL, + [DeviceName] [nvarchar](50) NULL, + [Address] [nvarchar](500) NULL, + [CreateDate] [date] NULL, + [ProjectId] [nvarchar](50) NULL, + [DeviceSerial] [nvarchar](50) NULL, + [isInOut] [nvarchar](50) NULL, + [ValidateCode] [nvarchar](50) NULL, + [YunMouDeviceId] [nvarchar](50) NULL, + [YunMouPermission] [nvarchar](50) NULL, + CONSTRAINT [PK_Project_Devices] PRIMARY KEY CLUSTERED +( + [DeviceId] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] + + + ALter TABLE [dbo].[Base_Project] add + [IsYunMou] [bit] NULL, + [YunMouGroupId] [nvarchar](50) NULL \ No newline at end of file diff --git a/SUBQHSE/BLL/BLL.csproj b/SUBQHSE/BLL/BLL.csproj index 8aaefc7..8d2447c 100644 --- a/SUBQHSE/BLL/BLL.csproj +++ b/SUBQHSE/BLL/BLL.csproj @@ -75,6 +75,14 @@ ..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll + + ..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1001\lib\net20\Microsoft.Office.Interop.Excel.dll + True + + + ..\packages\Microsoft.Office.Interop.Word.15.0.4797.1004\lib\net20\Microsoft.Office.Interop.Word.dll + True + ..\packages\Microsoft.QualityTools.Testing.Fakes.16.11.230815\lib\net35\Microsoft.QualityTools.Testing.Fakes.dll False @@ -113,7 +121,8 @@ ..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll - ..\packages\StackExchange.Redis.2.12.14\lib\net461\StackExchange.Redis.dll + False + bin\Debug\StackExchange.Redis.dll @@ -318,6 +327,7 @@ + @@ -836,6 +846,7 @@ + diff --git a/SUBQHSE/BLL/Common/Const.cs b/SUBQHSE/BLL/Common/Const.cs index 24b1354..bc7f4e0 100644 --- a/SUBQHSE/BLL/Common/Const.cs +++ b/SUBQHSE/BLL/Common/Const.cs @@ -6702,7 +6702,10 @@ namespace BLL /// 中央企业安全生产治本攻坚三年行动工作台账 /// public const string ActionWorkLedgerMenuId = "CB76394B-BDEB-4F45-9D19-F38612DC6591"; - + /// + /// 项目设备 + /// + public const string ProjectDevicesMenuId = "E4DC0A35-C585-4C4F-8F79-10F528892314"; /// /// 中央企业安全生产管理评价工作调度台账 diff --git a/SUBQHSE/BLL/Common/YunMouHelper.cs b/SUBQHSE/BLL/Common/YunMouHelper.cs new file mode 100644 index 0000000..b121ffc --- /dev/null +++ b/SUBQHSE/BLL/Common/YunMouHelper.cs @@ -0,0 +1,604 @@ + +using Newtonsoft.Json; +using System; +using System.Configuration; +using System.Drawing; +using System.IO; +using System.Net; +using System.Text; + +namespace BLL.Common +{ + public class YunMouHelper + { + public static string YunMouUrl = ConfigurationManager.AppSettings["YunMouUrl"]; + public static string ClientSecret = ConfigurationManager.AppSettings["ClientSecret"]; + public static string ClientId = ConfigurationManager.AppSettings["ClientId"]; + + public static string getToken() + { + try + { + string data = "client_id=" + ClientId + "&client_secret=" + ClientSecret + "&grant_type=client_credentials&scope=app"; + string result = Post(YunMouUrl + "oauth/token", data, "application/x-www-form-urlencoded", ""); + var j2 = JsonConvert.DeserializeObject(result); + return j2.access_token; + } + catch (Exception e) + { + + } + return ""; + + } + /// + /// 添加设备组(一个项目一个) + /// + /// + /// + /// + /// + public static string addDevicesGroups(string groupName, string groupNo, string access_token) + { + if (groupName.Length > 64) + { + groupName = groupName.Substring(0, 63); + } + string data = "{\"groupName\":\"" + groupName + "\",\"groupNo\":\"" + groupNo + "\"}"; + string result = Post(YunMouUrl + "api/v1/open/basic/groups/create", data, "application/json;charset=UTF-8", access_token); + + ErrLogInfo.WriteLog(result); + + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.message; + else + { + return ""; + } + } + + /// + /// 删除设备分组 + /// + /// + /// + /// + /// + public static string deleteDevicesGroups(string groupNo, string access_token) + { + + string result = Post(YunMouUrl + "api/v1/open/basic/groups/delete?groupNo=" + groupNo, "", "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(result); + + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.message; + else + { + return ""; + } + } + + /// + /// 添加设备 + /// + /// + /// + /// + /// + /// + public static string addDevices(string deviceSerial, string groupNo, string validateCode, string access_token, out string res) + { + string data = "{\"deviceSerial\":\"" + deviceSerial + "\",\"groupNo\":\"" + groupNo + "\",\"validateCode\":\"" + validateCode + "\"}"; + string result = Post(YunMouUrl + "api/v1/open/basic/devices/create", data, "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(result); + + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + { + res = j2.message; + return j2.data.groupId; + } + else + { + res = j2.message; + return ""; + } + } + /// + /// 修改设备名称(按设备序列号) + /// + /// + /// + /// + /// + public static string updateDevices(string deviceSerial, string deviceName, string access_token) + { + string data = "{\"deviceSerial\":\"" + deviceSerial + "\",\"deviceName\":\"" + deviceName + "\"}"; + string result = Post(YunMouUrl + "api/v1/open/basic/devices/update", data, "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(result); + + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.message; + else + { + return ""; + } + } + /// + /// 删除设备 + /// + /// + /// + /// + public static string deleteDevices(string deviceSerial, string access_token) + { + + string result = Post(YunMouUrl + "api/v1/open/basic/devices/delete?deviceSerial=" + deviceSerial, "", "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(result); + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.message; + else + { + return ""; + } + } + /// + /// 添加权限组,建议一个项目一个 + /// + /// + /// + /// + public static string addPermissionGroups(string groupName, string access_token) + { + + char[] TrimChar = { '、', ' ', '-', '\'', '\"', '\\', '.', '、', '-', '[', ']', '【', '】', '(', ')', '#', '@', '~', '<', '>' }; + //groupname不能大于32位 + if (groupName.Length > 32) + { + groupName = groupName.Substring(0, 31).Trim(TrimChar); + } + groupName = groupName.Replace("、", "").Replace("/", "").Replace(".", "").Replace("-", "").Replace("[", "").Replace("]", "").Replace("【", "").Replace("】", "").Replace("(", "") + .Replace(")", "").Replace("#", "").Replace("@", "").Replace("~", "").Replace("<", "").Replace(">", "") + .Replace("(", "") + .Replace(")", ""); + string data = "{\"groupName\":\"" + groupName + "\"}"; + string result = Post(YunMouUrl + "api/v1/open/accessControl/permissionGroups/create", data, "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(result); + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.data.groupId; + else + { + return ""; + } + } + + /// + /// 根据权限组下发权限 + /// + /// + /// + /// + public static string issuedByGroup(string groupId, string access_token) + { + string data = "{\"groupId\":\"" + groupId + "\"}"; + string result = Post(YunMouUrl + "api/v1/open/accessControl/allots/actions/issuedByGroup", data, "application/json;charset=UTF-8", access_token); + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.code; + else + { + return ""; + } + } + + + + /// + /// 删除权限组(会同时移除权限组下人员和设备下发记录以及已下发到设备的权限) + /// + /// + /// + /// + public static string deletePermissionGroups(string groupId, string access_token) + { + string result = Post(YunMouUrl + "api/v1/open/accessControl/permissionGroups/delete?groupId=" + groupId, "", "application/json;charset=UTF-8", access_token); + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + { + return j2.data.groupId; + } + else + { + return ""; + } + } + + /// + /// 填加员工到权限组 + /// + /// + /// + /// + /// + public static string addPersonsToGroups(string groupId, string[] employeeNos, string access_token) + { + + //string permissions = ""; + //if (employeeNos.Length == 1) + //{ + // permissions = "\"permissions\":[{\"employeeNo\": \"" + employeeNos[0] + "\",\"validBeginTime\": \"2020-01-11\"," + + // "\"validEndTime\": \"2050-12-30\"}]"; + //} + string data = "{\"groupId\":\"" + groupId + "\",\"employeeNos\":[\"" + string.Join("\", \"", employeeNos) + "\"],\"autoIssue\":\"true\"}"; + string result = Post(YunMouUrl + "api/v1/open/accessControl/permissionGroups/actions/addPersons", data, "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(result); + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.data.statisticsId; + else + { + return ""; + } + } + /// + /// 从权限组移除员工 + /// + /// + /// + /// + /// + public static string deletePersonsFromGroups(string groupId, string[] employeeNos, string access_token) + { + string data = "{\"groupId\":\"" + groupId + "\",\"employeeNos\":[\"" + string.Join("\", \"", employeeNos) + "\"]}"; + string result = Post(YunMouUrl + "api/v1/open/accessControl/permissionGroups/actions/removePersons", data, "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(result); + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.data.statisticsId; + else + { + return ""; + } + } + /// + /// 添加设备到权限组 + /// + /// + /// + /// + /// + public static string addDevicesToGroups(string groupId, string[] devices, string access_token) + { + string data = "{\"groupId\":\"" + groupId + "\",\"deviceSerials\":[\"" + string.Join("\", \"", devices) + "\"],\"autoIssue\":true,\"checkCapability\":true}"; + string result = Post(YunMouUrl + "api/v1/open/accessControl/permissionGroups/actions/addDevices", data, "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(result); + + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.code; + else + { + return ""; + } + } + /// + /// 从权限组移除设备 + /// + /// + /// + /// + /// + public static string deleteDevicesFromGroups(string groupId, string[] devices, string access_token) + { + string data = "{\"groupId\":\"" + groupId + "\",\"deviceSerials\":[\"" + string.Join("\", \"", devices) + "\"],\"autoIssue\":true,\"checkCapability\":true}"; + string result = Post(YunMouUrl + "api/v1/open/accessControl/permissionGroups/actions/removeDevices", data, "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(result); + + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.message; + else + { + return ""; + } + } + /// + /// 添加人员 + /// + /// + /// + /// + /// + /// + /// + + public static string addPerson(string employeeNo, string personName, string personPhone, string pic, string access_token) + { + string rootUrl = ConfigurationManager.AppSettings["localRoot"]; + string filename = rootUrl + pic; + FileInfo fi1 = new FileInfo(filename); + if (fi1.Length > 200 * 1024)//base64编码的人脸图片,图片大小需小于200kB,数据需去除base64前缀 + { + filename = filename.Replace(".jpg", "_new.jpg").Replace(".jpeg", "_new.jpeg"); + CropImage(fi1.FullName, filename, 200); + } + string faceImageBase64 = ImageToByte64String(filename, System.Drawing.Imaging.ImageFormat.Jpeg); // 图片的base64编码 + string data = "{\"employeeNo\":\"" + employeeNo + "\",\"personName\":\"" + personName + "\",\"faceImageBase64\":\"" + faceImageBase64 + "\",\"verifyImage\":true}"; + string result = Post(YunMouUrl + "api/v1/open/basic/persons/create", data, "application/json;charset=UTF-8", access_token); + + ErrLogInfo.WriteLog(personName + result); + + var j2 = JsonConvert.DeserializeObject(result); + return j2.code; + } + /// + /// 根据employeeNo更新人员信息 + /// + /// + /// + /// + /// + /// + /// + public static string updatePerson(string employeeNo, string personName, string personPhone, string pic, string access_token) + { + string rootUrl = ConfigurationManager.AppSettings["localRoot"]; + string filename = rootUrl + pic; + FileInfo fi1 = new FileInfo(filename); + if (fi1.Length > 200 * 1024)//base64编码的人脸图片,图片大小需小于200kB,数据需去除base64前缀 + { + filename = filename.Replace(".jpg", "_new.jpg").Replace(".jpeg", "_new.jpeg"); + CropImage(fi1.FullName, filename, 200); + } + string faceImageBase64 = ImageToByte64String(filename, System.Drawing.Imaging.ImageFormat.Jpeg); // 图片的base64编码 + string data = "{\"employeeNo\":\"" + employeeNo + "\",\"personName\":\"" + personName + "\",\"faceImageBase64\":\"" + faceImageBase64 + "\",\"verifyImage\":true}"; + string result = Post(YunMouUrl + "api/v1/open/basic/persons/update", data, "application/json;charset=UTF-8", access_token); + ErrLogInfo.WriteLog(personName + result); + var j2 = JsonConvert.DeserializeObject(result); + return j2.code; + } + /// + /// 获取人员 + /// + /// + /// + /// + public static string getPerson(string employeeNo, string access_token) + { + string result = Get(YunMouUrl + "api/v1/open/basic/persons/get?employeeNo=" + employeeNo, "application/json;charset=UTF-8", access_token); + return result; + } + + + + /// + /// 设备布防 + /// + /// + /// + /// + /// + public static string setDefence(string deviceSerial, string isDefence, string access_token) + { + string result = Post(YunMouUrl + "api/v1/ezviz/devices/actions/setDefence/deviceSerial?deviceSerial=" + deviceSerial + "&isDefence=" + isDefence, "", "application/json;charset=UTF-8", access_token); + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.message; + else + { + return ""; + } + } + + /// + /// 添加消息通道 + /// + /// + /// + public static string addConsumer(string access_token) + { + try + { + string result = Post(YunMouUrl + "api/v1/mq/consumer/group1", "", "application/json;charset=UTF-8", access_token); + var j2 = JsonConvert.DeserializeObject(result); + if (j2.code == "200") + return j2.data.consumerId; + + } + catch (Exception e) { } + return ""; + + } + /// + /// 提交偏移量 + /// + /// + /// + /// + public static string offsets(string consumerId, string access_token) + { + string data = "consumerId=" + consumerId; + string result = Post(YunMouUrl + "api/v1/mq/consumer/offsets", data, "application/x-www-form-urlencoded", access_token); + return result; + } + + /// + /// 消费消息 + /// + /// + /// + /// + public static string consumerMessage(string consumerId, string access_token) + { + try + { + string data = "consumerId=" + consumerId + "&autoCommit=true"; + string result = Post(YunMouUrl + "api/v1/mq/consumer/messages", data, "application/x-www-form-urlencoded", access_token); + return result; + } + catch (Exception e) { } + return ""; + } + + /// + /// POST请求 + /// + /// + /// + /// + /// + /// + public static string Post(string url, string data, string ContentType, string token) + { + Encoding encoding = Encoding.Default; + + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;//设置这个安全协议必须在创建请求之前! + HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;//创建请求对象 + request.Method = "POST";//请求方式 + request.ContentType = ContentType;//链接类型 + if (!string.IsNullOrEmpty(token)) + { + request.Headers.Add("Authorization", "Bearer " + token); + } + try + { + byte[] buffer = Encoding.UTF8.GetBytes(data); + //RequestStream.Write(bytes, 0, bytes.Length); + // byte[] buffer = encoding.GetBytes(data); + request.ContentLength = buffer.Length; + request.GetRequestStream().Write(buffer, 0, buffer.Length); + HttpWebResponse webresponse = request.GetResponse() as HttpWebResponse; + using (Stream s = webresponse.GetResponseStream()) + { + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + StreamReader reader = new StreamReader(s, Encoding.UTF8); + + string res = reader.ReadToEnd(); + ErrLogInfo.WriteLog(res); + return res; + } + } + catch (Exception ex) + { + return ""; + } + } + /// + /// GET请求 + /// + /// + /// + /// + /// + public static string Get(string url, string ContentType, string token) + { + Encoding encoding = Encoding.Default; + + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;//设置这个安全协议必须在创建请求之前! + HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;//创建请求对象 + request.Method = "GET";//请求方式 + request.ContentType = ContentType;//链接类型 + if (!string.IsNullOrEmpty(token)) + { + request.Headers.Add("Authorization", "Bearer " + token); + } + try + { + HttpWebResponse webresponse = request.GetResponse() as HttpWebResponse; + using (Stream s = webresponse.GetResponseStream()) + { + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + StreamReader reader = new StreamReader(s, Encoding.UTF8); + return reader.ReadToEnd(); + } + } + catch (Exception ex) + { + return ""; + } + } + public static string ImageToByte64String(string filePath, System.Drawing.Imaging.ImageFormat format) + { + Bitmap bitmap = new Bitmap(filePath); + MemoryStream memoryStream = new MemoryStream(); + bitmap.Save(memoryStream, format); + byte[] array = new byte[memoryStream.Length]; + memoryStream.Position = 0L; + memoryStream.Read(array, 0, (int)memoryStream.Length); + memoryStream.Close(); + return Convert.ToBase64String(array); + } + public static void CropImage(string inputFilePath, string outputFilePath, int maxSizeInKB) + { + // 加载图片 + using (Image image = Image.FromFile(inputFilePath)) + { + // 计算最大字节大小 + int maxSizeBytes = maxSizeInKB * 1024; + + // 如果图片大小已经小于或等于最大限制,则不裁剪直接保存 + if (GetImageSizeInBytes(image) <= maxSizeBytes) + { + image.Save(outputFilePath, image.RawFormat); + return; + } + + // 裁剪图片 + // 这里只是一个简单的示例,实际应用中可能需要根据需求来裁剪图片 + using (Image croppedImage = CropImageToHalfSize(image)) + { + // 保存裁剪后的图片 + using (MemoryStream memoryStream = new MemoryStream()) + { + croppedImage.Save(memoryStream, image.RawFormat); + + // 如果裁剪后的图片大小仍然大于限制,则递归裁剪 + if (memoryStream.Length > maxSizeBytes) + { + memoryStream.Position = 0; + string tempFile = outputFilePath.Replace(".jpg", "temp.jpg").Replace(".jpeg", "temp.jpg"); + using (FileStream fileStream = new FileStream(tempFile, FileMode.Create)) + { + memoryStream.CopyTo(fileStream); + } + CropImage(tempFile, outputFilePath, maxSizeInKB); + } + else + { + // 保存到文件 + memoryStream.Position = 0; + using (FileStream fileStream = new FileStream(outputFilePath, FileMode.Create)) + { + memoryStream.CopyTo(fileStream); + } + } + } + } + } + } + + private static Image CropImageToHalfSize(Image image) + { + // 这里只是一个示例,实际情况可能需要根据需求来裁剪图片 + int newWidth = image.Width / 2; + int newHeight = image.Height / 2; + return image.GetThumbnailImage(newWidth, newHeight, () => { return false; }, IntPtr.Zero); + } + + private static long GetImageSizeInBytes(Image image) + { + using (MemoryStream memoryStream = new MemoryStream()) + { + image.Save(memoryStream, image.RawFormat); + return memoryStream.Length; + } + } + } + + +} diff --git a/SUBQHSE/BLL/ProjectData/ProjectDeviceService.cs b/SUBQHSE/BLL/ProjectData/ProjectDeviceService.cs new file mode 100644 index 0000000..d6040b9 --- /dev/null +++ b/SUBQHSE/BLL/ProjectData/ProjectDeviceService.cs @@ -0,0 +1,86 @@ +namespace BLL +{ + using System.Collections.Generic; + using System.Linq; + using Model; + + public static class ProjectDeviceService + { + + /// + ///获取项目单位信息 + /// + /// + public static Model.Project_Devices GetProjectDeviceById(string deviceId) + { + return Funs.DB.Project_Devices.FirstOrDefault(e => e.DeviceId == deviceId); + } + + + /// + /// 增加项目设备信息 + /// + /// + public static void AddProjectDevice(Project_Devices projectDevices) + { + SUBQHSEDB db = Funs.DB; + Project_Devices newProjectUnit = new Project_Devices + { + DeviceId = SQLHelper.GetNewID(typeof(Model.Project_Devices)), + ProjectId = projectDevices.ProjectId, + DeviceName = projectDevices.DeviceName, + DeviceSerial = projectDevices.DeviceSerial, + CreateDate = projectDevices.CreateDate, + Address = projectDevices.Address, + IsInOut = projectDevices.IsInOut, + ValidateCode = projectDevices.ValidateCode, + YunMouDeviceId = projectDevices.YunMouDeviceId, + YunMouPermission = projectDevices.YunMouPermission, + }; + db.Project_Devices.InsertOnSubmit(newProjectUnit); + db.SubmitChanges(); + } + + /// + ///修改项目设备信息 + /// + /// + public static void UpdateProjectDevice(Model.Project_Devices devices) + { + Model.SUBQHSEDB db = Funs.DB; + Model.Project_Devices newDevices = db.Project_Devices.FirstOrDefault(e => e.DeviceId == devices.DeviceId); + if (newDevices != null) + { + newDevices.ProjectId = devices.ProjectId; + newDevices.DeviceName = devices.DeviceName; + newDevices.DeviceSerial = devices.DeviceSerial; + newDevices.CreateDate = devices.CreateDate; + newDevices.Address = devices.Address; + newDevices.IsInOut = devices.IsInOut; + newDevices.ValidateCode = devices.ValidateCode; + newDevices.YunMouPermission = devices.YunMouPermission; + newDevices.YunMouDeviceId = devices.YunMouDeviceId; + db.SubmitChanges(); + } + } + + /// + /// 根据项目单位Id删除一个项目单位信息 + /// + /// + public static void DeleteProjectDeviceById(string deviceId) + { + Model.SUBQHSEDB db = Funs.DB; + Model.Project_Devices devices = db.Project_Devices.FirstOrDefault(e => e.DeviceId == deviceId); + if (devices != null) + { + db.Project_Devices.DeleteOnSubmit(devices); + db.SubmitChanges(); + } + } + + + + + } +} diff --git a/SUBQHSE/FineUIPro.Web/FineUIPro.Web.csproj b/SUBQHSE/FineUIPro.Web/FineUIPro.Web.csproj index ec8315a..86d7c7a 100644 --- a/SUBQHSE/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SUBQHSE/FineUIPro.Web/FineUIPro.Web.csproj @@ -114,16 +114,16 @@ ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - + ..\packages\NPOI.2.5.5\lib\net45\NPOI.dll - + ..\packages\NPOI.2.5.5\lib\net45\NPOI.OOXML.dll - + ..\packages\NPOI.2.5.5\lib\net45\NPOI.OpenXml4Net.dll - + ..\packages\NPOI.2.5.5\lib\net45\NPOI.OpenXmlFormats.dll @@ -1164,6 +1164,8 @@ + + @@ -12649,6 +12651,20 @@ LocationSelect.aspx + + ProjectDevices.aspx + ASPXCodeBehind + + + ProjectDevices.aspx + + + ProjectDevicesEdit.aspx + ASPXCodeBehind + + + ProjectDevicesEdit.aspx + Schedule.aspx ASPXCodeBehind @@ -18522,7 +18538,7 @@ - +