public static void Copy(int networkMapId)
        {
            var copy = XmlDal.DataModel.GetNetworkMap(networkMapId).Clone();

            XmlDal.DataModel.NetworkMappingModel.NetworkMaps.Add(copy);
            XmlDal.Save();
        }
Пример #2
0
        public static void Save(ValueModel model)
        {
            Log.WriteEnter(typeof(ValueService).FullName, MethodBase.GetCurrentMethod().Name);
            var dataModel = XmlDal.DataModel;

            switch (model.Mode)
            {
            case InputMode.Add:
                model.Item.ValueId = XmlDal.DataModel.GetUniqueValueId();
                dataModel.ValuesModel.Values.Add(model.Item);
                break;

            case InputMode.Edit:
                var item = dataModel.GetValue(model.Item.ValueId);
                item.Copy(model.Item);
                break;

            case InputMode.Delete:
                dataModel.ValuesModel.Values.Remove(model.Item);
                break;
            }

            XmlDal.Save();
            XmlDal.DataModel.ValueCacheDataController.Invalidate();
        }
        /// <summary>
        /// Queues a Thread to Update the SockDrawer
        /// </summary>
        public static void Update(Action <TimeSpan> updateCompletedCallback, Action <IStatusModel> statusCallback, List <string> files, bool forceClear)
        {
            Validate();
            statusCallback(StatusModel.Update("Update Active Starting", null));

            ThreadPool.QueueUserWorkItem(UpdateAsync, new CallbackModel
            {
                UpdateCompletedCallback = updateCompletedCallback,
                StatusCallback          = statusCallback,
                SearchSockDrawer        = false,
                Files      = files,
                ForceClear = forceClear
            });
            XmlDal.Save();
        }
        /// <summary>
        /// Queues a Thread to Update the SockDrawer
        /// </summary>
        public static void Update(Action <TimeSpan> updateCompletedCallback, Action <IStatusModel> statusCallback, bool forceClear)
        {
            Validate();
            statusCallback(StatusModel.Update("Updating Sock Drawer..."));

            ThreadPool.QueueUserWorkItem(UpdateAsync, new CallbackModel
            {
                UpdateCompletedCallback = updateCompletedCallback,
                StatusCallback          = statusCallback,
                SearchSockDrawer        = true,
                Files      = XmlDal.CacheModel.Files.Select(n => n.Path).ToList(),
                ForceClear = forceClear
            });
            XmlDal.Save();
        }
Пример #5
0
        public static void Shutdown()
        {
            View.StatusUpdate(StatusModel.StartStopWatch);
            View.StatusUpdate(StatusModel.Update("Closing"));

            // ReSharper disable AssignNullToNotNullAttribute
            var configFile = DataPath.GetConfigFilePath();
            // ReSharper restore AssignNullToNotNullAttribute

            var path = Path.GetDirectoryName(configFile);

            if (path != null)
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
            }
            else
            {
                throw new Exception("DockPanel.config path is null");
            }

            if (SkipSaveLayout)
            {
                if (File.Exists(configFile))
                {
                    File.Delete(configFile);
                }
            }
            else
            {
                View.DockPanel.SaveAsXml(configFile);
            }

            SaveRestoreOpenDocuments();

            XmlDal.Save();
        }
Пример #6
0
        public static void Save(EventModel model)
        {
            Log.WriteEnter(typeof(FileService).FullName, MethodBase.GetCurrentMethod().Name);
            var stopwatch = new Stopwatch("Save EventPattern");

            try
            {
                var data = XmlDal.DataModel;

                switch (model.Mode)
                {
                case InputMode.Add:
                    model.Item.EventId = data.GetUniqueEventId();
                    ValidEventName(model.Item.Name, -1);
                    data.EventsModel.Events.Add(model.Item);
                    break;

                case InputMode.Edit:
                    ValidEventName(model.Item.Name, model.Item.EventId);
                    var item = data.GetEvent(model.Item.EventId);
                    item.Clone(model.Item);
                    break;

                case InputMode.Delete:
                    data.EventsModel.Events.Remove(model.Item);
                    break;
                }

                XmlDal.Save();
                XmlDal.DataModel.EventCacheDataController.Invalidate();
            }
            finally
            {
                stopwatch.Stop();
            }
        }
        public static void Save(HideOptionModel model)
        {
            var data = XmlDal.DataModel;

            switch (model.Mode)
            {
            case InputMode.Add:
                model.Item.HideOptionId = data.GetUniqueHideOptionId();
                data.HideOptionsModel.Options.Add(model.Item);
                break;

            case InputMode.Edit:
                var item = data.GetHideOption(model.Item.HideOptionId);
                item.Name = model.Item.Name;
                break;

            case InputMode.Delete:
                data.HideOptionsModel.Options.Remove(model.Item);
                break;
            }

            XmlDal.Save();
            XmlDal.DataModel.HideOptionCacheDataController.Invalidate();
        }
Пример #8
0
        public static void Save(CategoryModel model)
        {
            var data = XmlDal.DataModel;

            switch (model.Mode)
            {
            case InputMode.Add:
                model.Item.CategoryId = data.GetUniqueCategoryId();
                data.CategoriesModel.Categories.Add(model.Item);
                break;

            case InputMode.Edit:
                var item = data.GetCategory(model.Item.CategoryId);
                item.Name = model.Item.Name;
                break;

            case InputMode.Delete:
                data.CategoriesModel.Categories.Remove(model.Item);
                break;
            }

            XmlDal.Save();
            XmlDal.DataModel.CategoryCacheDataController.Invalidate();
        }