public string GetCarlistByRid(string RailId)
        {
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];
            if (user != null)
            {
                RailProperty rpt      = railPropertyBll.GetRailProperty(RailId);
                string       CaridStr = "";
                if (rpt.RailCaridstr != null && rpt.RailCaridstr != "")
                {
                    string[] RailCaridArr = rpt.RailCaridstr.Split(',');
                    string   CarStr       = "";
                    foreach (var Carid in RailCaridArr)
                    {
                        if (Carid != null && Carid != "")
                        {
                            CarStr += "'" + Carid + "',";
                        }
                    }
                    CaridStr = CarStr.Substring(0, CarStr.Length - 1);
                }
                else
                {
                    return(DtbConvertToJson(new DataTable(), 0));
                }
                StringBuilder sb = new StringBuilder();
                sb.Append("select ci.car_id,ci.car_no,ct.type_name,di.businessdivisionname,ti.ter_no,ti.TER_SIMCARD");
                sb.Append(" from Car_Info ci join car_type ct on ci.type_id=ct.type_id join dept_info di on ci.businessdivisionid=di.businessdivisionid");
                sb.Append(" left terminal_info ti on ci.car_id=ti.car_id left join");
                sb.Append(" (SELECT CAR_ID ");
                sb.Append(" FROM field_values GROUP BY CAR_ID) tt on ci.car_id=tt.car_id where 1=1 and ci.car_id in (" + CaridStr + ")");
                DataSet ds = c.GetColligateQuery("ColligateQuery.ProteanQuery", sb.ToString());
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    return(DtbConvertToJson(ds.Tables[0], ds.Tables[0].Rows.Count));
                }
                else
                {
                    return(DtbConvertToJson(ds.Tables[0], 0));
                }
            }
            else
            {
                return(DtbConvertToJson(new DataTable(), 0));
            }
        }
 public int Update(RailProperty entity)
 {
     return(ExecuteUpdate("RailProperty.UpdateRailProperty", entity));
 }
 public object Insert(RailProperty entity)
 {
     return(ExecuteInsert("RailProperty.InsertRailProperty", entity));
 }
 public int Update(RailProperty entity)
 {
     return(_iRailPropertyDao.Update(entity));
 }
        //public IList<RailProperty> GetRailPropertyList(object o)
        //{
        //return _iRailPropertyDao.GetRailPropertyList(o);
        //}

        public int Insert(RailProperty entity)
        {
            return(Convert.ToInt32(_iRailPropertyDao.Insert(entity)));
        }
        public int InsertRail(RailProperty entity)
        {
            entity.RailId = System.Guid.NewGuid().ToString();
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];
            if (user != null)
            {
                entity.Businessdivisionid = user.EnterId;
            }
            entity.RailState = 1;
            Regex regex = new Regex("(?<=\\()[^\\(\\)]*(?=\\))");

            //entity.Positiondata = "ksdfsdfkfaa";
            if (entity.RailData != null && entity.RailData.Trim() != "")
            {
                StringBuilder sb = new StringBuilder();
                char[]        c  = new char[3];
                c[0] = '(';
                c[1] = ')';
                c[2] = ' ';
                if (entity.RailShapetype == 1)
                {
                    MatchCollection m = regex.Matches(entity.RailData.Trim());
                    for (int i = 0; i < m.Count; i++)
                    {
                        //s = m[i].ToString().Trim(c);
                        string[] str = m[i].ToString().Split(',');
                        //计算最大X,最大Y,最小X,最小Y
                        if (entity.RailMaxx == 0 || entity.RailMaxx < Convert.ToDouble(str[0]))
                        {
                            entity.RailMaxx = Convert.ToDouble(str[0]);
                        }
                        if (entity.RailMinx == 0 || entity.RailMinx > Convert.ToDouble(str[0]))
                        {
                            entity.RailMinx = Convert.ToDouble(str[0]);
                        }
                        if (entity.RailMaxy == 0 || entity.RailMaxy < Convert.ToDouble(str[1]))
                        {
                            entity.RailMaxy = Convert.ToDouble(str[1]);
                        }
                        if (entity.RailMiny == 0 || entity.RailMiny > Convert.ToDouble(str[1]))
                        {
                            entity.RailMiny = Convert.ToDouble(str[1]);
                        }
                        //sb.Append(m[i].ToString().Replace('(','{').Replace(')','}')+",");
                        sb.Append("{x:" + str[0] + ",y:" + str[1] + "},");
                    }
                    //将电子围栏坐标以js数组的格式保存在数据库。
                    entity.RailData   = "[" + sb.ToString().Trim(',') + "]";
                    entity.RailCenter = "[{x:" + ((entity.RailMaxx + entity.RailMinx) / 2).ToString() + ",y:" + ((entity.RailMaxy + entity.RailMiny) / 2).ToString() + "}]";
                }
                else if (entity.RailShapetype == 0)
                {
                    string[]        strdata = entity.RailData.Split('$');
                    MatchCollection m       = regex.Matches(entity.RailData.Trim());
                    if (m.Count > 0)
                    {
                        string[] str    = m[0].ToString().Split(',');
                        double   degree = Convert.ToDouble(strdata[1]) / (2 * Math.PI * 6378137.0) * 360;

                        entity.RailMaxx   = Convert.ToDouble(str[0]) + degree;
                        entity.RailMinx   = Convert.ToDouble(str[0]) - degree;
                        entity.RailMaxy   = Convert.ToDouble(str[1]) + degree;
                        entity.RailMiny   = Convert.ToDouble(str[1]) + degree;
                        entity.RailData   = "[{x:" + str[0] + ",y:" + str[1] + ",Radius:" + strdata[1] + "}]";
                        entity.RailCenter = "[{x:" + str[0] + ",y:" + str[1] + "}]";
                    }
                }
                else
                {
                    MatchCollection m = regex.Matches(entity.RailData.Trim());
                    if (m.Count == 2)
                    {
                        string[] str = m[0].ToString().Split(',');
                        entity.RailMinx = Convert.ToDouble(str[0]);
                        entity.RailMiny = Convert.ToDouble(str[1]);
                        sb.Append("{x:" + str[0] + ",y:" + str[1] + "},");

                        str             = m[1].ToString().Split(',');
                        entity.RailMaxx = Convert.ToDouble(str[0]);
                        entity.RailMaxy = Convert.ToDouble(str[1]);
                        sb.Append("{x:" + str[0] + ",y:" + str[1] + "},");
                        entity.RailData   = "[" + sb.ToString().Trim(',') + "]";
                        entity.RailCenter = "[{x:" + ((entity.RailMaxx + entity.RailMinx) / 2).ToString() + ",y:" + ((entity.RailMaxy + entity.RailMiny) / 2).ToString() + "}]";
                    }
                }
            }
            entity.RailCdate = DateTime.Now;
            int a = Convert.ToInt32(railPropertyBll.Insert(entity));

            return(a);
        }