protected object[] Take(PositionsEntity position) { return(new object[] { "@DepID", position.DepID, "@PosName", position.PosName, // "@Temp",position.Temp, }); }
//private static readonly string connectionString = ConfigurationManager.ConnectionStrings["MyMvcDbConnection"].ConnectionString; //public static bool CheckUnique(string posName) //{ // bool check = false; // string query = string.Format("Select PosName FROM [POSITION] WHERE REPLACE(PosName, ' ', '') = '{0}'", posName); // using (SqlConnection connection = new SqlConnection(connectionString)) // { // SqlCommand cmd = new SqlCommand(query, connection); // connection.Open(); // SqlDataReader sdr = cmd.ExecuteReader(); // check = sdr.HasRows; // connection.Close(); // return (check); // } //} public bool InsertPosition(PositionsEntity position) { string sql = @"sp_position_INSERT"; using (TransactionScope ts = new TransactionScope()) { try { Db.Insert(sql, Take(position)); ts.Complete(); return(true); } catch { return(false); } } }
public static PositionModel ToDto(PositionsEntity entity) { return(new PositionModel { PosID = entity.PosID, DepID = entity.DepID, PosName = entity.PosName, DepName = entity.DepName, // Temp = entity.Temp }); }
public bool InsertPosandRole(PositionsEntity position, PosInRoleDetailDto[] list, string UPDATEDATA) { string sql = @"sp_position_INSERT"; string sql_role = @"sp_PosAndRole_INSERT"; string retID = ""; if (UPDATEDATA.Equals("INSERT")) { using (TransactionScope ts = new TransactionScope()) { retID = Db.InsertReturnID(sql, Take(position)); if (retID != null) { foreach (var ls in list) { object[] obj = { "@RoleID", ls.RoleID, "@PosID", retID }; try { Db.Insert(sql_role, obj); } catch { return(false); } } ts.Complete(); return(true); } else { return(false); } } } else if (UPDATEDATA.Equals("UPDATE")) { string sql_upd = @"sp_PosAndRole_UPDATE"; using (TransactionScope ts = new TransactionScope()) { DeletePosition(position.PosID); { foreach (var ls in list) { object[] obj = { "@RoleID", ls.RoleID, "@PosID", position.PosID }; Db.Insert(sql_upd, obj); } ts.Complete(); return(true); } } } return(false); }
public bool UpdatePosition(PositionsEntity position) { throw new NotImplementedException(); }
/// <summary> /// 获取电子围栏内所有摄像头信息 /// </summary> public string GetElectricFenceCameraList(SafeworkcontrolEntity data) { string ComerId = string.Empty; try { //三维监控点位服务接口地址 DataItemDetailBLL pdata = new DataItemDetailBLL(); var ThreeDApi = pdata.GetItemValue("kbsThreeMonitoringPoints"); space sp = new space(); spacedata sds = new spacedata(); List <spacegeo> geolist = new List <spacegeo>(); List <spacepnt> pntlist = new List <spacepnt>(); var comList = new KbscameramanageBLL().GetPageList("").Where(a => a.State == "在线" && a.CameraType == "枪机" && a.MonitoringArea != null).ToList(); spacegeo geo = new spacegeo(); geo.id = data.ID; if (data.Areacode != null) {//电子围栏坐标点 PositionsEntity alist = JsonConvert.DeserializeObject <PositionsEntity>(data.Areacode); List <double> dlist = new List <double>(); if (data.Areastate == 0) {//矩形 geo.type = 1; geo.distance = 0; //第一个点 dlist.Add(alist.positions[0].x); dlist.Add(alist.positions[0].z); //第二个点 dlist.Add(alist.positions[1].x); dlist.Add(alist.positions[0].z); //第三个点 dlist.Add(alist.positions[1].x); dlist.Add(alist.positions[1].z); //第四个点 dlist.Add(alist.positions[0].x); dlist.Add(alist.positions[1].z); //回到原点 dlist.Add(alist.positions[0].x); dlist.Add(alist.positions[0].z); geo.coor = dlist; geolist.Add(geo); } else if (data.Areastate == 1) {//圆形 geo.type = 0; dlist.Add(alist.positions[0].x); dlist.Add(alist.positions[0].z); geo.distance = Convert.ToInt32(data.Radius); geo.coor = dlist; geolist.Add(geo); } else if (data.Areastate == 2) {//手绘多边形 foreach (var ac in alist.positions) { dlist.Add(ac.x); dlist.Add(ac.z); } //闭合回到原点 dlist.Add(alist.positions[0].x); dlist.Add(alist.positions[0].z); geo.coor = dlist; geo.type = 1; geo.distance = 0; geolist.Add(geo); } foreach (var com in comList) {//摄像头坐标点集 PositionsEntity alist1 = JsonConvert.DeserializeObject <PositionsEntity>(com.MonitoringArea); if (alist1.floorID == alist.floorID) { List <double> dlist1 = new List <double>(); foreach (var ac in alist1.positions) { dlist1.Add(ac.x); dlist1.Add(ac.z); } //闭合回到原点 dlist1.Add(alist1.positions[0].x); dlist1.Add(alist1.positions[0].z); spacepnt pnt = new spacepnt() { id = com.CameraId, x = 0, y = 0, coor = dlist1 }; pntlist.Add(pnt); } } } sds.geo = geolist; sds.pnt = pntlist; sp.type = "2"; sp.data = sds; string rtn = HttpUtillibKbs.HttpThreeDPost(ThreeDApi, JsonConvert.SerializeObject(sp)); List <RtnSpace> rss = JsonConvert.DeserializeObject <List <RtnSpace> >(rtn); foreach (var item in rss) { if (string.IsNullOrEmpty(item.pntId)) { continue; } ComerId += item.pntId + ','; } return(ComerId); } catch (Exception er) { return(ComerId); } }