Beispiel #1
0
 public ProviderBase()
 {
     _localizationDataProvider = new LocalizationDataProvider();
     _appsDataProvider = new AppsDataProvider();
     _facebookDataProvider = new FacebookDataProvider();
     _userDataProvider = new UserDataProvider();
     _userFavoritesDataProvider = new UserFavoritesDataProvider();
     _userMessagesDataProvider = new UserMessagesDataProvider();
     _userVisitsDataProvider = new UserVisitsDataProvider();
     _userLikesDataProvider = new UserLikesDataProvider();
     _geoIpDataProvider = new GeoIpDataProvider();
 }
Beispiel #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            //WebRequest req = HttpWebRequest.Create("http://dataservice.datingbook.com/get_local");
            //req.Method = "POST";
            //req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
            //using (var dataStream = req.GetRequestStream())
            //{
            //    var bytes = Encoding.UTF8.GetBytes("lang=IL");
            //    dataStream.Write(bytes, 0, bytes.Length);
            //}

            //HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            //StreamReader reader = new StreamReader(res.GetResponseStream(), Encoding.UTF8);

            string localizedStr = File.ReadAllText(@"E:\dev\Dating\DatingBook\trunk\DatingBook.Web.DataService\static\local\local_en.json");
            //reader.ReadToEnd();
            //reader.Close();
            var localized = Newtonsoft.Json.Linq.JObject.Parse(localizedStr);

            LocalizationDataProvider prov = new LocalizationDataProvider();
            foreach (JProperty local in localized["data"])
            {
                //local.Value
                Translation trans = new Translation()
                {
                    Options = new List<TransKeyVal>(),
                    Value = local.Name
                };
                foreach (JObject val in local)
                {
                    foreach (var prop in val.Properties())
                    {
                        if (prop.Name == "label")
                        {
                            trans.Value = prop.Value.ToString();
                        }
                        else
                        {
                            trans.Options.Add(new TransKeyVal()
                            {
                                Key = prop.Name,
                                Value = prop.Value.ToString()
                            });
                        }
                    }
                }

                prov.UpsertTranslation("gokapara-newyork", local.Name, "english", trans);
            }
        }