private EstateSettings GetEstate(int estateID)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters["EstateID"] = estateID;
     List<string> retVals = GD.Query(new string[1] { "*" }, m_estateTable, filter, null, null, null);
     EstateSettings settings = new EstateSettings{
         EstateID = 0
     };
     if (retVals.Count > 0)
     {
         settings.FromOSD((OSDMap)OSDParser.DeserializeJson(retVals[4]));
     }
     return settings;
 }
        public override void FinishedMigration(IDataConnector genericData)
        {
            if (!genericData.TableExists("estates")) return;
            DataReaderConnection dr = genericData.QueryData("WHERE `Key` = 'EstateID'", "estates", "`ID`, `Key`, `Value`");

            if (dr != null)
            {
                try
                {
                    while (dr.DataReader.Read())
                    {
                        try
                        {
                            UUID ID = UUID.Parse(dr.DataReader["ID"].ToString());
                            string value = dr.DataReader["Value"].ToString();
                            QueryFilter filter = new QueryFilter();
                            filter.andFilters["`ID`"] = value;
                            filter.andFilters["`Key`"] = "EstateSettings";
                            List<string> results = genericData.Query(new string[1] { "`Value`" }, "estates", filter, null, null, null);
                            if ((results != null) && (results.Count >= 1))
                            {
                                EstateSettings es = new EstateSettings();
                                es.FromOSD((OSDMap)OSDParser.DeserializeLLSDXml(results[0]));
                                genericData.Insert("estateregions", new object[] { ID, value });

                                filter = new QueryFilter();
                                filter.andFilters["`EstateID`"] = value;

                                List<string> exist = genericData.Query(new string[1] { "`EstateID`" }, "estatesettings", filter, null, null, null);
                                if (exist == null || exist.Count == 0)
                                {
                                    genericData.Insert("estatesettings", new object[] { value, es.EstateName, es.EstateOwner, es.ParentEstateID, es.ToOSD() });
                                }
                            }
                        }
                        catch
                        {

                        }
                    }
                }
                catch
                {

                }
                finally
                {
                    dr.DataReader.Close();
                    genericData.CloseDatabase(dr);
                }
            }
        }