示例#1
0
        public static History LoadHistoryFromFile(string filePath)
        {
            History his = new History();

            Stream stream = null;
            XmlDictionaryReader xmlTextReader = null;

            try
            {
                if (File.Exists(filePath))
                {
                    stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                    DataContractSerializer serializer = new DataContractSerializer(typeof(History), new[]
                    {
                        typeof (BaseEntity),
                        typeof (Document),
                        typeof (Account),
                        typeof (ActuaalizeDoc),
                        typeof (Agreement),
                        typeof (Client),
                        typeof (CorpAgreement),
                        typeof (CorpClient),
                        typeof (DocumentBinary),
                        typeof(LinkedPerson)
                    });
                    xmlTextReader = XmlDictionaryReader.CreateTextReader(stream, new XmlDictionaryReaderQuotas());

                    his = (History)serializer.ReadObject(xmlTextReader, true);

                    xmlTextReader.Close();
                    stream.Close();
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (xmlTextReader != null)
                {
                    xmlTextReader.Close();
                }
                if (stream != null)
                {
                    stream.Close();
                }
            }

            return his;
        }
示例#2
0
        public static bool SaveHistoryToFile(string filePath, History userHistory)
        {
            Stream stream = null;
            XmlTextWriter xmlTextWriter = null;
            bool successfull = false;
            try
            {
                stream = new FileStream(filePath, FileMode.Create, FileAccess.Write);
                DataContractSerializer serializer = new DataContractSerializer(typeof(History), new[]
                    {
                        typeof (BaseEntity),
                        typeof (Document),
                        typeof (Account),
                        typeof (ActuaalizeDoc),
                        typeof (Agreement),
                        typeof (Client),
                        typeof (CorpAgreement),
                        typeof (CorpClient),
                        typeof (DocumentBinary),
                        typeof(LinkedPerson)
                    });
                xmlTextWriter = new XmlTextWriter(stream, null) { Formatting = Formatting.Indented, Indentation = 4 };

                serializer.WriteObject(xmlTextWriter, userHistory);

                xmlTextWriter.Close();
                stream.Close();

                successfull = true;
            }
            catch (Exception ex)
            {
                successfull = false;
            }
            finally
            {
                if (xmlTextWriter != null)
                {
                    xmlTextWriter.Close();
                }
                if (stream != null)
                {
                    stream.Close();
                }
            }
            return successfull;
        }
示例#3
0
        private void RunAllHistoryItems()
        {
            History h = (History)_userHistory.Clone();

            _userHistory = new History();
            historyListView.Items.Clear();

            foreach (var item in h.HistoryList)
            {
                BuildParamsTable(item);
                string postData = CreatePostString((Methods)Enum.Parse(typeof(Methods), item.MethodName));
                string responce = BeginSendRequest(postData);
                if (item.MethodName == "StartSession")
                {
                    TryGetSessionIdFromResponce(responce);
                }
            }
        }
示例#4
0
        public object Clone()
        {
            History h = new History();

            if (h.CurrentItem != null)
            {
                h.CurrentItem.MethodName = this.CurrentItem.MethodName;
                h.CurrentItem.Reply = this.CurrentItem.Reply;
                h.CurrentItem.Status = this.CurrentItem.Status;
            }

            foreach (var entity in HistoryList)
            {
                h.HistoryList.Add(entity);
            }

            return h;
        }
示例#5
0
        private void LoadHistoryFromFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "BARS History Files (*.history)|*.history";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                _userHistory = History.LoadHistoryFromFile(openFileDialog.FileName);
                WriteHistoryToListView();
            }
        }