Exemple #1
0
        public ConfigIntegrator(Param param, bool filesMoved)
        {
            this.param          = param;
            this.totalSitio     = param.dataToProcess.totalSitio;
            this.MCSteps        = param.dataToProcess.maxInterations * totalSitio * 5;
            this.valueDivResult = param.dataToResults.valueDivResult;
            this.valueDiscard   = param.dataToResults.valueDiscard;
            this.maxInterations = param.dataToProcess.maxInterations;

            this.dirBaseServer = new ExtendedDirectoryInfo(DirBaseService.GetDirBaseService().dirBaseServer);
            this.dirBaseWeb    = new ExtendedDirectoryInfo(DirBaseService.GetDirBaseService().dirBaseWeb);

            if (!filesMoved)
            {
                this.movimentsOccurred = ExtendedStreamReader.LinesOfFile(dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Debug\Debug.dat");
            }
            else
            {
                this.movimentsOccurred = ExtendedStreamReader.LinesOfFile(dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result\Debug.dat");
            }

            this.delta = (movimentsOccurred - valueDiscard) / valueDivResult;

            this.mcSteps = param.dataToProcess.maxInterations * 5 * param.dataToProcess.totalSitio;
        }
        private void SheetDebug(ref XLWorkbook workbook)
        {
            string sheetName   = "debug";
            var    worksheet01 = workbook.Worksheets.Add(sheetName);

            //DADOS
            string line;
            int    numberofLines = ExtendedStreamReader.LinesOfFile(dirServerDebug + @"\" + debugFile);

            //List<string> lines = new List<string>();
            using (ExtendedStreamReader file = new ExtendedStreamReader(dirServerDebug + @"\" + debugFile, this.param.dataToProcess.Guid, this.param.dataToProcess.crypt))
            {
                int rec = 0;
                int idx = 0;

                while ((line = file.ReadLine()) != null)
                {
                    if (!(idx < 1048576))
                    {
                        break;
                    }

                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    WriteSecondSheet(line, idx, ref worksheet01);
                    idx++;

                    if (rec == 99999)
                    {
                        SaveDebug(ref workbook);
                        //http://stackoverflow.com/questions/22747360/append-to-excel-file-with-closedxml
                        //int NumberOfLastRow = worksheet01.LastRowUsed().RowNumber();
                        //IXLCell CellForNewData = worksheet01.Cell(NumberOfLastRow + 1, 1);
                        rec = 0;

                        PrintPercentCompleted(idx, numberofLines);
                    }
                    else
                    {
                        rec++;
                    }
                }
                file.Close();
                file.Dispose();
            }
            //FIM DADOS
        }
        private void SheetTrajectory(ref XLWorkbook workbook)
        {
            // This is invariant
            NumberFormatInfo format = new NumberFormatInfo();

            // Set the 'splitter' for thousands
            format.NumberGroupSeparator = ".";
            // Set the decimal seperator
            format.NumberDecimalSeparator = ",";

            string sheetName = "Trajectory";

            var worksheet01 = workbook.Worksheets.Add(sheetName);

            int numberLines = ExtendedStreamReader.LinesOfFile(dirServerDebug + @"\" + debugFile);

            //DADOS
            string            line;
            List <Trajectory> trajectory = new List <Trajectory>();
            int _MCStep = 0;

            using (ExtendedStreamReader file = new ExtendedStreamReader(dirServerDebug + @"\" + debugFile, this.param.dataToProcess.Guid, this.param.dataToProcess.crypt))
            {
                double rg = 0;   //Calculo acumulado do Raio de GIração

                int cont = 0;    //Contador
                                 //int lastMove = 0; //valor do último movimento
                int contAdd = 1; //contador adicional



                while ((line = file.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    if (cont > 0)
                    {
                        string[] col = line.Split('\t');

                        int numberMov = ConvertCustom.ToInt32(col[0]);

                        if (numberMov < (delta * contAdd) + 1)
                        {
                            rg     += double.Parse(col[3], format); //coluna no qual contêm valor do raio de giração
                            _MCStep = ConvertCustom.ToInt32(col[0]);
                        }
                        else
                        {
                            double value = ((double)1 / delta) * rg;
                            trajectory.Add(new Trajectory()
                            {
                                MCStep = _MCStep, rg = value
                            });
                            contAdd++;
                            rg  = 0;
                            rg += Convert.ToDouble(col[3]); //coluna no qual contêm valor do raio de giração
                        }
                    }

                    cont++;
                }
                file.Close();
                file.Dispose();
            }
            //FIM DADOS


            //DATASHEET
            worksheet01.Cell("A1").Value = sheetName;

            worksheet01.Cell("A2").Value = "lines";
            worksheet01.Cell("B2").Value = numberLines;

            worksheet01.Cell("A3").Value = "MCSteps";
            worksheet01.Cell("B3").Value = MCSteps;

            worksheet01.Cell("A4").Value = "delta";
            worksheet01.Cell("B4").Value = delta;

            worksheet01.Cell("A5").Value = "idx";
            worksheet01.Cell("B5").Value = "MCSteps";
            worksheet01.Cell("C5").Value = "SUM((1 / delta) * md)";

            for (int i = 0; i < trajectory.Count; i++)
            {
                double value = trajectory[i].rg;
                _MCStep = trajectory[i].MCStep;
                worksheet01.Cell("A" + (i + 6)).Value = i;
                worksheet01.Cell("B" + (i + 6)).Value = _MCStep;
                worksheet01.Cell("C" + (i + 6)).Value = value;
            }
        }