public JournalFromFileViewModel(JournalItemsCollection journalItemsCollection)
		{
			Title = "Журнал событий ГК";
			DescriptorsManager.Create();
			JournalItemsCollection = journalItemsCollection;
			JournalItems = new ObservableCollection<JournalItemViewModel>();
			journalItemsCollection.JournalItems.ForEach(x => JournalItems.Add(new JournalItemViewModel(x)));
		}
Beispiel #2
0
		void OnSaveToFile()
		{
			var saveDialog = new SaveFileDialog()
			{
				Filter = "Журнал событий|*.fscj",
				DefaultExt = "Журнал событий|*.fscj"
			};
			if (saveDialog.ShowDialog().Value)
			{
				WaitHelper.Execute(() =>
				{
					if (File.Exists(saveDialog.FileName))
						File.Delete(saveDialog.FileName);

					var xmlSerializer = new XmlSerializer(typeof(JournalItemsCollection));
					using (var fileStream = new FileStream(saveDialog.FileName, FileMode.CreateNew))
					{
						var journalItems = new List<JournalItem>();
						JournalItems.ToList().ForEach(x => journalItems.Add(x.JournalItem));
						var journalItemsCollection = new JournalItemsCollection
						{
							JournalItems = journalItems,
							RecordCount = TotalCount,
							CreationDateTime = DateTime.Now,
							GkIP = Device.GetGKIpAddress()
						};
						xmlSerializer.Serialize(fileStream, journalItemsCollection);
					}
				});
			}
		}