Beispiel #1
0
        public static bool AddDatasets(IBindingList datasetBindingList, IList <int> selectedDatasets, string providerUrl, string UserName, string Password)
        {
            using (var localDb = new geosyncDBEntities())
            {
                foreach (int selected in selectedDatasets)
                {
                    var ds = (Dataset)datasetBindingList[selected];
                    try
                    {
                        ds.DatasetId         = GetNextDatasetID();
                        ds.LastIndex         = 0;
                        ds.ClientWfsUrl      = "";
                        ds.UserName          = UserName;
                        ds.Password          = Password;
                        ds.SyncronizationUrl = providerUrl;
                        localDb.AddObject(ds.EntityKey.EntitySetName, ds);
                        localDb.SaveChanges();
                        localDb.AcceptAllChanges();
                    }
                    catch (Exception ex)
                    {
                        logger.LogException(LogLevel.Error, "Error saving selected datasets!", ex);
                        return(false);
                    }
                }
            }

            return(true);
        }
        private void ReadGetCapabilities(geosyncDBEntities db, REP_CapabilitiesType rootCapabilities)
        {
            //Build Cababilities.XML
            //ServiceIndentification
            Dataset ds;

            m_DatasetBindingList = new MySortableBindingList <Dataset>();
            foreach (DatasetType dst in rootCapabilities.datasets)
            {
                ds           = db.CreateObject <Dataset>();
                ds.EntityKey = db.CreateEntityKey("Dataset", ds);

                ds.ProviderDatasetId = dst.datasetId;
                ds.Name = dst.name;
                DomainType dt = GetConstraint("CountDefault", rootCapabilities.OperationsMetadata.Constraint);
                if (dt != null)
                {
                    ds.MaxCount = Convert.ToInt32(dt.DefaultValue.Value);
                }
                ds.Applicationschema = dst.applicationSchema;
                Operation op = GetOperation("OrderChangelog", rootCapabilities.OperationsMetadata.Operation);
                if (op != null)
                {
                    string PostUrl = GetPostURL(op.DCP);
                    ds.SyncronizationUrl = PostUrl;
                }
                m_DatasetBindingList.Add(ds);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Removes the selected datasets from database.
        /// </summary>
        /// <param name="datasetBindingList">The dataset binding list.</param>
        /// <param name="selectedDatasets">The selected datasets.</param>
        /// <returns>True if OK, else False</returns>
        public static bool RemoveDatasets(List <SubscriberDataset> datasetBindingList, IList <int> selectedDatasets)
        {
            using (var localDb = new geosyncDBEntities())
            {
                foreach (int selected in selectedDatasets)
                {
                    var geoClientDataset = (SubscriberDataset)datasetBindingList[selected];

                    Dataset dataset =
                        (from d in localDb.Dataset where d.DatasetId == geoClientDataset.DatasetId select d)
                        .FirstOrDefault();
                    if (dataset == null)
                    {
                        return(false);
                    }
                    try
                    {
                        localDb.DeleteObject(dataset);
                        localDb.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        logger.LogException(LogLevel.Error, "Error removing selected datasets!", ex);
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #4
0
 public static string GetDatasource()
 {
     using (var localDb = new geosyncDBEntities())
     {
         return(localDb.Connection.DataSource);
     }
 }
Beispiel #5
0
        public static bool UpdateDataset(SubscriberDataset geoClientDataset)
        {
            using (var localDb = new geosyncDBEntities())
            {
                Dataset dataset =
                    (from d in localDb.Dataset where d.DatasetId == geoClientDataset.DatasetId select d)
                    .FirstOrDefault();
                if (dataset == null)
                {
                    return(false);
                }

                dataset.MaxCount             = geoClientDataset.MaxCount;
                dataset.LastIndex            = geoClientDataset.LastIndex;
                dataset.Name                 = geoClientDataset.Name;
                dataset.ProviderDatasetId    = geoClientDataset.ProviderDatasetId;
                dataset.SyncronizationUrl    = geoClientDataset.SynchronizationUrl;
                dataset.ClientWfsUrl         = geoClientDataset.ClientWfsUrl;
                dataset.Applicationschema    = geoClientDataset.Applicationschema;
                dataset.MappingFile          = geoClientDataset.MappingFile;
                dataset.AbortedEndIndex      = geoClientDataset.AbortedEndIndex;
                dataset.AbortedTransaction   = geoClientDataset.AbortedTransaction;
                dataset.AbortedChangelogPath = geoClientDataset.AbortedChangelogPath;
                dataset.ChangelogDirectory   = geoClientDataset.ChangelogDirectory;
                dataset.AbortedChangelogId   = geoClientDataset.AbortedChangelogId;
                dataset.UserName             = geoClientDataset.UserName;
                if (geoClientDataset.Password != "******")
                {
                    dataset.Password = geoClientDataset.Password;
                }

                localDb.SaveChanges();
                return(true);
            }
        }
Beispiel #6
0
 public static int GetMaxCount(int datasetID)
 {
     using (var localDb = new geosyncDBEntities())
     {
         var res = (from d in localDb.Dataset where d.DatasetId == datasetID select d.MaxCount).FirstOrDefault();
         return(res.GetValueOrDefault());
     }
 }
Beispiel #7
0
 public static List <string> GetDatasetNames()
 {
     using (var localDb = new geosyncDBEntities())
     {
         var res = (from d in localDb.Dataset select d.Name).ToList();
         return(res);
     }
 }
Beispiel #8
0
 public static IDictionary <int, string> GetDatasetNamesAsDictionary()
 {
     using (var localDb = new geosyncDBEntities())
     {
         var dict = localDb.Dataset.Select(t => new { t.DatasetId, t.Name })
                    .ToDictionary(t => t.DatasetId, t => t.Name);
         return(dict);
     }
 }
Beispiel #9
0
 public static IList <Int32> GetListOfDatasetIDs()
 {
     using (var localDb = new geosyncDBEntities())
     {
         IList <Int32> idList = new List <Int32>();
         var           res    = from d in localDb.Dataset select d.DatasetId;
         foreach (Int32 id in res)
         {
             idList.Add(id);
         }
         return(idList);
     }
 }
Beispiel #10
0
        public static SubscriberDataset GetDataset(int datasetId)
        {
            using (var localDb = new geosyncDBEntities())
            {
                Dataset dataset = (from d in localDb.Dataset where d.DatasetId == datasetId select d).FirstOrDefault();
                if (dataset == null)
                {
                    return(null);
                }

                var geoClientDataset = MapToGeoClientDataset(dataset);
                return(geoClientDataset);
            }
        }
Beispiel #11
0
        public static List <SubscriberDataset> GetAllDataset()
        {
            using (var localDb = new geosyncDBEntities())
            {
                List <Dataset> datasets = (from d in localDb.Dataset select d).ToList();

                var geoClientDatasets = new List <SubscriberDataset>();

                foreach (var dataset in datasets)
                {
                    geoClientDatasets.Add(MapToGeoClientDataset(dataset));
                }
                return(geoClientDatasets);
            }
        }
Beispiel #12
0
 public static string MappingFile(Int32 DatasetID)
 {
     using (var localDb = new geosyncDBEntities())
     {
         var res = from d in localDb.Dataset where d.DatasetId == DatasetID select d.MappingFile;
         if (res.First() != null)
         {
             return(res.First().ToString());
         }
         else
         {
             return("");
         }
     }
 }
Beispiel #13
0
 public static string TargetNamespace(Int32 DatasetID)
 {
     using (var localDb = new geosyncDBEntities())
     {
         var res = from d in localDb.Dataset where d.DatasetId == DatasetID select d.Applicationschema;
         if (res.First() != null)
         {
             return(res.First().ToString());
         }
         else
         {
             return("");
         }
     }
 }
Beispiel #14
0
 public static string GetLastIndex(int datasetID)
 {
     using (var localDb = new geosyncDBEntities())
     {
         var res = from d in localDb.Dataset where d.DatasetId == datasetID select d.LastIndex;
         if (res.FirstOrDefault() != null)
         {
             return(res.First().ToString());
         }
         else
         {
             return("");
         }
     }
 }
Beispiel #15
0
 public static string ClientWfsUrl(int datasetID)
 {
     using (var localDb = new geosyncDBEntities())
     {
         var res = from d in localDb.Dataset where d.DatasetId == datasetID select d.ClientWfsUrl;
         if (res.First() != null)
         {
             return(res.First().ToString());
         }
         else
         {
             return("");
         }
     }
 }
        public CapabilitiesDataBuilder(string ProviderURL, string UserName, string Password)
        {
            geosyncDBEntities db = new geosyncDBEntities();

            WebFeatureServiceReplicationPortClient client = new WebFeatureServiceReplicationPortClient();

            client.ClientCredentials.UserName.UserName = UserName;
            client.ClientCredentials.UserName.Password = Password;

            client.Endpoint.Address = new System.ServiceModel.EndpointAddress(ProviderURL);

            GetCapabilitiesType1 req = new GetCapabilitiesType1();

            REP_CapabilitiesType rootCapabilities = client.GetCapabilities(req);

            ReadGetCapabilities(db, rootCapabilities);
        }
Beispiel #17
0
        public static int GetNextDatasetID()
        {
            int max = 0;

            using (var localDb = new geosyncDBEntities())
            {
                var res = from d in localDb.Dataset select d.DatasetId;
                foreach (Int32 id in res)
                {
                    if (max < id)
                    {
                        max = id;
                    }
                }
            }
            return(max + 1);
        }
Beispiel #18
0
        public static bool AddEmptyDataset()
        {
            using (var localDb = new geosyncDBEntities())
            {
                var ds = new Dataset();
                try
                {
                    ds.DatasetId    = GetNextDatasetID();
                    ds.LastIndex    = 0;
                    ds.ClientWfsUrl = "";
                    localDb.AddObject("Dataset", ds);
                    localDb.SaveChanges();
                    localDb.AcceptAllChanges();
                }
                catch (Exception ex)
                {
                    logger.LogException(LogLevel.Error, "Error saving selected datasets!", ex);
                    return(false);
                }
            }

            return(true);
        }