Exemplo n.º 1
0
        public void Load(string fileName = null)
        {
            if (fileName == null)
            {
                if (String.IsNullOrEmpty(Properties.Settings.Default.DataFileName))
                {
                    fileName = REPOSITORY_FILE_NAME;
                }
                else
                {
                    fileName = Properties.Settings.Default.DataFileName;
                }
            }
            App.ToLogInfo(String.Format("Чтение репозитория из файла <{0}>", fileName));
            fileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ResourceAssembly.Location), REPOSITORY_FILE_NAME);
            IList <IRepositoryItem> list = BaseDeserializer <List <IRepositoryItem> > .GzJsonDeSerialize(
                fileName,
                (e) =>
            {
                App.ToLogException(e);
                App.ShowError(
                    String.Format("Не удалось загрузить список запросов.\n\t{0}", e.Message),
                    "ОШИБКА");
                return;
            });

            InitRepositoryItemsList(ref list);
            RepositoryItems = new ObservableCollection <IRepositoryItem>(list);
        }
Exemplo n.º 2
0
        private HierarchicalEmcosPointCollection LoadConfigPoints()
        {
            if (File.Exists(CONFIGURATION_FILENAME))
            {
                try
                {
                    //var result = BaseRepository<EmcosPoint>.XmlDeSerialize(LIST_Balance_POINTS_FILENAME, _callBackAction);
                    var result = BaseDeserializer <EmcosPoint> .GzJsonDeSerialize(CONFIGURATION_FILENAME, _callBackAction);

                    return(result?.Children);
                }
                catch (Exception ex)
                {
                    _callBackAction(ex);
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }