public static void ExportCandidatos() { tb_concurso concurso = new tb_concurso(); //string caminho = ; //MemoryStream ms = new MemoryStream(); //StreamWriter sw = new StreamWriter("D:\\teste.txt",true); //StreamWriter sw = new StreamWriter(ms); string nomeArquivo = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\dados_candidatos.bin"; //string nomeArquivo = System.IO.Path.GetDirectoryName(Application.StartupPath + @"\\Candidatos"); System.IO.File.Create(nomeArquivo).Close(); System.IO.TextWriter sw = System.IO.File.AppendText(nomeArquivo); List <tb_concurso> concurso_lista = new ConcursoBO().GetAll().ToList <tb_concurso>(); foreach (tb_concurso concurso_indice in concurso_lista) { sw.WriteLine("A|" + concurso_indice.cod_concurso + "|" + concurso_indice.descricao_concurso); List <tb_candidato> candidato_lista = new CandidatoBO().CandidatosConcurso(concurso_indice.cod_concurso).ToList(); foreach (tb_candidato candidato_indice in candidato_lista) { sw.WriteLine("B|" + candidato_indice.cod_candidato + "|" + candidato_indice.num_inscricao + "|" + candidato_indice.data_inscricao + "|" + candidato_indice.nome + "|" + candidato_indice.endereco + "|" + candidato_indice.numero + "|" + candidato_indice.bairro + "|" + candidato_indice.cod_cidade + "|" + candidato_indice.cep + "|" + candidato_indice.complemento + "|" + candidato_indice.uf + "|" + candidato_indice.data_nascimento + "|" + candidato_indice.telefone + "|" + candidato_indice.celular + "|" + candidato_indice.rg + "|" + candidato_indice.orgao_rg + "|" + candidato_indice.uf_rg + "|" + candidato_indice.cpf + "|" + candidato_indice.sexo + "|" + candidato_indice.deficiencia + "|" + candidato_indice.email + "|" + candidato_indice.cod_opcao + "|" + candidato_indice.nome_mae + "|" + candidato_indice.observacao + "|" + candidato_indice.falta + "|" + candidato_indice.nota + "|" + candidato_indice.estado_civil + "|" + candidato_indice.nome_pai + "|" + candidato_indice.naturalidade + "|" + candidato_indice.atendimento_especial); } } sw.WriteLine("C|" + DateTime.Now); sw.Close(); }
public void Kaydet() { saveFileDialog1.Title = "Kaydetmek için dosya adını girin"; saveFileDialog1.Filter = "Metin dosyaları|*.zyd"; saveFileDialog1.DefaultExt = "zyd"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { string dosya_adı; dosya_adı = saveFileDialog1.FileName; System.IO.TextWriter dosya = System.IO.File.CreateText(dosya_adı); dosya.Write("["); for (int i = 0; i < sekiller.Count; i++) { dosya.Write(NesneBilgileri(sekiller[i])); } dosya.Write("]"); dosya.Close(); } }
public static void SerializeToXml <T>(T ThisTypeInstance, System.IO.TextWriter tw) { if (ThisTypeInstance == null) { throw new NullReferenceException("ThisTypeInstance"); } System.Xml.Serialization.XmlSerializerNamespaces ns = GetSerializerNamespaces(ThisTypeInstance.GetType()); System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(ThisTypeInstance.GetType()); using (System.IO.TextWriter twTextWriter = tw) { // serializer.Serialize(twTextWriter, ThisTypeInstance); serializer.Serialize(twTextWriter, ThisTypeInstance, ns); twTextWriter.Close(); } // End Using twTextWriter serializer = null; } // End Sub SerializeToXml
private void LogSuspiciousResults() { LogWriter = System.IO.File.CreateText("E:\\temp\\sorata\\result.txt"); foreach (MIPSEvaluator.Result res in MIPS.Results) { bool log = false; for (int i = 0; i < res.Arguments.Length; i++) { if ((res.Arguments[i] >> 24) == 0x04 || (res.Arguments[i] >> 24) == 0x05 || (res.Arguments[i] >> 24) == 0x06) { log = true; } } if (log) { LogWriter.WriteLine(res.ToString()); } } LogWriter.Close(); }
public bool CreateNewDeviceXML(string fileName) { try { string s = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; s += @" <DeviceInstructions> <DeviceInfo> <DeviceName>Device Name</DeviceName> <Explanation></Explanation> <IP>192.168.1.161</IP> <Port>4001</Port> <CheckSumType>CheckSum,1 Byte</CheckSumType> <InstructionStructure>xxx</InstructionStructure> </DeviceInfo> <Instruction> <ID>1</ID> <Order>2</Order> <InstructionBytes>12 08 5A AA AA AA 72</InstructionBytes> <Explanation>Read Serial Number</Explanation> <CheckSum>1</CheckSum> </Instruction> <WorkbenchData> <ID>1</ID> <Instructions> </Instructions> </WorkbenchData> </DeviceInstructions>"; System.IO.TextWriter tw = System.IO.File.CreateText(fileName); tw.WriteLine(s); tw.Close(); return(true); } catch (Exception) { return(false); } }
public virtual void ShutDown() { Debug.WriteLine("Shutting down the runtime"); if (_timer != null) { StopTimer(_timer); System.Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine("{0} ===> {1} ms", _timer.Name, _timer.ElapsedMilliseconds); Console.ResetColor(); Console.WriteLine(); } System.IO.TextWriter profileOut = Console.Out; if ((Timers != null || Counters != null) && Configuration.ProfilerOutput != null) { var profileFilename = Configuration.ProfilerOutput; profileOut = System.IO.File.Exists(profileFilename) ? System.IO.File.AppendText(profileFilename) : System.IO.File.CreateText(profileFilename); } if (Timers != null) { Timers.ToXml(profileOut); //GenerateSummary(profileOut); } if (Counters != null) { Counters.PrintCounters(profileOut); } if (profileOut != Console.Out) { profileOut.Flush(); profileOut.Close(); } Instance = null; }
static void SaveText(System.IO.TextWriter Output_S) { try { Output_S.WriteLine(BaselineDict.Count); foreach (BaselineActivity a in BaselineDict.Values) { a.SaveText(Output_S); } } catch (Exception e) { throw e; } finally { if (Output_S != null) { Output_S.Close(); } } }
/// <summary> /// Send email from occurred error /// </summary> /// <param name="ex"></param> public static void ReportError(Exception ex) { string str = ex.Message + Environment.NewLine; str += "-------------------------------------------------------"; str += ex.Source + Environment.NewLine; str += "-------------------------------------------------------"; str += ex.StackTrace + Environment.NewLine; str += "-------------------------------------------------------"; str += ex.ToString(); try { string path = System.IO.Path.Combine(new Uri(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)).LocalPath, Guid.NewGuid().ToString() + ".txt"); using (System.IO.TextWriter tw = System.IO.File.CreateText(path)) { tw.WriteLine(str); tw.Close(); } } catch (Exception ex2) { System.Diagnostics.Debug.WriteLine(ex2.Message); } try { MailMessage mail = new System.Net.Mail.MailMessage(); mail.From = new System.Net.Mail.MailAddress("*****@*****.**"); mail.To.Add("*****@*****.**"); mail.Subject = "GuruxAMI error has occurred."; SmtpClient smtp = new SmtpClient("smtp.kolumbus.fi"); smtp.UseDefaultCredentials = false; mail.Body = str; smtp.Send(mail); } catch (Exception ex2) { System.Diagnostics.Debug.WriteLine(ex2.Message); } }
static public void SaveConfig() { string filename = string.Empty; try { var worldname = MyAPIGateway.Session.Name; worldname = Regex.Replace(worldname, "[<>:\"/\\|?*]", ""); // Remove invloid filename chars var xmlData = MyAPIGateway.Utilities.SerializeToXML <FTLConfig>(Configuration); filename = MyAPIGateway.Utilities.GamePaths.ModsPath + "\\322067487.sbm_Stargate\\" + string.Format(ConfigFileName, worldname); System.IO.TextWriter writer = MyAPIGateway.Utilities.WriteFileInLocalStorage(string.Format(ConfigFileName, worldname), typeof(FTLAdmin)); writer.Write(xmlData); writer.Flush(); writer.Close(); } catch (Exception ex) { Logger.Instance.LogMessage(filename); Logger.Instance.LogException(ex); } }
static void Main(string[] args) { bool consoleOut = false; string caseFile = "small"; string outFile = "out." + caseFile + ".txt"; string inFile = "in." + caseFile + ".txt"; System.IO.StreamReader sr = new System.IO.StreamReader(inFile); System.IO.TextWriter sw = consoleOut ? System.Console.Out : new System.IO.StreamWriter(outFile); int tests = int.Parse(sr.ReadLine()); for (int test = 0; test < tests; test++) { string[] tmp = sr.ReadLine().Split(' '); int a1 = int.Parse(tmp[0]); int a2 = int.Parse(tmp[1]); int b1 = int.Parse(tmp[2]); int b2 = int.Parse(tmp[3]); winning = 0; for (int i = a1; i <= a2; i++) { for (int j = b1; j <= b2; j++) { rec(i, j, true, true); } } sw.WriteLine("Case #" + (test + 1) + ": " + winning.ToString()); } if (consoleOut) { System.Console.ReadLine(); } sw.Close(); }
/// <summary> /// write all settings to file /// </summary> private static void writeAll() { try { // write to file settingsWriter = MyAPIGateway.Utilities.WriteFileInLocalStorage(settings_file_name, typeof(Settings)); write(strVersion, latestVersion.ToString()); // must be first line // write settings foreach (KeyValuePair <BoolSetName, bool> pair in boolSettings) { write(pair.Key.ToString(), pair.Value.ToString()); } foreach (KeyValuePair <IntSetName, int> pair in intSettings) { write(pair.Key.ToString(), pair.Value.ToString()); } foreach (KeyValuePair <FloatSetName, float> pair in floatSettings) { write(pair.Key.ToString(), pair.Value.ToString()); } foreach (KeyValuePair <DoubleSetName, double> pair in doubleSettings) { write(pair.Key.ToString(), pair.Value.ToString()); } foreach (KeyValuePair <StringSetName, string> pair in stringSettings) { write(pair.Key.ToString(), pair.Value.ToString()); } } finally { settingsWriter.Flush(); settingsWriter.Close(); settingsWriter = null; } }
public static void ErrorFileWrite(string module, string method, string errorMessage, string errorDetails) { string logPath = System.AppDomain.CurrentDomain.BaseDirectory + @"Logs"; if (!System.IO.Directory.Exists(logPath)) { System.IO.Directory.CreateDirectory(logPath); } string errorPath = System.AppDomain.CurrentDomain.BaseDirectory + @"Logs\Errors"; if (!System.IO.Directory.Exists(errorPath)) { System.IO.Directory.CreateDirectory(errorPath); } if (!System.IO.File.Exists(errorPath + @"\Errors.txt")) { using (System.IO.TextWriter tWriter = new System.IO.StreamWriter(errorPath + @"\Errors.txt")) { tWriter.WriteLine("{0}, {1}, {2}, {3}", DateTime.Now.ToString(), module, method, errorMessage); tWriter.WriteLine("********************************************************************"); tWriter.WriteLine(errorDetails); tWriter.WriteLine("********************************************************************"); tWriter.Close(); } } else { using (System.IO.TextWriter tWriter = System.IO.File.AppendText(errorPath + @"\Errors.txt")) { tWriter.WriteLine("{0}, {1}, {2}, {3}", DateTime.Now.ToString(), module, method, errorMessage); tWriter.WriteLine("********************************************************************"); tWriter.WriteLine(errorDetails); tWriter.WriteLine("********************************************************************"); tWriter.Close(); } } }
public static void CloseFile() { objTxtWriter.Close(); }
static void Main(string[] args) { bool consoleOut = false; string caseFile = "large"; string outFile = "out." + caseFile + ".txt"; string inFile = "in." + caseFile + ".txt"; System.IO.StreamReader sr = new System.IO.StreamReader(inFile); System.IO.TextWriter sw = consoleOut ? System.Console.Out : new System.IO.StreamWriter(outFile); int t = int.Parse(sr.ReadLine()); for (int ccase = 0; ccase < t; ccase++) { string line = sr.ReadLine(); string[] split = line.Split(' '); int n = int.Parse(split[0]); int k = int.Parse(split[1]); char[][] board = new char[n][]; for (int i = 0; i < n; i++) { board[i] = sr.ReadLine().ToCharArray(); } char[][] rot = new char[n][]; for (int i = 0; i < n; i++) { rot[i] = new char[n]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { rot[j][n - i - 1] = board[i][j]; } } for (int i = 0; i < n; i++) { for (int kk = 0; kk < n; kk++) { for (int j = n - 2; j >= 0; j--) { if (rot[j + 1][i] == '.') { char tmp = rot[j + 1][i]; rot[j + 1][i] = rot[j][i]; rot[j][i] = tmp; } } } } bool wonRed = false; bool wonBlue = false; //find hor for (int i = 0; i < n; i++) { char w = winner(rot[i], k); wonBlue = wonBlue || w == 'A' || w == 'B'; wonRed = wonRed || w == 'A' || w == 'R'; } //find vert for (int i = 0; i < n; i++) { List <char> col = new List <char>(); for (int j = 0; j < n; j++) { col.Add(rot[j][i]); } char w = winner(col.ToArray(), k); wonBlue = wonBlue || w == 'A' || w == 'B'; wonRed = wonRed || w == 'A' || w == 'R'; } //find diag for (int j = 0; j < n; j++) { char[] list = Program.createDiag(rot, 0, j, 1, 1); char w = winner(list, k); wonBlue = wonBlue || w == 'A' || w == 'B'; wonRed = wonRed || w == 'A' || w == 'R'; list = Program.createDiag(rot, 0, j, 1, -1); w = winner(list, k); wonBlue = wonBlue || w == 'A' || w == 'B'; wonRed = wonRed || w == 'A' || w == 'R'; } for (int j = 0; j < n; j++) { char[] list = Program.createDiag(rot, n - 1, j, -1, 1); char w = winner(list, k); wonBlue = wonBlue || w == 'A' || w == 'B'; wonRed = wonRed || w == 'A' || w == 'R'; list = Program.createDiag(rot, n - 1, j, -1, -1); w = winner(list, k); wonBlue = wonBlue || w == 'A' || w == 'B'; wonRed = wonRed || w == 'A' || w == 'R'; } sw.WriteLine("Case #" + (ccase + 1) + ": " + (wonRed && wonBlue ? "Both" : wonRed ? "Red" : wonBlue ? "Blue" : "Neither")); } if (consoleOut) { System.Console.ReadLine(); } sw.Close(); }
public static void Finish() { outp.Close(); }
private void LogSuspiciousResults() { LogWriter = System.IO.File.CreateText("E:\\temp\\sorata\\result.txt"); foreach (MIPSEvaluator.Result res in MIPS.Results) { bool log = false; for (int i = 0; i < res.Arguments.Length; i++) if ((res.Arguments[i] >> 24) == 0x04 || (res.Arguments[i] >> 24) == 0x05 || (res.Arguments[i] >> 24) == 0x06) log = true; if (log) LogWriter.WriteLine(res.ToString()); } LogWriter.Close(); }
private void escalonaProcessos(List <Processo> processos, int timeslice, int velocidade, List <TextBox> textboxes) { //5 - Percorre todos os processos de acordo com o seu timeslice e tempo de "pausa" setando como finalizado o processo após terminar o total de caracteres+ciclos while (true) { for (int i = 0; i < processos.Count(); i++) { if (!processos[i].finalizado) { ChangeMyColor(textboxes[i], Color.Yellow); } for (int j = 0; j < timeslice; j++) { if (!processos[i].finalizado) { int fracao = Convert.ToInt32(1000 * Decimal.Divide(1, Convert.ToInt32(numericUpDown1.Value))); string a = ""; System.Threading.Thread.Sleep(fracao); int posicaoString = processos[i].incrementaUltimoAdicionado(); if (posicaoString > -1) { a = processos[i].getInput().ElementAt(posicaoString).ToString(); ChangeMyText(textboxes[i], textboxes[i].Text + a); } if (processos[i].finalizado) { processosTerminados++; //6 - Joga os valores para a matriz de saída do TXT gravaMatriz(i, "T"); ChangeMyColor(textboxes[i], Color.Green); break; } else { //6 - Joga os valores para a matriz de saída do TXT gravaMatriz(i, a); } } else { break; } } if (!processos[i].finalizado) { ChangeMyColor(textboxes[i], Color.White); } } if (processosTerminados == processos.Count()) { break; } } string caminho = "saida.txt"; if (System.IO.File.Exists(caminho)) { System.IO.File.Delete(caminho); } System.IO.File.Create(caminho).Close(); System.IO.TextWriter txtWr = System.IO.File.AppendText(caminho); string log = escreveLog().ToString(); txtWr.WriteLine(log); txtWr.Close(); //Grava no TXT Process.Start("notepad.exe", caminho); //return true; }
public void ExtractAllFiles(string selpath, SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds, SimPe.Packages.ExtractableFile package) { int excount = 0; int filecount = 0; string xml = ""; bool run = WaitingScreen.Running; if (!run) { WaitingScreen.Wait(); } try { xml += "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + Helper.lbr; xml += "<package type=\"" + ((uint)package.Header.IndexType).ToString() + "\">" + Helper.lbr; for (int i = 0; i < pfds.Length; i++) { System.Windows.Forms.Application.DoEvents(); Packages.PackedFileDescriptor fii = (Packages.PackedFileDescriptor)pfds[i]; Data.TypeAlias a = fii.TypeName; fii.Path = null; string path = System.IO.Path.Combine(selpath, fii.Path); fii.Filename = null; string name = System.IO.Path.Combine(path, fii.Filename); try { if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } //make sure the sub xmls don't have a Filename fii.Path = ""; package.SavePackedFile(name, null, fii, true); fii.Path = null; xml += fii.GenerateXmlMetaInfo(); filecount++; } catch (Exception ex) { excount++; Helper.ExceptionMessage(Localization.Manager.GetString("errwritingfile") + " " + name, ex); if (excount >= 5) { if (Message.Show(Localization.Manager.GetString("ask000"), Localization.Manager.GetString("proceed"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { i = pfds.Length; } } } } //for i xml += "</package>" + Helper.lbr; System.IO.TextWriter tw = System.IO.File.CreateText(System.IO.Path.Combine(selpath, "package.xml")); try { tw.Write(xml); } catch (Exception ex) { Helper.ExceptionMessage(Localization.Manager.GetString("err001"), ex); } finally { tw.Close(); tw.Dispose(); tw = null; } } finally { if (!run) { WaitingScreen.Stop(); } } Message.Show(Localization.Manager.GetString("nfo000").Replace("{0}", filecount.ToString()), "Info", System.Windows.Forms.MessageBoxButtons.OK); }
public static bool ConvertList(String fileName) { List <DVBCTuning> _dvbcChannels = new List <DVBCTuning>(); string line; string[] tpdata; System.IO.TextReader tin = System.IO.File.OpenText(fileName); do { line = tin.ReadLine(); if (line != null) { if (line.Length > 0) { if (line.StartsWith(";")) { continue; } tpdata = line.Split(new char[] { ',' }); if (tpdata.Length != 3) { tpdata = line.Split(new char[] { ';' }); } if (tpdata.Length == 3) { try { DVBCTuning tuning = new DVBCTuning(); tuning.Frequency = Int32.Parse(tpdata[0]); string mod = tpdata[1].ToUpper(); switch (mod) { case "1024QAM": tuning.ModulationType = ModulationType.Mod1024Qam; break; case "112QAM": tuning.ModulationType = ModulationType.Mod112Qam; break; case "128QAM": tuning.ModulationType = ModulationType.Mod128Qam; break; case "160QAM": tuning.ModulationType = ModulationType.Mod160Qam; break; case "16QAM": tuning.ModulationType = ModulationType.Mod16Qam; break; case "16VSB": tuning.ModulationType = ModulationType.Mod16Vsb; break; case "192QAM": tuning.ModulationType = ModulationType.Mod192Qam; break; case "224QAM": tuning.ModulationType = ModulationType.Mod224Qam; break; case "256QAM": tuning.ModulationType = ModulationType.Mod256Qam; break; case "320QAM": tuning.ModulationType = ModulationType.Mod320Qam; break; case "384QAM": tuning.ModulationType = ModulationType.Mod384Qam; break; case "448QAM": tuning.ModulationType = ModulationType.Mod448Qam; break; case "512QAM": tuning.ModulationType = ModulationType.Mod512Qam; break; case "640QAM": tuning.ModulationType = ModulationType.Mod640Qam; break; case "64QAM": tuning.ModulationType = ModulationType.Mod64Qam; break; case "768QAM": tuning.ModulationType = ModulationType.Mod768Qam; break; case "80QAM": tuning.ModulationType = ModulationType.Mod80Qam; break; case "896QAM": tuning.ModulationType = ModulationType.Mod896Qam; break; case "8VSB": tuning.ModulationType = ModulationType.Mod8Vsb; break; case "96QAM": tuning.ModulationType = ModulationType.Mod96Qam; break; case "AMPLITUDE": tuning.ModulationType = ModulationType.ModAnalogAmplitude; break; case "FREQUENCY": tuning.ModulationType = ModulationType.ModAnalogFrequency; break; case "BPSK": tuning.ModulationType = ModulationType.ModBpsk; break; case "OQPSK": tuning.ModulationType = ModulationType.ModOqpsk; break; case "QPSK": tuning.ModulationType = ModulationType.ModQpsk; break; default: tuning.ModulationType = ModulationType.ModNotSet; break; } tuning.SymbolRate = Int32.Parse(tpdata[2]) / 1000; _dvbcChannels.Add(tuning); } catch { } } } } } while (!(line == null)); tin.Close(); String newPath = String.Format("{0}\\dvbc\\{1}.xml", System.IO.Path.GetDirectoryName(fileName), MakeDVBCName(System.IO.Path.GetFileNameWithoutExtension(fileName))); System.IO.TextWriter parFileXML = System.IO.File.CreateText(newPath); XmlSerializer xmlSerializer = new XmlSerializer(typeof(List <DVBCTuning>)); xmlSerializer.Serialize(parFileXML, _dvbcChannels); parFileXML.Close(); return(true); }
public override void FlushAndClose() { writer.Flush(); writer.Close(); }
private void btnAsHtml_Click(object sender, EventArgs e) { //string filePath = System.IO.Directory.GetCurrentDirectory().ToString() + "\\dataDictionary.html"; string filePath = System.IO.Path.GetTempPath() + "DataDictionary_" + Guid.NewGuid().ToString("N") + ".html"; if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } System.IO.TextWriter textWriter = System.IO.File.CreateText(filePath); textWriter.WriteLine("<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title></title>"); textWriter.WriteLine("<style type=\"text/css\">"); textWriter.WriteLine("table.dataDictionary { border-width: 1px; border-collapse: collapse; border-color: black; width: 100%;}"); textWriter.WriteLine("table.dataDictionary th { border-width: 1px; border-style: solid; padding: 4px; border-color: black; font-family: Verdana; font-size: x-small; font-weight:bold; background-color:#4a7ac9; color:#FFFFFF;}"); textWriter.WriteLine("table.dataDictionary td { border-width: 1px; border-style: solid; padding: 4px; border-color: black; font-family: Verdana; font-size: x-small; font-weight:normal;}"); textWriter.WriteLine(".styleTitle { font-family: \"Verdana\"; font-size: x-small; font-weight: normal; }"); textWriter.WriteLine("</style>"); textWriter.WriteLine("<br/>"); if (displayTable.TableName.StartsWith("code") == false) { textWriter.WriteLine(string.Format("<span class=\"styleTitle\"><strong>Data Dictionary for View [ {0} ]</strong></span><br />", view.Name)); textWriter.WriteLine(string.Format("<span class=\"styleTitle\">{0}</span><br />", view.FullName)); } textWriter.WriteLine(string.Format("<span class=\"styleTitle\">{0}</span><br />", DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString())); textWriter.WriteLine("<br/>"); textWriter.WriteLine("<table class=\"dataDictionary\">"); if (displayTable.TableName.StartsWith("code") == false) { textWriter.WriteLine("<tr><th>Page Position</th><th>Page Name</th><th>Tab Index</th><th>Prompt</th><th>Field Type</th><th>Name</th><th>Variable Type</th><th>Format</th><th>Special Info</th></tr>"); bool highlightRow = false; DataView dataView = new DataView(displayTable); dataView.Sort = sortExp; DataTable sortedTable = dataView.ToTable(); foreach (DataRow row in sortedTable.Rows) { textWriter.WriteLine(string.Format("<tr style=\"background-color: #{0}\">", highlightRow ? "EEEEEE" : "FFFFFF")); textWriter.WriteLine(string.Format("<td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td><td>{8}</td>", row[0].ToString(), row[1].ToString(), row[2].ToString(), row[3].ToString(), row[4].ToString(), row[5].ToString(), row[6].ToString(), row[7].ToString(), row[8].ToString())); textWriter.WriteLine("</tr>"); highlightRow = !highlightRow; } } else { bool highlightRow = false; DataView dataView = new DataView(displayTable); DataTable table = dataView.ToTable(); textWriter.WriteLine("<tr>"); foreach (DataColumn column in table.Columns) { textWriter.WriteLine("<th>{0}</th>", column.ColumnName); } foreach (DataRow row in table.Rows) { textWriter.WriteLine(string.Format("<tr style=\"background-color: #{0}\">", highlightRow ? "EEEEEE" : "FFFFFF")); object[] itemArray = row.ItemArray; foreach (object obj in itemArray) { textWriter.WriteLine(string.Format("<td>{0}</td>", (string)obj)); } textWriter.WriteLine("</tr>"); highlightRow = !highlightRow; } } textWriter.WriteLine("</table></body></html>"); textWriter.Close(); System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents = false; proc.StartInfo.FileName = filePath; proc.Start(); }
public FrmAssemblyInfo() { InitializeComponent(); MessageBox.Show(this.RunTime().ToString()); Version v = Assembly.GetExecutingAssembly().GetName().Version; string ver = string.Format("Versão: Major = {0}, Minor = {1}, Build = {2}, Revision = {3}", v.Major, v.Minor, v.Build, v.Revision); String nomeArquivo = AppDomain.CurrentDomain.BaseDirectory + "Versao.txt"; if (!System.IO.File.Exists(nomeArquivo)) { System.IO.File.Create(nomeArquivo).Close(); } System.IO.TextWriter arqTXT = System.IO.File.AppendText(nomeArquivo); arqTXT.WriteLine(ver); listBox1.Items.Clear(); arqTXT.Close(); System.IO.File.ReadAllLines(nomeArquivo).Aggregate(listBox1.Items, (a1, b) => { a1.Add(b); return(a1); }); foreach (var assemblyName in Assembly.GetExecutingAssembly() .GetReferencedAssemblies() .Where(w => w.FullName.IndexOf("FGlobus") != -1) ) { //Assembly assembly = Assembly.Load(assemblyName); //foreach (var type in assembly.GetTypes()) //{ Console.WriteLine(assemblyName.FullName); //} } Action <string, Assembly> aaa = null; aaa = (a2, a3) => a3 .GetReferencedAssemblies() .Where(w => w.FullName.IndexOf("FGlobus") != -1) .ToList() .ForEach(f => { Assembly assembly = Assembly.Load(f); if (assembly .GetReferencedAssemblies() .Where(w => w.FullName.IndexOf("FGlobus") != -1) .Count() > 0) { aaa("b=", assembly); } listBox2.Items.Add(String.Concat(a2, f.FullName)); }); aaa("a=", Assembly.GetExecutingAssembly()); //Action<Assembly> sss = null; //sss = a1 => a1.GetReferencedAssemblies() // .Aggregate(listBox2.Items, (a, b) => // { // sss(Assembly.GetAssembly(b.GetType())); // a.Add(b.FullName); // return a; // }); //sss(Assembly.GetExecutingAssembly()); //AssemblyName //Assembly.GetExecutingAssembly().GetReferencedAssemblies() //// This variable holds the amount of indenting that //// should be used when displaying each line of information. //Int32 indent = 0; //// Display information about the EXE assembly. //Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); //Display(indent, "Assembly identity={0}", a.FullName); //Display(indent + 1, "Codebase={0}", a.CodeBase); //// Display the set of assemblies our assemblies reference. //Display(indent, "Referenced assemblies:"); //foreach (AssemblyName an in a.GetReferencedAssemblies()) //{ // Display(indent + 1, "Name={0}, Version={1}, Culture={2}, PublicKey token={3}", an.Name, an.Version, an.CultureInfo.Name, (BitConverter.ToString(an.GetPublicKeyToken()))); //} //Display(indent, ""); //// Display information about each assembly loading into this AppDomain. ////AppDomain.CurrentDomain.GetAssemblies()[76].GetName().Name.IndexOf("BgmRodotec.FGlobus.Componentes.WinForms") //var xx = AppDomain.CurrentDomain.GetAssemblies() // .Where(w => w.FullName.IndexOf("BgmRodotec") != -1); //foreach (Assembly b in xx) //{ // Display(indent, "Assembly: {0}", b); // // Display information about each module of this assembly. // foreach (Module m in b.GetModules(true)) // { // Display(indent + 1, "Module: {0}", m.Name); // } // // Display information about each type exported from this assembly. // indent += 1; // //foreach (Type t in b.GetExportedTypes()) // //{ // //Display(0, ""); // //Display(indent, "Type: {0}", t); // //// For each type, show its members & their custom attributes. // //indent += 1; // //foreach (MemberInfo mi in t.GetMembers()) // //{ // // Display(indent, "Member: {0}", mi.Name); // // DisplayAttributes(indent, mi); // // // If the member is a method, display information about its parameters. // // if (mi.MemberType == MemberTypes.Method) // // { // // foreach (ParameterInfo pi in ((MethodInfo)mi).GetParameters()) // // { // // Display(indent + 1, "Parameter: Type={0}, Name={1}", pi.ParameterType, pi.Name); // // } // // } // // // If the member is a property, display information about the property's accessor methods. // // if (mi.MemberType == MemberTypes.Property) // // { // // foreach (MethodInfo am in ((PropertyInfo)mi).GetAccessors()) // // { // // Display(indent + 1, "Accessor method: {0}", am); // // } // // } // //} // //indent -= 1; // //} // //indent -= 1; //} }
public static void close(this TextWriter writer) { writer.Close(); }
public void Dispose() { writer.Flush(); writer.Close(); Console.WriteLine("IN DISPOSE"); }
public void Dispose() { writer_.Close(); }
static void Main(string[] args) { uint lastRequested = 0; Hashtable arguments = ParseArguments(args); imPrimary = false; int id = (int)arguments["id"]; int targetState = (int)arguments["cases"]; int numReplicas = (int)arguments["numreplicas"]; //Create the output stream try { //_writer = new System.IO.StreamWriter((String)arguments["out"], true); _writer = Console.Out; } catch { System.Environment.Exit(-1); } //Start up the common infraestructure ManagedRSLConfigParam cfg = new ManagedRSLConfigParam(); cfg.NewLeaderGracePeriodSec = 10; cfg.HeartBeatIntervalSec = 2; cfg.ElectionDelaySec = 5; cfg.MaxElectionRandomizeSec = 1; cfg.InitializeRetryIntervalSec = 1; cfg.PrepareRetryIntervalSec = 1; cfg.VoteRetryIntervalSec = 1; cfg.CPQueryRetryIntervalSec = 5; cfg.MaxCheckpointIntervalSec = 0; cfg.JoinMessagesIntervalSec = 1; cfg.MaxLogLenMB = 10; cfg.SendTimeoutSec = 10; cfg.ReceiveTimeoutSec = 10; cfg.MaxCacheLengthMB = 50; cfg.MaxVotesInLog = 1000; cfg.MaxOutstandingPerReplica = 10; cfg.MaxCheckpoints = 2; cfg.MaxLogs = 5; cfg.LogLenRandomize = 20; cfg.ElectionRandomize = 10; cfg.FastReadSeqThreshold = 5; cfg.InMemoryExecutionQueueSizeMB = 10; cfg.NumReaderThreads = 5; cfg.MaxMessageSizeMB = 1; cfg.WorkingDir = ".\\rslib" + id; ManagedRSLNode[] nodes = new ManagedRSLNode[numReplicas]; for (int i = 0; i < nodes.Length; i++) { nodes[i] = new ManagedRSLNode(); nodes[i].MemberId = (i + 1).ToString(); nodes[i].RslPort = (ushort)(20000 + (1000 * (i + 1))); nodes[i].HostName = "127.0.0.1"; nodes[i].Ip = new IPAddress(0x0100007F); // 127.0.0.1 } ManagedRSLNode selfNode = new ManagedRSLNode(); selfNode.MemberId = id.ToString(); selfNode.RslPort = (ushort)(20000 + (1000 * id)); selfNode.HostName = "127.0.0.1"; selfNode.Ip = new IPAddress(0x0100007F); // 127.0.0.1 ManagedRSLStateMachine.Init(".\\debuglogs" + id); //Create and initialize the state machine _stateMachine = new StateMachine((int)arguments["reqsize"]); if (_stateMachine.Initialize(cfg, nodes, selfNode, ManagedRSLProtocolVersion.ManagedRSLProtocolVersion_4, false) == false) { System.Environment.Exit(-1); } //Wait 3 seconds for the pending request to be executed System.Threading.Thread.Sleep(3000); _writer.WriteLine("{1} Initial state: {0}", _stateMachine.State, DateTime.Now); lastRequested = _stateMachine.State; //Execute the test scenario while (_stateMachine.State < targetState) { if (imPrimary) { if (_stateMachine.State == lastRequested) { if (_stateMachine.WriteToState((UInt32)_stateMachine.State + 1) == true) { lastRequested = _stateMachine.State + 1; lock (_writer) { _writer.WriteLine("{1} Request: {0}", lastRequested, DateTime.Now); } } } } else { lastRequested = _stateMachine.State; } _stateMachine.ReadFromState(); _writer.Flush(); System.Threading.Thread.Sleep(1); } _stateMachine.DumpState(); _writer.Flush(); try { _writerFlag = new System.IO.StreamWriter(String.Format("{0}.done", arguments["out"]), true); _writerFlag.WriteLine("DONE"); _writerFlag.Close(); } catch { System.Environment.Exit(-1); } _writer.Close(); System.Threading.Thread.Sleep(int.MaxValue); }
protected virtual void CloseConnection() { try { @in.Close(); @in = null; @out.Close(); @out = null; channel.Close(); channel = null; } catch ( Exception e ) { Console.Error.WriteLine( e ); e.PrintStackTrace( Console.Error ); } finally { if ( @in != null ) { try { @in.Close(); } catch ( IOException ioe ) { Console.Error.WriteLine( ioe ); } } if ( @out != null ) { @out.Close(); } if ( channel != null ) { try { channel.Close(); } catch ( IOException ioe ) { Console.Error.WriteLine( ioe ); } } } }
public string GenerateToFile() { string exportFileName = string.Empty; if (writer == null) { exportFileName = System.IO.Path.GetTempFileName(); writer = System.IO.File.CreateText(exportFileName); } //OR orFunctionID = null; //foreach (ESystemFunction function in SelectedFunctionList) //{ // if (orFunctionID == null) // orFunctionID = new OR(); // orFunctionID.add(new Match("FunctionID", function.FunctionID)); //} //OR orUserID = null; //foreach (EUser selectedUser in SelectedUserList) //{ // if (orUserID == null) // orUserID = new OR(); // orUserID.add(new Match("UserID", selectedUser.UserID)); //} DBFilter filter = new DBFilter(); if (!PeriodFrom.Ticks.Equals(0)) { filter.add(new Match("CreateDate", ">=", PeriodFrom)); } if (!PeriodTo.Ticks.Equals(0)) { filter.add(new Match("CreateDate", "<", PeriodTo.AddDays(1))); } //if (orFunctionID != null) // filter.add(orFunctionID); //if (orUserID != null) // filter.add(orUserID); if (!string.IsNullOrEmpty(SelectedFunctionList)) { filter.add(new IN("FunctionID", SelectedFunctionList, null)); } if (!string.IsNullOrEmpty(SelectedUserList)) { filter.add(new IN("UserID", SelectedUserList, null)); } if (!IsShowWithoutDataUpdate) { filter.add(new IN("AuditTrailID", "select distinct AuditTrailID from " + EAuditTrailDetail.db.dbclass.tableName, new DBFilter())); } //if (!string.IsNullOrEmpty(EmpNo.Text)) //{ // OR orEmpNoTerm = new OR(); // DBFilter empNoFilter = new DBFilter(); // empNoFilter.add(new Match("e.EmpNo"," like ","%"+EmpNo.Text.Trim() +"%")); // orEmpNoTerm.add(new IN("EmpID", "Select EmpID from " + EEmpPersonalInfo.db.dbclass.tableName + " e ", empNoFilter)); // //orEmpNoTerm.add(new Match("EmpID", 0)); // filter.add(orEmpNoTerm); //} filter.add("CreateDate", true); ArrayList auditTrailList = EAuditTrail.db.select(dbConn, filter); try { foreach (EAuditTrail auditTrail in auditTrailList) { if (IsClosed) { break; } string logText = auditTrail.GetLogText(dbConn, EmpNo, IsShowHeaderOnly, IsShowKeyIDOnly, IsDoNotConvertID); if (!string.IsNullOrEmpty(logText)) { writer.WriteLine(logText); } writer.Flush(); if (Updated != null) { Updated(this, new EventArgs()); } } } catch (Exception ex) { throw ex; } writer.Close(); return(exportFileName); }
static public void ShowError(System.Windows.Forms.IWin32Window owner, Exception Ex) { try { System.Diagnostics.Debug.WriteLine(Ex.ToString()); } catch { } //Save error to the last error log. //Vista: C:\ProgramData //XP: c:\Program Files\Common Files string path = string.Empty; //XP = 5.1 & Vista = 6.0 if (Environment.OSVersion.Platform == PlatformID.Unix) { path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); path = System.IO.Path.Combine(path, ".Gurux"); } else { if (Environment.OSVersion.Version.Major >= 6) { path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); } else { path = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles); } path = System.IO.Path.Combine(path, "Gurux"); } path = System.IO.Path.Combine(path, "GXDLMSDirector"); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } path = System.IO.Path.Combine(path, "LastError.log"); try { using (System.IO.TextWriter tw = System.IO.File.CreateText(path)) { tw.Write(Ex.ToString()); tw.Close(); } } catch (Exception) { //Skip all errors. } System.Windows.Forms.Control ctrl = owner as System.Windows.Forms.Control; if (ctrl != null && !ctrl.IsDisposed && ctrl.InvokeRequired) { ctrl.Invoke(new ShowErrorEventHandler(OnShowError), owner, Ex); } else { if (ctrl != null && ctrl.IsDisposed) { if (Ex.HelpLink != null) { System.Windows.Forms.MessageBox.Show(null, Ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1, 0, Ex.HelpLink); } else { System.Windows.Forms.MessageBox.Show(null, Ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } else { if (Ex.HelpLink != null) { System.Windows.Forms.MessageBox.Show(owner, Ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1, 0, Ex.HelpLink); } else { System.Windows.Forms.MessageBox.Show(owner, Ex.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } }