Exemple #1
0
        public static async Task SendEmail(string subject, string body, List <string> recipients, string imagePath = "")
        {
            try
            {
                ExperimentalFeatures.Enable(ExperimentalFeatures.EmailAttachments, ExperimentalFeatures.ShareFileRequest);

                var message = new EmailMessage
                {
                    Subject = subject,
                    Body    = body,
                    To      = recipients
                };

                if (imagePath != "")
                {
                    message.Attachments.Add(new EmailAttachment(imagePath));
                }

                await Email.ComposeAsync(message);
            }
            catch
            {
                // Email is not supported on this device
                await App.Current.MainPage.DisplayAlert("Error", "Emailing is not support on this device", "OK");
            }
        }
        public App()
        {
            ExperimentalFeatures.Enable("AppTheme_Experimental", "Shapes_Experimental");
            InitializeComponent();

            Microsoft.AppCenter.AppCenter
            .Start(Configs.AppCenter,
                   typeof(Analytics),
                   typeof(Crashes));

            ThemeControl.Update();
            //FontRegistry.RegisterFonts(FontAwesomeSolid.Font);

            this.StartInjecting()
            .SetInitialPage <SignUpPage>()


            .SetViewModelAssembly(typeof(ViewModelBase).Assembly)

            .AddHttpClient <IApiConsumer, ApiConsumer>(c
                                                       => c.BaseAddress = new Uri(Configs.Endpoint),
                                                       builder => builder.ConfigurePrimaryHttpMessageHandler <ApiHttpHandler>())

            .AddTransient <ApiHttpHandler>()
            .AddTransient <IThemeControl, ThemeControl>()

            .Build();
        }
Exemple #3
0
 public static void EnableExperimentalFeatures()
 {
     ExperimentalFeatures.Enable(
         ExperimentalFeatures.EmailAttachments,
         ExperimentalFeatures.ShareFileRequest,
         ExperimentalFeatures.OpenFileRequest);
 }
        public App()
        {
            InitializeComponent();

            ExperimentalFeatures.Enable(ExperimentalFeatures.ShareFileRequest);

            MainPage = new MainPage();
        }
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     Xamarin.Essentials.Platform.Init(this, savedInstanceState);
     ExperimentalFeatures.Enable(ExperimentalFeatures.EmailAttachments, ExperimentalFeatures.ShareFileRequest);
     SetContentView(Resource.Layout.activity_main);
     Initialize();
 }
Exemple #6
0
        public App()
        {
            InitializeComponent();

            // Required if using Xamarin.Essentials < 1.3.0
            ExperimentalFeatures.Enable(ExperimentalFeatures.ShareFileRequest);

            MainPage = new AppShell();
        }
        private async void OpenFileAsync()
        {
            var filePath = Property.ContractFilePath;

            ExperimentalFeatures.Enable(ExperimentalFeatures.OpenFileRequest, ExperimentalFeatures.ShareFileRequest);

            await Launcher.OpenAsync(
                new OpenFileRequest("Contract",
                                    new ReadOnlyFile(filePath)));
        }
        private async void ShareFileAsync()
        {
            ExperimentalFeatures.Enable(ExperimentalFeatures.ShareFileRequest, ExperimentalFeatures.OpenFileRequest);

            await Share.RequestAsync(new ShareFileRequest
            {
                Title = "Share Property Contract",
                File  = new ShareFile(Property.ContractFilePath)
            });
        }
 async private void ExportDB(object sender, EventArgs e)
 {
     ExperimentalFeatures.Enable("ShareFileRequest_Experimental");
     string filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Fees20.db3");
     //open the Share panel
     await Share.RequestAsync(new ShareFileRequest
     {
         Title = Title,
         File  = new ShareFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Fees20.db3"))
     });
 }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Forms.SetFlags("CollectionView_Experimental");
            ExperimentalFeatures.Enable(ExperimentalFeatures.EmailAttachments);
            Rg.Plugins.Popup.Popup.Init();
            Plugin.InputKit.Platforms.iOS.Config.Init();

            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
Exemple #11
0
        public App()
        {
            InitializeComponent();

            // Enable currently experimental features
            ExperimentalFeatures.Enable(
                ExperimentalFeatures.EmailAttachments,
                ExperimentalFeatures.ShareFileRequest);

            VersionTracking.Track();

            MainPage = new NavigationPage(new HomePage());
        }
        public App()
        {
            ExperimentalFeatures.Enable(ExperimentalFeatures.ShareFileRequest);

            Resources = new ResourceDictionary();
            Resources.Add("primaryGreen", Color.FromHex("91CA47"));
            Resources.Add("primaryDarkGreen", Color.FromHex("6FA22E"));
            var nav = new NavigationPage(new TodoListPage());

            nav.BarBackgroundColor = (Color)App.Current.Resources["primaryGreen"];
            nav.BarTextColor       = Color.White;

            MainPage = nav;
        }
Exemple #13
0
        public App()
        {
            ExperimentalFeatures.Enable("Shapes_Experimental", "SwipeView_Experimental");

            AppCenter.Start(Config.AppCenter, typeof(Crashes), typeof(Analytics));

            InitializeComponent();

            this.StartInjecting()
            .AddHttpClient <BerryClient>(c => {
                c.BaseAddress = new Uri(Config.Endpoint);
            })
            .Build();
        }
Exemple #14
0
        public App()
        {
            InitializeComponent();

            // Enable currently experimental features
            ExperimentalFeatures.Enable(
                ExperimentalFeatures.EmailAttachments,
                ExperimentalFeatures.ShareFileRequest,
                ExperimentalFeatures.OpenFileRequest);

            VersionTracking.Track();

            if (DeviceInfo.Idiom == DeviceIdiom.Watch)
            {
                MainPage = new NavigationPage(new CircleHomePage());
            }
            else
            {
                MainPage = new NavigationPage(new HomePage());
            }
        }
Exemple #15
0
        public override Task OnLaunchAsync(Bundle savedInstanceState)
        {
            Platform.Init(this, savedInstanceState);
            ExperimentalFeatures.Enable(ExperimentalFeatures.ShareFileRequest);

            BoilerManager.Initialize();
            MeasurementManager.Initialize();

            Messenger.Default.Register <TitleMessage>(this, (message) => SupportActionBar.Title = message.Title);
            Messenger.Default.Register <NotificationMessage>(this, (notification) =>
            {
                Toast
                .MakeText(this, notification.Notification, ToastLength.Long)
                .Show();
            });

            SetupDrawerView();

            navigationService = NavigationService;
            NavigationService.NavigateTo("Home");

            return(Task.CompletedTask);
        }
        public async Task SendEmail(string subject, string body, List <string> recipients, string filepath)
        {
            try
            {
                ExperimentalFeatures.Enable("EmailAttachments_Experimental"); // required to allow attachment in email
                List <EmailAttachment> emailAttachments = new List <EmailAttachment>();
                EmailAttachment        attachment       = new EmailAttachment(filepath);
                emailAttachments.Add(attachment);

                var message = new EmailMessage
                {
                    Subject     = subject,
                    Body        = body,
                    To          = recipients,
                    Attachments = emailAttachments
                };
                await Email.ComposeAsync(message);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Exemple #17
0
        public App()
        {
            ExperimentalFeatures.Enable(new string[] {
                "SwipeView_Experimental",
                "Shapes_Experimental",
                "Expander_Experimental"
            });


            InitializeComponent();

            AppCenter.Start(Config.AppCenter,
                            typeof(Analytics), typeof(Crashes));

            CurrentProvider = this.StartInjecting()

                              .SetInitialPage <SettingsPage>()

                              .AddHttpClient <RaspberryClient>(client => {
                client.BaseAddress = new Uri(Config.Endpoint);
            })

                              .Build();
        }
Exemple #18
0
        protected override void OnCreate(Bundle bundle)
        {
            base.SetTheme(Resource.Style.MainTheme);
            base.OnCreate(bundle);
            AppContext = ApplicationContext;

            Forms.SetFlags("CollectionView_Experimental");

            //Xamarin.FormsMaps.Init(this, bundle);
            HtmlLabelRenderer.Initialize();
            CrossMediaManager.Current.Init(this);
            CrossCurrentActivity.Current.Init(this, bundle);
            Popup.Init(this, bundle);
            Forms.Init(this, bundle);
            FormsMaterial.Init(this, bundle);
            ExperimentalFeatures.Enable(ExperimentalFeatures.EmailAttachments);

            //CachedImageRenderer.Init(enableFastRenderer: true);

            LoadApplication(new App());

            Window.SetStatusBarColor(Android.Graphics.Color.White);
            Window.SetTitleColor(Android.Graphics.Color.Black);
        }
        private async void SendEmailAsync(Vendor vendor)
        {
            var folder             = FileSystem.CacheDirectory;
            var attachmentFilePath = Path.Combine(folder, "draft-contract.pdf");

            using (var packageStream = await FileSystem.OpenAppPackageFileAsync("contract.pdf"))
            {
                using (var fileStream = File.OpenWrite(attachmentFilePath))
                {
                    await packageStream.CopyToAsync(fileStream);
                }
            }

            ExperimentalFeatures.Enable(ExperimentalFeatures.EmailAttachments);

            try
            {
                await Email.ComposeAsync(new EmailMessage
                {
                    To = new List <string> {
                        vendor.Email
                    },
                    Subject     = $"Re: {Property.Address}",
                    BodyFormat  = EmailBodyFormat.PlainText,
                    Body        = $"Hi {vendor.FirstName}, \n\n",
                    Attachments = new List <EmailAttachment>
                    {
                        new EmailAttachment(attachmentFilePath)
                    }
                });
            }
            catch (FeatureNotSupportedException ex)
            {
                await DialogService.ShowAlertAsync("Your device does not support this feature", "Feature Not Supported");
            }
        }
        async void OnButtonClicked(object sender, EventArgs args)
        {
            using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Create(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), idMuestreo + "_" + tipoActividad + ".xlsx"), SpreadsheetDocumentType.Workbook))
            {
                // Add a WorkbookPart to the document.
                WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart();
                workbookpart.Workbook = new Workbook();

                // Add a WorksheetPart to the WorkbookPart.
                WorksheetPart worksheetPart = workbookpart.AddNewPart <WorksheetPart>();
                SheetData     sheetData     = new SheetData();
                worksheetPart.Worksheet = new Worksheet(sheetData);

                // Add Sheets to the Workbook.
                Sheets sheets = spreadsheetDocument.WorkbookPart.Workbook.
                                AppendChild <Sheets>(new Sheets());

                // Append a new worksheet and associate it with the workbook.
                Sheet sheet = new Sheet()
                {
                    Id = spreadsheetDocument.WorkbookPart.
                         GetIdOfPart(worksheetPart),
                    SheetId = 1,
                    Name    = "Consolidacion del muestreo"
                };

                //Proyect Data
                InsertCell(1, 1, worksheetPart.Worksheet, "Datos del Muestreo");
                InsertCell(2, 1, worksheetPart.Worksheet, "Nombre del Proyecto: ");
                InsertCell(3, 1, worksheetPart.Worksheet, "Nombre del Muestreo: ");
                InsertCell(4, 1, worksheetPart.Worksheet, "Actividad: ");
                InsertCell(5, 1, worksheetPart.Worksheet, "ID Muestreo: ");
                InsertCell(6, 1, worksheetPart.Worksheet, "Descripcion: ");

                InsertCell(2, 2, worksheetPart.Worksheet, nombreProyecto);
                InsertCell(3, 2, worksheetPart.Worksheet, nombreMuestreo);
                InsertCell(4, 2, worksheetPart.Worksheet, tipoActividad);
                InsertCell(5, 2, worksheetPart.Worksheet, idMuestreo);
                InsertCell(6, 2, worksheetPart.Worksheet, desMuestreo);

                //Name of tables
                InsertCell(1, 4, worksheetPart.Worksheet, "Porcentaje general de tareas");
                InsertCell(1, 8, worksheetPart.Worksheet, "Porcentaje para tareas productivas");
                InsertCell(1, 12, worksheetPart.Worksheet, "Porcentaje para tareas contributivas");
                InsertCell(1, 16, worksheetPart.Worksheet, "Porcentaje para tareas no productivas");
                InsertCell(1, 20, worksheetPart.Worksheet, "Productividad por día");


                //General table (Header and then data)
                InsertCell(2, 4, worksheetPart.Worksheet, "Tarea");
                InsertCell(2, 5, worksheetPart.Worksheet, "Total");
                InsertCell(2, 6, worksheetPart.Worksheet, "Porcentaje");
                createTable(worksheetPart.Worksheet, 3, 4, 3, generalData);

                //TP table (Header and then data)
                InsertCell(2, 8, worksheetPart.Worksheet, "Tarea");
                InsertCell(2, 9, worksheetPart.Worksheet, "Total");
                InsertCell(2, 10, worksheetPart.Worksheet, "Porcentaje");
                createTable(worksheetPart.Worksheet, 3, 8, 3, tpDataA);
                //TC table (Header and then data)
                InsertCell(2, 12, worksheetPart.Worksheet, "Tarea");
                InsertCell(2, 13, worksheetPart.Worksheet, "Total");
                InsertCell(2, 14, worksheetPart.Worksheet, "Porcentaje");
                createTable(worksheetPart.Worksheet, 3, 12, 3, tcDataA);
                //TI table (Header and then data)
                InsertCell(2, 16, worksheetPart.Worksheet, "Tarea");
                InsertCell(2, 17, worksheetPart.Worksheet, "Total");
                InsertCell(2, 18, worksheetPart.Worksheet, "Porcentaje");
                createTable(worksheetPart.Worksheet, 3, 16, 3, tiDataA);
                //Days table (Header and then data)
                createTable(worksheetPart.Worksheet, 2, 20, 6, daysData);

                //General Chart
                DrawingsPart drawingsPart = worksheetPart.AddNewPart <DrawingsPart>();
                worksheetPart.Worksheet.Append(new DocumentFormat.OpenXml.Spreadsheet.Drawing()
                {
                    Id = worksheetPart.GetIdOfPart(drawingsPart)
                });
                ExcelCharts.CreatePieChart(drawingsPart, "'Consolidacion del muestreo'!$D$3:$D$5", "'Consolidacion del muestreo'!$E$3:$E$5", 8, true, "General");
                ExcelCharts.CreatePieChart(drawingsPart, "'Consolidacion del muestreo'!$H$3:$H$" + (2 + tpDataA.Count / 3).ToString(), "'Consolidacion del muestreo'!$I$3:$I$" + (2 + tpDataA.Count / 3).ToString(), 24, false, "TP");
                ExcelCharts.CreatePieChart(drawingsPart, "'Consolidacion del muestreo'!$L$3:$L$" + (2 + tcDataA.Count / 3).ToString(), "'Consolidacion del muestreo'!$M$3:$M$" + (2 + tcDataA.Count / 3).ToString(), 40, false, "TC");
                ExcelCharts.CreatePieChart(drawingsPart, "'Consolidacion del muestreo'!$P$3:$P$" + (2 + tiDataA.Count / 3).ToString(), "'Consolidacion del muestreo'!$Q$3:$Q$" + (2 + tiDataA.Count / 3).ToString(), 56, false, "TI");
                ExcelCharts.CreateLineChart(drawingsPart, "'Consolidacion del muestreo'!$T$3:$T$" + (2 + (daysData.Count - 6) / 6).ToString(), "'Consolidacion del muestreo'!$U$3:$U$" + (2 + (daysData.Count - 6) / 6).ToString(), 72, false, "Productividad x Dia");

                sheets.Append(sheet);

                workbookpart.Workbook.Save();

                // Close the document.
                spreadsheetDocument.Close();
            }


            // string pathN = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), idMuestreo + "_" + tipoActividad + ".xlsx");
            // ExcelCharts.CreatePieChart(pathN, 3, "'Consolidacion del muestreo'!$D$3:$D$5", "'Consolidacion del muestreo'!$E$3:$E$5", 8, 2);


            ExperimentalFeatures.Enable(ExperimentalFeatures.EmailAttachments);

            SendEmail("MAC - Proyecto (" + nombreProyecto + ") - Datos del muestreo (" + nombreMuestreo + ")", "Mensaje enviado usando el app móvil de Muestreo de Actividades Constructivas (MAC) \n Nombre del Proyecto: " + nombreProyecto + "\n Nombre del Muestreo: " + nombreMuestreo + "\n ID muestreo: " + idMuestreo + "\n Tipo Actividad: " + tipoActividad + "\n Descripcion: " + desMuestreo);
        }