Exemplo n.º 1
0
    public void ConvertToCountryData()
    {
        TextAsset   jsonData = Resources.Load <TextAsset>("population");
        SeriesArray data     = JsonUtility.FromJson <SeriesArray>(jsonData.text);

        CountryData[] countryDataList = new CountryData[data.AllData.Length];
        for (int i = 0; i < data.AllData.Length; i++)
        {
            SeriesData seriesData = data.AllData[i];

            CountryData countryData = new CountryData();
            countryDataList[i] = countryData;
            countryData.Name   = "UNKNOWN";
            countryData.Points = new CountryPoint[seriesData.Data.Length / 3];

            for (int j = 0, k = 0; j < seriesData.Data.Length; j += 3, k++)
            {
                CountryPoint p = new CountryPoint();
                p.y                   = Convert.ToInt32(seriesData.Data[j]);
                p.x                   = Convert.ToInt32(seriesData.Data[j + 1]);
                p.population          = seriesData.Data[j + 2];
                p.infection           = 0;
                countryData.Points[k] = p;
            }
        }

        WorldData worldData = new WorldData();

        worldData.Countries = countryDataList;
        string json = JsonUtility.ToJson(worldData);
    }
 internal void foo(string path,string choosenFile)
 {
     var custIndex = new List<int>();
     //if (choosenFile.Contains("Cust"))
     //{
         var lines = File.ReadAllLines(path + "\\" + choosenFile);
         foreach (string line in lines)
         {
             int errorCounter = 0;
             string[] items = line.Split('\t');
             //Put all your logic back here...
             if (errorCounter == 0)
             {
                 var countryData = new CountryData()
                                       {
                                           FirstCountry = items[0],
                                           ThirdCountry = items[2]
                                       };
                 countryDataList.Add(countryData);
                 multiCountryDataList.Add( new MultiCountryData() { SeceondCountryOption = items[1].Split(',')});
             }
         //}
       }
    
 }
Exemplo n.º 3
0
        public TravelioCountry(CountryData geoData, Location locationInfo, IEnumerable <AggregateData> aggregateData)
        {
            GeoData      = geoData;
            LocationInfo = locationInfo;

            AggregateData.AddRange(aggregateData);
        }
Exemplo n.º 4
0
        public async Task Task_GetCountry_OkResult()
        {
            var country = new CountryModel
            {
                CountryId = 5
            };

            //Arrange
            var options = new DbContextOptionsBuilder <CountryData>()
                          .UseInMemoryDatabase(databaseName: "Get_Countries")
                          .Options;


            // Run the test against one instance of the context
            using (var context = new CountryData(options))
            {
                var repository   = new CountryRepository(context);
                var modelmanager = new CountryManager(repository);



                //Act

                var result = await modelmanager.GetCountry(5);

                //Assert

                Assert.IsNotNull(result);
            }
        }
Exemplo n.º 5
0
        public async Task Task_UpdateCountry_OkResult()
        {
            var country = new CountryModel
            {
                CountryId = 5,
                Name      = "Nigeria",
                Continent = "Africa",
                //DateCreated = DateTime.Now
            };

            //Arrange
            var options = new DbContextOptionsBuilder <CountryData>()
                          .UseInMemoryDatabase(databaseName: "Get_Countries")
                          .Options;


            // Run the test against one instance of the context
            using (var context = new CountryData(options))
            {
                var repository   = new CountryRepository(context);
                var modelmanager = new CountryManager(repository);



                //Act
                await modelmanager.AddCountry(country);

                var result = await modelmanager.GetAllCountries();

                //Assert

                Assert.AreEqual(country.Name, result[0].Name);
            }
        }
Exemplo n.º 6
0
        public async Task RepoCreateandGetCountryFoUser()
        {
            //Arrange
            var userId  = "8742954e-0993-4498-bea5-5b3d60857a86";
            var country = new CountryModel
            {
                CountryId = 10,
                Name      = "Nigeria",
                Continent = "Africa",
                //DateCreated = DateTime.Now
            };

            var options = new DbContextOptionsBuilder <CountryData>()
                          .UseInMemoryDatabase(databaseName: "Get_Countries")
                          .Options;

            // Run the test against one instance of the context
            using (var context = new CountryData(options))
            {
                var repository   = new CountryRepository(context);
                var modelmanager = new CountryManager(repository);

                //Act
                await modelmanager.AddCountry(country);

                var result = await modelmanager.GetAllCountries();

                //Assert
                Assert.AreEqual(country.Name, result[0].Name);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Открыть ссылку в новом окне
        /// </summary>
        public void OpenLinkInNewWindow(CountryData country)
        {
            adminPanel.OpenAdminPage();
            adminPanel
            .EntryUserName("admin")
            .EntryUserPass("admin")
            .SubmitLogin();

            countriesLinkPage.OpenCountry(country.Code);

            string         mainIdWindow   = countriesLinkPage.GetIdCurrentWindow();
            IList <string> ExistIdWindows = countriesLinkPage.GetIdWindowsTab();

            foreach (string link in countriesLinkPage.GetLinks())
            {
                countriesLinkPage.OpenWindowTab();
                string newId = countriesLinkPage.GetNewWindow(ExistIdWindows);
                countriesLinkPage.GoToWindowTab(newId);
                Assert.IsTrue(countriesLinkPage.GetIdCurrentWindow() == newId);

                countriesLinkPage.OpenLink(link);
                countriesLinkPage.CloseWindow();
                countriesLinkPage.GoToWindowTab(mainIdWindow);
            }
        }
Exemplo n.º 8
0
        private async Task <TravelioCountry> PopulateTravelioCountry(int month, CountryData countryData)
        {
            var historicalController = new HistoricalController(_memCache, _configuration);
            var locationInfo         = historicalController.SearchCountry(countryData.Alpha2Code, countryData.Name);

            if (locationInfo != null)
            {
                var data = await historicalController.GetQuickDataForLocation(month, locationInfo.LocationId);

                if (data != null)
                {
                    var aggregate = data.GroupBy(hd => new { DataType = hd.DataType })
                                    .Select(g => new AggregateData
                    {
                        Label = g.Key.DataType.Description(),
                        Value = Math.Round(g.Average(x => x.Value), 1),
                    }).ToList();

                    var travelioCountry = new TravelioCountry(countryData, locationInfo, aggregate);

                    var cacheEntryOptions = new MemoryCacheEntryOptions()
                                            .SetAbsoluteExpiration(TimeSpan.FromDays(1));

                    _memCache.Set(countryData.Alpha2Code + "TravelioInfo" + month, travelioCountry, cacheEntryOptions);

                    return(travelioCountry);
                }
            }

            return(null);
        }
        public CountryDetailsViewModel()
        {
            XmlCountryRepository countryRepository = new XmlCountryRepository();
            CountryData          country           = countryRepository.GetCountryById(Navigation.Id);

            DataContext = country;
        }
Exemplo n.º 10
0
        public AuthenticationResult Authenticate(String p_SessionID)
        {
            Data        = null;
            CountryData = null;
            SessionID   = CommunicationToken = null;

            // Try to fetch token data.
            var s_TokenData = FetchTokenData(p_SessionID);

            // Check if we have the data we need.
            if (s_TokenData == null || s_TokenData.GetGSConfig == null || s_TokenData.GetGSConfig.User == null)
            {
                return(AuthenticationResult.NoTokenData);
            }

            // Check if the user was successfully logged in.
            if (String.IsNullOrWhiteSpace(s_TokenData.GetGSConfig.User.Email))
            {
                return(AuthenticationResult.InvalidSession);
            }

            // Store required information.
            CommunicationToken = s_TokenData.GetCommunicationToken;
            Data      = s_TokenData.GetGSConfig.User;
            SessionID = s_TokenData.GetGSConfig.SessionID;
            Library.Chat.ChatServers = s_TokenData.GetGSConfig.ChatServersWeighted;
            CountryData            = s_TokenData.GetGSConfig.Country;
            Library.Remora.Channel = s_TokenData.GetGSConfig.RemoraChannel;
            Library.TimeDifference = s_TokenData.GetGSConfig.Timestamp * 1000 - DateTime.UtcNow.ToUnixTimestampMillis();

            Trace.WriteLine(String.Format("Time difference calculated to {0}ms.", Library.TimeDifference));

            return(AuthenticationResult.Success);
        }
Exemplo n.º 11
0
 internal UserComponent(SharpShark p_Library)
     : base(p_Library)
 {
     Data        = null;
     CountryData = null;
     SessionID   = CommunicationToken = null;
 }
Exemplo n.º 12
0
        public bool InitSession()
        {
            Data        = null;
            CountryData = null;
            SessionID   = CommunicationToken = null;

            // Try to fetch token data.
            var s_TokenData = FetchTokenData();

            if (s_TokenData == null || s_TokenData.GetGSConfig == null)
            {
                return(false);
            }

            // Store required information.
            CommunicationToken       = s_TokenData.GetCommunicationToken;
            SessionID                = s_TokenData.GetGSConfig.SessionID;
            Library.Chat.ChatServers = s_TokenData.GetGSConfig.ChatServersWeighted;
            CountryData              = s_TokenData.GetGSConfig.Country;
            Library.Remora.Channel   = s_TokenData.GetGSConfig.RemoraChannel;
            Library.TimeDifference   = s_TokenData.GetGSConfig.Timestamp * 1000 - DateTime.UtcNow.ToUnixTimestampMillis();

            Trace.WriteLine(String.Format("Time difference calculated to {0}ms.", Library.TimeDifference));

            return(true);
        }
        private async void SelectedData()
        {
            string regionName = Location[Region];

            if (Region > 1 && Region < 6)
            {
                ContinentData continent = await covidService.FindContinent(regionName);

                TodayCases  = continent.TodayCases;
                Cases       = continent.Cases;
                TodayDeaths = continent.TodayDeaths;
                Deaths      = continent.Deaths;
                Recovered   = continent.Recovered;
                Active      = continent.Active;
                Tests       = continent.Tests;
            }
            else if (Region > 6)
            {
                CountryData country = await covidService.FindCountry(regionName);

                TodayCases  = country.TodayCases;
                Cases       = country.Cases;
                TodayDeaths = country.TodayDeaths;
                Deaths      = country.Deaths;
                Recovered   = country.Recovered;
                Active      = country.Active;
                Tests       = country.Tests;
            }
            else
            {
                GetGlobalData();
            }
        }
Exemplo n.º 14
0
        public async Task Should_Insert_CommissionAgent()
        {
            var id = _commissionAgentDataServices.NewId();
            var commissionAgent         = _commissionAgentDataServices.GetNewDo(id);
            var commissionAgentTypeData = new CommissionAgentTypeData();

            commissionAgentTypeData.Code = "2";
            commissionAgentTypeData.Name = "KARVE INFORMATICA S.L";
            //  commissionAgent.Type = commissionAgentTypeData;
            var dataCountry = new CountryData();

            dataCountry.Code        = "34";
            dataCountry.CountryName = "Spain";
            // commissionAgent.Country = dataCountry;
            ComisioViewObject comisio = (ComisioViewObject)commissionAgent.Value;

            comisio.NUM_COMI = _commissionAgentDataServices.NewId();
            Assert.NotNull(comisio.NUM_COMI);
            comisio.TIPOCOMI      = "2";
            comisio.CP            = "080012";
            comisio.NOMBRE        = "Giorgio";
            comisio.DIRECCION     = "Via Augusta 32";
            comisio.EMAIL         = "*****@*****.**";
            commissionAgent.Value = comisio;
            bool cAgent = await _commissionAgentDataServices.SaveAsync(commissionAgent);

            Assert.True(cAgent);
        }
Exemplo n.º 15
0
        private static void TestSinglePrediction(MLContext context)
        {
            // For this test we'll load the model back from disk.
            using (var stream = new FileStream(ModelPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                var loadedModel = context.Model.Load(stream);

                var predictionFunction = loadedModel.CreatePredictionEngine <CountryData, CountryHappinessScorePrediction>(context);

                // Record of Italy - expected 5.964
                var sample = new CountryData
                {
                    Population        = 58133509,
                    Area              = 301230,
                    PopulationDensity = 193,
                    Coastline         = 2.52f,
                    NetMigration      = 2.07f,
                    InfantMortality   = 5.94f,
                    GDP       = 26700,
                    Literacy  = 98.6f,
                    Phones    = 430.9f,
                    Arable    = 27.79f,
                    Climate   = 0,
                    Birthrate = 8.72f,
                    Deathrate = 10.4f
                };
                var prediction = predictionFunction.Predict(sample);

                OutputSinglePredictionResult(prediction);
            }
        }
    static void Main()
    {
        Dictionary<string, CountryData> countryData = new Dictionary<string, CountryData>();
        string[] input = Console.ReadLine().Split(new char[] { '|' });
        while (input[0] != "report")
        {
            string countryName = string.Join(" ", input[1].Trim().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries));
            string player = string.Join(" ", input[0].Trim().Split(new char[] { ' ','\t' }, StringSplitOptions.RemoveEmptyEntries));
            if (!countryData.ContainsKey(countryName))
            {
                countryData[countryName] = new CountryData();
            }
            if (!countryData[countryName].Players.Contains(player))
            {
                countryData[countryName].Players.Add(player);
            }
            countryData[countryName].Wins++;
            input = Console.ReadLine().Split(new char[] { '|' });
        }

        foreach (var kvp in countryData.OrderByDescending(x => x.Value.Wins))
        {
            Console.WriteLine($"{kvp.Key} ({kvp.Value.Players.Count} participants): {kvp.Value.Wins} wins");
        }
    }
Exemplo n.º 17
0
    public static void Main(string[] args)
    {
        XmlSerializer xsSubmit = new XmlSerializer(typeof(CountryData));
        var           subReq   = new CountryData();

        subReq.Countries.Add(new Country
        {
            CountryName       = "name",
            Countrycode       = "code",
            PercentOfBusiness = "12",
            AverageBusiness   = "123",
            SalesMade         = "120012"
        });
        subReq.Countries.Add(new Country
        {
            CountryName       = "name2",
            Countrycode       = "code2",
            PercentOfBusiness = "34",
            AverageBusiness   = "345",
            SalesMade         = "453453543"
        });
        var xml = "";

        using (var sww = new StringWriter())
        {
            using (XmlWriter writer = XmlWriter.Create(sww))
            {
                xsSubmit.Serialize(writer, subReq);
                xml = sww.ToString();
            }
        }
    }
        public int CountryCode(CountryData ItemCode)
        {
            CountryDal CountryDal = new CountryDal();

            try
            {
                switch (ItemCode.DataStatus)
                {
                case DataStatus.New:
                    CountryDal.Add(ItemCode);
                    break;

                case DataStatus.Modified:
                    CountryDal.update(ItemCode);
                    break;

                case DataStatus.Deleted:
                    CountryDal.Delete(ItemCode);
                    return(0);
                }
                return(ItemCode.ID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 19
0
 public GetStreamKeyFromSongIDRequest()
 {
     Country  = new CountryData();
     Mobile   = false;
     Prefetch = true;
     ReturnTS = true;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CountryDetailViewModel"/> class.
 /// </summary>
 /// <param name="country">The item<see cref="CountryData"/>.</param>
 public CountryDetailViewModel(CountryData country)
 {
     this.Title            = country?.CountryName;
     this.Country          = country;
     this.CasesPerMillion  = 1000000 * country.Cases / country.Population;
     this.DeathsPerMillion = 1000000 * country.Deaths / country.Population;
 }
Exemplo n.º 21
0
        public IActionResult GetCountrySalesForecast(string country,
                                                     [FromQuery] int year,
                                                     [FromQuery] int month, [FromQuery] float med,
                                                     [FromQuery] float max, [FromQuery] float min,
                                                     [FromQuery] float prev, [FromQuery] int count,
                                                     [FromQuery] float sales, [FromQuery] float std)
        {
            // Build country sample
            var countrySample = new CountryData(country, year, month, max, min, std, count, sales, med, prev);

            this.logger.LogInformation($"Start predicting");
            //Measure execution time
            var watch = System.Diagnostics.Stopwatch.StartNew();

            CountrySalesPrediction nextMonthSalesForecast = null;

            //Predict
            nextMonthSalesForecast = this.countrySalesModel.Predict(countrySample);

            //Stop measuring time
            watch.Stop();
            long elapsedMs = watch.ElapsedMilliseconds;

            this.logger.LogInformation($"Prediction processed in {elapsedMs} miliseconds");

            return(Ok(nextMonthSalesForecast.Score));
        }
Exemplo n.º 22
0
        public List <CountryData> GetAll()
        {
            List <CountryData> Lvar        = new List <CountryData>();
            CountryData        CountryData = null;
            DbDataReader       reader      = null;

            try
            {
                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyCon"].ConnectionString))
                {
                    SqlCommand command = new SqlCommand("CountryGetAll", connection);
                    connection.Open();
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        CountryData = (CountryData)GetFromReader(reader);
                        Lvar.Add(CountryData);
                    }
                }
                return(Lvar);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                CloseReader(reader);
            }
        }
 protected override void DisplayData()
 {
     CountryData         = logc.GetCountryDataByID(FndNumber.Text);
     FndNumber.Text      = CountryData.Code;
     TXTArabicName.Text  = CountryData.ArabicName;
     TXTEnglishName.Text = CountryData.EnglishName;
 }
Exemplo n.º 24
0
        public CountryData GetCountryDataByID(string ID)
        {
            CountryData  CountryData = new CountryData();
            DbDataReader reader      = null;

            try
            {
                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyCon"].ConnectionString))
                {
                    SqlCommand command = new SqlCommand(String.Format("Select * From Country Where Code = {0}", ID), connection);
                    connection.Open();
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        CountryData = (CountryData)GetFromReader(reader);
                    }
                }
                return(CountryData);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                CloseReader(reader);
            }
        }
Exemplo n.º 25
0
        public override void AddInitData()
        {
            string[,] countryDataArray = CountryData.CountryDataArray();
            if (!countryDataArray.IsNull() && countryDataArray.Length > 0)
            {
                for (int i = 0; i < countryDataArray.Length / 3; i++)
                {
                    string countryName   = countryDataArray[i, 0];
                    string abbrev        = countryDataArray[i, 1];
                    string phoneAreaCode = countryDataArray[i, 2];

                    Country c = Factory() as Country;
                    c.Abbreviation = (abbrev.IsNull() ? abbrev : abbrev.ToUpper());
                    c.Name         = countryName;

                    try
                    {
                        //Create(c);
                        CreateSave_ForInitializeOnly(c);
                    }
                    catch (NoDuplicateException e)
                    {
                        ErrorsGlobal.AddMessage(string.Format("Duplicate entry: '{0}'", c.ToString()), MethodBase.GetCurrentMethod(), e);
                    }
                }
            }
        }
Exemplo n.º 26
0
    protected void Display_AddEdit()
    {
        CountryData cCountry = new CountryData();
        if (m_iID > 0)
        {
            txt_id.Enabled = false;
            cCountry = m_refCountry.GetItem(Convert.ToInt32(this.m_iID));
        }

        txt_name.Text = cCountry.Name;
        txt_id.Text = cCountry.Id.ToString();
        chk_enabled.Checked = cCountry.Enabled;
        txt_long.Text = cCountry.LongIsoCode;
        txt_short.Text = cCountry.ShortIsoCode;

        // tr_id.Visible = (m_iID > 0)
        pnl_view.Visible = true;
        pnl_viewall.Visible = false;

        TotalPages.Visible = false;
        CurrentPage.Visible = false;
        lnkBtnPreviousPage.Visible = false;
        NextPage.Visible = false;
        LastPage.Visible = false;
        FirstPage.Visible = false;
        PageLabel.Visible = false;
        OfLabel.Visible = false;
    }
Exemplo n.º 27
0
        private void AddCriteriaToSessionVar()
        {
            //individual selection criteria
            foreach (LoanInquiryCriteria criteria in this.listCriteria)
            {
                LoanInquiryCriteria inqCriteria = new LoanInquiryCriteria();
                List <Control>      ctrlvalues  = inqCriteria.FindControls(new[] { "loaninquiry", "temp" }, criteria.Controls);

                if (ctrlvalues.Count > 0)
                {
                    ComboBoxData dataName = criteria.DataName;
                    string[]     values   = new string[3];
                    int          i        = 0;

                    //get all non-loaninquiry* objects - these have the values
                    foreach (Control ctrl in ctrlvalues)
                    {
                        switch (ctrl.GetType().Name)
                        {
                        case "State":
                            ComboBox states = (ComboBox)ctrl.Controls[0];
                            USState  state  = (USState)states.SelectedItem;
                            values[i++] = state.ShortName;
                            break;

                        case "Country":
                            ComboBox    countries = (ComboBox)ctrl.Controls[0];
                            CountryData country   = (CountryData)countries.SelectedItem;
                            values[i++] = country.Name;
                            break;

                        case "Gender":
                        case "Race":
                        case "Haircolor":
                        case "EyeColor":
                            ComboBox     list = (ComboBox)ctrl.Controls[0];
                            ComboBoxData item = (ComboBoxData)list.SelectedItem;
                            values[i++] = item.Description;
                            break;

                        case "Zipcode":
                        case "Date":
                            values[i++] = ctrl.Controls[0].Text;
                            break;

                        case "TextBox":
                        case "ComboBox":
                            values[i++] = ctrl.Text;
                            break;
                        }
                    }

                    InquirySelectedCriteria selCriteria = new InquirySelectedCriteria(criteria.loaninquiryDataTypeCombobox.SelectedItem.ToString(),
                                                                                      dataName.Description, dataName.Code, criteria.SearchType,
                                                                                      values, false);

                    GlobalDataAccessor.Instance.DesktopSession.InquirySelectionCriteria.SelectedCriteria.Add(selCriteria);
                }
            }
        }
    void Start()
    {
        string[] dataRows = data.text.Split(new char[] { '\n' });
        Debug.Log(dataRows[dataRows.Length - 1]);

        for (int i = 4; i < dataRows.Length - 1; i++)
        {
            string[]    row   = dataRows[i].Split(new char[] { ';' });
            CountryData cData = new CountryData();

            cData.countryName    = row[0];
            cData.economicStatus = row[1];
            float.TryParse(row[2], out cData.coastalPopulation);
            float.TryParse(row[3], out cData.wasteGenerationPerCapita);
            float.TryParse(row[4], out cData.percentPlasticInWasteStream);
            float.TryParse(row[5], out cData.percentInadequatelyManagedWaste);
            float.TryParse(row[6], out cData.percentLitteredWaste);
            float.TryParse(row[7], out cData.wasteGeneratedPerDay);
            float.TryParse(row[8], out cData.plasticWasteGeneration);
            float.TryParse(row[9], out cData.inadequatelyManagedPlasticPerDay);
            float.TryParse(row[10], out cData.plasticWasteLittered);
            float.TryParse(row[11], out cData.mismanagedPlasticeWaste);
            float.TryParse(row[12], out cData.mismanagedPlastWaste2010);
            float.TryParse(row[13], out cData.mismanagedPlastWaste2020);

            cDataList.Add(cData);
        }
        foreach (CountryData cData in cDataList)
        {
            Debug.Log(cData.countryName);
        }

        // waterColor.SetFloat("_RedValue",cDataList[6].wasteGenerationPerCapita);
        waterColor.SetFloat("_RedValue", currentValue);
    }
Exemplo n.º 29
0
        public void OnPost()
        {
            ViewData["confirmedCases"] = $"Po kliknięciu {country}";

            wc = new WebConnector("https://api.covid19api.com/");
            DateTime t1            = dateFrom;
            DateTime t2            = dateTo;
            string   manyDays      = "";
            string   countryOutput = country;

            countryOutput.ToLower();
            if (t1.Date == t2.Date)
            {
                wc.SetRecentTotalByCountry(countryOutput);
                CountryData cd2 = JsonParser.ExtractListData <CountryData>(wc.Connect())[0];
                ViewData["confirmedCases"] = "Potwierdzone przypadki: " + cd2.Confirmed.ToString();
            }
            else if (DateTime.Compare(t1, t2) < 0)
            {
                wc.SetPeriodTotalByCountry(country, t1, t2);
                List <CountryData> cdl = JsonParser.ExtractListData <CountryData>(wc.Connect());
                int      _c            = 0;
                DateTime tTemp         = t1;
                foreach (CountryData cd in cdl)
                {
                    manyDays += tTemp.AddDays(_c).ToShortDateString() + ": " + cd.Confirmed.ToString() + "\n";
                    _c++;
                }
                ViewData["confirmedCases"] = "Potwierdzone przypadki od " + t1.ToShortDateString() + " do " + t2.ToShortDateString() + " :\n" + manyDays;
            }
            else
            {
                ViewData["confirmedCases"] = $"Data 'Od' jest późniejsza od daty 'Do'!";
            }
        }
Exemplo n.º 30
0
        public async Task <IActionResult> SearchBestPlaceToGo(DestinationModel bestDestination)
        {
            var         shortList        = new List <CountryData>();
            CountryData departureCountry = null;

            try
            {
                switch (bestDestination.Weather)
                {
                //case "Any": { tMax = 100; tMin = -100; }; break;
                //case "Hot": { tMax = 100; tMin = 18; }; break;
                //case "Warm": { tMax = 30; tMin = 12; }; break;
                //case "Cold": { tMax = 15; tMin = -100; }; break;
                default:; break;
                }

                if (!MemoryCache.TryGetValue("GeoCountryList", out List <CountryData> countries))
                {
                    using (var client = new HttpClient())
                    {
                        var countriesString = await client.GetStringAsync(string.Format("{0}/visa/map", Endpoint));

                        countries = JsonConvert.DeserializeObject <List <CountryData> >(countriesString);

                        var memoryCacheOptions = new MemoryCacheEntryOptions()
                                                 .SetAbsoluteExpiration(TimeSpan.FromDays(5));
                        MemoryCache.Set("GeoCountryList", countries, memoryCacheOptions);
                    }
                }

                // first reduction
                departureCountry = countries.FirstOrDefault(c => string.Equals(c.Name, bestDestination.DepartureCountryName, StringComparison.CurrentCultureIgnoreCase));

                //visa free only, planning to do it for any kind of visa, but it doesn't make sense so far
                if (bestDestination.VisaType == "VF")
                {
                    shortList = countries.Where(c => departureCountry.VFCountries.Contains(c.Alpha2Code))
                                .Where(c => c.Region.Equals("World") ||
                                       string.Equals(c.Region, bestDestination.Area, StringComparison.CurrentCultureIgnoreCase))
                                .ToList();
                }
                else
                {
                    shortList = countries.Where(c => c.Region.Equals("World") ||
                                                string.Equals(c.Region, bestDestination.Area, StringComparison.CurrentCultureIgnoreCase))
                                .ToList();

                    shortList.Remove(departureCountry);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Destination exception:" + exception.Message);
            }


            ViewBag.Month = bestDestination.Month == "now" ? "" + DateTime.Now.Month : bestDestination.Month;
            return(View(new BestDestinationDto(shortList, departureCountry)));
        }
        public ActionResult DeleteConfirmed(long id)
        {
            CountryData countryData = db.CountryData.Find(id);

            db.CountryData.Remove(countryData);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 32
0
        private static void Main(string[] args)
        {
            var doc = new XmlDocument();
            doc.Load(@"Resources\countries.xml");
            var nodes = doc.SelectNodes("//person");
            foreach (XmlElement node in nodes)
            {
                Console.WriteLine(node.InnerXml);
            }

            var people = new CountryData<Country>().SelectMany(c => c.Cities).SelectMany(c => c.People);
            Console.WriteLine(string.Join("\n", people.Select(p => p.ToString())));

            Console.ReadLine();
        }
Exemplo n.º 33
0
    protected void Process_AddEdit()
    {
        CountryData cCountry = null;
        if (this.m_iID > 0)
        {
            cCountry = m_refCountry.GetItem(Convert.ToInt32(this.m_iID));
            cCountry.Id = System.Convert.ToInt32(txt_id.Text);
            cCountry.Name = (string)txt_name.Text;
            cCountry.LongIsoCode = (string)txt_long.Text;
            cCountry.ShortIsoCode = (string)txt_short.Text;
            cCountry.Enabled = System.Convert.ToBoolean(chk_enabled.Checked);
            m_refCountry.Update(cCountry);
            Response.Redirect(m_sPageName + "?action=view&id=" + m_iID.ToString(), false);
        }
        else
        {
            try
            {
                cCountry = m_refCountry.GetItem(System.Convert.ToInt32(txt_id.Text));
            }
            catch (Exception)
            {
                if (txt_long.Text.Length != 3)
                {
                    uxMessage.DisplayMode = Message.DisplayModes.Error;
                    uxMessage.Visible = true;
                    uxMessage.Text = GetMessage("lbl Long Iso Length");
                    return;
                }
                if (txt_short.Text.Length != 2)
                {
                    uxMessage.DisplayMode = Message.DisplayModes.Error;
                    uxMessage.Visible = true;
                    uxMessage.Text = GetMessage("lbl Short Iso Length"); ;
                    return;
                }
                cCountry = new CountryData(0, txt_name.Text, txt_short.Text, txt_long.Text, chk_enabled.Checked);
            }

            if ((cCountry != null) && cCountry.Id > 0)
            {
                throw (new Exception(GetMessage("lbl country dupe")));
            }
            else
            {
                cCountry.Id = System.Convert.ToInt32(txt_id.Text);
            }
            cCountry.Name = (string)txt_name.Text;
            try
            {
                m_refCountry.Add(cCountry);

                Response.Redirect(m_sPageName, false);
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("unique key") > -1)
                {
                    Utilities.ShowError(GetMessage("lbl country dupe"));
                }
                else
                {
                    Utilities.ShowError(ex.Message);
                }
            }
        }

        TotalPages.Visible = false;
        CurrentPage.Visible = false;
        lnkBtnPreviousPage.Visible = false;
        NextPage.Visible = false;
        LastPage.Visible = false;
        FirstPage.Visible = false;
        PageLabel.Visible = false;
        OfLabel.Visible = false;
    }
Exemplo n.º 34
0
    protected void Display_AddEdit()
    {
        CountryData cCountry = new CountryData();
        Ektron.Cms.Common.Criteria<TaxClassProperty> TaxClasscriteria = new Ektron.Cms.Common.Criteria<TaxClassProperty>(TaxClassProperty.Name, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        System.Collections.Generic.List<TaxClassData> TaxClassList = new System.Collections.Generic.List<TaxClassData>();

        TaxClassList = _TaxClassApi.GetList(TaxClasscriteria);
        _TaxApi = new TaxApi();

        if (m_iID > 0)
        {
            cCountry = _CountryApi.GetItem(Convert.ToInt32(this.m_iID));
            txt_name.Enabled = false;
            chk_enabled.Enabled = false;
            txt_long.Enabled = false;
            txt_short.Enabled = false;
            txt_numeric.Text = this.m_iID.ToString();
            txt_numeric.Enabled = false;
        }

        Util_BindCountries();

        txt_name.Text = cCountry.Name;
        lbl_id.Text = cCountry.Id.ToString();
        chk_enabled.Checked = cCountry.Enabled;
        txt_long.Text = cCountry.LongIsoCode;
        txt_short.Text = cCountry.ShortIsoCode;

        int txtClassList = 0;

        ltr_txtClass.Text = "<table class=\"ektronGrid\">";
        for (txtClassList = 0; txtClassList <= TaxClassList.Count - 1; txtClassList++)
        {
            ltr_txtClass.Text += "<tr>";
            ltr_txtClass.Text += "   <td class=\"label\">";
            ltr_txtClass.Text += "       <label id=\"taxClass" + txtClassList + "\" value=\"" + TaxClassList[txtClassList].Name + "\">" + TaxClassList[txtClassList].Name + ":</label>";
            ltr_txtClass.Text += "   </td>";
            if (_TaxApi.GetItemByCountryId(TaxClassList[txtClassList].Id, cCountry.Id) == null)
            {
                ltr_txtClass.Text += "   <td class=\"value\">";
                ltr_txtClass.Text += "       <input type=\"text\" name=\"txtClassRate" + txtClassList + "\" id=\"txtClassRate" + txtClassList + "\" value=\"0\" />%";
                ltr_txtClass.Text += "   </td>";
            }
            else
            {
                ltr_txtClass.Text += "   <td class=\"value\">";
                ltr_txtClass.Text += "       <input type=\"text\" name=\"txtClassRate" + txtClassList + "\" id=\"txtClassRate" + txtClassList + "\" value=\"" + _TaxApi.GetItemByCountryId(TaxClassList[txtClassList].Id, cCountry.Id).Rate * 100 + "\"/>%";
                ltr_txtClass.Text += "   </td>";
            }
            ltr_txtClass.Text += "<td >";
            ltr_txtClass.Text += "</td>";
            ltr_txtClass.Text += "</tr>";
        }
        ltr_txtClass.Text += "</table>";

        tr_id.Visible = m_iID > 0;
        pnl_view.Visible = true;
        pnl_viewall.Visible = false;

        TotalPages.Visible = false;
        CurrentPage.Visible = false;
        lnkBtnPreviousPage.Visible = false;
        NextPage.Visible = false;
        LastPage.Visible = false;
        FirstPage.Visible = false;
        PageLabel.Visible = false;
        OfLabel.Visible = false;
    }
Exemplo n.º 35
0
    protected void Process_AddEdit()
    {
        CountryData cCountry = null;
        TaxRateData tTax = null;
        Ektron.Cms.Common.Criteria<TaxClassProperty> TaxClasscriteria = new Ektron.Cms.Common.Criteria<TaxClassProperty>(TaxClassProperty.Name, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);
        System.Collections.Generic.List<TaxClassData> TaxClassList = new System.Collections.Generic.List<TaxClassData>();
        Ektron.Cms.Commerce.CountryTaxRateData m_CountryTax = new Ektron.Cms.Commerce.CountryTaxRateData();
        TaxClassList = _TaxClassApi.GetList(TaxClasscriteria);
        m_CountryTax = new CountryTaxRateData();
        _TaxApi = new TaxApi();

        if (this.m_iID > 0)
        {
            cCountry = _CountryApi.GetItem(Convert.ToInt32(this.m_iID));
            cCountry.Name = (string)txt_name.Text;
            cCountry.LongIsoCode = (string)txt_long.Text;
            cCountry.ShortIsoCode = (string)txt_short.Text;
            cCountry.Enabled = System.Convert.ToBoolean(chk_enabled.Checked);
            _CountryApi.Update(cCountry);

            for (int i = 0; i <= TaxClassList.Count - 1; i++)
            {
                tTax = _TaxApi.GetItemByCountryId(TaxClassList[i].Id, cCountry.Id);
                if (tTax == null)
                {
                    tTax = new CountryTaxRateData(cCountry.Id, TaxClassList[i].Id, 0);
                    if (Information.IsNumeric(Request.Form["txtClassRate" + i]))
                    {
                        tTax.Rate = System.Convert.ToDecimal(Convert.ToDecimal(Request.Form["txtClassRate" + i]) / 100);
                        _TaxApi.Add(tTax);
                    }
                }
                else
                {
                    if (Information.IsNumeric(Request.Form["txtClassRate" + i]))
                    {
                        tTax.Rate = System.Convert.ToDecimal(Convert.ToDecimal(Request.Form["txtClassRate" + i]) / 100);
                        _TaxApi.Update(tTax);
                    }
                }
            }

            Response.Redirect(_PageName + "?action=view&id=" + m_iID.ToString(), false);
        }
        else
        {
            cCountry = new CountryData(Convert.ToInt32(txt_numeric.Text), txt_name.Text, txt_short.Text, txt_long.Text, chk_enabled.Checked);
            _CountryApi.Add(cCountry);

            for (int i = 0; i <= TaxClassList.Count - 1; i++)
            {
                tTax = new CountryTaxRateData(cCountry.Id, TaxClassList[i].Id, 0);
                if (Information.IsNumeric(Request.Form["txtClassRate" + i]))
                {
                    tTax.Rate = System.Convert.ToDecimal(Convert.ToDecimal(Request.Form["txtClassRate" + i]) / 100);
                    _TaxApi.Add(tTax);
                }
            }

            Response.Redirect(_PageName, false);
        }

        TotalPages.Visible = false;
        CurrentPage.Visible = false;
        lnkBtnPreviousPage.Visible = false;
        NextPage.Visible = false;
        LastPage.Visible = false;
        FirstPage.Visible = false;
        PageLabel.Visible = false;
        OfLabel.Visible = false;
    }
Exemplo n.º 36
0
    protected void Process_AddEdit()
    {
        WarehouseData wareHouse = null;
        m_refWarehouse = new WarehouseApi();

        if (this.m_iID > 0)
        {
            wareHouse = m_refWarehouse.GetItem(this.m_iID);
        }

        RegionData rData;
        rData = new RegionData();
        rData = m_refRegion.GetItem(Convert.ToInt64(drp_address_region.SelectedValue));

        CountryData cData;
        cData = new CountryData();
        cData = m_refCountry.GetItem(System.Convert.ToInt32(drp_address_country.SelectedValue));

        if (this.m_iID == 0)
        {
            wareHouse = new WarehouseData(txt_address_name.Text, new AddressData());
        }

        wareHouse.Name = (string)txt_address_name.Text;

        if (this.m_iID > 0)
        {
            wareHouse.Id = Convert.ToInt64(lbl_address_id.Text);
        }

        wareHouse.Address.AddressLine1 = (string)txt_address_line1.Text;
        wareHouse.Address.AddressLine2 = (string)txt_address_line2.Text;
        wareHouse.Address.City = (string)txt_address_city.Text;
        if (wareHouse.Address.Region == null)
        {
            wareHouse.Address.Region = new RegionData();
        }
        wareHouse.Address.Region.Id = Convert.ToInt64(drp_address_region.SelectedValue);
        wareHouse.Address.PostalCode = (string)txt_address_postal.Text;
        if (wareHouse.Address.Country == null)
        {
            wareHouse.Address.Country = new CountryData();
        }
        wareHouse.Address.Country.Id = System.Convert.ToInt32(drp_address_country.SelectedValue);
        wareHouse.IsDefaultWarehouse = System.Convert.ToBoolean(chk_default_warehouse.Checked);

        if (this.m_iID > 0)
        {
            m_refWarehouse.Update(wareHouse);
            Response.Redirect(m_sPageName + "?action=view&id=" + this.m_iID.ToString(), false);
        }
        else
        {
            m_refWarehouse.Add(wareHouse);
            Response.Redirect(m_sPageName, false);
        }
    }
Exemplo n.º 37
0
    // COUNTRY_DATA <-> COUNTRY
    public static CountryData fromComponent(Country country)
    {
        if (country == null) {
            return null;
        }

        CountryData countryData = new CountryData();
        countryData.descriptorData = fromComponent(country.descriptor);
        return countryData;
    }
Exemplo n.º 38
0
 public static void toComponent(CountryData countryData, Country country)
 {
     toComponent(countryData.descriptorData, country.descriptor);
 }
Exemplo n.º 39
0
    protected void Process_ViewAddress()
    {
        AddressData aAddress = null;
        long originalAddressId = this.m_iID;

        //need to get customer before address update to see if default addresses have changed.
        cCustomer = CustomerManager.GetItem(m_iCustomerId);
        aAddress = this.m_iID > 0 ? (AddressManager.GetItem(this.m_iID)) : (new AddressData());

        aAddress.Name = (string)txt_address_name.Text;
        aAddress.Company = (string)txt_address_company.Text;
        aAddress.AddressLine1 = (string)txt_address_line1.Text;
        aAddress.AddressLine2 = (string)txt_address_line2.Text;
        aAddress.City = (string)txt_address_city.Text;
        RegionData rData = new RegionData();
        rData.Id = Convert.ToInt64(drp_address_region.SelectedValue);
        aAddress.Region = rData;
        aAddress.PostalCode = (string)txt_address_postal.Text;
        CountryData cData = new CountryData();
        cData.Id = System.Convert.ToInt32(drp_address_country.SelectedValue);
        aAddress.Country = cData;
        aAddress.Phone = (string)txt_address_phone.Text;

        if (this.m_iID > 0)
        {
            AddressManager.Update(aAddress);
        }
        else
        {
            AddressManager.Add(aAddress, m_iCustomerId);
        }

        this.m_iID = aAddress.Id;

        bool updateBilling = false;
        bool updateShipping = false;

        if (chk_default_billing.Checked)
        {
            cCustomer.BillingAddressId = aAddress.Id;
            updateBilling = true;
        }

        if (chk_default_shipping.Checked)
        {
            cCustomer.ShippingAddressId = aAddress.Id;
            updateShipping = true;
        }

        //if the default addresses have been unchecked - need to reset them to 0.
        if (!chk_default_billing.Checked && cCustomer.BillingAddressId == originalAddressId)
        {
            cCustomer.BillingAddressId = 0;
            updateBilling = true;
        }

        if (!chk_default_shipping.Checked && cCustomer.ShippingAddressId == originalAddressId)
        {
            cCustomer.ShippingAddressId = 0;
            updateShipping = true;
        }

        if (updateBilling)
        {
            CustomerManager.ChangeBillingAddress(m_iCustomerId, cCustomer.BillingAddressId);
        }
        if (updateShipping)
        {
            CustomerManager.ChangeShippingAddress(m_iCustomerId, cCustomer.ShippingAddressId);
        }

        string pagemode = (string)("&page=" + Request.QueryString["page"]);
        Response.Redirect(this.m_sPageName + "?action=viewaddress&id=" + this.m_iID.ToString() + "&customerid=" + this.m_iCustomerId.ToString() + pagemode, false);
    }