public static void Write(string file, AltaCache overview) { if (string.IsNullOrEmpty(file)) throw new Exception("File Not Empty"); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(AltaCache)); System.Xml.XmlWriterSettings setting = new System.Xml.XmlWriterSettings(); setting.Encoding = Encoding.UTF8; setting.CloseOutput = true; setting.NewLineChars = "\r\n"; setting.Indent = true; if (!File.Exists(file)) { using (Stream s = File.Open(file, FileMode.OpenOrCreate)) { System.Xml.XmlWriter tmp = System.Xml.XmlWriter.Create(s, setting); writer.Serialize(tmp, overview); } } else { using (Stream s = File.Open(file, FileMode.Truncate)) { System.Xml.XmlWriter tmp = System.Xml.XmlWriter.Create(s, setting); writer.Serialize(tmp, overview); } } }
public static void Write(string file, AltaCache overview) { if (string.IsNullOrEmpty(file)) { throw new Exception("File Not Empty"); } System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(AltaCache)); System.Xml.XmlWriterSettings setting = new System.Xml.XmlWriterSettings(); setting.Encoding = Encoding.UTF8; setting.CloseOutput = true; setting.NewLineChars = "\r\n"; setting.Indent = true; if (!File.Exists(file)) { using (Stream s = File.Open(file, FileMode.OpenOrCreate)) { System.Xml.XmlWriter tmp = System.Xml.XmlWriter.Create(s, setting); writer.Serialize(tmp, overview); } } else { using (Stream s = File.Open(file, FileMode.Truncate)) { System.Xml.XmlWriter tmp = System.Xml.XmlWriter.Create(s, setting); writer.Serialize(tmp, overview); } } }
private void Application_Startup(object sender, StartupEventArgs e) { Define.Fonts = ExCss.ReadFile(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Asset\Fonts\font-awesome.min.css")); if (!File.Exists(FileName)) { MessageBox.Show("Không tìm thấy file cấu hình!"); Application.Current.Shutdown(); return; } Registry = new ModifyRegistry(); key = Registry.Read("MTC_KEY"); if (string.IsNullOrEmpty(key)) { this.MainWindow = new MTC(); this.MainWindow.Show(); return; } setting = Config.Read(FileName,key); if (setting == null || setting.EndDate.Date< DateTime.Now.Date) { MessageBox.Show("Phần mềm đã hết hạn sử dụng."); this.MainWindow = new MTC(); this.MainWindow.Show(); return; } if (setting.temp_folder.IndexOf(@"://") < 0 || setting.temp_folder.IndexOf(@"\\")<0) { setting.temp_folder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, setting.temp_folder); } if (!System.IO.Directory.Exists(setting.temp_folder)) { System.IO.Directory.CreateDirectory(setting.temp_folder); } cache = AltaCache.Read(CacheName); TypeUsers = MysqlHelper.getTypeUserAll(); TypeMedias = new MediaTypeArray(TypeMedia.getList()); TypeDevices = new DeviceTypeArray(TypeDevice.getList()); initVLC(); if (cache.autoLogin && !string.IsNullOrEmpty(cache.hashUserName)) { int tmpResult = UserData.getUserIdByHash(cache.hashUserName); UILogin form = new UILogin(); if (tmpResult != -1) { byte[] tmp = UserData.getFingerPrinter(tmpResult); form.cacheName = UserData.getUserName(tmpResult); if (tmp != null) { form.Template = new DPFP.Template(); form.Template.DeSerialize(tmp); } form.Show(); } else { form.Show(); } return; } this.MainWindow = new UILogin(); this.MainWindow.Show(); Console.WriteLine("Debug"); }