Пример #1
0
        public IEnumerable <PriceNorm> Find(int ym)
        {
            return(getQuerryResult($"ym={ym}"
                                   , (table) =>
            {
                DataBase.IOrAndDo query = makeRangePeriod(table.QUERRY().SHOW.WHERE, ym,
                                                          C.PriceNorm.YMFrom,
                                                          C.PriceNorm.YMTo);

                query = makeRangePeriod(query, ym,
                                        C.PriceNorm.ResolutionClarify, new int[] { C.ResolutionClarify.YMFrom },
                                        C.PriceNorm.ResolutionClarify, new int[] { C.ResolutionClarify.YMTo });

                query = makeRangePeriod(query, ym,
                                        C.PriceNorm.ResolutionClarify, new int[] { C.ResolutionClarify.Resolution, C.Resolution.YMFrom },
                                        C.PriceNorm.ResolutionClarify, new int[] { C.ResolutionClarify.Resolution, C.Resolution.YMTo });

                query.DO();
            }
                                   , (result) =>
            {
                {
                    var pollutions = LogicHelper.PollutionLogic.Find();
                    var resolutionClarifies = LogicHelper.ResolutionClarifyLogic.Find(ym);

                    var pollutionDictionary = LogicHelper.PollutionLogic.GetDictionary(pollutions);
                    var resolutionClarifyDictionary = LogicHelper.ResolutionClarifyLogic.GetDictionary(resolutionClarifies);

                    foreach (var priceNorm in result)
                    {
                        if (pollutionDictionary.ContainsKey(priceNorm.PollutionID))
                        {
                            var pollution = pollutionDictionary[priceNorm.PollutionID];

                            priceNorm.Add(pollution);
                        }
                        if (resolutionClarifyDictionary.ContainsKey(priceNorm.ResolutionClarifyID))
                        {
                            var resolutionClarify = resolutionClarifyDictionary[priceNorm.ResolutionClarifyID];

                            priceNorm.Add(resolutionClarify);
                            resolutionClarify.Add(priceNorm);
                        }
                    }
                }
            }));
        }
Пример #2
0
        /// <summary>
        /// Поулчить список отборов
        /// </summary>
        /// <param name="ym">Период</param>
        /// <param name="sampleStatus">статус отбора</param>
        /// <param name="actualNumber">актуальный(>0) или нет</param>
        /// <returns></returns>
        public IEnumerable <SelectionWell> Find(int ym, uint?sampleStatus, bool actualNumber = true)
        {
            return(getQuerryResult($"ym={ym}|sampleStatus={(sampleStatus.HasValue ? sampleStatus.Value.ToString() : "null")}", (table) =>
            {
                DataBase.IOrAndDo query = table.QUERRY()
                                          .SHOW
                                          .WHERE
                                          .ARC(C.SelectionWell.Sample, C.Sample.YM).EQUI.BV(ym);

                if (sampleStatus.HasValue)
                {
                    query.AND.ARC(C.SelectionWell.Sample, C.Sample.Status).EQUI.BV(sampleStatus.Value);
                }

                if (actualNumber)
                {
                    query.AND.AC(C.SelectionWell.Number).More.BV <int>(0);
                }

                query = makeRangePeriod(query, ym,
                                        C.SelectionWell.Well, new int[] { C.Well.YMFrom },
                                        C.SelectionWell.Well, new int[] { C.Well.YMTo });

                query = makeRangePeriod(query, ym,
                                        C.SelectionWell.Well, new int[] { C.Well.Object, C.Objecte.YMFrom },
                                        C.SelectionWell.Well, new int[] { C.Well.Object, C.Objecte.YMTo });

                query = makeRangePeriod(query, ym,
                                        C.SelectionWell.Well, new int[] { C.Well.Object, C.Objecte.Client, C.Client.YMFrom },
                                        C.SelectionWell.Well, new int[] { C.Well.Object, C.Objecte.Client, C.Client.YMTo });

                query.DO();

                var models = getModels(table);

                models = models.OrderBy(x => x.Number).ToArray();

                return models;
            }
                                   , (result) =>
            {
                var dictionary = this.GetDictionary(result);

                {
                    var values = LogicHelper.ValuesSelectionLogic.Find(ym, sampleStatus);

                    foreach (var value in values)
                    {
                        if (dictionary.ContainsKey(value.SelectionWellID))
                        {
                            var selectionWell = dictionary[value.SelectionWellID];

                            selectionWell.Add(value);
                        }
                    }
                }

                {
                    LogicHelper.SampleLogic.Find(ym, sampleStatus);  //достаточно загрузить записи, т.к. внутри производится соотнение с SelectionWell
                }

                {
                    var wells = LogicHelper.WellLogic.Find(ym);

                    var wellDictionary = LogicHelper.WellLogic.GetDictionary(wells);

                    foreach (var selectionWell in result)
                    {
                        if (wellDictionary.ContainsKey(selectionWell.WellID))
                        {
                            var well = wellDictionary[selectionWell.WellID];

                            selectionWell.Add(well);
                        }
                    }
                }

                {
                    var objects = LogicHelper.ObjecteLogic.Find(ym);

                    var ObjecteLogicDictionary = LogicHelper.ObjecteLogic.GetDictionary(objects);

                    foreach (var selectionWell in result)
                    {
                        if (ObjecteLogicDictionary.ContainsKey(selectionWell.ObjectID))
                        {
                            var objecte = ObjecteLogicDictionary[selectionWell.ObjectID];

                            selectionWell.Add(objecte);
                        }
                    }
                }
            }));
        }