コード例 #1
0
        public static void SaveValueOfDebugFile()
        {
            string dir      = IO.Directory.SubDirDebug;
            string pathFile = dir + @"\" + AppConfigClient.Param.files.Debug;

            if (!existFileForSaveDebug)
            {
                existFileForSaveDebug = File.Exists(pathFile);
            }

            if (existFileForSaveDebug)
            {
                long?len = File.Length(pathFile);
                if (len != null)
                {
                    if (len >= (1024 * 1024 * 1024)) //1 GB
                    {
                        AppConfigClient.Param.files.count++;
                        AppConfigClient.Param.files.Debug = "Debug" + (AppConfigClient.Param.files.count - 1) + Directory.FileExtension;
                    }
                }
            }

            bool append                 = true;
            ExtendedStreamWriter tw     = new ExtendedStreamWriter(pathFile, append, Config.CurrentGuid, AppConfigClient.Crypt);
            StringBuilder        output = new StringBuilder();

            //Se arquivo de saída tiver tamanho igual zero (0), significa que é um novo arquivo.
            if (tw.BaseStream().Length == 0)
            {
                //Portanto, monta-se o header do arquivo de saída
                output.Append(
                    "McSteps\t" +
                    "contMoves:NumberOfMovementsApplied\t" +

                    "environment:DeltaE\t" +
                    "environment:RG\t" +
                    "environment:DPP\t" +
                    "environment:R\t" +
                    "environment:TransitionProbability\t" +

                    "chain:UPrevious\t" +
                    "chain:U\t" +

                    "chain:TotalNeighborTopological\t" +
                    "chain:selectNode\t" +
                    "chain:typeOfLattice\t" +
                    "chain:neighborContacts\t" +
                    "chain:numberNeighborTopological");
                tw.WriteLine(output.ToString());
                output.Clear();
            }


            output.Append(
                GCPS.McSteps + "\t" +
                GCPS.chain.contMoves.NumberOfMovementsApplied + "\t" +

                Structs.Environment.deltaE + "\t" +
                Structs.Environment.rg + "\t" +
                Structs.Environment.dpp + "\t" +
                Structs.Environment.lastR + "\t" +
                Structs.Environment.transitionProbability + "\t" +

                GCPS.chain.UPrevious + "\t" +
                GCPS.chain.U + "\t" +
                GCPS.chain.TotalNeighborTopological() + "\t" +
                GCPS.chain.selectNode + "\t" +
                GCPS.chain.typeOfLattice + "\t" +
                GCPS.chain.neighborContacts + "\t" +
                GCPS.chain.numberNeighborTopological);
            tw.WriteLine(output.ToString());


            output = null;

            try
            {
                tw.Flush();
                tw.Close();
            }
            finally
            {
                tw = null;
            }
        }