当前位置: 首页>>代码示例>>C#>>正文


C# DataStore.Disconnect方法代码示例

本文整理汇总了C#中DataStore.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# DataStore.Disconnect方法的具体用法?C# DataStore.Disconnect怎么用?C# DataStore.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataStore的用法示例。


在下文中一共展示了DataStore.Disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBaseData

        /// <summary>Get the base data that is in scope.</summary>
        public DataTable GetBaseData(string tableName)
        {
            if (tables.ContainsKey(tableName))
                return tables[tableName];

            else if (tableName != null)
            {
                Simulation parentSimulation = Apsim.Parent(this, typeof(Simulation)) as Simulation;
                Zone parentZone = Apsim.Parent(this, typeof(Zone)) as Zone;
                Experiment parentExperiment = Apsim.Parent(this, typeof(Experiment)) as Experiment;

                string baseFilter = null;
                // If the graph is in a zone then just graph the zone.
                if (parentZone != null && !(parentZone is Simulation))
                {
                    // in a zone.
                    baseFilter = string.Format("SimulationName='{0}' and ZoneName='{1}'", parentSimulation.Name, parentZone.Name);
                }
                else
                {
                    List<string> simulationNames = new List<string>();
                    if (parentSimulation != null)
                        simulationNames.Add(parentSimulation.Name);  // in a simulation.

                    else if (parentExperiment != null)
                        simulationNames.AddRange(parentExperiment.Names());

                    else
                    {
                        // Must be in a folder at the top level or at the top level of the .apsimx file.
                        IModel parentOfGraph = this.Parent;

                        // Look for experiments.
                        foreach (Experiment experiment in Apsim.ChildrenRecursively(parentOfGraph, typeof(Experiment)))
                            simulationNames.AddRange(experiment.Names());

                        // Look for simulations if we didn't find any experiments.
                        foreach (Simulation simulation in Apsim.ChildrenRecursively(parentOfGraph, typeof(Simulation)))
                        {
                            if (simulation.Parent is Experiment)
                            { }
                            else
                                simulationNames.Add(simulation.Name);
                        }
                    }

                    // convert simulationNames to a filter.
                    foreach (string simulationName in simulationNames)
                    {
                        if (baseFilter != null)
                            baseFilter += ",";
                        baseFilter += "'" + simulationName + "'";
                    }
                    baseFilter = "SimulationName IN (" + baseFilter + ")";
                }

                DataStore dataStore = new DataStore(this);
                DataTable data = dataStore.GetFilteredData(tableName, baseFilter);
                dataStore.Disconnect();
                tables.Add(tableName, data);
                return data;
            }

            return null;
        }
开发者ID:hut104,项目名称:ApsimX,代码行数:66,代码来源:Graph.cs

示例2: OnSimulationCompleted

        private void OnSimulationCompleted(object sender, EventArgs e)
        {
            // Get rid of old data in .db
            DataStore dataStore = new DataStore(this);
            if (this.simulation != null)
            {
                dataStore.DeleteOldContentInTable(this.simulation.Name, this.Name);
            }
            // Write and store a table in the DataStore
            if (this.columns != null && this.columns.Count > 0)
            {
                DataTable table = new DataTable();

                foreach (ReportColumn variable in this.columns)
                    variable.AddColumnsToTable(table);

                foreach (ReportColumn variable in this.columns)
                    variable.AddRowsToTable(table);

                dataStore.WriteTable(this.simulation.Name, this.Name, table);

                this.columns.Clear();
                this.columns = null;
            }

            dataStore.Disconnect();
            dataStore = null;
        }
开发者ID:kiwiroy,项目名称:ApsimX,代码行数:28,代码来源:Report.cs

示例3: Run

        /// <summary>Main run method for performing our calculations and storing data.</summary>
        /// <param name="dataStore">The data store.</param>
        /// <exception cref="ApsimXException">
        /// Could not find model data table:  + ObservedTableName
        /// or
        /// Could not find observed data table:  + ObservedTableName
        /// </exception>
        public void Run(DataStore dataStore)
        {
            if (PredictedTableName != null && ObservedTableName != null)
            {
                dataStore.DeleteTable(this.Name);

                DataTable predictedDataNames = dataStore.RunQuery("PRAGMA table_info(" + PredictedTableName + ")");
                DataTable observedDataNames  = dataStore.RunQuery("PRAGMA table_info(" + ObservedTableName + ")");

                if (predictedDataNames == null)
                    throw new ApsimXException(this, "Could not find model data table: " + ObservedTableName);

                if (observedDataNames == null)
                    throw new ApsimXException(this, "Could not find observed data table: " + ObservedTableName);

                IEnumerable<string> commonCols = from p in predictedDataNames.AsEnumerable()
                                               join o in observedDataNames.AsEnumerable() on p["name"] equals o["name"]
                                               select p["name"] as string;

                StringBuilder query = new StringBuilder("SELECT ");
                foreach (string s in commonCols)
                {
                    if (s == FieldNameUsedForMatch || s == FieldName2UsedForMatch || s == FieldName3UsedForMatch)
                        query.Append("I.'@field', ");
                    else
                        query.Append("I.'@field' AS '[email protected]', R.'@field' AS '[email protected]', ");

                    query.Replace("@field", s);
                }

                query.Append("FROM " + ObservedTableName + " I INNER JOIN " + PredictedTableName + " R USING (SimulationID) WHERE I.'@match1' = R.'@match1'");
                if (FieldName2UsedForMatch != null)
                    query.Append(" AND I.'@match2' = R.'@match2'");
                if (FieldName3UsedForMatch != null)
                    query.Append(" AND I.'@match3' = R.'@match3'");
                query.Replace(", FROM", " FROM"); // get rid of the last comma
                query.Replace("I.'SimulationID' AS 'Observed.SimulationID', R.'SimulationID' AS 'Predicted.SimulationID'", "I.'SimulationID' AS 'SimulationID'");

                query = query.Replace("@match1", FieldNameUsedForMatch);
                query = query.Replace("@match2", FieldName2UsedForMatch);
                query = query.Replace("@match3", FieldName3UsedForMatch);

                DataTable predictedObservedData = dataStore.RunQuery(query.ToString());

                if (predictedObservedData != null)
                    dataStore.WriteTable(null, this.Name, predictedObservedData);
                dataStore.Disconnect();
            }
        }
开发者ID:hol353,项目名称:ApsimX,代码行数:56,代码来源:PredictedObserved.cs


注:本文中的DataStore.Disconnect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。