/// <summary> /// Gets the loading end controls. /// </summary> /// <param name="file">The file.</param> /// <returns></returns> public async Task <EndControlsLoadingModel> GetLoadingEndControls(string file) { EndControlsLoadingModel endControls = new EndControlsLoadingModel(); try { using (var client = new RestClient(new Uri("https://api-tray.intragest.info/api/"))) { client.Authenticator = new HttpBasicAuthenticator("astek.tracker", "3B]U/2Z8w7fDce=("); var request = new RestRequest("PackingGetLoadingEndControls", Method.GET); request.AddQueryParameter("file_number", file); var result = await client.Execute <EndControlsLoadingModel>(request).ConfigureAwait(false); endControls = result.Data; } } catch (Exception e) { var da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture), MethodName = e.Source }); } return(endControls); }
/// <summary> /// Gets the branch details asynchronous. /// </summary> /// <param name="countryId">The country identifier.</param> /// <param name="language">The language.</param> /// <param name="brandId">The brand identifier.</param> /// <returns></returns> public async Task <ObservableCollection <BranchModel> > GetBranchDetailsAsync(int countryId, string language, int brandId) { ObservableCollection <BranchModel> branchDetails = new ObservableCollection <BranchModel>(); try { using (var client = new RestClient(new Uri("https://api-tray.intragest.info/api/"))) { client.Authenticator = new HttpBasicAuthenticator("astek.tracker", "3B]U/2Z8w7fDce=("); var request = new RestRequest("Branches", Method.GET); request.AddParameter("lang", language); request.AddParameter("country_id", countryId); // request.AddParameter("brand_id", brandId); var result = await client.Execute <ObservableCollection <BranchModel> >(request).ConfigureAwait(false); branchDetails = result.Data; } } catch (Exception e) { DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture), MethodName = e.Source }); } return(branchDetails); }
/// <summary> /// Sends the email dump. /// The Catch expection will log the error in SQLlite DB /// The dump functionality will allow the error to send by mail /// </summary> /// <param name="attachment">The attachment.</param> /// <returns></returns> public async Task <bool> SendEmailDump(string attachment) { bool success; try { //TODO adding personal email add for testing MailMessage mail = new MailMessage("*****@*****.**", "*****@*****.**", "Dump PackingCygest ", ""); SmtpClient smtpclient = new SmtpClient("46.105.132.129") { Credentials = new System.Net.NetworkCredential("*****@*****.**", "z5$!&2FnZNKS3CjJ") }; mail.Attachments.Add(new Attachment(attachment)); await smtpclient.SendMailAsync(mail); success = true; } catch (Exception e) { success = false; DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(CultureInfo.CurrentCulture), MethodName = e.Source }); } return(success); }
public string Base64ToByte(string base64, string name, string folder) { var sdCardPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/Android/Data/PackingCygest.Android/files/" + folder + "/"; //var sdCardPath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath + "/" + folder + "/"; Directory.CreateDirectory(sdCardPath); var filename = Path.Combine(sdCardPath, name + ".jpg"); try { byte[] b = Convert.FromBase64String(base64); System.IO.File.WriteAllBytes(filename, b); } catch (Exception e) { DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(CultureInfo.CurrentCulture), MethodName = e.Source }); } return(filename); }
//Get Missing Barcode from API public async Task <ObservableCollection <string> > GetMissingBarocde(string filenum) { ObservableCollection <string> lstMissingBarcode = new ObservableCollection <string>(); try { using (var client = new RestClient(new Uri("https://api-tray.intragest.info/api/"))) { client.Authenticator = new HttpBasicAuthenticator("astek.tracker", "3B]U/2Z8w7fDce=("); var request = new RestRequest("PackingGetItemsBCMissing", Method.GET); request.AddQueryParameter("file_number", filenum); var result = await client.Execute <ObservableCollection <string> >(request).ConfigureAwait(false);; lstMissingBarcode = result.Data; } } catch (Exception e) { var da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture), MethodName = e.Source }); } return(lstMissingBarcode); }
/// <summary> /// Gets the rubric item asynchronous. /// </summary> /// <returns></returns> public async Task <ObservableCollection <RubricsModel> > GetRubricItemAsync() { ObservableCollection <RubricsModel> rubrics = new ObservableCollection <RubricsModel>(); try { using (var client = new RestClient(new Uri("https://api-tray.intragest.info/api/"))) { client.Authenticator = new HttpBasicAuthenticator("astek.tracker", "3B]U/2Z8w7fDce=("); var request = new RestRequest("PackingGetRubrics", Method.GET); var result = await client.Execute <ObservableCollection <RubricsModel> >(request).ConfigureAwait(false); rubrics = result.Data; } } catch (Exception e) { var da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture), MethodName = e.Source }); } return(rubrics); }
/// <summary> /// Gets the scanned bar code. /// </summary> /// <returns></returns> public async Task <string> GetScannedBarCode() { try { MobileBarcodeScanner scanner = new MobileBarcodeScanner(); scanner.BottomText = "Focus on Barcode"; var result = await scanner.Scan(); if (result != null) { code = result.Text; } } catch (Exception ex) { DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = ex.Message, StackTrace = ex.StackTrace, TimeSpan = DateTime.Today.ToString(CultureInfo.CurrentCulture), MethodName = ex.Source }); } return(code); }
/// <summary> /// PackingCygests the post signature. /// </summary> /// <param name="signature">The signature.</param> /// <returns></returns> public async Task <bool> PackingCygestPostSignature(SignatureModel signature) { bool retval = false; try { using (var client = new RestClient(new Uri("https://api-tray.intragest.info/api/"))) { client.Authenticator = new HttpBasicAuthenticator("astek.tracker", "3B]U/2Z8w7fDce=("); var request = new RestRequest("PackingPostSignature", Method.POST); request.AddJsonBody(signature); var result = await client.Execute <bool>(request); if (result != null) { retval = result.IsSuccess; } } } catch (Exception e) { var da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture), MethodName = e.Source }); } return(retval); }
/// <summary> /// Sets the underline. /// </summary> /// <param name="underlined">if set to <c>true</c> [underlined].</param> private void SetUnderline(bool underlined) { try { var textView = (TextView)Control; if (underlined) { textView.PaintFlags |= PaintFlags.UnderlineText; } else { textView.PaintFlags &= ~PaintFlags.UnderlineText; } } catch (Exception e) { var da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(CultureInfo.CurrentCulture), MethodName = e.Source }); } }
/// <summary> /// Saves the picture to disk. /// The catch part will through error /// The Catch expection will log the error in SQLlite DB /// The dump functionality will allow the error to send by mail /// </summary> /// <param name="filename">The filename.</param> /// <param name="imageData">The image data.</param> public void SavePictureToDisk(string filename, byte[] imageData) { var dir = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim); var pictures = dir.AbsolutePath; //adding a time stamp time file name to allow saving more than one image... otherwise it overwrites the previous saved image of the same name string name = filename + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg"; string filePath = System.IO.Path.Combine(pictures, name); try { System.IO.File.WriteAllBytes(filePath, imageData); //mediascan adds the saved image into the gallery var mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile); mediaScanIntent.SetData(Uri.FromFile(new Java.IO.File(filePath))); Forms.Context.SendBroadcast(mediaScanIntent); } catch (Exception e) { DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(CultureInfo.CurrentCulture), MethodName = e.Source }); } }
/// <summary> /// Gets the branches details. /// </summary> /// <param name="countryId">The country identifier.</param> /// <param name="cultureInfo">The culture information.</param> /// <returns></returns> public async Task GetBranchesDetails(int countryId, string cultureInfo) { try { SetActivityIndicatorBlurred(true); ActOpacity = 1; MainStackLayout = false; PackingCygestPageLayoutOpacity = 0.4; Status = "Loading data..."; var connected = CrossConnectivity.Current.IsConnected; if (connected) { Branch = await _branchService.GetBranchDetailsAsync(countryId, cultureInfo, BrandId); if (Branch.Count == 0 && _appViewModel.DefaultedCultureInfo != "fr-FR") { BranchModel tempBranch = new BranchModel { Id = 0, Code = "Unknown", Name = "Unknown" }; Branch.Add(tempBranch); } else { BranchModel tempBranch = new BranchModel { Id = 0, Code = "Inconnu", Name = "Inconnu" }; Branch.Add(tempBranch); } SetActivityIndicatorBlurred(false); MainStackLayout = true; PackingCygestPageLayoutOpacity = 1; Status = ""; } } catch (Exception e) { await _pageService.DisplayAlert(LblError, LblNoConnection, LblOk); DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture), MethodName = e.Source }); } }
/// <summary> /// Initializes a new instance of the <see cref="DelSynchroViewModel"/> class. /// </summary> /// <param name="pageService">The page service.</param> /// <param name="infomodel">The infomodel.</param> public DelSynchroViewModel(IPageService pageService, FileInfoDeliveryModel infomodel) { HandleTranslation(_appViewModel.DefaultedCultureInfo); PageService = pageService; InfoModel = infomodel; _dbAccess = new DatabaseAccessAsync(); _db = new DatabaseAccess(); Back = new Command(GoBack); ProgressValue = 0; LoadingText = LoadingTextWait; LoadingIndicator = true; PerfomCall(); }
/// <summary> /// Initializes a new instance of the <see cref="LoadSynchroViewModel"/> class. /// </summary> /// <param name="pageService">The page service.</param> /// <param name="loading">The loading.</param> /// <param name="fileInfo">The file information.</param> public LoadSynchroViewModel(IPageService pageService, NewLoadingModel loading, FileInfoModel fileInfo) { HandleTranslation(_appViewModel.DefaultedCultureInfo); PageService = pageService; _loading = loading; _fileInfo = fileInfo; _db = new DatabaseAccess(); _dbAsync = new DatabaseAccessAsync(); PerfomCall(); _db.EmptyDatabaseForLoadSynchro(); FinshSynchro = new Command(GoToControls); LoadingText = LoadingTextWait; LoadingIndicator = true; SyncComplete = false; }
/// <summary> /// Gets all countries. /// </summary> /// <param name="cultureDetails">The culture details.</param> /// <returns></returns> public async Task GetAllCountries(string cultureDetails) { try { SetActivityIndicatorBlurred(true); ActOpacity = 1; MainStackLayout = false; PackingCygestPageLayoutOpacity = 0.4; Status = "Loading data..."; var connected = CrossConnectivity.Current.IsConnected; if (connected) { Countries = await _countryService.GetAllCountriesAsync(cultureDetails.Substring(0, 2)); if (Countries != null) { SetActivityIndicatorBlurred(false); MainStackLayout = true; PackingCygestPageLayoutOpacity = 1; Status = ""; } else { Countries = new ObservableCollection <CountryModel>(); await _pageService.DisplayAlert(LblError, LblNoConnection, LblOk); } SetActivityIndicatorBlurred(false); MainStackLayout = true; PackingCygestPageLayoutOpacity = 1; Status = ""; } } catch (Exception e) { await _pageService.DisplayAlert(LblError, LblNoConnection, LblOk); DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture), MethodName = e.Source }); } }
/// <summary> /// Barcodes the page. /// </summary> /// <param name="pageService">The page service.</param> /// <returns></returns> public async Task <string> BarcodePage(IPageService pageService) { PageService = pageService; var barCode = DependencyService.Get <IBarcodeScanner>(); Func <string, string> temp = (obj) => { return(result); }; try { result = await barCode.GetScannedBarCode(); //moce result from here //result = fullBarCode.Substring(0, fullBarCode.Length - 3); var fileCode = result.Substring(0, result.Length - 3); if (Localize.BaseCode.Contains(fileCode)) { return(result); } else { return(""); } //if (!string.IsNullOrEmpty(result)) //{ // System.Diagnostics.Debug.WriteLine("Scanned Barcode: " + result); //} } catch (Exception ex) { DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = ex.Message, StackTrace = ex.StackTrace, TimeSpan = DateTime.Today.ToString(CultureInfo.CurrentCulture), MethodName = ex.Source }); } return(result); }
public void DeleteDownloadedPhoto(string photopath) { try { if (!string.IsNullOrEmpty(photopath)) { System.IO.File.Delete(photopath); } } catch (Exception e) { DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(CultureInfo.CurrentCulture), MethodName = e.Source }); } }
/// <summary> /// Gets the base64 image string. /// </summary> /// <param name="filename">The filename.</param> /// <returns></returns> public string GetBase64ImageString(string filename) { string res = string.Empty; try { byte[] b = System.IO.File.ReadAllBytes(filename); res = Convert.ToBase64String(b); } catch (Exception e) { DatabaseAccessAsync da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(CultureInfo.CurrentCulture), MethodName = e.Source }); } return(res); }
private async Task GetFileItemsDelivery(string fileNumber) { IsDownloading = true; ObservableCollection <string> lstMissingBarcode = new ObservableCollection <string>(); try { var connected = CrossConnectivity.Current.IsConnected; if (connected) { lstMissingBarcode = await _newLoadingService.GetMissingBarocde(fileNumber); if (lstMissingBarcode != null) { MissingBarcodeItem = lstMissingBarcode; } } else { _pageService.DisplayAlert(LblNoNetwork, LblPleaseEnableYourNetwork, "ok"); } IsDownloading = false; } catch (Exception e) { IsDownloading = false; var da = new DatabaseAccessAsync(); da.InsertException(new PackingCygestExceptionModel { Message = e.Message, StackTrace = e.StackTrace, TimeSpan = DateTime.Today.ToString(System.Globalization.CultureInfo.CurrentCulture), MethodName = e.Source }); } }