Esempio n. 1
0
        private void AddGPSHistoryDataToOracle(string strDEVICE_BM, int [] IDS)
        {
            string strTableName = "T_BUSI_POS_HIST";

            try
            {
                Point2Ds pt2Ds = GetPoint2DsFromLine(IDS);
                if (pt2Ds.Count > 0)
                {
                    string strPoints = JSONHelper.ObjectToJSON(pt2Ds);
                    string strDT_ST  = "to_date('2013-09-10','yyyy-mm-dd')";
                    string strDT_ET  = "to_date('2013-10-10','yyyy-mm-dd')";

                    string strSQL = string.Format("insert into {0}(ID,DEVICE_BM,REC_DATETIME_ST,REC_DATETIME_ET,REC_POS_CONTENT) values(get_guid(),'{1}',{2},{3},empty_blob())",
                                                  strTableName,
                                                  strDEVICE_BM,
                                                  strDT_ST,
                                                  strDT_ET);
                    string strROWID = DbHelperOra.ExecuteOracleSql(DbHelperOra.connectionString_172, strSQL);
                    string strWhere = string.Format("rowid = '{0}'", strROWID);
                    DbHelperOra.RwiteBlobToTable(DbHelperOra.connectionString_172, strTableName, "REC_POS_CONTENT", strWhere, strPoints);
                }
            }
            catch (SystemException sysEx)
            { }
        }
Esempio n. 2
0
        //以业务行政区划为主,添加到数据库中
        private void WriteToDatabaseByMIS()
        {
            string strTableName  = "T_BUSI_XZQH";
            string strTableName2 = "t_base_013_district";
            int    iIndex        = 0;

            try
            {
                //using (conn = new OracleConnection(connString))
                {
                    string    strQuery = string.Format("select  t.district_code,t.district_name,t.district_parent,t.district_level from {0} t where t.district_parent is not null order by t.district_level", strTableName2);
                    DataSet   dtSet    = DbHelperOra.Query(DbHelperOra.connectionString_Local, strQuery);
                    DataTable dtTable  = dtSet.Tables[0];

                    foreach (DataRow dr in dtTable.Rows)
                    {
                        iIndex++;
                        string strBM      = string.Format("{0}", dr[0]);
                        string strName    = string.Format("{0}", dr[1]);
                        string strPCODE   = string.Format("{0}", dr[2]);
                        string strRLEVEL  = string.Format("{0}", dr[3]);
                        double dTolerance = 0.0002;
                        {
                            dTolerance = GetTolerance(strBM);
                        }
                        Recordset recdst2          = GetRecordsetByCode(strBM);
                        Lib.Base.Define.csCenter c = new Lib.Base.Define.csCenter();
                        Lib.Base.Define.csBounds b = new Lib.Base.Define.csBounds();
                        if (recdst2 != null && recdst2.RecordCount > 0)
                        {
                            GeoLine geoLine1 = recdst2.GetGeometry() as GeoLine;
                            //c.center = geoLine1.Bounds.Center;
                            c.center = GetCenterPoint(strBM);
                            strName  = string.Format("{0}", recdst2.GetFieldValue("NAME"));
                            while (!recdst2.IsEOF)
                            {
                                try
                                {
                                    GeoLine geoLine2 = recdst2.GetGeometry() as GeoLine;

                                    for (int i = 0; i < geoLine2.PartCount; i++)
                                    {
                                        GeoLine geoL    = new GeoLine(geoLine2[i]);
                                        GeoLine geoLine = null;
                                        if (geoL[0].Count < 400)
                                        {
                                            geoLine = geoL;
                                        }
                                        else
                                        {
                                            geoLine = Geometrist.Resample(geoL, ResampleType.RTGeneral, dTolerance) as GeoLine;
                                        }
                                        b.bounds.Add(geoLine[0].Clone());
                                    }
                                }
                                catch (SystemException sysEx)
                                {
                                    string strErr = sysEx.Message;
                                }
                                recdst2.MoveNext();
                            }
                            string strCenter = JSONHelper.ObjectToJSON(c.center);
                            if (strBM.Length > 0)
                            {
                                string strGUID   = Guid.NewGuid().ToString("N").ToUpper();
                                string strPoints = JSONHelper.ObjectToJSON(b);
                                string strSQL    = string.Format("insert into {0}(ID,QHMC,QHBM,PID,CENTER,QHJB,VIEWBOUNDS) values('{1}','{2}','{3}','{4}','{5}',{6},empty_blob())",
                                                                 strTableName,
                                                                 strGUID,
                                                                 strName,
                                                                 strBM,
                                                                 strPCODE,
                                                                 strCenter,
                                                                 strRLEVEL);
                                string strROWID  = DbHelperOra.ExecuteOracleSql(DbHelperOra.connectionString_172, strSQL);
                                string strFilter = string.Format("rowid = '{0}'", strROWID);
                                DbHelperOra.RwiteRegionBoundsBlobToTable(DbHelperOra.connectionString_172, strTableName, "VIEWBOUNDS", strFilter, strPoints);
                            }
                        }
                        else
                        {
                            try
                            {
                                string strLogFile = string.Format("{0}Undolog.txt", AppDomain.CurrentDomain.BaseDirectory);
                                if (File.Exists(strLogFile))
                                {
                                    StreamWriter sw         = new StreamWriter(strLogFile, true);
                                    string       strContext = string.Format("未能找到图元的编码,{0}:{1}", strBM, strName);
                                    sw.WriteLine(strContext);
                                    sw.Close();
                                }
                                else
                                {
                                    StreamWriter sw         = File.CreateText(strLogFile);
                                    string       strContext = string.Format("未能找到图元的编码,{0}:{1}", strBM, strName);
                                    sw.WriteLine(strContext);
                                    sw.Close();
                                }
                            }
                            catch { }
                        }
                    }

                    MessageBox.Show("入库完毕");
                }
            }
            catch (SystemException sysEx)
            {
                string strErr = sysEx.Message;
            }
        }
Esempio n. 3
0
        //以GIS地图为主,添加到数据库中
        private void WriteToDatabaseByGIS()
        {
            string strTableName  = "t_busi_xzqh_bygis";
            string strTableName2 = "t_gov_region";
            int    iIndex        = 0;

            try
            {
                //using (conn = new OracleConnection(connString))
                //先删除原来数据
                {
                    {
                        string strSQL = string.Format("delete {0}", strTableName);
                        DbHelperOra.ExecuteSql(DbHelperOra.connectionString_172, strSQL);
                    }
                }
                //插入第一条数据“中国”
                {
                    {
                        string strSQL = string.Format("insert into {0}(id,qhmc,qhbm,pid,qhjb,center,viewbounds,qhpy) values('E312A4C4B6F9416283B7E4052A27C031','中国','000000','0',0,null,empty_blob(),'zhongguo')",
                                                      strTableName);
                        DbHelperOra.ExecuteSql(DbHelperOra.connectionString_172, strSQL);
                    }
                }
                {
                    //拿到所有区划
                    string    strQuery = string.Format("select  t.r_code,t.r_name,t.r_pcode,t.r_level from {0} t where t.r_pcode is not null order by t.r_level", strTableName2);
                    DataSet   dtSet    = DbHelperOra.Query(DbHelperOra.connectionString_Local, strQuery);
                    DataTable dtTable  = dtSet.Tables[0];

                    foreach (DataRow dr in dtTable.Rows)
                    {
                        iIndex++;
                        //获取区划代码
                        string strBM = string.Format("{0}", dr[0]);
                        if (strBM.Length < 6)
                        {
                            continue;
                        }
                        string      strName   = string.Format("{0}", dr[1]);
                        string      strPCODE  = string.Format("{0}", dr[2]);
                        string      strRLEVEL = string.Format("{0}", dr[3]);
                        csGovRegion csGR      = new csGovRegion(strName, strBM, strPCODE);
                        SetRegionInfo(csGR);
                        if (csGR.RegionCenter != null)
                        {
                            if (strBM.Length > 0)
                            {
                                string strGUID   = Guid.NewGuid().ToString("N").ToUpper();
                                string strCenter = JSONHelper.ObjectToJSON(csGR.RegionCenter.center);
                                string strPoints = JSONHelper.ObjectToJSON(csGR.RegionBounds.bounds);
                                string strSQL    = string.Format("insert into {0}(ID,QHMC,QHBM,PID,CENTER,QHJB,VIEWBOUNDS) values('{1}','{2}','{3}','{4}','{5}',{6},empty_blob())",
                                                                 strTableName,
                                                                 strGUID,
                                                                 strName,
                                                                 strBM,
                                                                 strPCODE,
                                                                 strCenter,
                                                                 strRLEVEL);
                                string strROWID  = DbHelperOra.ExecuteOracleSql(DbHelperOra.connectionString_172, strSQL);
                                string strFilter = string.Format("rowid = '{0}'", strROWID);
                                DbHelperOra.RwiteRegionBoundsBlobToTable(DbHelperOra.connectionString_172, strTableName, "VIEWBOUNDS", strFilter, strPoints);
                            }
                        }
                    }

                    MessageBox.Show("入库完毕");
                }
            }
            catch (SystemException sysEx)
            {
                string strErr = sysEx.Message;
            }
        }