예제 #1
0
 public void Seed(Model model)
 {
     if (model.Categories != null)
     {
         Categories.AddRange(model.Categories);
     }
     if (model.Products != null)
     {
         Products.AddRange(model.Products);
     }
     if (model.Regions != null)
     {
         Regions.AddRange(model.Regions);
     }
     if (model.Shops != null)
     {
         Shops.AddRange(model.Shops);
     }
     if (model.Customers != null)
     {
         Customers.AddRange(model.Customers);
     }
     if (model.Campaigns != null)
     {
         Campaigns.AddRange(model.Campaigns);
     }
     if (model.Sales != null)
     {
         Sales.AddRange(model.Sales);
     }
     if (model.LeadStates != null)
     {
         LeadStates.AddRange(model.LeadStates);
     }
     if (model.LeadHistory != null)
     {
         LeadHistory.AddRange(model.LeadHistory);
     }
     if (model.Budget != null)
     {
         Budget.AddRange(model.Budget);
     }
     if (model.RegionWiseSales != null)
     {
         RegionWiseSales.AddRange(model.RegionWiseSales);
     }
     if (model.Opportunities != null)
     {
         Opportunities.AddRange(model.Opportunities);
     }
     if (model.ProfitAndSales != null)
     {
         ProfitAndSales.AddRange(model.ProfitAndSales);
     }
     if (model.RegionSales != null)
     {
         RegionSales.AddRange(model.RegionSales);
     }
     SaveChanges();
 }
예제 #2
0
 public void Include(EntityData otherData)
 {
     Alerts.AddRange(otherData.Alerts);
     EmailAlertRecipients.AddRange(otherData.EmailAlertRecipients);
     SmsAlertRecipients.AddRange(otherData.SmsAlertRecipients);
     AlertReports.AddRange(otherData.AlertReports);
     AlertRules.AddRange(otherData.AlertRules);
     ApplicationLanguages.AddRange(otherData.ApplicationLanguages);
     ContentLanguages.AddRange(otherData.ContentLanguages);
     Countries.AddRange(otherData.Countries);
     DataCollectors.AddRange(otherData.DataCollectors);
     Districts.AddRange(otherData.Districts);
     GatewaySettings.AddRange(otherData.GatewaySettings);
     HeadManagerConsents.AddRange(otherData.HeadManagerConsents);
     HealthRisks.AddRange(otherData.HealthRisks);
     HealthRiskLanguageContents.AddRange(otherData.HealthRiskLanguageContents);
     Localizations.AddRange(otherData.Localizations);
     LocalizedTemplates.AddRange(otherData.LocalizedTemplates);
     NationalSocieties.AddRange(otherData.NationalSocieties);
     Notifications.AddRange(otherData.Notifications);
     Projects.AddRange(otherData.Projects);
     SupervisorUserProjects.AddRange(otherData.SupervisorUserProjects);
     ProjectHealthRisks.AddRange(otherData.ProjectHealthRisks);
     RawReports.AddRange(otherData.RawReports);
     Regions.AddRange(otherData.Regions);
     Reports.AddRange(otherData.Reports);
     Users.AddRange(otherData.Users);
     UserNationalSocieties.AddRange(otherData.UserNationalSocieties);
     Villages.AddRange(otherData.Villages);
     Zones.AddRange(otherData.Zones);
 }
예제 #3
0
        public Regions PickStartingRegions(Map map, Regions availableOptions)
        {
            int numberToPick = availableOptions.Count > 6 ? 6 : availableOptions.Count;

            IEnumerable<RegionScore<StartRegion>> scores = _calc.CalculateStartRegions(map);

            var pickList = new Regions();

            pickList.AddRange(scores
                .OrderByCumulativeScore()
                .Where(r => availableOptions.Contains(r.Region))
                .Select(r => r.Region)
                .Take(numberToPick));

            return pickList;
        }
예제 #4
0
        protected override async Task FetchDataAsync()
        {
            var stations = await base.Api.GetAsync <List <StationModel> >(
                $"{Constants.Endpoints.Stations}?{Constants.ApiOptions.IncludeDeleted}");

            var regions = await base.Api.GetAsync <List <RegionModel> >(
                $"{Constants.Endpoints.Regions}?{Constants.ApiOptions.IncludeDeleted}");

            var castedStations = stations.Select(s => new StationViewModel(s, Save, Cancel));
            var castedRegions  = regions.Select(r => new RegionViewModel(r, Save, Cancel));

            Stations.AddRange(castedStations);
            Regions.AddRange(castedRegions);

            var selectedStationId = Navigator.GetNavigationData <Guid>();

            if (selectedStationId != null && selectedStationId != Guid.Empty)
            {
                this.Selected = Stations.FirstOrDefault(s => s.Id == selectedStationId);
            }
        }
        private void Connect()
        {
            if (_reader != null || _isConnected)
            {
                _reader.Destroy();
            }

            if (IsConnected)
            {
                IsConnected = false;
                OnPropertyChanged("ConnectButtonContent");
                return;
            }

            //ConfigureAntennaBoxes(null);
            //ConfigureProtocols(null);

            try
            {
                // Creates a Reader Object for operations on the Reader.
                string readerUri = SelectedComPort.Name;
                //Regular Expression to get the com port number from comport name .
                //for Ex: If The Comport name is "USB Serial Port (COM19)" by using this
                // regular expression will get com port number as "COM19".
                MatchCollection mc = Regex.Matches(readerUri, @"(?<=\().+?(?=\))");
                foreach (Match m in mc)
                {
                    readerUri = m.ToString();
                }
                _reader = Reader.Create(string.Concat("tmr:///", readerUri));

                //uri = readerUri;

                // If Option selected add the serial-reader-specific message logger
                // before connecting, so we can see the initialization.
                //if ((bool)chkEnableTransportLogging.IsChecked)
                //{
                //    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                //    saveFileDialog1.Filter = "Text Files (.txt)|*.txt";
                //    saveFileDialog1.Title = "Select a File to save transport layer logging";
                //    string strDestinationFile = "UniversalReader_transportLog"
                //        + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + @".txt";
                //    saveFileDialog1.FileName = strDestinationFile;
                //    // Show the Dialog.
                //    // If the user clicked OK in the dialog and
                //    // a .txt file was selected, open it.
                //    if (saveFileDialog1.ShowDialog() == true)
                //    {
                //        StreamWriter writer = new StreamWriter(saveFileDialog1.FileName);
                //        writer.AutoFlush = true;
                //        if (_reader is SerialReader)
                //            _reader.Transport += SerialListener;
                //    }
                //    else
                //    {
                //        chkEnableTransportLogging.IsChecked = false;
                //    }
                //}

                //chkEnableTransportLogging.IsEnabled = false;

                // Set the selected baud rate, so that api try's connecting to the
                // module with the selected baud rate first
                SetBaudRate();

                //Show the status
                //lblshowStatus.Content = "Connecting..";
                Mouse.SetCursor(Cursors.Wait);
                _reader.Connect();

                Mouse.SetCursor(Cursors.Arrow);

                //readerStatus.IsEnabled = true;
                var regionToSet = (Reader.Region)_reader.ParamGet("/reader/region/id");

                Regions.Add("Select");
                Regions.AddRange(((Reader.Region[])_reader.ParamGet("/reader/region/supportedRegions")).Select(r => r.ToString()));

                if (regionToSet != Reader.Region.UNSPEC)
                {
                    //set the region on module
                    SelectedRegion = Regions[Regions.IndexOf(regionToSet.ToString())];
                }
                else
                {
                    SelectedRegion = Regions[Regions.IndexOf("Select")];
                }

                // TODO: Initialize max and min read power for read power slider
                //InitializeRdPwrSldrMaxNMinValue();

                //Initialize settings received o
                _optimalReaderSettings = null;
                InitializeOptimalSettings();

                //_reader.ParamSet("/reader/transportTimeout", int.Parse(txtRFOnTimeout.Text) + 5000);
                //try setting a unique ID
                //reader.ParamSet("/reader/hostname", "this reader");
                //if (_reader is SerialReader)
                //{
                //    cbxBaudRate.IsEnabled = true;
                //}

                // Load Gen2 Settings
                //initialReaderSettingsLoaded = false;
                //LoadGen2Settings();
                //initialReaderSettingsLoaded = true;

                ////Enable fast search on for mercury6, astra-ex, m6e.
                //if (model.Equals("Astra") || model.Equals("M5e")
                //    || model.Equals("M5e Compact") || model.Equals("M5e EU")
                //    || model.Equals("M4e") || model.Equals("M5e PRC"))
                //{
                //    chkEnableFastSearch.IsEnabled = false;
                //}

                //btnRead.IsEnabled = true;
                //advanceReaderSettings.IsEnabled = true;
                //if (_reader is SerialReader)
                //{
                //    var br = _reader.ParamGet("/reader/baudRate").ToString();
                //    SelectedBaudRate = br;

                //    //initializeBaudRate();
                //    if (!(model.Equals("M6e") || model.Equals("M6e Micro") || model.Equals("M6e Micro USB")
                //        || model.Equals("M6e Micro USBPro") || model.Equals("M6e PRC") || model.Equals("M6e Nano")))
                //    {
                //        _reader.ParamSet("/reader/tagReadData/reportRssiInDbm", true);
                //    }
                //}
                //ConfigureAntennaBoxes(_reader);
                //supportedProtocols = (TagProtocol[])_reader.ParamGet("/reader/version/supportedProtocols");
                //ConfigureProtocols(supportedProtocols);
                //btnConnect.ToolTip = "Disconnect";
                //btnConnect.Content = "Disconnect";
                //btnConnectExpander.Content = btnConnect.Content+"...";

                ////Enable save data, btnClearTagReads, read-once, readasyncread buttons
                //saveData.IsEnabled = true;
                //btnClearTagReads.IsEnabled = true;
                //btnRead.IsEnabled = true;

                ////startRead.IsEnabled = true;
                //InitializeRdrDiagnostics();
                //// Disabling equal time switching for both Nano and Micro USB modules.
                //// Because these modules has only one antenna.
                //if (model.Equals("M6e Nano") || model.Equals("M6e Micro USB") || model.Equals("M6e Micro USBPro"))
                //{
                //    rdBtnEqualSwitching.IsEnabled = false;
                //    rdBtnEqualSwitching.IsChecked = false;
                //    rdBtnAutoSwitching.IsChecked = true;
                //}
                //else
                //{
                //    rdBtnEqualSwitching.IsEnabled = true;
                //    rdBtnEqualSwitching.IsChecked = true;
                //    rdBtnAutoSwitching.IsChecked = false;
                //}
                Mouse.SetCursor(Cursors.Arrow);
                //CustomizedMessageBox = new URACustomMessageBoxWindow();

                //// Clear firmware Update open file dialog status
                //txtFirmwarePath.Text = "";
                IsConnected = true;
            }
            catch (Exception ex)
            {
                Mouse.SetCursor(Cursors.Arrow);
                //btnConnect.IsEnabled = true;
                //initialReaderSettingsLoaded = true;
                //lblshowStatus.Content = "Disconnected";
                //chkEnableTransportLogging.IsEnabled = true;
                //gridReadOptions.IsEnabled = false;
                //regioncombo.IsEnabled = false;
                //gridDisplayOptions.IsEnabled = false;
                Trace.TraceError("Connection error. " + ex.Message + ex.StackTrace);
                if (ex is IOException)
                {
                    if (!(SelectedComPort.Name.Contains("COM") || SelectedComPort.Name.Contains("com")))
                    {
                        MessageBox.Show("Application needs a valid Reader Address of type COMx",
                                        "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        MessageBox.Show("Reader not connected on " + SelectedComPort.Name, "Error",
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    //cmbReaderAddr.IsEnabled = true;
                    //cmbFixedReaderAddr.IsEnabled = true;
                }
                else if (ex is ReaderException)
                {
                    if (ex.Message.IndexOf("target machine actively refused") != -1)
                    {
                        MessageBox.Show("Error connecting to reader: " + "Connection attempt failed...",
                                        "Reader Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else if (ex is FAULT_BL_INVALID_IMAGE_CRC_Exception || ex is FAULT_BL_INVALID_APP_END_ADDR_Exception)
                    {
                        MessageBox.Show("Error connecting to reader: " + ex.Message + ". Please update the module firmware.", "Reader Error",
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                        //expdrFirmwareUpdate.IsExpanded = true;
                        //expdrFirmwareUpdate.Focus();
                        ////Dock the settings/status panel if not docked, to display Firmware update options
                        //if (pane1Button.Visibility == System.Windows.Visibility.Visible)
                        //{
                        //    pane1Button.RaiseEvent(new RoutedEventArgs(ButtonBase.MouseEnterEvent));
                        //    pane1Pin.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
                        //}
                        //if (expdrConnect.IsExpanded)
                        //{
                        //    expdrConnect.IsExpanded = false;
                        //}
                    }
                    else
                    {
                        MessageBox.Show("Error connecting to reader: " + ex.Message, "Reader Error",
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else if (ex is UnauthorizedAccessException)
                {
                    MessageBox.Show("Access to " + SelectedComPort.Name + " denied. Please check if another "
                                    + "program is accessing this port", "Error!", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
                else
                {
                    if (-1 != ex.Message.IndexOf("target machine actively refused"))
                    {
                        MessageBox.Show("Error connecting to reader: " + "Connection attempt failed...",
                                        "Reader Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        MessageBox.Show("Error connecting to reader: " + ex.Message, "Reader Error",
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }