コード例 #1
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);
            }
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }