Beispiel #1
0
        public bool API_DelObjFromDataByObjServerId(int iObjServerId)
        {
            bool   bResult = false;
            string strSql  = "Delete from ObjTable where id = @id";
            string strConn = YimaDataBase.GetSqlConnectionString();

            using (OleDbConnection conn = new OleDbConnection(strConn))
            {
                using (OleDbCommand cmd = new OleDbCommand(strSql, conn))
                {
                    cmd.Parameters.Add("id", OleDbType.Integer);
                    cmd.Parameters["id"].Value = iObjServerId;

                    try
                    {
                        conn.Open();
                        int i = cmd.ExecuteNonQuery();

                        if (i > 0)
                        {
                            bResult = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        string message = ex.ToString();
                    }
                }
            }
            return(bResult);
        }
Beispiel #2
0
        public string API_GetPointObjectImgSizeFromData(int iObjServerId)
        {
            string     strObjInfo = "";
            JSONHelper jsonHelper = new JSONHelper();

            string  strSql    = "select iObjImgWidth,iObjImgHeight from ObjTable where id = " + iObjServerId.ToString();
            string  strConn   = YimaDataBase.GetSqlConnectionString();
            DataSet ds        = YimaDataBase.ExecuteSqlReDataSet(strSql, strConn);
            int     iObjCount = ds.Tables[0].Rows.Count;


            if (iObjCount > 0)
            {
                string objImgWidth  = ds.Tables[0].Rows[0]["iObjImgWidth"].ToString();
                string objImgHeight = ds.Tables[0].Rows[0]["iObjImgHeight"].ToString();
                jsonHelper.AddItem("objImgWidth", objImgWidth);
                jsonHelper.AddItem("objImgHeight", objImgHeight);
                jsonHelper.ItemOk();
            }


            strObjInfo = jsonHelper.ToString();

            return(strObjInfo);
        }
Beispiel #3
0
        public bool API_SetObjImgUrlByServerId(int iServerId, string strObjImgUrl)
        {
            bool bResult = false;

            int imgWidth  = 0;
            int imgHeight = 0;

            bool bGetSizeResult = API_GetImgSizeByUrl(strObjImgUrl, ref imgWidth, ref imgHeight);

            if (bGetSizeResult == true)
            {
                string strConn = YimaDataBase.GetSqlConnectionString();
                strObjImgUrl = strObjImgUrl.Replace("'", "‘");
                string strSql = "update ObjTable set strObjImgUrl='" + strObjImgUrl + "',iObjImgWidth=" + imgWidth.ToString() + ",iObjImgHeight=" + imgHeight.ToString() + " where id = " + iServerId.ToString();
                int    ii     = YimaDataBase.ExecuteSql(strSql, strConn);

                if (ii > 0)
                {
                    bResult = true;
                }

                /*
                 * string strSql = "update ObjTable set strObjImgUrl=@objImgUrl,iObjImgWidth=@iObjImgWidth,iObjImgHeight=@iObjImgHeight where id = @id";
                 * using (OleDbConnection conn = new OleDbConnection(strConn))
                 * {
                 *  using (OleDbCommand cmd = new OleDbCommand(strSql, conn))
                 *  {
                 *      cmd.Parameters.Add("id", OleDbType.Integer);
                 *      cmd.Parameters["id"].Value = iServerId;
                 *
                 *      cmd.Parameters.Add("objImgUrl", OleDbType.VarChar, 50);
                 *      cmd.Parameters["objImgUrl"].Value = strObjImgUrl;
                 *
                 *      cmd.Parameters.Add("iObjImgWidth", OleDbType.Integer);
                 *      cmd.Parameters["iObjImgWidth"].Value = imgWidth;
                 *
                 *      cmd.Parameters.Add("iObjImgHeight", OleDbType.Integer);
                 *      cmd.Parameters["iObjImgHeight"].Value = imgHeight;
                 *
                 *      try
                 *      {
                 *          conn.Open();
                 *          int i = cmd.ExecuteNonQuery();
                 *
                 *          if (i > 0)
                 *          {
                 *              bResult = true;
                 *          }
                 *      }
                 *      catch (Exception ex)
                 *      {
                 *          string message = ex.ToString();
                 *      }
                 *  }
                 * }
                 * */
            }
            return(bResult);
        }
Beispiel #4
0
        public bool API_SetObjectGeoByServerId(int iServerId, string strObjGeo)
        {
            bool bResult = false;
            //string strSql = "update ObjTable set strObjGeo=@objGeo where id = @id";
            string strConn = YimaDataBase.GetSqlConnectionString();

            strObjGeo = strObjGeo.Replace("'", "‘");

            string strSql = "update ObjTable set strObjGeo='" + strObjGeo + "' where id = " + iServerId.ToString();
            int    ii     = YimaDataBase.ExecuteSql(strSql, strConn);

            if (ii > 0)
            {
                bResult = true;
            }
            return(ii > 0);

            /*
             * using (OleDbConnection conn = new OleDbConnection(strConn))
             * {
             *  using (OleDbCommand cmd = new OleDbCommand(strSql, conn))
             *  {
             *      cmd.Parameters.Add("id", OleDbType.Integer);
             *      cmd.Parameters["id"].Value = iServerId;
             *
             *      cmd.Parameters.Add("objGeo", OleDbType.VarChar, 2000);
             *      cmd.Parameters["objGeo"].Value = strObjGeo;
             *
             *      try
             *      {
             *          conn.Open();
             *          int i = cmd.ExecuteNonQuery();
             *
             *          if (i > 0)
             *          {
             *              bResult = true;
             *          }
             *      }
             *      catch (Exception ex)
             *      {
             *          string message = ex.ToString();
             *      }
             *  }
             * }
             *
             * return bResult;
             */
        }
Beispiel #5
0
        public string API_GetAllObjectInfoFromData()
        {
            string strObjInfo = "";


            string     strSql     = "select id,iObjLayerId,strObjName,strObjContent,strObjGeo,dtObjDate,strCompany,iObjStyleId,strObjImgUrl,iObjImgWidth,iObjImgHeight from ObjTable order by iObjLayerId ";
            string     strConn    = YimaDataBase.GetSqlConnectionString();
            DataSet    ds         = YimaDataBase.ExecuteSqlReDataSet(strSql, strConn);
            int        iObjCount  = ds.Tables[0].Rows.Count;
            JSONHelper jsonHelper = new JSONHelper();

            for (int i = 0; i < iObjCount; i++)
            {
                string strServerId     = ds.Tables[0].Rows[i]["id"].ToString();
                string strObjLayerId   = ds.Tables[0].Rows[i]["iObjLayerId"].ToString();
                string strObjName      = ds.Tables[0].Rows[i]["strObjName"].ToString();
                string strObjContent   = ds.Tables[0].Rows[i]["strObjContent"].ToString();
                string strObjGeo       = ds.Tables[0].Rows[i]["strObjGeo"].ToString();
                string strObjDate      = ds.Tables[0].Rows[i]["dtObjDate"].ToString();
                string strCompany      = ds.Tables[0].Rows[i]["strCompany"].ToString();
                string strObjStyleId   = ds.Tables[0].Rows[i]["iObjStyleId"].ToString();
                string strObjImgUrl    = ds.Tables[0].Rows[i]["strObjImgUrl"].ToString();
                string strObjImgWidth  = ds.Tables[0].Rows[i]["iObjImgWidth"].ToString();
                string strObjImgHeight = ds.Tables[0].Rows[i]["iObjImgHeight"].ToString();

                jsonHelper.AddItem("strServerId", strServerId);
                jsonHelper.AddItem("strObjLayerId", strObjLayerId);
                jsonHelper.AddItem("strObjName", strObjName);
                jsonHelper.AddItem("strObjContent", strObjContent);
                jsonHelper.AddItem("strObjGeo", strObjGeo);
                jsonHelper.AddItem("strObjDate", strObjDate);
                jsonHelper.AddItem("strObjStyleId", strObjStyleId);
                jsonHelper.AddItem("strObjImgUrl", strObjImgUrl);
                jsonHelper.AddItem("strObjImgWidth", strObjImgWidth);
                jsonHelper.AddItem("strObjImgHeight", strObjImgHeight);
                jsonHelper.ItemOk();
            }


            strObjInfo = jsonHelper.ToString();

            return(strObjInfo);
        }
Beispiel #6
0
        public bool API_SetObjectContentByServerId(int iServerId, string strObjectContent)
        {
            strObjectContent = strObjectContent.Replace("'", "’");
            string strConn = YimaDataBase.GetSqlConnectionString();

            string strSql = "update ObjTable set strObjContent='" + strObjectContent + "' where id = " + iServerId.ToString();
            int    ii     = YimaDataBase.ExecuteSql(strSql, strConn);

            return(ii > 0);

            /*
             * string strSql = "update ObjTable set strObjContent=@strObjContent where id = @id";
             * using (OleDbConnection conn = new OleDbConnection(strConn))
             * {
             *  using (OleDbCommand cmd = new OleDbCommand(strSql, conn))
             *  {
             *      cmd.Parameters.Add("id", OleDbType.Integer);
             *      cmd.Parameters["id"].Value = iServerId;
             *
             *      cmd.Parameters.Add("strObjContent", OleDbType.VarChar, 100);
             *      cmd.Parameters["strObjContent"].Value = strObjectContent;
             *
             *      try
             *      {
             *          conn.Open();
             *          int i = cmd.ExecuteNonQuery();
             *
             *          if (i > 0)
             *          {
             *              bResult = true;
             *          }
             *      }
             *      catch (Exception ex)
             *      {
             *          string message = ex.ToString();
             *      }
             *  }
             * }
             * return bResult;
             */
        }
        /// <summary>
        /// 添加一个图层
        /// </summary>
        /// <param name="strLayerName">图层名称(string)</param>
        /// <param name="iLayerType">图层类型(int):1=点图层、2=线图层、3=面图层</param>
        /// <param name="iIsShowOrNot">图层是否显示(int):1=显示,0=隐藏</param>
        /// <param name="strContent">备注(string)</param>
        /// <returns></returns>
        public static int AddNewLayer(string strLayerName, int iLayerType, int iIsShowOrNot, string strContent)
        {
            int    iPointServerId = -1;
            string strSql         = "insert into LayerTable(iObjLayerId,strObjName,strObjContent,strObjGeo,dtObjDate,strCompany,iObjStyleId,strObjImgUrl,iObjImgWidth,iObjImgHeight)values(@objLayerId,@objName,@objContent,@objGeo,@objDate,@company,@objStyleId,@objImgUrl,@objImgWidth,@objImgHeight)";
            string strConn        = YimaDataBase.GetSqlConnectionString();

            using (OleDbConnection conn = new OleDbConnection(strConn))
            {
                using (OleDbCommand cmd = new OleDbCommand(strSql, conn))
                {
                    cmd.Parameters.Add("objLayerId", OleDbType.Integer);
                    cmd.Parameters["objLayerId"].Value = Convert.ToInt32(objLayerId);

                    cmd.Parameters.Add("objName", OleDbType.VarChar, 50);
                    cmd.Parameters["objName"].Value = objName;

                    cmd.Parameters.Add("objContent", OleDbType.VarChar, 100);
                    cmd.Parameters["objContent"].Value = objContent;
                }
            }
        }
Beispiel #8
0
        //添加新物标信息到数据库,并返回物标的再数据库中的id,即serverId
        public int API_AddObjToData(string objLayerId, string objType, string objName, string objContent, string objGeo, string company, string objStyleId, string objImgUrl)
        {
            int imgWidth  = 0;
            int imgHeight = 0;

            if (!objImgUrl.Equals(""))
            {
                API_GetImgSizeByUrl(objImgUrl, ref imgWidth, ref imgHeight);
            }

            int    iPointServerId = -1;
            string strSql         = "insert into ObjTable(iObjLayerId,strObjName,strObjContent,strObjGeo,dtObjDate,strCompany,iObjStyleId,strObjImgUrl,iObjImgWidth,iObjImgHeight)values(@objLayerId,@objName,@objContent,@objGeo,@objDate,@company,@objStyleId,@objImgUrl,@objImgWidth,@objImgHeight)";
            string strConn        = YimaDataBase.GetSqlConnectionString();

            using (OleDbConnection conn = new OleDbConnection(strConn))
            {
                using (OleDbCommand cmd = new OleDbCommand(strSql, conn))
                {
                    cmd.Parameters.Add("objLayerId", OleDbType.Integer);
                    cmd.Parameters["objLayerId"].Value = Convert.ToInt32(objLayerId);

                    cmd.Parameters.Add("objName", OleDbType.VarChar, 50);
                    cmd.Parameters["objName"].Value = objName;

                    cmd.Parameters.Add("objContent", OleDbType.VarChar, 100);
                    cmd.Parameters["objContent"].Value = objContent;

                    cmd.Parameters.Add("objGeo", OleDbType.VarChar, 2000);
                    cmd.Parameters["objGeo"].Value = objGeo;

                    cmd.Parameters.Add("objDate", OleDbType.Date);
                    cmd.Parameters["objDate"].Value = DateTime.Now;

                    cmd.Parameters.Add("company", OleDbType.VarChar, 50);
                    cmd.Parameters["company"].Value = company;

                    cmd.Parameters.Add("objStyleId", OleDbType.Integer);
                    cmd.Parameters["objStyleId"].Value = Convert.ToInt32(objStyleId);

                    cmd.Parameters.Add("objImgUrl", OleDbType.VarChar, 50);
                    cmd.Parameters["objImgUrl"].Value = objImgUrl;

                    cmd.Parameters.Add("objImgWidth", OleDbType.Integer);
                    cmd.Parameters["objImgWidth"].Value = imgWidth;

                    cmd.Parameters.Add("objImgHeight", OleDbType.Integer);
                    cmd.Parameters["objImgHeight"].Value = imgHeight;
                    try
                    {
                        conn.Open();
                        int i = cmd.ExecuteNonQuery();

                        if (i > 0)//得到刚刚插入的记录id(即标注id)
                        {
                            cmd.CommandText = "select @@identity as id";
                            iPointServerId  = Convert.ToInt32(cmd.ExecuteScalar());
                        }
                    }
                    catch (Exception ex)
                    {
                        string message = ex.ToString();
                    }
                }
            }

            return(iPointServerId);
        }