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

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