Ejemplo n.º 1
0
        private async Task <int> AddMOND(ge_project project)
        {
            string[] AllPoints = new string[] { "" };

            var resp = await new ge_gINTController(_context,
                                                   _authorizationService,
                                                   _userManager,
                                                   _env,
                                                   _ge_config
                                                   ).getMONG(project.Id, AllPoints);
            var okResult = resp as OkObjectResult;

            if (okResult.StatusCode != 200)
            {
                return(-1);
            }

            MONG = okResult.Value as List <MONG>;
            if (MONG == null)
            {
                return(-1);
            }

            resp = await new ge_gINTController(_context,
                                               _authorizationService,
                                               _userManager,
                                               _env,
                                               _ge_config
                                               ).getPOINT(project.Id, AllPoints);
            okResult = resp as OkObjectResult;
            if (okResult.StatusCode != 200)
            {
                return(-1);
            }

            POINT = okResult.Value as List <POINT>;
            if (POINT == null)
            {
                return(-1);
            }

            MOND = new List <MOND>();
            MONV = new List <MONV>();

            int projectId = POINT.FirstOrDefault().gINTProjectID;

            foreach (LTM_Survey_Data_Add survey in Survey_Data_Add)
            {
                if (survey == null)
                {
                    continue;
                }

                POINT pt = POINT.Find(p => p.PointID == survey.hole_id);

                if (pt == null)
                {
                    if ((survey.package.Contains("A") && projectId == 1) ||
                        (survey.package.Contains("B") && projectId == 2) ||
                        (survey.package.Contains("C") && projectId == 3) ||
                        (survey.package.Contains("D") && projectId == 4))
                    {
                        Console.WriteLine("Package {0} survey.hole_id [{1}] not found", survey.package, survey.hole_id);
                    }
                    continue;
                }

                List <MONG> pt_mg = MONG.Where(m => m.PointID == survey.hole_id).ToList();

                if (pt_mg.Count == 0)
                {
                    Console.WriteLine("Package {0} monitoring point for survey.hole_id {1} not found", survey.package, survey.hole_id);
                    continue;
                }

                MONG mg = pt_mg.Find(m => m.ItemKey == survey.mong_ID);

                if (mg == null)
                {
                    mg = pt_mg.FirstOrDefault();
                }

                DateTime?survey_start = gINTDateTime(survey.date1_getDT());

                if (survey_start == null)
                {
                    continue;
                }



                DateTime survey_startDT = gINTDateTime(survey.time1_getDT()).Value;
                DateTime survey_endDT   = gINTDateTime(survey.time2_getDT()).Value;

                // if (survey.globalid == new Guid("bf8e8e5f-7394-4363-bfc2-9bfe876b048a")) {
                //     Console.WriteLine ("{0}       {1}", survey_startDT, survey.time1_getDT());
                // }

                MONV mv = NewMONV(pt, survey);

                mv.MONV_STAR = survey_startDT;
                mv.MONV_ENDD = survey_endDT;

                mv.MONV_DIPR = survey.dip_req;
                mv.MONV_GASR = survey.gas_mon;
                mv.MONV_LOGR = survey.logger_downld_req;

                mv.MONV_REMG = survey.gas_fail + " " + survey.gas_com;
                mv.MONV_REMD = survey.dip_fail + " " + survey.dip_com;
                mv.MONV_REML = survey.logger_fail + " " + survey.logger_com;
                mv.MONV_REMS = survey.samp_fail + " " + survey.samp_com;
                mv.PUMP_TYPE = survey.purg_pump + " " + survey.purg_pump_oth;

                mv.MONV_WEAT = survey.weath;
                mv.MONV_TEMP = survey.temp;
                mv.MONV_WIND = survey.wind;

                if (survey.dip_instr != null)
                {
                    mv.DIP_SRLN = survey.dip_instr;
                    mv.DIP_CLBD = gINTDateTime(survey.dip_cali_d_getDT());
                }

                if (survey.interface_instr != null)
                {
                    mv.DIP_SRLN = survey.interface_instr;
                    mv.DIP_CLBD = gINTDateTime(survey.interface_cali_d_getDT());
                }

                mv.FLO_SRLN = survey.purg_meter;
                mv.FLO_CLBD = gINTDateTime(survey.purg_meter_cali_d_getDT());

                mv.GAS_SRLN = survey.gas_instr;
                mv.GAS_CLBD = gINTDateTime(survey.gas_cali_d_getDT());

                mv.PID_SRLN = survey.PID_instr;
                mv.PID_CLBD = gINTDateTime(survey.PID_cali_d_getDT());

                mv.RND_REF   = survey.mon_rd_nb;
                mv.MONV_DATM = survey.dip_datum;

                mv.AIR_PRESS = survey.atmo_pressure;
                mv.AIR_TEMP  = survey.atmo_temp;

                mv.PIPE_DIA = survey.pipe_diam;

                if (survey.dip_datum_offset != null)
                {
                    mv.MONV_DIS = ((float)survey.dip_datum_offset.Value) / 100f;
                }

                mv.MONV_MENG = survey.Creator;
                MONV.Add(mv);



                //    if (IgnoreDataRepeat_GlobalId.Contains(survey.globalid)) {
                //        continue;
                //    }

                if (survey.QA_status.Contains("Dip_Approved"))
                {
                    AddDip(mg, survey);
                }

                if (survey.QA_status.Contains("Purge_Approved"))
                {
                    AddPurge(mg, survey);
                }

                if (survey.QA_status.Contains("Gas_Approved"))
                {
                    AddGas(mg, survey);
                }
            }

            return(MOND.Count());
        }