Ejemplo n.º 1
0
        public bool DeleteResultFromDB(MeasurementResults obj)
        {
            bool isSuccess = false;

            try
            {
                /// Create new record in YXbsMeastask
                YXbsMeasurementres measRes = new YXbsMeasurementres(ConnectDB.Connect_Main_);
                measRes.Format("*");
                if (obj != null)
                {
                    if ((obj.Id.MeasTaskId != null) && (obj.StationMeasurements != null) && (obj.Id.SubMeasTaskId != ConnectDB.NullI) && (obj.Id.SubMeasTaskStationId != ConnectDB.NullI))
                    {
                        if (obj.StationMeasurements.StationId != null)
                        {
                            if (measRes.Fetch(string.Format(" (meastaskid={0}) and (sensorid={1}) and (submeastaskid={2}) and (submeastaskstationid={3})", obj.Id.MeasTaskId.Value, obj.StationMeasurements.StationId.Value, obj.Id.SubMeasTaskId, obj.Id.SubMeasTaskStationId)))
                            {
                                foreach (FrequencyMeasurement dt_param in obj.FrequenciesMeasurements.ToArray())
                                {
                                    YXbsFrequencymeas dtr = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                                    dtr.Format("*");
                                    if (dt_param != null)
                                    {
                                        if (dtr.Fetch(string.Format("id_xbs_measurementres={0}", measRes.m_id)))
                                        {
                                            dtr.Delete();
                                        }
                                    }
                                    dtr.Close();
                                    dtr.Dispose();
                                }
                                foreach (LocationSensorMeasurement dt_param in obj.LocationSensorMeasurement.ToArray())
                                {
                                    YXbsLocationsensorm dtr = new YXbsLocationsensorm(ConnectDB.Connect_Main_);
                                    dtr.Format("*");
                                    if (dt_param != null)
                                    {
                                        if (dtr.Fetch(string.Format("id_xbs_measurementres={0}", measRes.m_id)))
                                        {
                                            dtr.Delete();
                                        }
                                    }
                                    dtr.Close();
                                    dtr.Dispose();
                                }
                                foreach (MeasurementResult dt_param in obj.MeasurementsResults.ToArray())
                                {
                                    if (obj.TypeMeasurements == MeasurementType.Level)
                                    {
                                        YXbsLevelmeasres dtr = new YXbsLevelmeasres(ConnectDB.Connect_Main_);
                                        dtr.Format("*");
                                        if (dt_param != null)
                                        {
                                            if (dtr.Fetch(string.Format("id_xbs_measurementres={0}", measRes.m_id)))
                                            {
                                                dtr.Delete();
                                            }
                                        }
                                        dtr.Close();
                                        dtr.Dispose();
                                    }
                                    else if (obj.TypeMeasurements == MeasurementType.SpectrumOccupation)
                                    {
                                        YXbsSpectoccupmeas dtr = new YXbsSpectoccupmeas(ConnectDB.Connect_Main_);
                                        dtr.Format("*");
                                        if (dt_param != null)
                                        {
                                            if (dtr.Fetch(string.Format("id_xbs_measurementres={0}", measRes.m_id)))
                                            {
                                                dtr.Delete();
                                            }
                                        }
                                        dtr.Close();
                                        dtr.Dispose();
                                    }
                                }
                                isSuccess = true;
                                measRes.Delete();
                            }
                        }
                    }
                    else if (obj.Id.MeasTaskId != null)
                    {
                        {
                            measRes.Filter = string.Format(" (meastaskid={0}) ", obj.Id.MeasTaskId.Value);
                            for (measRes.OpenRs(); !measRes.IsEOF(); measRes.MoveNext())
                            {
                                foreach (FrequencyMeasurement dt_param in obj.FrequenciesMeasurements.ToArray())
                                {
                                    YXbsFrequencymeas dtr = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                                    dtr.Format("*");
                                    if (dt_param != null)
                                    {
                                        dtr.Filter = string.Format("id_xbs_measurementres={0}", measRes.m_id);
                                        for (dtr.OpenRs(); !dtr.IsEOF(); dtr.MoveNext())
                                        {
                                            dtr.Delete();
                                        }
                                    }
                                    dtr.Close();
                                    dtr.Dispose();
                                }

                                foreach (LocationSensorMeasurement dt_param in obj.LocationSensorMeasurement.ToArray())
                                {
                                    YXbsLocationsensorm dtr = new YXbsLocationsensorm(ConnectDB.Connect_Main_);
                                    dtr.Format("*");
                                    if (dt_param != null)
                                    {
                                        dtr.Filter = string.Format("id_xbs_measurementres={0}", measRes.m_id);
                                        for (dtr.OpenRs(); !dtr.IsEOF(); dtr.MoveNext())
                                        {
                                            dtr.Delete();
                                        }
                                    }
                                    dtr.Close();
                                    dtr.Dispose();
                                }

                                foreach (MeasurementResult dt_param in obj.MeasurementsResults.ToArray())
                                {
                                    if (obj.TypeMeasurements == MeasurementType.Level)
                                    {
                                        YXbsLevelmeasres dtr = new YXbsLevelmeasres(ConnectDB.Connect_Main_);
                                        dtr.Format("*");
                                        if (dt_param != null)
                                        {
                                            dtr.Filter = string.Format("id_xbs_measurementres={0}", measRes.m_id);
                                            for (dtr.OpenRs(); !dtr.IsEOF(); dtr.MoveNext())
                                            {
                                                dtr.Delete();
                                            }
                                        }
                                        dtr.Close();
                                        dtr.Dispose();
                                    }
                                    else if (obj.TypeMeasurements == MeasurementType.SpectrumOccupation)
                                    {
                                        YXbsSpectoccupmeas dtr = new YXbsSpectoccupmeas(ConnectDB.Connect_Main_);
                                        dtr.Format("*");
                                        if (dt_param != null)
                                        {
                                            dtr.Filter = string.Format("id_xbs_measurementres={0}", measRes.m_id);
                                            for (dtr.OpenRs(); !dtr.IsEOF(); dtr.MoveNext())
                                            {
                                                dtr.Delete();
                                            }
                                        }
                                        dtr.Close();
                                        dtr.Dispose();
                                    }
                                }
                                isSuccess = true;
                                measRes.Delete();
                            }
                        }
                    }
                    measRes.Close();
                    measRes.Dispose();
                }
            }
            catch (Exception)
            { isSuccess = false; }
            return(isSuccess);
        }
Ejemplo n.º 2
0
        public List <ClassSDRResults> ReadlResultFromDB(int ID)
        {
            // Список объектов в рамках конкретного адаптера ICSM
            List <ClassSDRResults> L_IN = new List <ClassSDRResults>();

            try
            {
                Task tsk = new Task(() => {
                    YXbsMeasurementres res_val = new YXbsMeasurementres(ConnectDB.Connect_Main_);
                    res_val.Format("*");
                    // выбирать только таски, для которых STATUS не NULL
                    res_val.Filter = string.Format("(ID={0})", ID);
                    for (res_val.OpenRs(); !res_val.IsEOF(); res_val.MoveNext())
                    {
                        ClassSDRResults ICSM_T  = new ClassSDRResults();
                        ICSM_T.freq_meas        = new List <YXbsFrequencymeas>();
                        ICSM_T.level_meas_res   = new List <YXbsLevelmeasres>();
                        ICSM_T.loc_sensorM      = new List <YXbsLocationsensorm>();
                        ICSM_T.meas_res         = new YXbsMeasurementres();
                        ICSM_T.spect_occup_meas = new List <YXbsSpectoccupmeas>();

                        ICSM_T.meas_res = new YXbsMeasurementres();
                        var m_fr        = new YXbsMeasurementres(ConnectDB.Connect_Main_);
                        m_fr.CopyDataFrom(res_val);
                        ICSM_T.meas_res = m_fr;

                        /*
                         * YXbsFrequencymeas XbsYXbsFrequencymeas_ = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                         * XbsYXbsFrequencymeas_.Format("*");
                         * XbsYXbsFrequencymeas_.Filter = string.Format("(id_xbs_measurementres={0})", res_val.m_id);
                         * for (XbsYXbsFrequencymeas_.OpenRs(); !XbsYXbsFrequencymeas_.IsEOF(); XbsYXbsFrequencymeas_.MoveNext())
                         * {
                         *  var m_fr_ = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                         *  m_fr_.CopyDataFrom(XbsYXbsFrequencymeas_);
                         *  ICSM_T.freq_meas.Add(m_fr_);
                         *  m_fr_.Close();
                         *  m_fr_.Dispose();
                         * }
                         * XbsYXbsFrequencymeas_.Close();
                         * XbsYXbsFrequencymeas_.Dispose();
                         */

                        YXbsLevelmeasres XbsYXbsLevelmeasres_ = new YXbsLevelmeasres(ConnectDB.Connect_Main_);
                        XbsYXbsLevelmeasres_.Format("*");
                        XbsYXbsLevelmeasres_.Filter = string.Format("(id_xbs_measurementres={0})", res_val.m_id);
                        for (XbsYXbsLevelmeasres_.OpenRs(); !XbsYXbsLevelmeasres_.IsEOF(); XbsYXbsLevelmeasres_.MoveNext())
                        {
                            var m_fr_ = new YXbsLevelmeasres(ConnectDB.Connect_Main_);
                            m_fr_.CopyDataFrom(XbsYXbsLevelmeasres_);
                            ICSM_T.level_meas_res.Add(m_fr_);

                            //////// получить частоты
                            YXbsFrequencymeas XbsYXbsFrequencymeas_ = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                            XbsYXbsFrequencymeas_.Format("*");
                            XbsYXbsFrequencymeas_.Filter = string.Format("(id_xbs_measurementres={0}) and (Num={1})", res_val.m_id, m_fr_.m_id);
                            for (XbsYXbsFrequencymeas_.OpenRs(); !XbsYXbsFrequencymeas_.IsEOF(); XbsYXbsFrequencymeas_.MoveNext())
                            {
                                var m_fr_f = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                                m_fr_f.CopyDataFrom(XbsYXbsFrequencymeas_);
                                ICSM_T.freq_meas.Add(m_fr_f);
                                m_fr_f.Close();
                                m_fr_f.Dispose();
                            }
                            XbsYXbsFrequencymeas_.Close();
                            XbsYXbsFrequencymeas_.Dispose();
                            /////////

                            m_fr_.Close();
                            m_fr_.Dispose();
                        }
                        XbsYXbsLevelmeasres_.Close();
                        XbsYXbsLevelmeasres_.Dispose();

                        YXbsLevelmeasonlres XbsYXbsLevelmeasonlres_ = new YXbsLevelmeasonlres(ConnectDB.Connect_Main_);
                        XbsYXbsLevelmeasonlres_.Format("*");
                        XbsYXbsLevelmeasonlres_.Filter = string.Format("(id_xbs_measurementres={0})", res_val.m_id);
                        for (XbsYXbsLevelmeasonlres_.OpenRs(); !XbsYXbsLevelmeasonlres_.IsEOF(); XbsYXbsLevelmeasonlres_.MoveNext())
                        {
                            var m_fr_ = new YXbsLevelmeasonlres(ConnectDB.Connect_Main_);
                            m_fr_.CopyDataFrom(XbsYXbsLevelmeasonlres_);
                            ICSM_T.level_meas_onl_res.Add(m_fr_);

                            //////// получить частоты
                            YXbsFrequencymeas XbsYXbsFrequencymeas_ = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                            XbsYXbsFrequencymeas_.Format("*");
                            XbsYXbsFrequencymeas_.Filter = string.Format("(id_xbs_measurementres={0}) and (Num={1})", res_val.m_id, m_fr_.m_id);
                            for (XbsYXbsFrequencymeas_.OpenRs(); !XbsYXbsFrequencymeas_.IsEOF(); XbsYXbsFrequencymeas_.MoveNext())
                            {
                                var m_fr_f = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                                m_fr_f.CopyDataFrom(XbsYXbsFrequencymeas_);
                                ICSM_T.freq_meas.Add(m_fr_f);
                                m_fr_f.Close();
                                m_fr_f.Dispose();
                            }
                            XbsYXbsFrequencymeas_.Close();
                            XbsYXbsFrequencymeas_.Dispose();
                            /////////

                            m_fr_.Close();
                            m_fr_.Dispose();
                        }
                        XbsYXbsLevelmeasonlres_.Close();
                        XbsYXbsLevelmeasonlres_.Dispose();

                        YXbsSpectoccupmeas XbsYXbsSpectoccupmeas_ = new YXbsSpectoccupmeas(ConnectDB.Connect_Main_);
                        XbsYXbsSpectoccupmeas_.Format("*");
                        XbsYXbsSpectoccupmeas_.Filter = string.Format("(id_xbs_measurementres={0})", res_val.m_id);
                        for (XbsYXbsSpectoccupmeas_.OpenRs(); !XbsYXbsSpectoccupmeas_.IsEOF(); XbsYXbsSpectoccupmeas_.MoveNext())
                        {
                            var m_fr_ = new YXbsSpectoccupmeas(ConnectDB.Connect_Main_);
                            m_fr_.CopyDataFrom(XbsYXbsSpectoccupmeas_);
                            ICSM_T.spect_occup_meas.Add(m_fr_);

                            //////// получить частоты
                            YXbsFrequencymeas XbsYXbsFrequencymeas_ = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                            XbsYXbsFrequencymeas_.Format("*");
                            XbsYXbsFrequencymeas_.Filter = string.Format("(id_xbs_measurementres={0}) and (Num={1})", res_val.m_id, m_fr_.m_id);
                            for (XbsYXbsFrequencymeas_.OpenRs(); !XbsYXbsFrequencymeas_.IsEOF(); XbsYXbsFrequencymeas_.MoveNext())
                            {
                                var m_fr_f = new YXbsFrequencymeas(ConnectDB.Connect_Main_);
                                m_fr_f.CopyDataFrom(XbsYXbsFrequencymeas_);
                                ICSM_T.freq_meas.Add(m_fr_f);
                                m_fr_f.Close();
                                m_fr_f.Dispose();
                            }
                            XbsYXbsFrequencymeas_.Close();
                            XbsYXbsFrequencymeas_.Dispose();
                            /////////

                            m_fr_.Close();
                            m_fr_.Dispose();
                        }
                        XbsYXbsSpectoccupmeas_.Close();
                        XbsYXbsSpectoccupmeas_.Dispose();

                        YXbsLocationsensorm XbsYXbsLocationsensorm_ = new YXbsLocationsensorm(ConnectDB.Connect_Main_);
                        XbsYXbsLocationsensorm_.Format("*");
                        XbsYXbsLocationsensorm_.Filter = string.Format("(id_xbs_measurementres={0})", res_val.m_id);
                        for (XbsYXbsLocationsensorm_.OpenRs(); !XbsYXbsLocationsensorm_.IsEOF(); XbsYXbsLocationsensorm_.MoveNext())
                        {
                            var m_fr_ = new YXbsLocationsensorm(ConnectDB.Connect_Main_);
                            m_fr_.CopyDataFrom(XbsYXbsLocationsensorm_);
                            ICSM_T.loc_sensorM.Add(m_fr_);
                            m_fr_.Close();
                            m_fr_.Dispose();
                        }
                        XbsYXbsLocationsensorm_.Close();
                        XbsYXbsLocationsensorm_.Dispose();
                        L_IN.Add(ICSM_T);
                        m_fr.Close();
                        m_fr.Dispose();
                    }
                    res_val.Close();
                    res_val.Dispose();
                });
                tsk.Start();
                //tsk.Wait();
                Console.WriteLine("Readl Result From DB Objects ...");
            }
            catch (Exception)
            {
            }
            return(L_IN);
        }