Ejemplo n.º 1
0
        bool ProcessExportData()
        {
            bool worked = false;

            if (ExampleList.Count > 0)
            {
                try
                {
                    string dirName = DependencyService.Get <IFile>().GetDirectory();
                    System.Diagnostics.Debug.WriteLine("Excel directory name: " + dirName);
                    System.Diagnostics.Debug.Flush();

                    string filespec = DependencyService.Get <IFile>().GenerateFilespec(dirName, ExampleModel.EXPORT_FILENAME);

                    System.Diagnostics.Debug.WriteLine("Excel filespec: " + filespec);
                    System.Diagnostics.Debug.Flush();

                    GenerateSpeadsheet generateSpeadsheet = new GenerateSpeadsheet();

                    worked = generateSpeadsheet.CreateSpeadsheet(filespec, WORKSHEET_NAME, ExampleList);

                    if (worked)
                    {
                        worked = DependencyService.Get <IFile>().SetDownload(dirName, ExampleModel.EXPORT_FILENAME, "example desc");
                        if (worked)
                        {
                            MessagingCenter.Send(this, "DataExportedSuccessfully");
                            System.Diagnostics.Debug.WriteLine("Export successful.");
                            System.Diagnostics.Debug.Flush();
                        }
                        else
                        {
                            MessagingCenter.Send(this, "DataDownloadFolderFailed");
                            System.Diagnostics.Debug.WriteLine("Set download directory failed.");
                            System.Diagnostics.Debug.Flush();
                        }
                    }
                    else
                    {
                        MessagingCenter.Send(this, "DataExportFailure");
                        System.Diagnostics.Debug.WriteLine("Create example spreadsheet failed");
                        System.Diagnostics.Debug.Flush();
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message);
                    System.Diagnostics.Debug.Flush();
                }
            }
            else
            {
                MessagingCenter.Send(this, "NoDataToExport");
                worked = true;
            }

            return(worked);
        }
Ejemplo n.º 2
0
        public void Test1()
        {
            ExampleModel example = new ExampleModel();

            GenerateSpeadsheet generateSpeadsheet = new GenerateSpeadsheet();

            bool worked = generateSpeadsheet.CreateSpeadsheet(GetFilename(), "test", example.ExportList);

            Assert.True(worked);
        }