| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- using comal.timesheets.CustomControls;
- using System;
- using System.Collections.Generic;
- using InABox.Core;
- using InABox.Configuration;
- using Comal.Classes;
- using InABox.Clients;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- using XF.Material.Forms.UI.Dialogs;
- using comal.timesheets.SiteITPModule;
- using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
- using PRSClasses;
- using comal.timesheets.QAForms;
- using System.IO;
- namespace comal.timesheets
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class Site : ContentPage
- {
- Job job = new Job();
- bool bDocViwerOpen = false;
- bool webViewNavigationFinished = false;
- public Site(Job _job)
- {
- InitializeComponent();
- NavigationPage.SetHasBackButton(this, false);
- job = _job;
- if (job.ID != Guid.Empty)
- {
- selectJobBtn.Text = job.JobNumber + " " + job.Name;
- }
- //if (Security.IsAllowed<CanViewGeneralJobDocuments>())
- // GeneralDocumentsFrame.IsVisible = true;
- //if (Security.IsAllowed<CanViewJobDocumentMileStoneFiles>())
- // JobDocumentsFrame.IsVisible = true;
- }
- void BackBtn_Clicked(object sender, EventArgs e)
- {
- if (bDocViwerOpen)
- {
- titleLbl.Text = "Site Module";
- bDocViwerOpen = false;
- Content = siteStackLayout;
- }
- else
- {
- Navigation.PopAsync();
- }
- }
- private void SelectJobBtn_Clicked(object sender, EventArgs e)
- {
- try
- {
- JobSelectionPage jobSelectionPage = new JobSelectionPage();
- jobSelectionPage.OnItemSelected += (() =>
- {
- JobShell jobshell = jobSelectionPage.Job;
- job.ID = jobshell.ID;
- job.JobNumber = jobshell.JobNumber;
- job.Name = jobshell.Name;
- selectJobBtn.Text = jobshell.DisplayName;
- });
- Navigation.PushAsync(jobSelectionPage);
- }
- catch { }
- }
- private void ITPs_Tapped(object sender, EventArgs e)
- {
- try
- {
- if (job.ID == Guid.Empty)
- {
- DisplayAlert("Alert", "Select a job first", "OK");
- return;
- }
- var siteITPChooser = new SiteITPChooser(job);
- Navigation.PushAsync(siteITPChooser);
- }
- catch { }
- }
- private void JobForms_Tapped(object sender, EventArgs e)
- {
- try
- {
- if (job.ID == Guid.Empty)
- {
- DisplayAlert("Alert", "Select a job first", "OK");
- return;
- }
- DigitalFormsPicker picker = new DigitalFormsPicker("Job", job.ID);
- Navigation.PushAsync(picker);
- }
- catch { }
- }
- private async void JobDocs_Tapped(object sender, EventArgs e)
- {
- try
- {
- if (job.ID == Guid.Empty)
- {
- DisplayAlert("Alert", "Select a job first", "OK");
- return;
- }
- JobDocViewer viewer = new JobDocViewer(job);
- Navigation.PushAsync(viewer);
- }
- catch (Exception ex)
- {
- DisplayAlert("Error", ex.Message, "OK");
- }
- }
- private async void SiteDocs_Tapped(object sender, EventArgs e)
- {
- try
- {
- if (job.ID == Guid.Empty)
- {
- DisplayAlert("Alert", "Select a job first", "OK");
- return;
- }
- webViewNavigationFinished = false;
- string jobid = job.ID.ToString();
- string userid = Encryption.Encrypt(App.Settings.UserID, DateTime.Now.ToString("yyyy-MM-dd"), true);
- string password = Encryption.Encrypt(App.Settings.Password, DateTime.Now.ToString("yyyy-MM-dd"), true);
- var webSettings = new GlobalConfiguration<WebSettings>().Load();
- string fullUrl = webSettings.URL + ":" + webSettings.Port + "/v1/Job/job_documents?id=" + jobid + "&userid=" + userid + "&password=" + password;
- Xamarin.Forms.WebView webView = new Xamarin.Forms.WebView() { Source = fullUrl };
- webView.On<Xamarin.Forms.PlatformConfiguration.Android>().EnableZoomControls(true);
- webView.On<Xamarin.Forms.PlatformConfiguration.Android>().DisplayZoomControls(true);
- titleLbl.Text = "View Documents";
- bDocViwerOpen = true;
- var progress = await MaterialDialog.Instance.LoadingDialogAsync(message: "Connecting to server");
- webView.Navigated += (object sender2, WebNavigatedEventArgs e2) => { Device.BeginInvokeOnMainThread(async () => { await progress.DismissAsync(); }); };
- Content = webView;
- }
- catch { }
- }
- private void Products_Tapped(object sender, EventArgs e)
- {
- if (GlobalVariables.ProductsLoaded)
- {
- ProductList products = new ProductList(GlobalVariables.ProductShells);
- Navigation.PushAsync(products);
- }
- else
- {
- ProductList products = new ProductList();
- Navigation.PushAsync(products);
- }
- }
- private void PurchaseOrders_Tapped(object sender, EventArgs e)
- {
- //if (Security.CanView<PurchaseOrder>())
- //{
- // if (job.ID == Guid.Empty)
- // {
- // DisplayAlert("Alert", "Select a job first", "OK");
- // return;
- // }
- //}
- }
- private void SiteManufacturing_Tapped(object sender, EventArgs e)
- {
- SiteManufacturing setoutsScreen = new SiteManufacturing(job.ID);
- Navigation.PushAsync(setoutsScreen);
- }
- }
- }
|