public IEnumerable <Person> Read()
        {
            CreateConnectionAndQuery("SELECT Id, FirstName, LastName, Age FROM person");
            ResultSet dataReader = query.executeQuery();

            personList.Clear();

            while (dataReader.next())
            {
                personList.Add(
                    new Person(
                        (uint)dataReader.getInt(0),
                        dataReader.getString(1),
                        dataReader.getString(2),
                        (uint)dataReader.getInt(3)
                        )
                    );
            }

            dataReader.close();
            dataReader.Dispose();
            DisposeConnection();

            return(personList);
        }
        static public Hashtable find(string sql)
        {
            PDO       pdo       = new PDO();
            ResultSet resultSet = pdo.query(sql);
            Hashtable result    = resultSet.hasNext() ? resultSet.fetch() : new Hashtable();

            resultSet.Dispose();
            pdo.Dispose();
            return(result);
        }
        public void DisposeResultSet()
        {
            // Setup: Mock file stream factory, mock db reader
            var mockFileStreamFactory = new Mock <IFileStreamFactory>();

            // If: I setup a single resultset and then dispose it
            ResultSet rs = new ResultSet(Common.Ordinal, Common.Ordinal, mockFileStreamFactory.Object);

            rs.Dispose();

            // Then: The file that was created should have been deleted
            mockFileStreamFactory.Verify(fsf => fsf.DisposeFile(It.IsAny <string>()), Times.Once);
        }
 /// <summary>
 /// Disposes of the underlying resources.
 /// </summary>
 public void Dispose()
 {
     if (ResultGraph != null)
     {
         ResultGraph.Dispose();
         ResultGraph = null;
     }
     if (ResultSet != null)
     {
         ResultSet.Dispose();
         ResultSet = null;
     }
 }
Beispiel #5
0
        public void DisposeResultSet()
        {
            // Setup: Mock file stream factory, mock db reader
            var mockFileStreamFactory = new Mock <IFileStreamFactory>();
            var mockDataReader        = Common.CreateTestConnection(null, false).CreateCommand().ExecuteReaderAsync().Result;

            // If: I setup a single resultset and then dispose it
            ResultSet rs = new ResultSet(mockDataReader, Common.Ordinal, Common.Ordinal, mockFileStreamFactory.Object);

            rs.Dispose();

            // Then: The file that was created should have been deleted
            mockFileStreamFactory.Verify(fsf => fsf.DisposeFile(It.IsAny <string>()), Times.Once);
        }
        static public List <Hashtable> select(string sql)
        {
            List <Hashtable> list = new List <Hashtable>();
            PDO       pdo         = new PDO();
            ResultSet resultSet   = pdo.query(sql);

            while (resultSet.hasNext())
            {
                list.Add(resultSet.fetch());
            }
            resultSet.Dispose();
            pdo.Dispose();
            return(list);
        }
        public List <Hashtable> select()
        {
            List <Hashtable> result = new List <Hashtable>();
            string           sql    = builder.buildSelect();

            PDO       pdo       = new PDO();
            ResultSet resultSet = pdo.query(sql);

            while (resultSet.hasNext())
            {
                result.Add(resultSet.fetch());
            }
            resultSet.Dispose();
            pdo.Dispose();
            return(result);
        }
        public List <string> column(string field)
        {
            List <string> result = new List <string>();

            string sql = builder.buildSelect();

            PDO       pdo       = new PDO();
            ResultSet resultSet = pdo.query(sql);

            while (resultSet.hasNext())
            {
                Hashtable hashtable = resultSet.fetch();
                result.Add(hashtable[field].ToString());
            }
            resultSet.Dispose();
            pdo.Dispose();
            return(result);
        }
        protected void selectCollect(Collect <Hashtable> collect)
        {
            if (collect == null)
            {
                throw new NullReferenceException("collect 列不能为Null");
            }
            string sql = builder.buildSelect();

            PDO       pdo       = new PDO();
            ResultSet resultSet = pdo.query(sql);

            while (resultSet.hasNext())
            {
                collect.Add(resultSet.fetch());
            }
            resultSet.Dispose();
            pdo.Dispose();
        }
        public Hashtable column(string field, string key)
        {
            Hashtable result = new Hashtable();

            string sql = builder.buildSelect();

            PDO       pdo       = new PDO();
            ResultSet resultSet = pdo.query(sql);

            while (resultSet.hasNext())
            {
                Hashtable hashtable = resultSet.fetch();
                var       k         = hashtable[key];
                var       v         = hashtable[field];
                result[k] = v;
            }
            resultSet.Dispose();
            pdo.Dispose();
            return(result);
        }
        public Hashtable find()
        {
            //limit(1);
            string    sql       = builder.buildSelect();
            PDO       pdo       = new PDO();
            ResultSet resultSet = pdo.query(sql);
            Hashtable hashtable = null;

            if (resultSet.hasNext())
            {
                hashtable = resultSet.fetch();
            }
            else
            {
                hashtable = new Hashtable();
            }
            resultSet.Dispose();
            pdo.Dispose();
            return(hashtable);
        }
Beispiel #12
0
        virtual protected Hashtable parseData(Hashtable data, bool isInsert)
        {
            Hashtable result = new Hashtable();

            // 分析数据
            try
            {
                var       sql       = getTableFind(parseTable());
                PDO       pdo       = new PDO();
                ResultSet resultSet = pdo.query(sql);
                int       length    = resultSet.columnCount();
                for (int i = 0; i < length; i++)
                {
                    string col  = resultSet.columnName(i);
                    string type = resultSet.columnType(i);
                    if (col.ToLower().Equals("id"))
                    {
                        continue;
                    }
                    if (data.ContainsKey(col))
                    {
                        object content = data[col];
                        if (content is ArrayList)
                        {
                            ArrayList var = (ArrayList)content;
                            if (var[0].Equals("inc") || var[0].Equals("dec"))
                            {
                                string fuhao = var[0].Equals("inc") ? "+" : "-";
                                result.Add(col, col + fuhao + var[1]);
                            }
                        }
                        else
                        {
                            result.Add(col, getFieldValue(type, content.ToString()));
                        }
                    }
                    else
                    {
                        if (isInsert)
                        {
                            result.Add(col, getFieldDefault(type));
                        }
                    }
                }
                resultSet.Dispose();
                pdo.Dispose();

                /*
                 * DataSet dataSet = Connect.getDataSet(sql);
                 * DataColumnCollection columns = dataSet.Tables[0].Columns;
                 * for (int i = 0; i < columns.Count; i++)
                 * {
                 *  DataColumn column = columns[i];
                 *  string col = column.ColumnName;
                 *  string type = column.DataType.ToString();
                 *  if (col.ToLower().Equals("id"))
                 *  {
                 *      continue;
                 *  }
                 *  if (data.ContainsKey(col))
                 *  {
                 *      object content = data[col];
                 *      if (content is ArrayList)
                 *      {
                 *          ArrayList var = (ArrayList) content;
                 *          if (var[0].Equals("inc") || var[0].Equals("dec"))
                 *          {
                 *              string fuhao = var[0].Equals("inc") ? "+" : "-";
                 *              result.Add(col, col + fuhao + var[1]);
                 *          }
                 *      }
                 *      else
                 *      {
                 *          result.Add(col, getFieldValue(type, content.ToString()));
                 *      }
                 *  }
                 *  else
                 *  {
                 *      if (isInsert)
                 *      {
                 *          result.Add(col, getFieldDefault(type));
                 *      }
                 *  }
                 * }*/
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(result);
        }
        void ReleaseDesignerOutlets()
        {
            if (ActionBar != null)
            {
                ActionBar.Dispose();
                ActionBar = null;
            }

            if (AddressOK != null)
            {
                AddressOK.Dispose();
                AddressOK = null;
            }

            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (BottomSeparator != null)
            {
                BottomSeparator.Dispose();
                BottomSeparator = null;
            }

            if (DistanceFilters != null)
            {
                DistanceFilters.Dispose();
                DistanceFilters = null;
            }

            if (DistanceFiltersOpenClose != null)
            {
                DistanceFiltersOpenClose.Dispose();
                DistanceFiltersOpenClose = null;
            }

            if (DistanceLimit != null)
            {
                DistanceLimit.Dispose();
                DistanceLimit = null;
            }

            if (DistanceLimitInput != null)
            {
                DistanceLimitInput.Dispose();
                DistanceLimitInput = null;
            }

            if (DistanceSourceAddress != null)
            {
                DistanceSourceAddress.Dispose();
                DistanceSourceAddress = null;
            }

            if (DistanceSourceAddressLabel != null)
            {
                DistanceSourceAddressLabel.Dispose();
                DistanceSourceAddressLabel = null;
            }

            if (DistanceSourceAddressText != null)
            {
                DistanceSourceAddressText.Dispose();
                DistanceSourceAddressText = null;
            }

            if (DistanceSourceCurrent != null)
            {
                DistanceSourceCurrent.Dispose();
                DistanceSourceCurrent = null;
            }

            if (DistanceSourceCurrentLabel != null)
            {
                DistanceSourceCurrentLabel.Dispose();
                DistanceSourceCurrentLabel = null;
            }

            if (DistanceUnitText != null)
            {
                DistanceUnitText.Dispose();
                DistanceUnitText = null;
            }

            if (FilterLayout != null)
            {
                FilterLayout.Dispose();
                FilterLayout = null;
            }

            if (ListType != null)
            {
                ListType.Dispose();
                ListType = null;
            }

            if (ListView != null)
            {
                ListView.Dispose();
                ListView = null;
            }

            if (ListViewMap != null)
            {
                ListViewMap.Dispose();
                ListViewMap = null;
            }

            if (LoaderCircle != null)
            {
                LoaderCircle.Dispose();
                LoaderCircle = null;
            }

            if (LoaderCircleLeftConstraint != null)
            {
                LoaderCircleLeftConstraint.Dispose();
                LoaderCircleLeftConstraint = null;
            }

            if (LoadNext != null)
            {
                LoadNext.Dispose();
                LoadNext = null;
            }

            if (LoadPrevious != null)
            {
                LoadPrevious.Dispose();
                LoadPrevious = null;
            }

            if (MapSatellite != null)
            {
                MapSatellite.Dispose();
                MapSatellite = null;
            }

            if (MapStreet != null)
            {
                MapStreet.Dispose();
                MapStreet = null;
            }

            if (MapView != null)
            {
                MapView.Dispose();
                MapView = null;
            }

            if (MenuAbout != null)
            {
                MenuAbout.Dispose();
                MenuAbout = null;
            }

            if (MenuChatList != null)
            {
                MenuChatList.Dispose();
                MenuChatList = null;
            }

            if (MenuChatListBg != null)
            {
                MenuChatListBg.Dispose();
                MenuChatListBg = null;
            }

            if (MenuChatListBgCorner != null)
            {
                MenuChatListBgCorner.Dispose();
                MenuChatListBgCorner = null;
            }

            if (MenuContainer != null)
            {
                MenuContainer.Dispose();
                MenuContainer = null;
            }

            if (MenuHelpCenter != null)
            {
                MenuHelpCenter.Dispose();
                MenuHelpCenter = null;
            }

            if (MenuIcon != null)
            {
                MenuIcon.Dispose();
                MenuIcon = null;
            }

            if (MenuLayer != null)
            {
                MenuLayer.Dispose();
                MenuLayer = null;
            }

            if (MenuLocation != null)
            {
                MenuLocation.Dispose();
                MenuLocation = null;
            }

            if (MenuLogIn != null)
            {
                MenuLogIn.Dispose();
                MenuLogIn = null;
            }

            if (MenuLogOut != null)
            {
                MenuLogOut.Dispose();
                MenuLogOut = null;
            }

            if (MenuRegister != null)
            {
                MenuRegister.Dispose();
                MenuRegister = null;
            }

            if (MenuSettings != null)
            {
                MenuSettings.Dispose();
                MenuSettings = null;
            }

            if (NoResult != null)
            {
                NoResult.Dispose();
                NoResult = null;
            }

            if (OpenFilters != null)
            {
                OpenFilters.Dispose();
                OpenFilters = null;
            }

            if (OpenSearch != null)
            {
                OpenSearch.Dispose();
                OpenSearch = null;
            }

            if (OrderBy != null)
            {
                OrderBy.Dispose();
                OrderBy = null;
            }

            if (RefreshDistance != null)
            {
                RefreshDistance.Dispose();
                RefreshDistance = null;
            }

            if (ResultSet != null)
            {
                ResultSet.Dispose();
                ResultSet = null;
            }

            if (RippleMain != null)
            {
                RippleMain.Dispose();
                RippleMain = null;
            }

            if (RippleRefreshDistance != null)
            {
                RippleRefreshDistance.Dispose();
                RippleRefreshDistance = null;
            }

            if (RoundBottom != null)
            {
                RoundBottom.Dispose();
                RoundBottom = null;
            }

            if (SearchIn != null)
            {
                SearchIn.Dispose();
                SearchIn = null;
            }

            if (SearchLayout != null)
            {
                SearchLayout.Dispose();
                SearchLayout = null;
            }

            if (SearchTerm != null)
            {
                SearchTerm.Dispose();
                SearchTerm = null;
            }

            if (Snackbar != null)
            {
                Snackbar.Dispose();
                Snackbar = null;
            }

            if (SnackBottomConstraint != null)
            {
                SnackBottomConstraint.Dispose();
                SnackBottomConstraint = null;
            }

            if (SnackTopConstraint != null)
            {
                SnackTopConstraint.Dispose();
                SnackTopConstraint = null;
            }

            if (SortBy_LastActiveDate != null)
            {
                SortBy_LastActiveDate.Dispose();
                SortBy_LastActiveDate = null;
            }

            if (SortBy_RegisterDate != null)
            {
                SortBy_RegisterDate.Dispose();
                SortBy_RegisterDate = null;
            }

            if (SortBy_ResponseRate != null)
            {
                SortBy_ResponseRate.Dispose();
                SortBy_ResponseRate = null;
            }

            if (SortByCaption != null)
            {
                SortByCaption.Dispose();
                SortByCaption = null;
            }

            if (StatusBar != null)
            {
                StatusBar.Dispose();
                StatusBar = null;
            }

            if (StatusImage != null)
            {
                StatusImage.Dispose();
                StatusImage = null;
            }

            if (StatusText != null)
            {
                StatusText.Dispose();
                StatusText = null;
            }

            if (UseGeoContainer != null)
            {
                UseGeoContainer.Dispose();
                UseGeoContainer = null;
            }

            if (UseGeoNo != null)
            {
                UseGeoNo.Dispose();
                UseGeoNo = null;
            }

            if (UseGeoNoLabel != null)
            {
                UseGeoNoLabel.Dispose();
                UseGeoNoLabel = null;
            }

            if (UseGeoYes != null)
            {
                UseGeoYes.Dispose();
                UseGeoYes = null;
            }

            if (UseGeoYesLabel != null)
            {
                UseGeoYesLabel.Dispose();
                UseGeoYesLabel = null;
            }

            if (UserSearchList != null)
            {
                UserSearchList.Dispose();
                UserSearchList = null;
            }
        }