private void WriteSyncAttemptToDisk(int deploymentId, string mac, DeviceSyncAttempt attempt)
        {
            try
            {
                Java.IO.File sdCard = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads);
                Java.IO.File dir    = new Java.IO.File($"{ sdCard.AbsolutePath }/ThinkActive/Deployments/{deploymentId.ToString()}/{attempt.deploymentUserId}/{mac}/");


                if (!dir.Exists())
                {
                    dir.Mkdirs();
                }

                Java.IO.File file = new Java.IO.File(dir, $"{ (DateTime.UtcNow.ToString("s") + "Z").Replace(':', '-') + "-" + attempt.deploymentUserId.ToString() + "-" + mac}.json");

                if (!file.Exists())
                {
                    Java.IO.FileWriter writer = new Java.IO.FileWriter(file);
                    writer.Write(JsonConvert.SerializeObject(attempt));
                    writer.Flush();
                    writer.Close();
                }
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
                Crashes.TrackError(e);
            }
        }
예제 #2
0
 private void saveFl(string texto)
 {
     Java.IO.File sdCard = Android.OS.Environment.ExternalStorageDirectory;
     Java.IO.File dir    = new Java.IO.File(sdCard.AbsolutePath + "/SonryVitaMote");
     dir.Mkdirs();
     Java.IO.File file = new Java.IO.File(dir, "ip.scf");
     if (!file.Exists())
     {
         file.CreateNewFile();
         file.Mkdir();
         Java.IO.FileWriter writer = new Java.IO.FileWriter(file);
         writer.Write(texto);
         writer.Flush();
         writer.Close();
         Toast.MakeText(this, "Successfully Saved", ToastLength.Long).Show();
     }
     else
     {
         Java.IO.FileWriter writer = new Java.IO.FileWriter(file);
         writer.Write(texto);
         writer.Flush();
         writer.Close();
         Toast.MakeText(this, "Successfully Edited", ToastLength.Long).Show();
     }
 }
예제 #3
0
        /// <summary>
        /// Writes log in csv format.
        /// </summary>
        public void WriteLogData()
        {
            if (mSocketConnection.LogData != null)
            {
                RemoveFolder();
                string dirName = "";
                if (mLoggingActive)
                {
                    DateTime time = DateTime.Now;
                    dirName = string.Format("{0}{1:D2}{2:D2}_{3:D2}{4:D2}{5:D2}", time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second);
                    var storageDir = new Java.IO.File(MainActivity.ApplicationFolderPath + Java.IO.File.Separator + dirName);
                    var logWriter  = new Java.IO.FileWriter(new Java.IO.File(storageDir, "controls.csv"));
                    storageDir.Mkdirs();
                    logWriter.Write(mSocketConnection.LogData);
                    logWriter.Close();
                }

                mPeerSettings[mSelectedMac] = ControllerView.Settings;
                dirName = MainActivity.ApplicationFolderPath + Java.IO.File.Separator + "settings";
                string settingsString = "";
                foreach (KeyValuePair <string, ControllerSettings> kvp in mPeerSettings)
                {
                    settingsString += kvp.Key + "," + kvp.Value.TrimYaw + ";" + kvp.Value.TrimPitch + ";" + kvp.Value.TrimRoll + ";"
                                      + (mLoggingActive ? "true" : "false") + ";" + mMinYaw + ";" + mMaxYaw + ";" + mMinPitch + ";"
                                      + mMaxPitch + ";" + mMinRoll + ";" + mMaxRoll + "\n";
                }

                var settingsWriter = new Java.IO.FileWriter(new Java.IO.File(dirName, "settings.csv"));
                settingsWriter.Write(settingsString);
                settingsWriter.Close();
            }
        }
예제 #4
0
        private void saveCM()
        {
            string cmtxt = (int)allM [(int)s1.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s2.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s3.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s4.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s5.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s6.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s7.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s8.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s9.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s10.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s11.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s12.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s13.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s14.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s15.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s16.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s17.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s18.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s19.SelectedItemId] + System.Environment.NewLine + (int)allM [(int)s20.SelectedItemId];

            Java.IO.File sdCard = Android.OS.Environment.ExternalStorageDirectory;
            Java.IO.File dir    = new Java.IO.File(sdCard.AbsolutePath + "/SonryVitaMote");
            dir.Mkdirs();
            Java.IO.File file = new Java.IO.File(dir, "cm.scf");
            if (!file.Exists())
            {
                file.CreateNewFile();
                file.Mkdir();
                Java.IO.FileWriter writer = new Java.IO.FileWriter(file);
                writer.Write(cmtxt);
                writer.Flush();
                writer.Close();
            }
            else
            {
                Java.IO.FileWriter writer = new Java.IO.FileWriter(file);
                writer.Write(cmtxt);
                writer.Flush();
                writer.Close();
                Toast.MakeText(this, "Successfully Saved", ToastLength.Long).Show();
            }
        }
예제 #5
0
        public void Write()
        {
            DateTime time      = DateTime.Now;
            string   fileName  = string.Format("{0}{1:D2}{2:D2}_{3:D2}{4:D2}{5:D2}", time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second);
            var      logWriter = new Java.IO.FileWriter(new Java.IO.File(MainActivity.ApplicationFolderPath + Java.IO.File.Separator + "wifi", fileName + ".csv"));
            string   title     = $"Log from {fileName}\nBytes: {mBytes}\nRepetitions: {mRepetitions}\nDelay: {mDelay}\n\n";

            logWriter.Write(title);
            logWriter.Flush();
            foreach (Data wd in mResults)
            {
                logWriter.Write(wd.ToString());
                logWriter.Flush();
            }
            logWriter.Close();
        }
        protected override void OnDestroy()
        {
            base.OnDestroy();
            DateTime time    = DateTime.Now;
            string   logName = string.Format("{0}{1:D2}{2:D2}_{3:D2}{4:D2}{5:D2}_log", time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second);
            var      writer  = new Java.IO.FileWriter(new Java.IO.File(mStorageDirPath, logName + ".csv"));

            writer.Write(DataTransfer.DEBUG);
            ConnectedThread.Cancel();
            writer.Close();
        }
예제 #7
0
#pragma warning disable CS0162, IDE0060 // Unreachable code detected

        public void LogFile(string data, bool nextLine = true)
        {
            if (!LOG_STARTUP_DATA)
            {
                return;
            }
            string path = GetPath(true, "/cloudstreamlog.txt");
            var    file = new Java.IO.File(path);

            if (!file.Exists())
            {
                file.CreateNewFile();
            }
            Java.IO.FileWriter writer = new Java.IO.FileWriter(file, true);
            writer.Write(data + (nextLine ? "\n" : ""));
            writer.Flush();
            writer.Close();
        }
예제 #8
0
        public void btnAdd_OnClick(object sender, EventArgs e)
        {
            //get EditText txtTask from view
            EditText txtTask = FindViewById <EditText>(Resource.Id.txtTask);

            //create new task
            Todo objNewTask = new Todo(txtTask.Text)
            {
                Location = "", Time = DateTime.Now.Ticks.ToString()
            };

            TodoBL       objTodoBL       = new TodoBL();
            IList <Todo> currentListTodo = new List <Todo>();

            //get output stream file to write
            using (Stream readStream = this.OpenFileInput(new MainActivity().filePath))
            {
                //get current list task
                currentListTodo = objTodoBL.GetAllTask(readStream);
                currentListTodo.Add(objNewTask);

                readStream.Close();
            }

            Java.IO.File dataFile = this.GetFileStreamPath(new MainActivity().filePath);

            //clear current content file data
            using (Java.IO.FileOutputStream fileOutput = new Java.IO.FileOutputStream(dataFile.AbsolutePath, false))
            {
                Java.IO.FileWriter fWriter = new Java.IO.FileWriter(fileOutput.FD);
                fWriter.Write(string.Empty);
                fWriter.Flush();
                fWriter.Close();
            }



            Stream writeStream = this.OpenFileOutput(new MainActivity().filePath, FileCreationMode.Append);

            objTodoBL.AddTask(currentListTodo, writeStream);

            //return previous activity
            this.Finish();
        }
예제 #9
0
        /// <summary>
        /// Writes log in csv format to mobile storage.
        /// Saves user options
        /// </summary>
        private void WriteLogData()
        {
            if (mSocketConnection.LogData != null)
            {
                RemoveFolder();
                string dirName = "";
                if (mLoggingActive)
                {
                    DateTime time = DateTime.Now;
                    dirName = string.Format("{0}{1:D2}{2:D2}_{3:D2}{4:D2}{5:D2}", time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second);
                    var storageDir = new Java.IO.File(MainActivity.ApplicationFolderPath + Java.IO.File.Separator + dirName);
                    storageDir.Mkdirs();
                    var logWriter = new Java.IO.FileWriter(new Java.IO.File(storageDir, "controls.csv"));
                    logWriter.Write(mSocketConnection.LogData);
                    logWriter.Close();
                    foreach (KeyValuePair <string, LogData> kvp in mSocketConnection.DroneLogs)
                    {
                        var writer = new Java.IO.FileWriter(new Java.IO.File(storageDir, kvp.Key + ".csv"));
                        writer.Write(kvp.Value.ToString());
                        writer.Close();
                    }
                }
                mPeerSettings[mSelectedBssid] = ControllerView.Settings;
                dirName = MainActivity.ApplicationFolderPath + Java.IO.File.Separator + "settings";
                string settingsString = "";
                foreach (KeyValuePair <string, ControllerSettings> kvp in mPeerSettings)
                {
                    settingsString += kvp.Key + "," + kvp.Value.TrimYaw + ";" + kvp.Value.TrimPitch + ";" + kvp.Value.TrimRoll + ";"
                                      + mLoggingActive + ";" + mLogBatteryActive + ";" + mLogRadarActive + ";" + mLogCollisionStatusActive + ";"
                                      + mLogControlsMobileActive + ";" + mLogControlsDroneActive + ";" + mLogDebug1Active + ";"
                                      + mLogDebug2Active + ";" + mLogDebug3Active + ";" + mLogDebug4Active + ";" + mMinYaw + ";" + mMaxYaw + ";"
                                      + mMinPitch + ";" + mMaxPitch + ";" + mMinRoll + ";" + mMaxRoll + "\n";;
                }

                var settingsWriter = new Java.IO.FileWriter(new Java.IO.File(dirName, "settings.csv"));
                settingsWriter.Write(settingsString);
                settingsWriter.Close();
            }
        }
예제 #10
0
        public static Java.IO.File WriteFile(string name, string basePath, string write)
        {
            try {
                File.Delete(basePath + "/" + name);
            }
            catch (System.Exception) {
            }
            //name = Regex.Replace(name, @"[^A-Za-z0-9\.]+", String.Empty);
            //name.Replace(" ", "");
            //  name = name.ToLower();

            Java.IO.File file  = new Java.IO.File(basePath, name);
            Java.IO.File _file = new Java.IO.File(basePath);
            CloudStreamCore.print("PATH: " + basePath + "/" + name);
            _file.Mkdirs();
            file.CreateNewFile();
            Java.IO.FileWriter writer = new Java.IO.FileWriter(file);
            // Writes the content to the file
            writer.Write(write);
            writer.Flush();
            writer.Close();
            return(file);
        }
 public bool WriteData(string address, string data, EFolders eFolders)
 {
     try
     {
         address = CombineFolderPath(address, eFolders);
         JFile file = new JFile(address);
         if (file.IsFile && file.CanWrite())
         {
             Java.IO.FileWriter writer = new Java.IO.FileWriter(file);
             writer.Write(data);
             writer.Flush();
             writer.Close();
             writer.Dispose();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(false);
     //throw new NotImplementedException();
 }
예제 #12
0
        public void CheckAndCopyAseetinfos()
        {
#if PAndroid
            if (CheckGameResInfosSD())
            {
                return;
            }

            Java.IO.File path = new Java.IO.File(EngineNS.CEngine.Instance.FileManager.ProjectContent);
            if (!path.Exists())
            {
                path.Mkdirs();
            }

            //path.Close();
            string       filename = EngineNS.CEngine.Instance.FileManager.ProjectContent + "assetinfos.txt";
            Java.IO.File file     = new Java.IO.File(EngineNS.CEngine.Instance.FileManager.ProjectContent, "assetinfos.xml");
            try
            {
                file.CreateNewFile();
                //file.Close();
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            Java.IO.FileWriter fw = new Java.IO.FileWriter(EngineNS.CEngine.Instance.FileManager.ProjectContent + "assetinfos.xml");

            byte[] xmlcode = FileManager.ReadFile("Content/assetinfos.xml");
            string str     = System.Text.Encoding.ASCII.GetString(xmlcode);

            fw.Write(str, 0, str.Length);
            fw.Flush();
            fw.Close();
#endif
        }
예제 #13
0
        private void WriteTextFile()
        {
            var sdCardPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
            var filePath = System.IO.Path.Combine(sdCardPath, "MyTextFile.txt");

            using (Java.IO.FileWriter writer = new Java.IO.FileWriter(filePath, true))
            {
                writer.Write(DateTime.Now + ", " + service.getLocation().Latitude + ", " + service.getLocation().Longitude + " / n");
                FileText.Text = SaveData.writeData(DateTime.Now, service.getLocation());
                writer.Flush();
                writer.Close();
            }
        }