Exemple #1
0
        public void googleFreeTranslation()
        {
            // https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl={langtotranslate}&hl={originlang}&dt=t&dt=bd&dj=1&source=icon&q={text}

            translations = new languageTranslations(stateCore);
            if (langToTranslate.Equals(""))
            {
                langToTranslate = stateCore.defaultTranslatedLang;
            }

            if (originLang.Equals(""))
            {
                originLang = stateCore.currentLang;
            }

            translated = "";
            string str = originalTextToTranslate;
            int    idx = str.IndexOf(Environment.NewLine + " _________________________" + Environment.NewLine);

            if (idx > 0)
            {
                str = str.Substring(0, idx);
            }
            // these chars are allowed   !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
            str = str.Replace(Environment.NewLine, "#$%@# ").Replace(".", "#$%@# ");
            string url = stateCore.addons("translation")("url").Replace("{langtotranslate}", langToTranslate).Replace("{originlang}", originLang).Replace("{text}", Uri.EscapeDataString(str)).Replace("{key}", stateCore.addons("translation")("key"));

            HttpDataRequestGoogleFree = new HttpDataGetData(stateCore, url);
            HttpDataRequestGoogleFree.initialize();
            HttpDataRequestGoogleFree.loadQueue(default, default, default);
Exemple #2
0
 /* TODO ERROR: Skipped EndRegionDirectiveTrivia */
 /* TODO ERROR: Skipped RegionDirectiveTrivia */
 public void loadLocation()
 {
     changeDataLoadedState(true);
     loadIpAddressData = new HttpDataGetData(enVars, "https://api.ipify.org");
     loadIpAddressData.initialize();
     loadIpAddressData.startRequest();
 }
Exemple #3
0
        /* TODO ERROR: Skipped EndRegionDirectiveTrivia */
        /* TODO ERROR: Skipped RegionDirectiveTrivia */
        private void sendCrashReports()
        {
            taskManager.setStatus("checkUpdates", Conversions.ToInteger(tasksManager.tasksManagerClass.BUSY));

            // TODO: send encryped and auth crach reports plus add latency time on more
            var crashFile = new FileInfo(Path.Combine(state.basePath, "crash.log"));

            crashFile.Refresh();
            if (crashFile.Exists & state.SendDiagnosticData && BasicLibraries.FileManagementLib.FileInUse(Path.Combine(state.basePath, "crash.log")))
            {
                updateStatusMessage?.Invoke(this, "sending crash report data...");
                string report = My.MyProject.Computer.FileSystem.ReadAllText(Path.Combine(state.basePath, "crash.log"), System.Text.Encoding.UTF8);
                var    logs   = Strings.Split(report, "-------------end report---------------");
                sendCrashData = new HttpDataGetData(state, state.customization.crashReportServerAddr);
                sendCrashData.initialize();
                for (int i = 0, loopTo = logs.Length - 1; i <= loopTo; i++)
                {
                    if (logs[i].Replace(" ", "").Replace(System.Environment.NewLine, "").Equals(""))
                    {
                        continue;
                    }

                    var vars = new Dictionary <string, string>();
                    vars.Add("uuid", state.userId);
                    vars.Add("report", Uri.EscapeDataString(logs[i]));
                    sendCrashData.loadQueue(vars, null, state.libraryPath);
                }

                sendCrashData.startRequest();
            }
            else
            {
                taskManager.setStatus("checkUpdates", Conversions.ToInteger(tasksManager.tasksManagerClass.FINISHED));
            }
        }
Exemple #4
0
        private void loadIpAddressData_dataArrived(object sender, string responseData, Dictionary <string, string> misc)
        {
            IPAddress _ip = null;

            if (IPAddress.TryParse(responseData, out _ip).Equals(true))
            {
                enVars.currentIpAddress = responseData;
                loadLocationCoordinates = new HttpDataGetData(enVars, "http://ip-api.com/json/" + responseData);
                loadLocationCoordinates.initialize();
                loadLocationCoordinates.startRequest();
            }
        }
Exemple #5
0
 private void loadLocationCoordinates_dataArrived(object sender, string responseData, Dictionary <string, string> misc)
 {
     AeonLabs.Environment.environmentVarsCore.locationDataStructure locationDataItem;
     locationDataItem = enVars.locationData;
     try
     {
         var jsonLatResult = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseData);
         if (jsonLatResult.ContainsKey("lat") & jsonLatResult.ContainsKey("lon"))
         {
             locationDataItem.latitude  = jsonLatResult["lat"].ToString().Replace(",", ".");
             locationDataItem.longitude = jsonLatResult["lon"].ToString().Replace(",", ".");
             enVars.locationData        = locationDataItem;
             loadLocationData           = new HttpDataGetData(enVars, "http://nominatim.openstreetmap.org/reverse?format=json&lat=" + enVars.locationData.latitude + "&lon=" + enVars.locationData.longitude + "&zoom=18&addressdetails=1");
             loadLocationData.initialize();
             loadLocationData.startRequest();
         }
     }
     catch (Exception ex)
     {
         changeDataLoadedState(false, LOAD_LOCATION);
         enVars.stateErrorMessage = ex.ToString();
     }
 }