Esempio n. 1
0
        private void GetDateSources(ConfigNode node)
        {
            var sourceName = node.Attributes["name"];
            var sourceType = node.Attributes["type"];

            if (sourceType.ToLower() != "mysql")
            {
                throw new NotSupportedException("nova not support " + sourceType);
            }

            var userName = node.TryGetNode("UserName").InnerText;
            var password = node.TryGetNode("Password").InnerText;
            var sqlMode  = node.TryGetNode("SqlMode").InnerText;

            var locations = node.TryGetNodes("Locations/Location");
            var index     = 0;

            foreach (var item in locations)
            {
                Datasources.Add(String.Format("{0}[{1}]", sourceName, index), new DataSourceConfig()
                {
                    SourceName = String.Format("{0}[{1}]", sourceName, index),
                    SourceType = sourceType,
                    UserName   = userName,
                    Password   = password,
                    SqlMode    = sqlMode,
                    Host       = item.Attributes["host"],
                    Port       = Convert.ToInt32(item.Attributes["port"]),
                    Database   = item.Attributes["database"]
                });
                index++;
            }
        }
        private int[] mCount2            = new int[3];      //存放后CLICK的管线 每段长度的个数
        public PipeStatist(LengthStatistics m_LengthStatis, SceneControl m_SceneControl, CaliberStatist m_CaliberStatist, int m_Index, MaterialStatist m_MaterialStatist, OwnerStatist m_OwnerStatist)
        {
            mIndex                = m_Index;
            this.mOwnerStatist    = m_OwnerStatist;
            this.mMaterialStatist = m_MaterialStatist;
            this.mCaliberStatist  = m_CaliberStatist;
            this.mLengthStatis    = m_LengthStatis;
            this.mSceneControl    = m_SceneControl;
            //获取数据源的名字
            Datasources m_datasources = mSceneControl.Scene.Workspace.Datasources;

            mDataSourceName = m_datasources[0].Alias;
            InitializeComponent();
            switch (mIndex)
            {
            case 1: Array.Clear(mCount, 0, mCount.Length);
                Array.Clear(mCount1, 0, mCount1.Length);
                Array.Clear(mCount2, 0, mCount2.Length);
                LengBar();
                break;

            case 2: Array.Clear(mCount, 0, mCount.Length);
                Array.Clear(mCount1, 0, mCount1.Length);
                Array.Clear(mCount2, 0, mCount2.Length);
                CaliberBar();
                break;

            case 3: MaterialBar();
                break;

            case 4: OwnerBar();
                break;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Datasources != null)
         {
             hashCode = hashCode * 59 + Datasources.GetHashCode();
         }
         if (Step != null)
         {
             hashCode = hashCode * 59 + Step.GetHashCode();
         }
         if (Archives != null)
         {
             hashCode = hashCode * 59 + Archives.GetHashCode();
         }
         if (Path != null)
         {
             hashCode = hashCode * 59 + Path.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Returns true if OrgApacheSlingCommonsMetricsRrd4jImplCodahaleMetricsReporterProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingCommonsMetricsRrd4jImplCodahaleMetricsReporterProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingCommonsMetricsRrd4jImplCodahaleMetricsReporterProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Datasources == other.Datasources ||
                     Datasources != null &&
                     Datasources.Equals(other.Datasources)
                     ) &&
                 (
                     Step == other.Step ||
                     Step != null &&
                     Step.Equals(other.Step)
                 ) &&
                 (
                     Archives == other.Archives ||
                     Archives != null &&
                     Archives.Equals(other.Archives)
                 ) &&
                 (
                     Path == other.Path ||
                     Path != null &&
                     Path.Equals(other.Path)
                 ));
        }
Esempio n. 5
0
        /// <summary>
        /// 添加等级符号专题图
        /// Add the theme of graduated symbol
        /// </summary>
        public void ThemeRangeThemeDisplay()
        {
            try
            {
                Map    map    = m_mapControl.Map;
                Layers layers = map.Layers;
                Int32  count  = layers.Count;

                Datasources   datasources   = m_workspace.Datasources;
                Datasource    datasource    = datasources[0];
                Datasets      datasets      = datasource.Datasets;
                DatasetVector datasetVector = datasets["BaseMap_R"] as DatasetVector;

                ThemeGraduatedSymbol themeGraduatedSymbol = new ThemeGraduatedSymbol();
                themeGraduatedSymbol.Expression    = "Urban";
                themeGraduatedSymbol.BaseValue     = 150.00000;
                themeGraduatedSymbol.GraduatedMode = GraduatedMode.SquareRoot;
                themeGraduatedSymbol.IsFlowEnabled = false;

                GeoStyle geoStyle = themeGraduatedSymbol.PositiveStyle;
                geoStyle.LineColor = Color.Pink;

                m_layer          = layers.Add(datasetVector, themeGraduatedSymbol, true);
                m_themeLayerName = m_layer.Name;

                m_mapControl.Map.Refresh();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Esempio n. 6
0
		private Datasources FindCurrentDatasources()
		{
			if ( this.mruConnections == null )
				return null;

			Datasources datasources = mruConnections.FindDatasources( dbConnectionParameter.Provider );
			return datasources;
		}
Esempio n. 7
0
		private void DbConnectionParameter_GetDatasourceAddressValues( object sender, StringLookupGetValuesEventArgs args )
		{
			Datasources datasources = FindCurrentDatasources();
			if ( datasources == null )
				return;

			args.Values.Clear();
			foreach ( var ds in datasources.Datasource ) {
				args.Values.Add( ds.Address );
			}
		}
Esempio n. 8
0
		private void DbConnectionParameter_GetDatasourceNameValues( object sender, StringLookupGetValuesEventArgs args )
		{
			if ( this.mruConnections == null )
				return;

			Datasources datasources = mruConnections.FindDatasources( dbConnectionParameter.Provider );
			if ( datasources == null )
				return;

			args.Values.Clear();
			foreach ( var ds in datasources.Datasource ) {
				args.Values.Add( ds.Comment );
			}

		}
Esempio n. 9
0
        public SQLQuery(Workspace workspace, SceneControl scenecontrol, UseData useData, DataGridView datagridview)
        {
            InitializeComponent();
            mUseData      = useData;
            mDataGridView = datagridview;
            mScenecontrol = scenecontrol;
            //layer3DsTree1.Scene = scenecontrol.Scene;
            mWorkspace = workspace;
            //layer3DsTree1.SimpleMode = true;
            //移除屏幕图层和地形图层节点
            //  layer3DsTree1.TerrainLayersNode.Remove();
            //  layer3DsTree1.ScreenLayer3DNode.Remove();
            //  layer3DsTree1.Icons = TreeIconTypes.None | TreeIconTypes.TypeIcon;
            //  layer3DsTree1.MultiSelect = false;
            GetTreeNode();
            Datasources m_datasources = mScenecontrol.Scene.Workspace.Datasources;

            mDataSourceName = m_datasources[0].Alias;
        }
Esempio n. 10
0
        void LoadApplications(DirectoryInfo directoryInfo, Storage storage)
        {
            var fileInfo = directoryInfo.GetFiles("adlib.pbk");

            foreach (var file in fileInfo)
            {
                var path            = file.FullName.ToLower();
                var applicationInfo = new ApplicationInfo(path, storage);
                var applicationNode = new ApplicationNode(path, applicationInfo);
                Applications.Add(path, applicationNode);

                foreach (var dataSourceInfo in applicationInfo.DataSourceList)
                {
                    if (dataSourceInfo.DatabaseType == DatabaseType.NormalDatabase)
                    {
                        var dataSourceNode = new DataSourceNode(applicationInfo, dataSourceInfo);
                        Datasources.Add(dataSourceNode.Path, dataSourceNode);
                    }
                }
            }
        }
Esempio n. 11
0
        public EditInstrumentViewModel(Instrument model, IDataClient client, IClosableView view, IDialogCoordinator dialogCoordinator) : base(model, new InstrumentValidator())
        {
            _view             = view;
            DialogCoordinator = dialogCoordinator;
            if (model.Sessions == null)
            {
                model.Sessions = new List <InstrumentSession>();
            }
            if (model.Tags == null)
            {
                model.Tags = new List <Tag>();
            }

            foreach (var session in model.Sessions)
            {
                Sessions.Add(new SessionViewModel(session));
            }

            ContractMonths = new ObservableCollection <KeyValuePair <int, string> >();
            //fill the continuous futures contrat month combobox
            for (int i = 1; i < 10; i++)
            {
                ContractMonths.Add(new KeyValuePair <int, string>(i, MyUtils.Ordinal(i) + " Contract"));
            }

            Load = ReactiveCommand.CreateFromTask(async _ =>
            {
                var tags              = client.GetTags();
                var sessionTemplates  = client.GetSessionTemplates();
                var exchanges         = client.GetExchanges();
                var underlyingSymbols = client.GetUnderlyingSymbols();
                var datasources       = client.GetDatasources();

                await Task.WhenAll(tags, sessionTemplates, exchanges, underlyingSymbols, datasources).ConfigureAwait(true);

                var responses = new ApiResponse[] { tags.Result, sessionTemplates.Result, exchanges.Result, underlyingSymbols.Result, datasources.Result };
                if (await responses.DisplayErrors(this, DialogCoordinator).ConfigureAwait(true))
                {
                    return;
                }

                foreach (var tag in tags.Result.Result.Select(x => new CheckBoxTag(x, model.Tags.Contains(x))))
                {
                    AllTags.Add(tag);
                    tag.PropertyChanged += Tag_PropertyChanged;
                }

                Exchanges.AddRange(exchanges.Result.Result);

                foreach (var template in sessionTemplates.Result.Result)
                {
                    SessionTemplates.Add(template);
                }
                foreach (var us in underlyingSymbols.Result.Result)
                {
                    UnderlyingSymbols.Add(us);
                }
                foreach (var ds in datasources.Result.Result)
                {
                    Datasources.Add(ds);
                }
            });

            //Sessions
            AddNewSession = ReactiveCommand.Create(() => AddSession());
            RemoveSession = ReactiveCommand.Create <SessionViewModel>(ExecRemoveSession);

            //Save
            var saveCanExecute = this
                                 .WhenAnyValue(x => x.HasErrors)
                                 .Select(x => !x);

            Save = ReactiveCommand.CreateFromTask(async _ =>
            {
                if (model.ID == null || model.ID <= 0)
                {
                    //adding a new instrument
                    return(await client.AddInstrument(model).ConfigureAwait(true));
                }
                else
                {
                    //updating an existing one
                    return(await client.UpdateInstrument(model).ConfigureAwait(true));
                }
            }
                                                  , saveCanExecute);
            Save.Subscribe(async result =>
            {
                var errors = await result.DisplayErrors(this, DialogCoordinator).ConfigureAwait(true);
                if (!errors)
                {
                    AddedInstrument = result.Result;
                    _view.Close();
                }
            });

            this.Validate();
        }
        public override void PopulateDatabases(IDatasource datasource)
        {
            DatabaseObjectsCollection <IDatabase> databases = new DatabaseObjectsCollection <IDatabase>(datasource);

            SqlConnection sqlConnection = null;

            sqlConnection = new SqlConnection();
            sqlConnection.ConnectionString = datasource.ConnectionString;
            try
            {
                sqlConnection.Open();
            }
            catch (SqlException ex)
            {
                switch (ex.Number)
                {
                case 2:
                case 3:
                case 53:
                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                    {
                        Datasources.Remove(datasource as SQLServerDatasource);
                    }));
                    break;

                default:
                    break;
                }

                throw ex;
            }

            Version version = new Version(sqlConnection.ServerVersion);
            string  manifestToken;

            if (!IsVersionSupported(version, out manifestToken))
            {
                throw new NotSupportedException(string.Format("Version '{0}' is not supported!", version == null ? "unknown" : version.ToString()));
            }

            string sql = string.Empty;

            if (version.Major >= 9)
            {
                sql = "use master; select name from sys.databases order by name";
            }
            else
            {
                sql = "use master; select name from sysdatabases order by name";
            }

            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);

            sqlCommand.CommandTimeout = 20;

            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            while (sqlDataReader.Read())
            {
                databases.Add(new Database(datasource)
                {
                    Name = sqlDataReader["name"].ToString()
                });
            }

            sqlDataReader.Close();

            datasource.Databases = databases;

            if (sqlConnection != null && sqlConnection.State == ConnectionState.Open)
            {
                sqlConnection.Close();
            }
        }
        public override void PopulateDatabases(IDatasource datasource)
        {
            DatabaseObjectsCollection <IDatabase> databases = new DatabaseObjectsCollection <IDatabase>(datasource);

            SqlConnection sqlConnection = null;

            sqlConnection = new SqlConnection();
            sqlConnection.ConnectionString = datasource.ConnectionString;

            try
            {
                sqlConnection.Open();
            }
            catch (SqlException ex)
            {
                switch (ex.Number)
                {
                case 2:
                case 3:
                case 53:
                    Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                    {
                        Datasources.Remove(datasource as SQLServerDatasource);
                    }));
                    break;

                default:
                    break;
                }

                throw ex;
            }

            string sqlversion = sqlConnection.ServerVersion;

            sqlversion = sqlversion.Split('.').FirstOrDefault(); //major version
            int    intsqlversion = Convert.ToInt32(sqlversion);
            string sql           = string.Empty;

            if (intsqlversion == 8)
            {
                datasource.ProviderManifestToken = "2000";
            }
            else if (intsqlversion == 9)
            {
                datasource.ProviderManifestToken = "2005";
            }
            else if (intsqlversion == 10)
            {
                datasource.ProviderManifestToken = "2008";
            }

            if (intsqlversion >= 9)
            {
                sql = "use master; select name from sys.databases order by name";
            }
            else
            {
                sql = "use master; select name from sysdatabases order by name";
            }

            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);

            sqlCommand.CommandTimeout = 20;

            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();

            while (sqlDataReader.Read())
            {
                databases.Add(new Database(datasource)
                {
                    Name = sqlDataReader["name"].ToString()
                });
            }

            sqlDataReader.Close();

            datasource.Databases = databases;

            if (sqlConnection != null && sqlConnection.State == ConnectionState.Open)
            {
                sqlConnection.Close();
            }
        }