Beispiel #1
0
        public static Task<bool> ControlSystemExist(string name)
        {
            var efo = new EquipmentFilterObject { Name = name };
            var task = new TaskCompletionSource<bool>();
            var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cee.GetQuickControlSystemsCompleted += (s, e) => task.SetResult(e.Result.Any());
            cee.GetQuickControlSystemsAsync(efo);
            return task.Task;
        }
        public void ProcessSearchFilter()
        {
            EquipmentFilterObject efo = new EquipmentFilterObject();

            //Keyword
            if (!String.IsNullOrEmpty(Keyword)){efo.Keyword = Keyword;}

            //Area
            if (SelectedArea != null && SelectedArea.Name != All) efo.AreaId = SelectedArea.Id;

            //SubArea
            if (SelectedSubArea != null && SelectedSubArea.Name != All) efo.SubAreaId = SelectedSubArea.Id;

            //PipeClasses
            if (mSelectedPipeClass != null && mSelectedPipeClass.Name != All) { efo.PipeClassId = mSelectedPipeClass.Id; }

            //PipeSizes
            if (mSelectedPipeSize != null && mSelectedPipeSize.Name != All) { efo.PipeSizeId = mSelectedPipeSize.Id; }

            //PipeFluidCodes
            if (mSelectedPipeFluidCode != null && mSelectedPipeFluidCode.Name != All) { efo.PipeFluidCodeId = mSelectedPipeFluidCode.Id; }

            //PipeSpecialFeatures
            if (mSelectedPipeSpecialFeature != null && mSelectedPipeSpecialFeature.Name != All) { efo.PipeSpecialFeatureId = mSelectedPipeSpecialFeature.Id; }

            //PandIDDocumentId
            if (mSelectedPAndIdDocument != null && mSelectedPAndIdDocument.Name != All) { efo.PidDocumentId = mSelectedPAndIdDocument.Id; }

            //ComponentTypes
            if (mSelectedComponentType != null && mSelectedComponentType.Name != All) { efo.ComponentTypeId = mSelectedComponentType.Id; }

               //Manufacturers
            if (mSelectedManufacturer != null && mSelectedManufacturer.Name != All) { efo.ManufacturerId = mSelectedManufacturer.Id; }

            //Models
            if (mSelectedModel != null && mSelectedModel.Name != All) { efo.ModelId = mSelectedModel.Id; }

            //IsActive
            if (mSelectedIsActive != All) efo.IsActive = mSelectedIsActive == Yes;

            IsGridBusy = true;

            DatabaseLoader.GetQuickPipes(efo).ContinueWith((getPipesTask) =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    Pipes = getPipesTask.Result;
                    RaisePropertyChanged("Pipes");

                    FilteredControlDataContext.SummaryTotal = Pipes.Count;
                    FilteredControlDataContext.RaisePropertyChanged("SummaryTotal");
                    CMS.Cache.FilteredExportPipeIdList= Pipes.Select(x => x.Id).ToList();
                    IsGridBusy = false;
                });
            });
        }
Beispiel #3
0
        //public List<QuickPipe> GetQuickPipes2()
        //{
        //    Stopwatch sw = new Stopwatch();
        //    sw.Start();
        //    using (CmsEntities cee = new CmsEntities())
        //    {
        //        List<QuickPipe> quickPipes = (from p in cee.Pipes
        //                                      join eqComps in cee.PipeComponents.DefaultIfEmpty() on p.Id equals eqComps.PipeId into components
        //                                      join pId in cee.Documents.DefaultIfEmpty() on p.PIDDocumentId equals pId.Id into piddoc
        //                                      from subComponent in components.DefaultIfEmpty()
        //                                      orderby p.Area.AreaNumber, p.SequenceNo
        //                                      select new QuickPipe
        //                                      {
        //                                          Id = p.Id,
        //                                          AreaNumber = p.Area.AreaNumber,
        //                                          SubAreaId = p.Unit != null ? p.Unit.CellId : p.EquipmentModule != null ? p.EquipmentModule.Unit != null ? p.EquipmentModule.Unit.CellId : (int?)null : (int?)null,
        //                                          Description = p.Description,
        //                                          SequenceNo = p.SequenceNo,
        //                                          Class = p.PipeClass.Name,
        //                                          ClassId = p.PipeClass.Id,
        //                                          Size = p.PipeSize.Name,
        //                                          FluidCode = p.PipeFluidCode.Name,
        //                                          SpecialFeature = p.PipeSpecialFeature.Name,
        //                                          Category = p.PipeCategory.Name,
        //                                          From = p.From,
        //                                          To = p.To,
        //                                          IsActive = p.IsActive,
        //                                          Manufacturer = (subComponent == null ? String.Empty : subComponent.Manufacturer.Name),
        //                                          Model = (subComponent == null ? String.Empty : subComponent.Model.Name),
        //                                          PandIdName = piddoc.FirstOrDefault().Name,
        //                                          ComponentType = subComponent.PipeComponentType.Name
        //                                      }).ToList();
        //        ////Build up the ComponentTypes
        //        //Dictionary<int, QuickPipe> qeDictionary = new Dictionary<int, QuickPipe>();
        //        //foreach (QuickPipe qPipe in quickPipes)
        //        //{
        //        //    if (qeDictionary.ContainsKey(qPipe.Id))
        //        //    {
        //        //        qeDictionary[qPipe.Id].Manufacturer = String.Format("{0},{1}", qeDictionary[qPipe.Id].Manufacturer, qPipe.Manufacturer);
        //        //        qeDictionary[qPipe.Id].Model = String.Format("{0},{1}", qeDictionary[qPipe.Id].Model, qPipe.Model);
        //        //        continue;
        //        //    }
        //        //    qeDictionary.Add(qPipe.Id, qPipe);
        //        //}
        //        //var returnValue = qeDictionary.Values.ToList();
        //        //return returnValue;
        //        return quickPipes;
        //    }
        //}
        public byte[] GetQuickPipes(EquipmentFilterObject equipmentFilterObject)
        {
            using (CmsEntities cee = new CmsEntities())
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();

                var quickPipes = new List<QuickPipe>();

                var query = (from x in cee.Pipes select x);

                //Keyword
                if (!String.IsNullOrEmpty(equipmentFilterObject.Keyword))
                {
                    string[] textArray = CommonUtils.GetSearchTextArray(equipmentFilterObject.Keyword);

                    query = query.Where(BuildPipeKeywordPredicate(textArray));
                }

                //AreaId
                if (equipmentFilterObject.AreaId.HasValue)
                {
                    query = query.Where(x => x.AreaId == equipmentFilterObject.AreaId.Value);
                }

                //SubAreaId
                if (equipmentFilterObject.SubAreaId.HasValue)
                {
                    query = query.Include("Unit").Include("EquipmentModule.Unit");
                    query = query.Where(x => x.Unit != null ? x.Unit.CellId == equipmentFilterObject.SubAreaId.Value
                        : x.EquipmentModule != null && (x.EquipmentModule.Unit != null && x.EquipmentModule.Unit.CellId == equipmentFilterObject.SubAreaId.Value));
                }

                //PipeClass
                if (equipmentFilterObject.PipeClassId.HasValue)
                {
                    query = query.Where(x => x.ClassId == equipmentFilterObject.PipeClassId.Value);
                }

                //PipeSize
                if (equipmentFilterObject.PipeSizeId.HasValue)
                {
                    query = query.Where(x => x.SizeId == equipmentFilterObject.PipeSizeId.Value);
                }

                //PipeFluidCode
                if (equipmentFilterObject.PipeFluidCodeId.HasValue)
                {
                    query = query.Where(x => x.FluidCodeId == equipmentFilterObject.PipeFluidCodeId.Value);
                }

                //PipeSpecialFeature
                if (equipmentFilterObject.PipeSpecialFeatureId.HasValue)
                {
                    query = query.Where(x => x.SpecialFeatureId == equipmentFilterObject.PipeSpecialFeatureId.Value);
                }

                //PidDocumentId
                if (equipmentFilterObject.PidDocumentId.HasValue)
                {
                    query = query.Where(x => x.PIDDocumentId == equipmentFilterObject.PidDocumentId.Value);
                }

                //ComponentTypeId
                if (equipmentFilterObject.ComponentTypeId.HasValue)
                {
                    query = query.Where(x => x.PipeComponents.Any(c => c.PipeComponentTypeId == equipmentFilterObject.ComponentTypeId.Value));
                }

                //ManufacturerId
                if (equipmentFilterObject.ManufacturerId.HasValue)
                {
                    query = query.Where(x => x.PipeComponents.Any(c => c.ManufacturerId == equipmentFilterObject.ManufacturerId.Value));
                }

                //ModelId
                if (equipmentFilterObject.ModelId.HasValue)
                {
                    query = query.Where(x => x.PipeComponents.Any(c => c.ModelId == equipmentFilterObject.ModelId.Value));
                }

                //IsActive
                if (equipmentFilterObject.IsActive.HasValue)
                {
                    query = query.Where(x => x.IsActive == equipmentFilterObject.IsActive.Value);
                }

                quickPipes = query.Include("Area").Include("PipeSize").Include("PipeClass").Include("PipeFluidCode").Include("PipeSpecialFeature").AsEnumerable().Select(x =>
                     new QuickPipe
                    {
                        Id = x.Id,
                        Name = String.Format("{0}{1:D3}-{2}-{3}-{4}-{5}",
                            x.Area != null ? x.Area.AreaNumber.ToString() : string.Empty,
                            x.SequenceNo,
                            x.PipeClass != null ? x.PipeClass.Name : string.Empty,
                            x.PipeSize != null ? x.PipeSize.Name : string.Empty,
                            x.PipeFluidCode != null ? x.PipeFluidCode.Name : string.Empty,
                            x.PipeSpecialFeature != null ? x.PipeSpecialFeature.Name : string.Empty),
                        Description = x.Description,
                        IsActive = x.IsActive
                    }).OrderBy(x => x.Name).ToList();

                sw.Stop();
                Debug.WriteLine("It took {0} seconds to get Pipes from GetQuickPipes()", sw.Elapsed.TotalSeconds);

                MemoryStream byteStream = new MemoryStream();
                Serializer.Serialize(byteStream, quickPipes);

                return byteStream.ToArray();
            }
        }
        public void ProcessSearchFilter()
        {
            EquipmentFilterObject efo = new EquipmentFilterObject();

            //IsActive
            if (mSelectedIsActive != All) efo.IsActive = mSelectedIsActive == Yes;

            //Keyword

            if (!String.IsNullOrEmpty(Keyword))
            {
                efo.Keyword = Keyword;
            }

            //Area
            if (SelectedArea != null && SelectedArea.Name != All) efo.AreaId = SelectedArea.Id;

            //SubArea
            if (SelectedSubArea != null && SelectedSubArea.Name != All) efo.SubAreaId = SelectedSubArea.Id;

            //EquipmentTypeId
            if (mSelectedEquipmentType != null && mSelectedEquipmentType.Name != All)
            {
                efo.EquipmentTypeId = mSelectedEquipmentType.Id;
            }

            //PandIDDocumentId
            if (mSelectedPAndIdDocument != null && mSelectedPAndIdDocument.Name != All)
            {
                efo.PidDocumentId = mSelectedPAndIdDocument.Id;
            }

            //SpecificationDocumentId
            if (mSelectedSpecificationDocument != null && mSelectedSpecificationDocument.Name != All)
            {
                efo.SpecificationDocumentId = mSelectedSpecificationDocument.Id;
            }

            //ComponentTypes
            if (mSelectedComponentType != null && mSelectedComponentType.Name != All)
            {
                efo.ComponentTypeId = mSelectedComponentType.Id;
            }

            //Classified
            if (mSelectedClassified != All) efo.IsClassified = mSelectedClassified == Yes;

            //Manufacturers
            if (mSelectedManufacturer != null && mSelectedManufacturer.Name != All)
            {
                efo.ManufacturerId = mSelectedManufacturer.Id;
            }

            //Models
            if (mSelectedModel != null && mSelectedModel.Name != All)
            {
                efo.ModelId = mSelectedModel.Id;
            }

            //MaintenanceSystemId
            if (!String.IsNullOrEmpty(MaintenanceSysId))
            {
                efo.MaintenanceSysId = MaintenanceSysId;
            }

            IsGridBusy = true;

            DatabaseLoader.GetQuickMechanicalEquipments(efo).ContinueWith((getMechanicalEquipmentsTask) =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    MechanicalEquipments = getMechanicalEquipmentsTask.Result;
                    RaisePropertyChanged("MechanicalEquipments");

                    FilteredControlDataContext.SummaryTotal = MechanicalEquipments.Count;
                    FilteredControlDataContext.RaisePropertyChanged("SummaryTotal");
                    CMS.Cache.FilteredExportMechIdList = MechanicalEquipments.Select(x => x.Id).ToList();
                    IsGridBusy = false;
                });
            });
        }
Beispiel #5
0
 public static Task<List<QuickControlSystem>> GetQuickControlSystems(EquipmentFilterObject efo)
 {
     var task = new TaskCompletionSource<List<QuickControlSystem>>();
     var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
     cee.GetQuickControlSystemsCompleted += (s, e) => task.SetResult(Serializer.Deserialize<List<QuickControlSystem>>(new MemoryStream(e.Result)));
     cee.GetQuickControlSystemsAsync(efo);
     return task.Task;
 }
        private void ProcessSearchFilter()
        {
            EquipmentFilterObject efo = new EquipmentFilterObject();

            //Keyword

            if (!String.IsNullOrEmpty(Keyword))
            {
                efo.Keyword = Keyword;
            }

            //Area
            if (SelectedArea != null && SelectedArea.Name != All) efo.AreaId = SelectedArea.Id;

            //SubArea
            if (SelectedSubArea != null && SelectedSubArea.Name != All) efo.SubAreaId = SelectedSubArea.Id;

            //UpperEquipment
            if (SelectedUpperEquipment != null && SelectedUpperEquipment.Name != All)
            {
                if (SelectedUpperEquipment.EquipmentModuleId.HasValue)
                    efo.EquipmentModuleId = SelectedUpperEquipment.EquipmentModuleId.Value;
                else
                    efo.UnitId = SelectedUpperEquipment.UnitId;
            }

            //EquipmentTypeId
            if (mSelectedEquipmentType != null && mSelectedEquipmentType.Name != All)
            {
                efo.EquipmentTypeId = mSelectedEquipmentType.Id;
            }

            //SpecificationDocumentId
            if (mSelectedSpecificationDocument != null && mSelectedSpecificationDocument.Name != All)
            {
                efo.SpecificationDocumentId = mSelectedSpecificationDocument.Id;
            }

            IsGridBusy = true;

            DatabaseLoader.GetQuickControlSystems(efo).ContinueWith((getQuickControlSystemsTask) =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    ControlSystems = getQuickControlSystemsTask.Result;
                    RaisePropertyChanged("ControlSystems");

                    IsGridBusy = false;
                });
            });
        }
        public void ProcessSearchFilter()
        {
            EquipmentFilterObject efo = new EquipmentFilterObject();

            //IsActive
            if (mSelectedIsActive != All) efo.IsActive = mSelectedIsActive == Yes;

            //Keyword

            if (!String.IsNullOrEmpty(Keyword))
            {
                efo.Keyword = Keyword;
            }

            //Area
            if (SelectedArea != null && SelectedArea.Name != All) efo.AreaId = SelectedArea.Id;

            //SubArea
            if (SelectedSubArea != null && SelectedSubArea.Name != All) efo.SubAreaId = SelectedSubArea.Id;

            //EquipmentTypeId
            if (mSelectedEquipmentType != null && mSelectedEquipmentType.Name != All)
            {
                efo.EquipmentTypeId = mSelectedEquipmentType.Id;
            }

            //PandIDDocumentId
            if (mSelectedPAndIdDocument != null && mSelectedPAndIdDocument.Name != All)
            {
                efo.PidDocumentId = mSelectedPAndIdDocument.Id;
            }

            //SpecificationDocumentId
            if (mSelectedSpecificationDocument != null && mSelectedSpecificationDocument.Name != All)
            {
                efo.SpecificationDocumentId = mSelectedSpecificationDocument.Id;
            }

            //ComponentTypes
            if (mSelectedComponentType != null && mSelectedComponentType.Name != All)
            {
                efo.ComponentTypeId = mSelectedComponentType.Id;
            }

            //Classified
            if (mSelectedClassified != All) efo.IsClassified = mSelectedClassified == Yes;

            //Manufacturers
            if (mSelectedManufacturer != null && mSelectedManufacturer.Name != All)
            {
                efo.ManufacturerId = mSelectedManufacturer.Id;
            }

            //Models
            if (mSelectedModel != null && mSelectedModel.Name != All)
            {
                efo.ModelId = mSelectedModel.Id;
            }

            //MaintenanceSystemId
            if (!String.IsNullOrEmpty(MaintenanceSysId))
            {
                efo.MaintenanceSysId = MaintenanceSysId;
            }

            IsGridBusy = true;

            DatabaseLoader.GetQuickElectricalEquipments(efo).ContinueWith((getDocumentsTask) =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    ElectricalEquipments = getDocumentsTask.Result;

                    if (mSelectedEquipmentId.HasValue)
                    {
                        ElectricalEquipments = (from x in ElectricalEquipments where x.Id != mSelectedEquipmentId select x).ToList();
                    }

                    RaisePropertyChanged("ElectricalEquipments");
                    IsGridBusy = false;
                });
            });
        }
        private void ProcessSearchFilter()
        {
            EquipmentFilterObject efo = new EquipmentFilterObject();

            //IsActive
            if (mSelectedIsActive != All) efo.IsActive = mSelectedIsActive == Yes;

            //Keyword

            if (!String.IsNullOrEmpty(Keyword))
            {
                efo.Keyword = Keyword;
            }

            //Area
            if (SelectedArea != null && SelectedArea.Name != All) efo.AreaId = SelectedArea.Id;

            //SubArea
            if (SelectedSubArea != null && SelectedSubArea.Name != All) efo.SubAreaId = SelectedSubArea.Id;

            //UpperEquipment
            if (SelectedUpperEquipment != null && SelectedUpperEquipment.Name != All)
            {
                if (SelectedUpperEquipment.EquipmentModuleId.HasValue)
                    efo.EquipmentModuleId = SelectedUpperEquipment.EquipmentModuleId.Value;
                else
                    efo.UnitId = SelectedUpperEquipment.UnitId;
            }

            //Graphic
            if (mSelectedGraphic != null && mSelectedGraphic.Name != All)
            {
                efo.GraphicId = mSelectedGraphic.Id;
            }

            //EquipmentTypeId
            if (mSelectedEquipmentType != null && mSelectedEquipmentType.Name != All)
            {
                efo.EquipmentTypeId = mSelectedEquipmentType.Id;
            }

            //PandIDDocumentId
            if (mSelectedPAndIdDocument != null && mSelectedPAndIdDocument.Name != All)
            {
                efo.PidDocumentId = mSelectedPAndIdDocument.Id;
            }

            //SpecificationDocumentId
            if (mSelectedSpecificationDocument != null && mSelectedSpecificationDocument.Name != All)
            {
                efo.SpecificationDocumentId = mSelectedSpecificationDocument.Id;
            }

            //ComponentTypes
            if (mSelectedComponentType != null && mSelectedComponentType.Name != All)
            {
                efo.ComponentTypeId = mSelectedComponentType.Id;
            }

            //Classified
            if (mSelectedClassified != All) efo.IsClassified = mSelectedClassified == Yes;

            IsGridBusy = true;

            DatabaseLoader.GetQuickControlSystems(efo).ContinueWith((getQuickControlSystemsTask) =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    ControlSystems = getQuickControlSystemsTask.Result;
                    RaisePropertyChanged("ControlSystems");

                    FilteredControlDataContext.SummaryTotal = ControlSystems.Count;
                    FilteredControlDataContext.RaisePropertyChanged("SummaryTotal");
                    CMS.Cache.FilteredExportControlIdList = ControlSystems.Select(x => x.Id).ToList();

                    IsGridBusy = false;
                });
            });
        }
        public byte[] GetQuickInstruments(EquipmentFilterObject equipmentFilterObject)
        {
            using (CmsEntities cee = new CmsEntities())
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();

                var quickInstruments = new List<QuickInstrument>();

                var query = (from x in cee.Instruments select x);

                //Keyword
                if (!String.IsNullOrEmpty(equipmentFilterObject.Keyword))
                {
                    string[] textArray = CommonUtils.GetSearchTextArray(equipmentFilterObject.Keyword);

                    query = query.Where(BuildInstrumentKeywordPredicate(textArray));
                }

                //EquipmentId
                if (equipmentFilterObject.EquipmentTypeId.HasValue)
                {
                    query = query.Where(x => x.InstrumentTypeId == equipmentFilterObject.EquipmentTypeId.Value);
                }

                //AreaId
                if (equipmentFilterObject.AreaId.HasValue)
                {
                    query = query.Where(x => x.AreaId == equipmentFilterObject.AreaId.Value);
                }

                //SubAreaId
                if (equipmentFilterObject.SubAreaId.HasValue)
                {
                    query = query.Include("Unit").Include("EquipmentModule.Unit");
                    query = query.Where(x => x.Unit != null ? x.Unit.CellId == equipmentFilterObject.SubAreaId.Value
                        : x.EquipmentModule != null && (x.EquipmentModule.Unit != null && x.EquipmentModule.Unit.CellId == equipmentFilterObject.SubAreaId.Value));
                }

                //MaintenanceSysId
                if (!String.IsNullOrEmpty(equipmentFilterObject.MaintenanceSysId))
                {
                    query = query.Where(x => x.MaintSystemId.ToLower().Trim().Contains(equipmentFilterObject.MaintenanceSysId.ToLower().Trim()));
                }

                //PidDocumentId
                if (equipmentFilterObject.PidDocumentId.HasValue)
                {
                    query = query.Where(x => x.PandIDDocumentId == equipmentFilterObject.PidDocumentId.Value);
                }

                //ComponentTypeId
                if (equipmentFilterObject.ComponentTypeId.HasValue)
                {
                    query = query.Where(x => x.InstrumentComponents.Any(c => c.InstrumentComponentTypeId == equipmentFilterObject.ComponentTypeId.Value));
                }

                //SpecificationDocumentId
                if (equipmentFilterObject.SpecificationDocumentId.HasValue)
                {
                    query = query.Where(x => x.SpecificationDocumentId == equipmentFilterObject.SpecificationDocumentId.Value);
                }

                //IsClassified
                if (equipmentFilterObject.IsClassified.HasValue)
                {
                    query = query.Where(x => x.Classified == equipmentFilterObject.IsClassified.Value);
                }

                //ManufacturerId
                if (equipmentFilterObject.ManufacturerId.HasValue)
                {
                    query = query.Where(x => x.InstrumentComponents.Any(c => c.ManufacturerId == equipmentFilterObject.ManufacturerId.Value));
                }

                //ModelId
                if (equipmentFilterObject.ModelId.HasValue)
                {
                    query = query.Where(x => x.InstrumentComponents.Any(c => c.ModelId == equipmentFilterObject.ModelId.Value));
                }

                //IsActive
                if (equipmentFilterObject.IsActive.HasValue)
                {
                    query = query.Where(x => x.IsActive == equipmentFilterObject.IsActive.Value);
                }

                 if (equipmentFilterObject.InstrumentSorting == CommonUtils.InstrumentSorting.Alphabetically)
                 {
                     query = query.OrderBy(x => x.Name);
                 }
                 else
                 {
                     //if (Name.Length > 2)
                     //{
                     //    string loopName = Name.Substring(2, Name.Length - 2);
                     //    return loopName;
                     //}

                     query = query.OrderBy(x => x.Name.Length > 2 ? x.Name.Substring(2, x.Name.Length - 2) : "0");
                 }

                quickInstruments = (from x in query
                                    select new QuickInstrument
                                    {
                                        Id = x.Id,
                                        Name = x.Name,
                                        Description = x.Description,
                                        IsActive = x.IsActive
                                    }).ToList();

                sw.Stop();
                Debug.WriteLine("It took {0} seconds to get Instruments from GetQuickInstruments()", sw.Elapsed.TotalSeconds);

                MemoryStream byteStream = new MemoryStream();
                Serializer.Serialize(byteStream, quickInstruments);

                return byteStream.ToArray();

            }
        }
        /// <summary>
        ///     Filters the pipes in the data grid
        /// </summary>
        private void ProcessSearchFilter()
        {
            var efo = new EquipmentFilterObject();

            //Keyword
            if (!string.IsNullOrEmpty(View.KeywordTextBox.Text))
            {
                efo.Keyword = View.KeywordTextBox.Text;
            }

            //Control System Type
            if (SelectedControlSystemType != null && SelectedControlSystemType.Name != "All")
            {
                efo.EquipmentTypeId = SelectedControlSystemType.Id;
            }

            //Area
            if (SelectedArea != null && SelectedArea.Name != "All")
            {
                efo.AreaId = SelectedArea.Id;
            }

            //SubArea
            if (SelectedCell != null && SelectedCell.Name != "All")
            {
                efo.SubAreaId = SelectedCell.Id;
            }

            //UpperEquipment
            if (SelectedUpperEquipment != null && SelectedUpperEquipment.Name != "All")
            {
                if (SelectedUpperEquipment.EquipmentModuleId.HasValue)
                    efo.EquipmentModuleId = SelectedUpperEquipment.EquipmentModuleId.Value;
                else
                    efo.UnitId = SelectedUpperEquipment.UnitId;
            }

            //SpecificationDocumentId
            if (SelectedFunctionalSpecification != null && SelectedFunctionalSpecification.Name != "All")
            {
                efo.SpecificationDocumentId = SelectedFunctionalSpecification.Id;
            }

            DatabaseLoader.GetQuickControlSystems(efo).ContinueWith(getQuickControlSystemsTask =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    ControlSystems = getQuickControlSystemsTask.Result;
                    RaisePropertyChanged("ControlSystems");
                });
            });
        }
        public byte[] GetQuickControlSystems(EquipmentFilterObject equipmentFilterObject)
        {
            using (var cee = new CmsEntities())
            {
                var sw = new Stopwatch();
                sw.Start();

                var quickControlSystems = new List<QuickControlSystem>();

                var query = (from x in cee.ControlSystems select x);

                //Keyword
                if (!String.IsNullOrEmpty(equipmentFilterObject.Keyword))
                {
                    var textArray = CommonUtils.GetSearchTextArray(equipmentFilterObject.Keyword);

                    query = query.Where(BuildControlKeywordPredicate(textArray));
                }

                //Name
                if (!String.IsNullOrEmpty(equipmentFilterObject.Name))
                {
                    query = query.Where(x => x.Name.ToLower() == equipmentFilterObject.Name.ToLower());
                }

                //EquipmentId
                if (equipmentFilterObject.EquipmentTypeId.HasValue)
                {
                    query = query.Where(x => x.ControlSystemTypeId == equipmentFilterObject.EquipmentTypeId.Value);
                }

                //AreaId
                if (equipmentFilterObject.AreaId.HasValue)
                {
                    query = query.Where(x => x.AreaId == equipmentFilterObject.AreaId.Value);
                }

                //SubAreaId
                if (equipmentFilterObject.SubAreaId.HasValue)
                {
                    query = query.Include("Unit").Include("EquipmentModule.Unit");
                    query = query.Where(x => x.Unit != null ? x.Unit.CellId == equipmentFilterObject.SubAreaId.Value
                        : x.EquipmentModule != null && (x.EquipmentModule.Unit != null && x.EquipmentModule.Unit.CellId == equipmentFilterObject.SubAreaId.Value));
                }

                //UpperEquipment
                if (equipmentFilterObject.UnitId.HasValue)
                {
                    query = query.Where(x => x.UnitId == equipmentFilterObject.UnitId.Value);
                }
                if (equipmentFilterObject.EquipmentModuleId.HasValue)
                {
                    query = query.Where(x => x.EquipmentModuleId == equipmentFilterObject.EquipmentModuleId.Value);
                }

                //GraphicId
                if (equipmentFilterObject.GraphicId.HasValue)
                {
                    query = query.Where(x => x.GraphicId == equipmentFilterObject.GraphicId.Value);
                }

                //PidDocumentId
                if (equipmentFilterObject.PidDocumentId.HasValue)
                {
                    query = query.Where(x => x.PandIDDocumentId == equipmentFilterObject.PidDocumentId.Value);
                }

                //ComponentTypeId
                if (equipmentFilterObject.ComponentTypeId.HasValue)
                {
                    query = query.Where(x => x.ControlSystemComponents.Any(c => c.ControlSystemComponentTypeId == equipmentFilterObject.ComponentTypeId.Value));
                }

                //SpecificationDocumentId
                if (equipmentFilterObject.SpecificationDocumentId.HasValue)
                {
                    query = query.Where(x => x.SpecificationDocumentId == equipmentFilterObject.SpecificationDocumentId.Value);
                }

                //IsClassified
                if (equipmentFilterObject.IsClassified.HasValue)
                {
                    query = query.Where(x => x.Classified == equipmentFilterObject.IsClassified.Value);
                }

                //IsActive
                if (equipmentFilterObject.IsActive.HasValue)
                {
                    query = query.Where(x => x.IsActive == equipmentFilterObject.IsActive.Value);
                }

                quickControlSystems = (from x in query
                                       orderby x.Name
                                       select new QuickControlSystem
                                       {
                                           Id = x.Id,
                                           Name = x.Name,
                                           Description = x.Description,
                                           IsActive = x.IsActive
                                       }).ToList();

                sw.Stop();
                Debug.WriteLine("It took {0} seconds to get  ControlSystems from GetQuickControlSystems()", sw.Elapsed.TotalSeconds);

                var byteStream = new MemoryStream();
                Serializer.Serialize(byteStream, quickControlSystems);

                return byteStream.ToArray();
            }
        }