Пример #1
0
        void ILoader.Load(EnumG1ArcGisTnRecType type)
        {
            //*************
            //Lay connection info hien tai
            //SdeUserInfo va SqlUserInfo la static
            SdeConnection conn = new SdeConnection();
            ISdeConnectionInfo sdeConn = conn as ISdeConnectionInfo;
            ISdeUserInfo sdeUser = sdeConn.GetSdeUserInfo();
            //ISqlConnectionInfo sqlConn = (ISqlConnectionInfo)sdeConn;

            //MessageBox.Show(sqlConn.GetSqlUserInfo().UserName);
            _sqlUser = sdeUser.GetSqlUserInfo();

            SqlDataReader reader = null;
            //_pair = new XPair();
            LoaderEventArg e=new LoaderEventArg(type);
            //MessageBox.Show(string.Format("line 39 Loader:--{0}, so luong view:{1}", _sql, _lstView.Count));
            try
            {
                if (_sqlTable.IsClosed())
                {
                    _sqlTable.SetUserInfo(_sqlUser.GetConnectionStringAsArray());
                    //MessageBox.Show(String.Format("line 59 Loader, ConnectionString={0}", _sqlUser.GetConnectionString()));

                    _sqlTable.OpenConnection();
                }

                reader = _sqlTable.GetSqlCommand(_sql).ExecuteReader();
                //MessageBox.Show("line 49 Loader: --" + reader.HasRows.ToString() + "--" + _sql);
                //_pair.ClearPair();
                foreach (IReceiverView r in _lstView)
                {
                    r.ReceiveData(reader,type);
                }
                reader.Close();
                _sqlTable.CloseConnection();
                onFinished(e);

            }
            catch (Exception e1)
            {
                if (reader != null)
                {
                    reader.Close();
                }
                _sqlTable.CloseConnection();
                //MessageBox.Show("line 67 - Loader \n" + e1.ToString());
            }
        }
Пример #2
0
 void IReceiverView.SetSql(EnumG1ArcGisTnRecType type, string sql)
 {
     _dicSql[type] = sql;
 }
Пример #3
0
 void IReceiverView.SetTableName(EnumG1ArcGisTnRecType type, string tableName)
 {
     _dicTableName[type] = tableName;
 }
Пример #4
0
 void IReceiverView.SetColsNameInWhereClause(EnumG1ArcGisTnRecType type, string colsName)
 {
     this._dicColsNameInWhereClause[type] = colsName;
 }
Пример #5
0
        void IReceiverView.ReceiveData(System.Data.SqlClient.SqlDataReader data, EnumG1ArcGisTnRecType type)
        {
            //MessageBox.Show(string.Format("line 169 CalculationView, fild count={0},isclose{1}", data.FieldCount, data.IsClosed));
            #region load doan duong
            _lstDoanDuong = new XPair();
            if (type == EnumG1ArcGisTnRecType.Doanduong)
            {

                string doanduong = "";
                string batdau = "";
                string ketthuc = "";
                while (data.Read())
                {

                    if (data.HasRows)
                    {
                        if (data.IsDBNull(1))
                        {
                            batdau = "...";
                        }
                        else
                        {
                            batdau = data.GetString(1);
                        }
                        if (data.IsDBNull(2))
                        {
                            ketthuc = "...";
                        }
                        else
                        {
                            ketthuc = data.GetString(2);
                        }
                        doanduong = string.Format("Từ {0} đền {1}", batdau, ketthuc);
                        _lstDoanDuong.NewPair(int.Parse(data.GetValue(0).ToString()), doanduong);
                    }
                }
            }
            #endregion

            #region load duong
            else if (type == EnumG1ArcGisTnRecType.Duong)
            {
                _lstDuong = new XPair();

                if (data.HasRows)
                {
                    while (data.Read())
                    {
                        _lstDuong.NewPair(0, data.GetString(0));
                    }
                }
                //MessageBox.Show(string.Format("line 178 CalculationView, lstDuong cout:{0}", _lstDuong.ListPair.Count));
            }
            #endregion

            #region load xa
            else if (type == EnumG1ArcGisTnRecType.Xa)
            {
                _lstXa = new XPair();
                while (data.Read())
                {

                    if (data.HasRows)
                    {
                        _lstXa.NewPair(int.Parse(data.GetValue(0).ToString()), data.GetString(1));
                    }
                }
            }
            #endregion
        }
Пример #6
0
 void IReceiverView.Load(EnumG1ArcGisTnRecType type)
 {
     SdeConnection conn = new SdeConnection();
     ISdeConnectionInfo sdeConn = (ISdeConnectionInfo)conn;
     _fcName = new TnFeatureClassName(sdeConn.Workspace);
     _tblName = new TnTableName(sdeConn.Workspace);
     //if (type == EnumG1ArcGisTnRecType.Duong)
     //{
     //    this._dicSql[type]=string.Format("select distinct {0} from {1}", this._dicColsName[type], this._dicTableName[type]);
     //}
     //else if (type == EnumG1ArcGisTnRecType.Doanduong)
     //{
     //    string.Format("select {0},{1},{2} from {3} where {4}=N'{5}'", _fcName.FC_DUONG.MA_DUONG, _fcName.FC_DUONG.BAT_DAU, _fcName.FC_DUONG.KET_THUC, "sde.thixa_duong", _dicColsNameInWhereClause[type], cbxDuong.Text);
     //}
     _dicSql[EnumG1ArcGisTnRecType.Doanduong] = string.Format("select {0},{1},{2} from {3} where {4}=N'{5}'", _tblName.TEN_DUONG.MA_DUONG, _tblName.TEN_DUONG.BAT_DAU, _tblName.TEN_DUONG.KET_THUC, DataNameTemplate.Ten_Duong, _tblName.TEN_DUONG.TEN_DUONG, cbxDuong.Text);
     //_dicSql.Add(EnumG1ArcGisTnRecType.Doanduong, );
     //_sql = string.Format("select {0},{1},{2} from {3} where {4}='a'", _fcName.FC_DUONG.MA_DUONG, _fcName.FC_DUONG.BAT_DAU, _fcName.FC_DUONG.KET_THUC, "do.thixa_duong", _fcName.FC_DUONG.TEN_DUONG);
     //_dicSql.Add(EnumG1ArcGisTnRecType.Doanduong, "");
     _dicSql[EnumG1ArcGisTnRecType.Duong] = string.Format("select distinct {0} from {1}", _tblName.TEN_DUONG.TEN_DUONG, DataNameTemplate.Ten_Duong);
     //_dicSql.Add(EnumG1ArcGisTnRecType.Huyen, "");
     _dicSql[EnumG1ArcGisTnRecType.Xa] = string.Format("select {0},{1} from {2}", _fcName.FC_RANH_XA_POLY.MA_XA, _fcName.FC_RANH_XA_POLY.TEN_XA, DataNameTemplate.Ranh_Xa_Poly);
     //MessageBox.Show("line 126 CalculationView --" + type.ToString() + "\n " + _dicSql[EnumG1ArcGisTnRecType.Xa]);
     _loaderController.ReqLoad(type);
 }
Пример #7
0
 public LoaderEventArg(EnumG1ArcGisTnRecType type)
 {
     this._type = type;
 }
Пример #8
0
 void ILoaderController.ReqLoad(EnumG1ArcGisTnRecType type)
 {
     _loader.Sql = _view.DicSQL[type];
     _loader.Load(type);
 }