Close() public méthode

public Close ( ) : void
Résultat void
        public void Compile(string fileName)
        {
            var parent = Directory.GetParent(fileName);
            var dir = Directory.CreateDirectory($"output_{parent.Name}");

            var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);

            var tacFilePath = $"{dir.FullName}/{fileNameWithoutExtension}.tac";
            var asmFilePath = $"{dir.FullName}/{fileNameWithoutExtension}.asm";
            try
            {
                FileIn = File.CreateText(tacFilePath);
                var streamReader = new StreamReader(fileName);
                var lexAnalyzer = new LexicalAnalyzerService(streamReader);
                var symbolTable = new SymbolTable
                {
                    Printer = (val) =>
                    {
                        Console.WriteLine(val);
                    }
                };

                var syntaxParser = new SyntaxParserService(lexAnalyzer, symbolTable);

                PrintSourceCode(File.ReadAllText(fileName));
                syntaxParser.Parse();
                FileIn.Close();

                Intelx86GeneratorService.Generate(
                    File.ReadAllLines(tacFilePath),
                    syntaxParser.GlobalStrings,
                    syntaxParser.MethodLocalSize,
                    syntaxParser.MethodParamSize,
                    (str) => {
                        if (File.Exists(asmFilePath))
                        {
                            File.Delete(asmFilePath);
                        }

                        File.AppendAllText(asmFilePath, str);
                        Console.WriteLine(str);
                    });

            }
            catch (Exception ex)
            {
                // Delete out file
                if (File.Exists(tacFilePath))
                {
                    FileIn.Close();
                    File.Delete(tacFilePath);
                }

                Print("Oops, there seems to be something wrong.\n\n", ErrorColor);
                Print(ex.Message, ErrorColor);
            }
        }
 public LogTextWriter(string filePath, string prefix = null, string suffix = null, string newline = "\n")
 {
     _outputQueue = new ConcurrentQueue<string>();
     _outputRun = 1;
     _outputThread = new Thread(() =>
     {
         string o;
             using (FileStream _fs = File.Open(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
             {
         _innerWriter = new StreamWriter(_fs);
         _innerWriter.NewLine = newline;
         while (Thread.VolatileRead(ref _outputRun) == 1 || _outputQueue.Count > 0)
         {
             if (_outputQueue.Count > 0)
             {
                 while (_outputQueue.TryDequeue(out o))
                     _innerWriter.Write(o);
                 _innerWriter.Flush();
             }
             else
                 Thread.Sleep(_outputThreadDelay);
         }
     //				_fs.Close();
         _innerWriter.Close();
             }
     });
     _outputThread.Priority = ThreadPriority.BelowNormal;
     _outputThread.Start();
     _prefix = prefix;
     _suffix = suffix;
 }
        public void ValidateFile(Stream stream, TextWriter outstream, Action<int> progress, Action<string> status)
        {
            try {
                MZTabErrorList errorList = new MZTabErrorList(Level.Info);

                try {
                    validate(stream, outstream, errorList, progress, status);
                    //refine();
                } catch (MZTabException e) {
                    outstream.Write(MZTabProperties.MZTabExceptionMessage);
                    errorList.Add(e.Error);
                } catch (MZTabErrorOverflowException) {
                    outstream.Write(MZTabProperties.MZTabErrorOverflowExceptionMessage);
                }

                errorList.print(outstream);
                if (errorList.IsNullOrEmpty()) {
                    outstream.Write("No errors in this section!" + MZTabConstants.NEW_LINE);
                }

                outstream.Close();
                //stream.Close();
            } catch (Exception e) {
                MessageBox.Show(e.Message, e.StackTrace);
            }
        }
Exemple #4
0
/*************************************************************************************************************************/
        public void flush_save_file()
        {
            int anz_lines;

            Log.PushStackInfo("FMRS_Util.flush_save_file", "enter flush_save_file()");
            Log.dbg("flush save file");

            string[] lines = IO.File.ReadAllLines(FILES.SAVE_TXT);
            anz_lines = lines.Length;

            Log.dbg("delete {0} lines", anz_lines);

            IO.TextWriter file = IO.File.CreateText(FILES.SAVE_TXT);
            while (anz_lines != 0)
            {
                file.WriteLine("");
                anz_lines--;
            }
            file.Close();

            foreach (KeyValuePair <save_cat, Dictionary <string, string> > content in Save_File_Content)
            {
                Save_File_Content[content.Key].Clear();
            }

            bflush_save_file = false;
            init_save_file();
            read_save_file();

            Log.PopStackInfo("leave flush_save_file()");
        }
        protected override void OnStart(string[] args)
        {
            if (!EventLog.SourceExists("SSISIncomingDirectoryWatcher", "."))
            {
                EventLog.CreateEventSource("SSISIncomingDirectoryWatcher", "Application");
            }

            Lg = new EventLog("Application", ".", "SSISIncomingDirectoryWatcher");
            Lg.WriteEntry("Service started at " + DateTime.Now, EventLogEntryType.Information);

            try
            {

                tw = File.CreateText(logFilePath);
                tw.WriteLine("Service started at {0}", DateTime.Now);
                readInConfigValues();
                Watcher = new FileSystemWatcher();
                Watcher.Path = dirToWatch;
                Watcher.IncludeSubdirectories = false;
                Watcher.Created += new FileSystemEventHandler(watcherChange);
                Watcher.EnableRaisingEvents = true;
            }
            catch (Exception ex)
            {
                Lg.WriteEntry(ex.Message, EventLogEntryType.Error);
            }
            finally
            {
                tw.Close();
            }
        }
Exemple #6
0
		public static void GenerateResult (TextReader sr, TextWriter sw, Uri baseUri)
		{
			while (sr.Peek () > 0) {
				string uriString = sr.ReadLine ();
				if (uriString.Length == 0 || uriString [0] == '#')
					continue;
				Uri uri = (baseUri == null) ?
					new Uri (uriString) : new Uri (baseUri, uriString);

				sw.WriteLine ("-------------------------");
				sw.WriteLine (uriString);
				sw.WriteLine (uri.ToString ());
				sw.WriteLine (uri.AbsoluteUri);
				sw.WriteLine (uri.Scheme);
				sw.WriteLine (uri.Host);
				sw.WriteLine (uri.LocalPath);
				sw.WriteLine (uri.Query);
				sw.WriteLine (uri.Port);
				sw.WriteLine (uri.IsFile);
				sw.WriteLine (uri.IsUnc);
				sw.WriteLine (uri.IsLoopback);
				sw.WriteLine (uri.UserEscaped);
				sw.WriteLine (uri.HostNameType);
				sw.WriteLine (uri.AbsolutePath);
				sw.WriteLine (uri.PathAndQuery);
				sw.WriteLine (uri.Authority);
				sw.WriteLine (uri.Fragment);
				sw.WriteLine (uri.UserInfo);
				sw.Flush ();
			}
			sr.Close ();
			sw.Close ();
		}
        protected override void RunPostCompile()
        {
            if (string.IsNullOrEmpty(MapFile))
                return;

            using (writer = new StreamWriter(MapFile))
            {
                // Emit map file header
                writer.WriteLine(CompilerOptions.OutputFile);
                writer.WriteLine();
                writer.WriteLine("Timestamp is {0}", DateTime.Now);
                writer.WriteLine();
                writer.WriteLine("Preferred load address is {0:x16}", (object)Linker.BaseAddress);
                writer.WriteLine();

                // Emit the sections
                EmitSections(Linker);
                writer.WriteLine();

                // Emit all symbols
                EmitSymbols(Linker);

                writer.Close();
            }
        }
Exemple #8
0
        /// <summary>
        /// Método que gera o arquivo fora perfil
        /// </summary>
        /// <param name="pTexto">Texto que irá ser gravado no arquivo fora perfil</param>
        public void GerarArquivo(StringBuilder pTexto)
        {
            try
            {
                string lNomeArquivo    = ConfigurationManager.AppSettings["PathFORAPERFIL"].ToString() + "FORA_PERFIL.prn";
                string lRenamedArquivo = ConfigurationManager.AppSettings["PathFORAPERFIL"].ToString() + "FORA_PERFIL_" + DateTime.Now.ToString("yyyyMMdd") + ".prn";

                if (!System.IO.File.Exists(lNomeArquivo))
                {
                    System.IO.File.Create(lNomeArquivo).Close();
                }
                else
                {
                    System.IO.File.Move(lNomeArquivo, lRenamedArquivo);
                    System.IO.File.Create(lNomeArquivo).Close();
                }

                System.IO.TextWriter lArquivo = System.IO.File.AppendText(lNomeArquivo);
                lArquivo.Write(pTexto);

                lArquivo.Close();

                this.EnviarEmailForaPerfil(lNomeArquivo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #9
0
        /// <summary>
        /// Write all settings to file. Only server should call this!
        /// </summary>
        private void writeAll()
        {
            try
            {
                settingsWriter = MyAPIGateway.Utilities.WriteFileInLocalStorage(settings_file_name, typeof(ServerSettings));

                write(strVersion, m_currentVersion.ToString());                 // must be first line

                // write settings
                foreach (KeyValuePair <SettingName, Setting> pair in AllSettings)
                {
                    write(pair.Key.ToString(), pair.Value.ValueAsString());
                }

                settingsWriter.Flush();
            }
            catch (Exception ex)
            { Logger.AlwaysLog("Failed to write settings to " + settings_file_name + ": " + ex, Rynchodon.Logger.severity.WARNING); }
            finally
            {
                if (settingsWriter != null)
                {
                    settingsWriter.Close();
                    settingsWriter = null;
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// Método que gera arquivo de suitability para a fato
        /// </summary>
        /// <param name="pTexto">Texto com o conteúdo di arquivo que irá ser gravado na pasta específica</param>
        public void GerarArquivoSuitability(StringBuilder pTexto)
        {
            try
            {
                string lNomeArquivo = ConfigurationManager.AppSettings["PathSUITABILITYFATO"].ToString() + "SUITABILITY" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                //string lRenamedArquivo = ConfigurationManager.AppSettings["PathSUITABILITYFATO"].ToString() + "suitability_clientes_" + DateTime.Now.ToString("yyyyMMdd") + ".txt";

                //if (!System.IO.File.Exists(lNomeArquivo))
                //{
                System.IO.File.Create(lNomeArquivo).Close();
                //}
                //else
                //{
                //    System.IO.File.Move(lNomeArquivo, lRenamedArquivo);
                //    System.IO.File.Create(lNomeArquivo).Close();
                //}

                System.IO.TextWriter lArquivo = System.IO.File.AppendText(lNomeArquivo);
                lArquivo.Write(pTexto);

                lArquivo.Close();

                //this.EnviarEmailForaPerfil(lNomeArquivo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #11
0
        static void Main(string[] args)
        {
            output = Console.Out;
            output = new StreamWriter(@"Assignment2.smt");
            start("P Int Int Int", "QF_UFLIA");

            int[] chip = new int[2] {29,22};
            int[] powerComponent = new int[2] {4,2};
            int[,] components = new int[8, 2] {{9,7},{12,6},{10,7},{18,5},{20,4},{10,6},{8,6},{10,8}};
            int powerDist = 17;

            //All components must occur
            for (int i = 2; i < components.Length + 2; i++) {
                output.WriteLine("(or");
                for (int x = 0; x < chip [0]; x++) {
                    for (int y = 0; y < chip [1]; y++) {
                        output.WriteLine("(= (P {0} {1}) {2})", x, y, i);
                    }
                }
                output.WriteLine(")");
            }

            end();

            output.Close();
            //Console.ReadKey();
        }
        public void Output(TextWriter writer)
        {
            var outputList = new List<AuditResultsOutput>();
            foreach (var result in _results)
            {
                if (_auditEventTypes.HasFlag(AuditEventTypes.ResolvedAssemblyReferences))
                    outputList.AddRange(result.ResolvedAssemblyReferences.Select(u => new AuditResultsOutput {PackageName = result.Package.Id, Category = "Resolved Assembly", Item = u.Name}));
                if (_auditEventTypes.HasFlag(AuditEventTypes.UnloadablePackageFiles))
                    outputList.AddRange(result.UnloadablePackageFiles.Select(u => new AuditResultsOutput { PackageName = result.Package.Id, Category = "Unloadable Package File", Item = u }));
                if (_auditEventTypes.HasFlag(AuditEventTypes.UnresolvedAssemblyReferences))
                    outputList.AddRange(result.UnresolvedAssemblyReferences.Select(u => new AuditResultsOutput { PackageName = result.Package.Id, Category = "Unresolved Assembly", Item = u.Name }));
                if (_auditEventTypes.HasFlag(AuditEventTypes.UnresolvedDependencies))
                    outputList.AddRange(result.UnresolvedDependencies.Select(u => new AuditResultsOutput { PackageName = result.Package.Id, Category = "Unresolved Package Dependency", Item = u.Id }));
                if (_auditEventTypes.HasFlag(AuditEventTypes.UnusedPackageDependencies))
                    outputList.AddRange(result.UnusedPackageDependencies.Select(u => new AuditResultsOutput { PackageName = result.Package.Id, Category = "Unused Package Dependency", Item = u.Id }));
                if (_auditEventTypes.HasFlag(AuditEventTypes.UsedPackageDependencies))
                    outputList.AddRange(result.UsedPackageDependencies.Select(u => new AuditResultsOutput { PackageName = result.Package.Id, Category = "Used Package Dependency", Item = u.Id }));
                if (_auditEventTypes.HasFlag(AuditEventTypes.FeedResolvableReferences))
                    outputList.AddRange(result.FeedResolvableReferences.Select(u => new AuditResultsOutput { PackageName = result.Package.Id, Category = "Feed Resolvable Assembly", Item = u.Name }));
                if (_auditEventTypes.HasFlag(AuditEventTypes.GacResolvableReferences))
                    outputList.AddRange(result.GacResolvableReferences.Select(u => new AuditResultsOutput { PackageName = result.Package.Id, Category = "GAC Resolvable Assembly", Item = u.Name }));
                if (_auditEventTypes.HasFlag(AuditEventTypes.UnresolvableAssemblyReferences))
                    outputList.AddRange(result.UnresolvableReferences.Select(u => new AuditResultsOutput { PackageName = result.Package.Id, Category = "Unresolvable Assembly Reference (not on feed or in GAC)", Item = u.Name }));
            }

            foreach (var output in outputList)
                writer.WriteLine(output.ToString());
            writer.Close();
        }
Exemple #13
0
        private static void AdicionarNoXML(string filename)
        {
            if (data.Columns.Count == 0)
                data.Columns.Add("CaminhoArquivo");

            if (data.Rows.Count > 10)
            {
                int iterador = data.Rows.Count - 1;

                while (iterador > 10)
                {
                    data.Rows.Remove(data.Rows[iterador]);
                    iterador--;
                }
            }

            int posicao = VerificaLista(filename);

            if (posicao != -1)
            {
                data.Rows[posicao].Delete();
            }

            data.Rows.Add(filename);
            writer = File.CreateText(xml);
            data.WriteXml(writer);
            writer.Close();
        }
Exemple #14
0
        protected void btnImprimir_Click(object sender, EventArgs e)
        {
            string msgDeclaracao = string.Format("Eu, {0} portador do Rg {1} , CPF {2} Adoro estudar {3} porque é uma Linguagem {4} </br> {5} , {6} , {7} </br> Declaro ser {8} de idade</br></br>"
                                                 , txtNome.Text
                                                 , txtRg.Text
                                                 , txtCpf.Text
                                                 , txtLing.Text
                                                 , txtAdj.Text
                                                 , txtCidade.Text
                                                 , txtxDia.Text
                                                 , txtAno.Text
                                                 , txtMaior.Text);

            lblDeclaracao.Text = msgDeclaracao;

            string declaracao = "C:\\Users\\damia\\Documents\\Faculdade Logatti\\carta.txt";

            if (!System.IO.File.Exists(declaracao))
            {
                System.IO.File.Create(declaracao).Close();
            }
            System.IO.TextWriter arquivo = System.IO.File.AppendText(declaracao);
            arquivo.WriteLine(msgDeclaracao);
            arquivo.Close();


            //InserirBanco(txtNome.Text);
        }
Exemple #15
0
        /// <summary>
        /// Saves a Graph to CSV format
        /// </summary>
        /// <param name="g">Graph</param>
        /// <param name="output">Writer to save to</param>
        public void Save(IGraph g, TextWriter output)
        {
            try
            {
                foreach (Triple t in g.Triples)
                {
                    this.GenerateNodeOutput(output, t.Subject, TripleSegment.Subject);
                    output.Write(',');
                    this.GenerateNodeOutput(output, t.Predicate, TripleSegment.Predicate);
                    output.Write(',');
                    this.GenerateNodeOutput(output, t.Object, TripleSegment.Object);
                    output.Write("\r\n");
                }

                output.Close();
            }
            catch
            {
                try
                {
                    output.Close();
                }
                catch
                {
                    //No error handling, just trying to clean up
                }
                throw;
            }
        }
Exemple #16
0
 public void log(String value)
 {
     writer = new StreamWriter(fileName,true);
     writer.WriteLine(" ");
     writer.WriteLine("[ "+System.DateTime.UtcNow+" ] "+value);
     writer.Close();
 }
Exemple #17
0
        public void GerandoArquivoLogPeloServico(string strDescrição)
        {
            try
            {
                DateTime data = DateTime.Now;

                string CaminhoArquivoLog = "";
                CaminhoArquivoLog = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory.ToString()) + "\\..\\..\\..\\..\\Modulos\\Log\\Log-" + data.ToString("dd-MM-yyyy") + ".txt";

                if (!System.IO.File.Exists(CaminhoArquivoLog))
                {
                    FileStream   file = new FileStream(CaminhoArquivoLog, FileMode.Create);
                    BinaryWriter bw   = new BinaryWriter(file);
                    bw.Close();
                }

                string nomeArquivo           = CaminhoArquivoLog;
                System.IO.TextWriter arquivo = System.IO.File.AppendText(nomeArquivo);

                // Agora é só sair escrevendo
                arquivo.WriteLine(data.ToString("HH:mm:ss") + " - " + strDescrição);

                arquivo.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
        }
Exemple #18
0
        public static bool WriteInLog(string textoLog)
        {
            try
            {
                //Cria mensagem de log
                var mensagem = DateTime.Now.ToString("G") + " | " + textoLog;

                //Escreve na tela (console)
                System.Console.WriteLine(mensagem);


                //Abre o arquivo para a escrita
                System.IO.TextWriter arquivo = System.IO.File.AppendText(_caminhoArquivo);
                //Escreve no arquivo
                arquivo.WriteLine(mensagem);
                //Fecha o arquivo
                arquivo.Close();

                return(true);
            }
            catch (Exception e) //Ocorreu algum erro na escrita do arquivo, portanto retorna false
            {
                return(false);
            }
        }
Exemple #19
0
        public void GerandoArquivoLog(string strDescrição, int CodCaminho)
        {
            DateTime data = DateTime.Now;

            string CaminhoArquivoLog = "";

            if (CodCaminho == 1)//HabilServiceNFSe
            {
                CaminhoArquivoLog = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory.ToString()) + "\\..\\..\\..\\..\\Modulos\\Log\\Log-" + data.ToString("dd-MM-yyyy") + ".txt";
            }
            else//HabilInformatica
            {
                CaminhoArquivoLog = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory.ToString()) + "\\Log\\Log-" + data.ToString("dd-MM-yyyy") + ".txt";
            }

            if (!System.IO.File.Exists(CaminhoArquivoLog))
            {
                FileStream   file = new FileStream(CaminhoArquivoLog, FileMode.Create);
                BinaryWriter bw   = new BinaryWriter(file);
                bw.Close();
            }
            string nomeArquivo = CaminhoArquivoLog;

            System.IO.TextWriter arquivo = System.IO.File.AppendText(nomeArquivo);

            // Agora é só sair escrevendo
            arquivo.WriteLine(data.ToString("HH:mm:ss") + " - " + strDescrição);

            arquivo.Close();
        }
        public static void doDiagnostic()
        {
            System.IO.TextWriter stream = getDiagnosticFile();
            if (stream != null)
            {
                stream.WriteLine("Diagnostic le " + DateTime.Now.ToLongDateString() + " à " + DateTime.Now.ToLongTimeString());
                stream.WriteLine();

                stream.WriteLine("== XP Nessecaire par niveau ==");
                stream.WriteLine(".");
                for (int i = 0; i < 30; i++)
                {
                    stream.WriteLine("Niveau {0}: {1}xp", i.ToString(), XPHelper.GetXpForLevel(i).ToString());
                    if (i == 20)
                    {
                        stream.WriteLine("-- Niveaux de prestiges --");
                    }
                }

                stream.WriteLine(".");
                int xplvlmax = 0;
                for (int i = 0; i < 20; i++)
                {
                    xplvlmax += XPHelper.GetXpForLevel(i);
                }
                stream.WriteLine("XP Total Nessecaire pour level 20 : " + xplvlmax);
            }
            Console.WriteLine("Diagnostic terminé, voir " + fileName);
            stream.Close();
        }
Exemple #21
0
 public static void WriteToStream(TextWriter stream, DataTable table, bool header, bool quoteall)
 {
     if (header)
     {
         for (int i = 0; i < table.Columns.Count; i++)
         {
             WriteItem(stream, table.Columns[i].Caption, quoteall);
             if (i < table.Columns.Count - 1)
                 stream.Write(',');
             else
                 stream.Write("\r\n");
         }
     }
     foreach (DataRow row in table.Rows)
     {
         for (int i = 0; i < table.Columns.Count; i++)
         {
             WriteItem(stream, row[i], quoteall);
             if (i < table.Columns.Count - 1)
                 stream.Write(',');
             else
                 stream.Write("\r\n");
         }
     }
     stream.Flush();
     stream.Close();
 }
Exemple #22
0
        static int Main(string[] args)
        {
            try
            {
                if (!File.Exists(templateName))
                {
                    Console.WriteLine(templateName + " not found."); return 1;
                }

                try
                {
                    fStream = new FileStream(@"FreeImage.cs", FileMode.Create);
                }
                catch
                {
                    Console.WriteLine("Unable to create output file."); return 2;
                }

                textOut = new StreamWriter(fStream);

                string[] content = File.ReadAllLines(templateName);

                for (int lineNumber = 0; lineNumber < content.Length; lineNumber++)
                {
                    string line = content[lineNumber].Trim();
                    Match match = searchPattern.Match(line);

                    if (match.Success && match.Groups.Count == 2 && match.Groups[1].Value != null)
                    {
                        if (!File.Exists(baseFolder + match.Groups[1].Value))
                        {
                            throw new FileNotFoundException(baseFolder + match.Groups[1].Value + " does not exist.");
                        }

                        ParseFile(baseFolder + match.Groups[1].Value);
                    }
                    else
                    {
                        textOut.WriteLine(content[lineNumber]);
                    }
                }

                return 0;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                //Console.WriteLine("Error while parsing.");
                return 3;
            }
            finally
            {
                if (textOut != null)
                {
                    textOut.Flush();
                    textOut.Close();
                }
            }
        }
 /// <summary>
 /// Creates a profiler object
 /// </summary>
 /// <param name="filename">Name of file to save profiling log to</param>
 /// <param name="append">True if the file should not be overwritten</param>
 public Profiler(string filename, bool append)
 {
     // done to make sure file path is writeable – each time logging used new streamwriter opened & closed to prevent file locking for entire AWB session
     log = new StreamWriter(filename, append, Encoding.Unicode);
     log.Close();
     FileName = filename;
     Append = append;
 }
Exemple #24
0
 /// <summary>
 /// Writes to log.
 /// </summary>
 /// <param name="text">The text.</param>
 protected void WriteToLog(string text)
 {
     using (System.IO.TextWriter tw = System.IO.File.AppendText(string.Format("{0}\\CachingProvider_Errors.txt", this.logPath)))
     {
         tw.WriteLine(text);
         tw.Close();
     }
 }
Exemple #25
0
 public static void Write(TextWriter writer, bool ownsStream, Action<JsonWriter.Item> resolver, JsonWriterOptions options = null)
 {
     JsonWriter w = new JsonWriter(writer, options);
     if (options == null) options = defaultOptions;
     resolver(w.itemWriter);
     if (ownsStream)
         writer.Close();
 }
 protected override void OnShutdown()
 {
     EventLog Lg = new EventLog("Application", ".", "SSISIncomingDirectoryWatcher");
     tw = (TextWriter)File.AppendText(logFilePath);
     Lg.WriteEntry("Service shutdown at " + DateTime.Now, EventLogEntryType.Information);
     tw.WriteLine("Service shutdown at {0}", DateTime.Now);
     tw.Close();
 }
 public void OnDestroy()
 {
     if (Tw != null)
     {
         Tw.Close();
     }
     GameEvents.onGameSceneLoadRequested.Remove(logSceneSwitch);
 }
Exemple #28
0
 public Tracer()
 {
     m_traceFileName = Path.Combine(Application.StartupPath, "trace.txt");
     FileStream fs = new FileStream(m_traceFileName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
     m_tw = new StreamWriter(fs);
     m_tw.WriteLine("Started " + DateTime.Now);
     m_tw.WriteLine("Framework: " + Environment.Version + " Program: " + Project.PROGRAM_NAME_HUMAN + " " + Project.PROGRAM_VERSION_HUMAN + " Build: " + Project.PROGRAM_VERSION_RELEASEDATE);
     m_tw.Close();
 }
 public static void LogCria()
 {
     try
     {
         File.Delete(D.AplicacaoDiretorio + D.LogImportacaoArquivo);
     }
     catch { }
     log = new StreamWriter(D.AplicacaoDiretorio + D.LogImportacaoArquivo);
     log.Close();
 }
Exemple #30
0
 public void Close()
 {
     lock (iolock)
     {
         if (writer != null)
         {
             writer.Close();
         }
     }
 }
Exemple #31
0
/*************************************************************************************************************************/
        public void init_recover_file()
        {
            Log.PushStackInfo("FMRS_Util.init_recover_file", "enter init_recover_file()");
            Log.dbg("init recover file");

            IO.TextWriter file = IO.File.CreateText(FILES.RECOVER_TXT);
            file.Close();

            Log.PopStackInfo("leave init_recover_file()");
        }
Exemple #32
0
 public static void LogCria()
 {
     try
     {
         File.Delete(D.AplicacaoDiretorio + D.DEPRECIADO_APP_LOGFILENAME);
     }
     catch { }
     log = new StreamWriter(D.AplicacaoDiretorio + D.DEPRECIADO_APP_LOGFILENAME);
     log.Close();
 }
Exemple #33
0
 public static void LogCria()
 {
     try
     {
         File.Delete(D.ApplicationDirectory + D.NeoDebug_LogFile);
     }
     catch { }
     log = new StreamWriter(D.ApplicationDirectory + D.NeoDebug_LogFile);
     log.Close();
 }
Exemple #34
0
        /// <summary>
        /// Shows an error message.
        /// </summary>
        public static void ShowError(IWin32Window parent, string title, Exception ex)
        {
            try
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }

                if (ex.StackTrace != null)
                {
                    Gurux.Common.GXCommon.TraceWrite(ex.StackTrace.ToString());
                }
                string path = ApplicationDataPath;
                if (System.Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    path = Path.Combine(path, ".Gurux");
                }
                else
                {
                    path = Path.Combine(path, "Gurux");
                }
                path = Path.Combine(path, "LastError.txt");
                try
                {
                    using (System.IO.TextWriter tw = System.IO.File.CreateText(path))
                    {
                        tw.Write(ex.ToString());
                        if (ex.StackTrace != null)
                        {
                            tw.Write("----------------------------------------------------------\r\n");
                            tw.Write(ex.StackTrace.ToString());
                        }
                        tw.Close();
                    }
                    GXFileSystemSecurity.UpdateFileSecurity(path);
                }
                catch (Exception)
                {
                    //Skip error.
                }
                if (parent != null && !((Control)parent).IsDisposed && !((Control)parent).InvokeRequired)
                {
                    MessageBox.Show(parent, ex.Message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(ex.Message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch
            {
                //Do nothing. Fatal exception blew up message box.
            }
        }
Exemple #35
0
 public void WriteCsSources(EntityApp app, DbFirstConfig config)
 {
     _app = app;
       _config = config;
       HasErrors = false;
       var fileStream = File.Create(_config.OutputPath);
       _output = new StreamWriter(fileStream);
       WriteSource();
       _output.Flush();
       _output.Close();
 }
        public void GuardarCambios(TextBox ma, RichTextBox so)
        {
            ma.Text = turuta;

            String mensaje;
            mensaje = so.Text;
            archivo = new StreamWriter(turuta);
            archivo.Write(mensaje);
            archivo.Close();
            MessageBox.Show("Edicion correcta");
        }
        public static void SavePath(string src, Path p)
        {
            output = File.CreateText(src);

            foreach (var point in p.CurrentPath)
            {
                output.WriteLine(point);
            }

            output.Close();
        }
Exemple #38
0
        private void button3_Click(object sender, EventArgs e)
        {
            textBox2.Text=rutal;

               String mensaje;
               mensaje = richTextBox1.Text;
               archivo = new StreamWriter(rutal);
               archivo.Write(mensaje);
               archivo.Close();
               MessageBox.Show("perfecto");
        }
Exemple #39
0
    private void OnApplicationQuit()
    {
        if (!writtenFile & file != null)
        {
            file.Close();
            writtenFile = true;
        }

        EmailObject.gameObject.SetActive(true);
        EmailObject.GetComponent <SendEmail>().Emailer(fileName);
    }
Exemple #40
0
 /// <summary>
 /// Saves the Result Set to the given Stream in the SPARQL Results JSON Format
 /// </summary>
 /// <param name="results">Result Set to save</param>
 /// <param name="output">Stream to save to</param>
 public void Save(SparqlResultSet results, TextWriter output)
 {
     try
     {
         this.GenerateOutput(results, output);
         output.Close();
     }
     catch
     {
         try
         {
             output.Close();
         }
         catch
         {
             //No Catch Actions
         }
         throw;
     }
 }
Exemple #41
0
 private Log()
 {
     fileName = "Log.txt";
     writer = new StreamWriter(fileName);
     writer.WriteLine("Types of Log:");
     writer.WriteLine("Error Log: There is a problem with the program that needs to be fixed.\n This error mostly occurs due to the fact that an error occured with the scripting or loading a file and not due to the fact that there is something wrong with the library.");
     writer.WriteLine("Program Run Log: This log means that everything pertaining to this line of log has loaded itself sucessfully");
     writer.WriteLine("");
     writer.WriteLine("Starting to log....");
     writer.Close();
 }
        public void DecompileFile(string input, TextWriter writer)
        {
            var assembly = AssemblyDefinition.ReadAssembly(input, new ReaderParameters() {
                AssemblyResolver = new IgnoringExceptionsAssemblyResolver()
            });

            var decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule));
            decompiler.AddAssembly(assembly);
            decompiler.GenerateCode(new PlainTextOutput(writer));
            writer.Close();
        }
Exemple #43
0
 /// <summary>
 /// Saves the Result Set to the given Stream in the Sparql Results XML Format
 /// </summary>
 /// <param name="results"></param>
 /// <param name="output"></param>
 public virtual void Save(SparqlResultSet results, TextWriter output)
 {
     try
     {
         XmlDocument doc = this.GenerateOutput(results);
         doc.Save(output);
         output.Close();
     }
     catch
     {
         try
         {
             output.Close();
         }
         catch
         {
             //No Catch Actions
         }
         throw;
     }
 }
Exemple #44
0
 /// <summary>
 /// Saves the Result Set to the given Stream as an XHTML Table with embedded RDFa
 /// </summary>
 /// <param name="g">Graph to save</param>
 /// <param name="output">Stream to save to</param>
 public void Save(IGraph g, TextWriter output)
 {
     try
     {
         HtmlWriterContext context = new HtmlWriterContext(g, output);
         this.GenerateOutput(context);
         output.Close();
     }
     catch
     {
         try
         {
             output.Close();
         }
         catch
         {
             //No Catch Actions
         }
         throw;
     }
 }
Exemple #45
0
        public void WriteCsSources(EntityApp app, DbFirstConfig config)
        {
            _app      = app;
            _config   = config;
            HasErrors = false;
            var fileStream = File.Create(_config.OutputPath);

            _output = new StreamWriter(fileStream);
            WriteSource();
            _output.Flush();
            _output.Close();
        }//method
Exemple #46
0
 public override void CreateIndexFile(string path)
 {
     using (System.IO.TextWriter texList = File.CreateText(Path.Combine(path, "index.txt")))
     {
         foreach (gcaxMLTEntry entry in Entries)
         {
             texList.WriteLine("{0},{1}", entry.Name, entry.BankID.ToString("D2"));
         }
         texList.Flush();
         texList.Close();
     }
 }
Exemple #47
0
 /// <summary>
 /// 写日志
 /// </summary>
 /// <param name="str"></param>
 public void WriteLog(string str)
 {
     try
     {
         output = File.AppendText(strFileName);
         output.WriteLine(System.DateTime.Now + "\n" + str);
         output.Close();
     }
     catch (Exception ex)
     {
     }
 }
Exemple #48
0
/*************************************************************************************************************************/
        public void write_save_values_to_file()
        {
            Log.PushStackInfo("FMRS_Util.write_save_values_to_file", "entering write_save_values_to_file()");

            set_save_value(save_cat.SETTING, "Window_X", Convert.ToInt32(windowPos.x).ToString());
            set_save_value(save_cat.SETTING, "Window_Y", Convert.ToInt32(windowPos.y).ToString());
            set_save_value(save_cat.SETTING, "Armed", _SETTING_Armed.ToString());
            set_save_value(save_cat.SETTING, "Minimized", _SETTING_Minimize.ToString());
            set_save_value(save_cat.SETTING, "Enabled", _SETTING_Enabled.ToString());
            //set_save_value(save_cat.SETTING, "Messages", _SETTING_Messages.ToString());
            //set_save_value(save_cat.SETTING, "Auto_Cut_Off", _SETTING_Auto_Cut_Off.ToString());
            //set_save_value(save_cat.SETTING, "Auto_Recover", _SETTING_Auto_Recover.ToString());
            //set_save_value(save_cat.SETTING, "Throttle_Log", _SETTING_Throttle_Log.ToString());
            set_save_value(save_cat.SAVE, "Main_Vessel", _SAVE_Main_Vessel.ToString());
            set_save_value(save_cat.SAVE, "Has_Launched", _SAVE_Has_Launched.ToString());
            set_save_value(save_cat.SAVE, "Launched_At", _SAVE_Launched_At.ToString());
            set_save_value(save_cat.SAVE, "Flight_Reset", _SAVE_Flight_Reset.ToString());
            set_save_value(save_cat.SAVE, "Kick_To_Main", _SAVE_Kick_To_Main.ToString());
            set_save_value(save_cat.SAVE, "Switched_To_Dropped", _SAVE_Switched_To_Dropped.ToString());
            set_save_value(save_cat.SAVE, "Switched_To_Savefile", _SAVE_Switched_To_Savefile);
            set_save_value(save_cat.SAVE, "SaveFolder", _SAVE_SaveFolder);

            write_vessel_dict_to_Save_File_Content();

            IO.TextWriter file = IO.File.CreateText(FILES.SAVE_TXT);
            file.Flush();
            file.Close();
            file = IO.File.CreateText(FILES.SAVE_TXT);
            foreach (KeyValuePair <save_cat, Dictionary <string, string> > save_cat_block in Save_File_Content)
            {
                foreach (KeyValuePair <string, string> writevalue in save_cat_block.Value)
                {
                    file.WriteLine(save_cat_toString(save_cat_block.Key) + "=" + writevalue.Key + "=" + writevalue.Value);
                }
            }
            file.Close();

            Log.dbg("Save File written in private void write_save_values_to_file()");
            Log.PopStackInfo("leaving save_values_to_file()");
        }
Exemple #49
0
 /// <summary>
 /// 写txt
 /// </summary>
 /// <param name="str"></param>
 public void WriteLine(string str)
 {
     try
     {
         output = File.AppendText(strFileName);
         output.WriteLine(str);
         output.Close();
     }
     catch (Exception ex)
     {
         err = ex.Message;
     }
 }
Exemple #50
0
 /// <summary>
 /// 写日志
 /// </summary>
 /// <param name="str"></param>
 public void WriteLog(string str)
 {
     if (!Neusoft.FrameWork.Management.Connection.IsWeb)
     {
         try
         {
             output = File.AppendText(strFileName);
             output.WriteLine(System.DateTime.Now + "\n" + str);
             output.Close();
         }
         catch {}
     }
 }
Exemple #51
0
 /// <summary>
 /// closes the static log file
 /// </summary>
 private static void close()
 {
     if (logWriter == null)
     {
         return;
     }
     using (lock_log.AcquireExclusiveUsing()) {
         logWriter.Flush();
         logWriter.Close();
         logWriter = null;
         closed    = true;
     }
 }
Exemple #52
0
 public static void LogEntry(String logMessage, TextWriter w)
 {
     w.Write("Log Entry :\r\n");
     //w.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToShortDateString());
     w.WriteLine(logMessage);
     w.WriteLine("---------------------------------------");
     // Update the underlying file.
     w.Flush();
     // Close the writer and underlying file.
     w.Close();
     //Update the tbLog
     //tb.AppendText(File.ReadAllText(Common.MainLog));
 }
Exemple #53
0
/*************************************************************************************************************************/
        public void write_record_file()
        {
            Log.PushStackInfo("FMRS_THL.write_record_file", "FMRS_THL_Log: entering write_record_file()");
            Log.dbg("FMRS_THL_Log: write to record file");

            writing = true;

            Throttle_Log_Buffer.Sort(delegate(entry x, entry y)
            {
                if (x.time > y.time)
                {
                    return(1);
                }
                else
                {
                    return(-1);
                }
            });

            IO.TextWriter writer = null;
            try
            {
                writer = IO.File.AppendText(FMRS.FILES.RECORD_TXT);
                writer.WriteLine("##########################################");
                foreach (entry temp in Throttle_Log_Buffer)
                {
                    writer.WriteLine(temp.ToString());
                }

                if (!started)
                {
                    writer.WriteLine("####EOF####");
                }
            }
            finally
            {
                writer?.Close();
            }

            Throttle_Log_Buffer.Clear();
            writing = false;

            foreach (entry temp in temp_buffer)
            {
                Throttle_Log_Buffer.Add(temp);
            }
            temp_buffer.Clear();

            FMRS.Log.PopStackInfo("FMRS_THL_Log: leave write_record_file()");
        }
Exemple #54
0
/*************************************************************************************************************************/
        public void flush_record_file()
        {
            Log.PushStackInfo("FMRS_THL.flush_record_file", "FMRS_THL_Log: entering flush_record_file()");
            Log.dbg("FMRS_THL_Log: flush record file");

            IO.TextWriter writer = IO.File.CreateText(FMRS.FILES.RECORD_TXT);
            writer.Flush();
            writer.Close();

            Throttle_Log_Buffer.Clear();
            temp_buffer.Clear();

            Log.PopStackInfo("FMRS_THL_Log: leave flush_record_file()");
        }
Exemple #55
0
        /// <summary>
        /// Make sure that a dictionary exists for the specified writing system.
        /// </summary>
        public static Dictionary EnsureDictionary(int ws, string icuLocale, ILgWritingSystemFactory wsf)
        {
            Enchant.Dictionary result = EnchantHelper.GetDictionary(ws, wsf);
            if (result != null)
            {
                return(result);
            }
            string dirPath = GetSpellingDirectoryPath();

            if (!System.IO.Directory.Exists(dirPath))
            {
                System.IO.Directory.CreateDirectory(dirPath);
            }
            string dicPath = GetDicPath(dirPath, icuLocale);

            System.IO.TextWriter writer = System.IO.File.CreateText(System.IO.Path.ChangeExtension(dicPath, ".aff"));
            writer.WriteLine("SET UTF-8");
            writer.Close();
            if (!System.IO.File.Exists(dicPath))
            {
                // If it already exists, probably we disabled it by deleting the .aff file--an approach we
                // no longer use; re-creating it should reinstate it.
                writer = System.IO.File.CreateText(dicPath);
                writer.WriteLine("0");
                writer.Close();
            }
            // Apparently, although the broker will find the new dictionary when asked for it explicitly,
            // it doesn't appear in the list of possible dictionaries (Enchant.Broker.Default.Dictionaries)
            // which is used to populate the spelling dictionary combo box in the writing system dialog
            // unless we dispose the old broker (which causes a new one to be created).
            // Note: I (JohnT) have a vague recollection that disposing the broker can cause problems for
            // any existing dictionaries we hang on to. So don't dispose it more than necessary.
            Enchant.Broker.Default.Dispose();
            // Now it should exist!
            return(EnchantHelper.GetDictionary(ws, wsf));
        }
Exemple #56
0
 /// <summary>
 /// Generates a Package XML File containing all informations needed to recreate the Package
 /// </summary>
 /// <param name="flname">The Filename for the File</param>
 public void GeneratePackageXML(string flname)
 {
     System.IO.TextWriter fs = System.IO.File.CreateText(flname);
     try
     {
         fs.WriteLine("<?xml version=\"1.0\" encoding=\"" + fs.Encoding.HeaderName + "\" ?>");
         fs.Write(GeneratePackageXML(false));
     }
     finally
     {
         fs.Close();
         fs.Dispose();
         fs = null;
     }
 }
Exemple #57
0
 /// <summary>
 /// Finalize the logging stream for termination.
 /// </summary>
 private void Shutdown()
 {
     // We need to stop listening for the shutdown signal.
     MyAPIGateway.Entities.OnCloseAll -= Shutdown;
     // We need to check if there is unwritten content in the cache.
     if (m_cache.Length > 0)
     {
         // Write the remaining content.
         m_writer.WriteLine(m_cache);
     }
     // Empty the writer's buffer out.
     m_writer.Flush();
     // Now shut the writer down.
     m_writer.Close();
     // Mark the logger as unavailable.
     isTerminated = true;
 }
Exemple #58
0
 /// <summary>
 /// Saves Metainformations about a PackedFile as xml output
 /// </summary>
 /// <param name="flname">The Filename</param>
 /// <param name="pfd">The description of the File</param>
 protected void SaveMetaInfo(string flname, PackedFileDescriptor pfd)
 {
     System.IO.TextWriter fs = System.IO.File.CreateText(flname);
     try
     {
         fs.WriteLine("<?xml version=\"1.0\" encoding=\"" + fs.Encoding.HeaderName + "\" ?>");
         fs.WriteLine("<package type=\"" + ((uint)Header.IndexType).ToString() + "\">");
         fs.Write(pfd.GenerateXmlMetaInfo());
         fs.WriteLine("</package>");
     }
     finally
     {
         fs.Close();
         fs.Dispose();
         fs = null;
     }
 }
Exemple #59
0
/*************************************************************************************************************************/
        public void write_recover_file()
        {
            Log.PushStackInfo("FMRS_Util.write_recover_file", "enter write_recover_file()");

            flush_recover_file();

            Log.dbg("write recover file");

            IO.TextWriter file = IO.File.CreateText(FILES.RECOVER_TXT);

            foreach (recover_value writevalue in recover_values)
            {
                file.WriteLine(writevalue.cat + "=" + writevalue.key + "=" + writevalue.value);
            }
            file.Close();

            Log.PopStackInfo("leave write_recover_file()");
        }
Exemple #60
0
        public static string CreateFileLog()
        {
            //Pega diretorio atual e concatena com o nome do arquivo

            //Se nao existe, cria o arquivo
            if (!System.IO.File.Exists(_caminhoArquivo))
            {
                System.IO.File.Create(_caminhoArquivo).Close();
            }

            //Abre o arquivo para a escrita
            System.IO.TextWriter arquivo = System.IO.File.AppendText(_caminhoArquivo);

            arquivo.Close();

            //Retorna o caminho do arquivo de log
            return(_caminhoArquivo);
        }