public async void SendRegistrationToServer() { SessionHelper sessionHelper = new SessionHelper(this); string AuthToken = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY); string PushToken = sessionHelper.GetSessionKey(SessionKeys.PUSH_TOKEN_KEY); if (!String.IsNullOrEmpty(AuthToken)) { switch (Xamarin.Forms.Device.OS) { case Xamarin.Forms.TargetPlatform.Android: //PushTokenEntities pushEntity = new PushTokenEntities { AuthToken = AuthToken, DevicePushToken = PushToken, DeviceType = DeviceTypeEnum.ANDROID.ToString() }; //JsonValue jsonData = await HttpRequestHelper<PushTokenEntities>.POSTreq(ServiceTypes.UpdatePushToken, pushEntity); //break; case Xamarin.Forms.TargetPlatform.Other: PushTokenEntities pushEntity = new PushTokenEntities { AuthToken = AuthToken, DevicePushToken = PushToken, DeviceType = DeviceTypeEnum.ANDROID.ToString() }; JsonValue jsonData = await HttpRequestHelper <PushTokenEntities> .POSTreq(ServiceTypes.UpdatePushToken, pushEntity); break; case Xamarin.Forms.TargetPlatform.iOS: break; case Xamarin.Forms.TargetPlatform.Windows: break; } } }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.OrderReciept); SessionHelper sessionHelper = new SessionHelper(this); string Username = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY); string UserID = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY); string AuthToken = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY); JsonValue jsonReciept = await HttpRequestHelper <RecieptEntity> .GetRequest(ServiceTypes.GetOrderedRecieptsForStore, "/" + AuthToken + "/" + UserID); ParseRecieptJSON(jsonReciept); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.QuotedReciept); TextView storeUsernameText = FindViewById <TextView>(Resource.Id.txtUsername); SessionHelper sessionHelper = new SessionHelper(this); string Username = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY); string UserID = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY); string AuthToken = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY); storeUsernameText.Text = "Hello " + Username; JsonValue jsonReciept = await HttpRequestHelper <QuotedEntity> .GetRequest(ServiceTypes.GetQuotedRecieptsForCustomer, "/" + AuthToken + "/" + UserID); ParseRecieptJSON(jsonReciept); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); //LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService); //View contentView = inflater.Inflate(Resource.Layout.Reciept, null, false); //drawerLayout.AddView(contentView); SetContentView(Resource.Layout.Reciept); TextView storeUsernameText = FindViewById <TextView>(Resource.Id.txtUsername); SessionHelper sessionHelper = new SessionHelper(this); string Username = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY); string UserID = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY); string AuthToken = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY); storeUsernameText.Text = "Hello " + Username; EditText recieptName = FindViewById <EditText>(Resource.Id.editrecieptTxt); Button btnAddReciept = FindViewById <Button>(Resource.Id.addreciept); JsonValue jsonReciept = await HttpRequestHelper <RecieptEntity> .GetRequest(ServiceTypes.GetReciepts, "/" + AuthToken + "/" + UserID); ParseRecieptJSON(jsonReciept); btnAddReciept.Click += async(sender, e) => { try { RecieptDTO recieptDTO = new RecieptDTO(); recieptDTO.CreatedOn = DateTime.Now.ToString(); recieptDTO.Name = recieptName.Text; recieptDTO.StoreID = Convert.ToInt32(UserID); recieptDTO.Status = ((int)ReceiptStatusEnum.New).ToString(); RecieptEntity recieptEntity = new RecieptEntity { AuthToken = AuthToken, recieptDTO = recieptDTO }; JsonValue json = await HttpRequestHelper <RecieptEntity> .POSTreq(ServiceTypes.AddReciept, recieptEntity); ParseJSON(json); JsonValue jsonReciept1 = await HttpRequestHelper <RecieptEntity> .GetRequest(ServiceTypes.GetReciepts, "/" + AuthToken + "/" + UserID); ParseRecieptJSON(jsonReciept1); } catch (Exception ex) { } }; }
public void Save(string key, string value) { int userId = CurrentUser.GetSignInView().UserId.ToInt(); if (userId.Equals(0)) { return; } if (string.IsNullOrWhiteSpace(key)) { return; } if (string.IsNullOrWhiteSpace(value)) { return; } const string sessionKey = BackOffice.Admin.LocalizeMixERP.sessionKey; string cultureCode = Conversion.TryCastString(SessionHelper.GetSessionKey(sessionKey)); if (string.IsNullOrWhiteSpace(cultureCode)) { return; } Data.Admin.LocalizeMixERP.Save(cultureCode, key, value); }
private static void SetCulture() { if (SessionHelper.GetSessionKey("Culture") == null) { return; } string cultureName = Conversion.TryCastString(SessionHelper.GetSessionKey("Culture")); CultureInfo culture = new CultureInfo(cultureName); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.OrderedProduct); RecieptDTO user = JsonConvert.DeserializeObject <RecieptDTO>(Intent.GetStringExtra("RecieptData")); //var extras = Intent.GetParcelableExtra("RecieptData") ?? String.Empty; string textRecieptName = user.Name; textRecieptID = user.RecieptID.ToString(); TextView txtRecieptName = FindViewById <TextView>(Resource.Id.recieptTxt); TextView txtProductName = FindViewById <TextView>(Resource.Id.editProductName); TextView txtProductQuantity = FindViewById <TextView>(Resource.Id.editProductQuantity); txtRecieptName.Text = textRecieptName; SessionHelper sessionHelper = new SessionHelper(this); string Username = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY); string UserID = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY); string AuthToken = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY); JsonValue jsonProduct = await HttpRequestHelper <ProductEntity> .GetRequest(ServiceTypes.GetProducts, "/" + AuthToken + "/" + textRecieptID); ParseRecieptJSON(jsonProduct); Button SendReceiptToCustomer = FindViewById <Button>(Resource.Id.btnSendReceiptToCustomer); Button UpdateSubTotal = FindViewById <Button>(Resource.Id.btnUpdateOrderAmount); UpdateSubTotal.Click += UpdateSubTotal_Click; SendReceiptToCustomer.Click += async(sender, e) => { UpdateProductEntity updateProductEntity = new UpdateProductEntity { AuthToken = AuthToken, productInfo = GetProductsData() }; JsonValue json = await HttpRequestHelper <UpdateProductEntity> .POSTreq(ServiceTypes.UpdateProductAvailability, updateProductEntity); ParseJSON(json); }; }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); //LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService); //View contentView = inflater.Inflate(Resource.Layout.Stores, null, false); //drawerLayout.AddView(contentView); SetContentView(Resource.Layout.Stores); RecieptID = Intent.GetStringExtra("RecieptID"); SessionHelper sessionHelper = new SessionHelper(this); AuthToken = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY); JsonValue jsonProduct = await HttpRequestHelper <StoreEntity> .GetRequest(ServiceTypes.GetAllUsers, "/" + AuthToken); ParseStoreJSON(jsonProduct); }
private void ParseJSON(JsonValue json) { // Extract the array of name/value results for the field name "weatherObservation". JsonValue loginResults = json; // Extract the "stationName" (location string) and write it to the location TextBox: bool isSuccess = loginResults["IsSuccess"]; if (isSuccess) { Toast.MakeText(this, "User logging in.", ToastLength.Short).Show(); int UserID = loginResults["UserID"]; string token = loginResults["Token"]; string name = loginResults["FullName"]; string pushToken = loginResults["PushToken"]; SessionHelper sessionHelper = new SessionHelper(this); sessionHelper.SaveSessionKey(SessionKeys.SESSION_TOKEN_KEY, token); sessionHelper.SaveSessionKey(SessionKeys.SESSION_USERID_KEY, UserID.ToString()); sessionHelper.SaveSessionKey(SessionKeys.SESSION_USERNAME_KEY, name); string PushToken = sessionHelper.GetSessionKey(SessionKeys.PUSH_TOKEN_KEY); if (!String.IsNullOrEmpty(PushToken)) { if (!PushToken.Equals(pushToken)) { SendRegistrationToServer(); } } var dashboardActivity = new Intent(this, typeof(DashboardActivity)); StartActivity(dashboardActivity); } else { string errorMessage = loginResults["Message"]; Toast.MakeText(this, errorMessage, ToastLength.Short).Show(); } }
public static string ParseExpression(string expression, Collection <DataTable> dataTableCollection, Assembly assembly) { if (string.IsNullOrWhiteSpace(expression)) { return(string.Empty); } string logo = ConfigurationHelper.GetReportParameter("LogoPath"); expression = expression.Replace("{LogoPath}", PageUtility.GetCurrentDomainName() + PageUtility.ResolveUrl(logo)); //Or else logo will not be exported into excel. expression = expression.Replace("{PrintDate}", DateTime.Now.ToString(LocalizationHelper.GetCurrentCulture())); foreach (var match in Regex.Matches(expression, "{.*?}")) { string word = match.ToString(); if (word.StartsWith("{Session.", StringComparison.OrdinalIgnoreCase)) { string sessionKey = RemoveBraces(word); sessionKey = sessionKey.Replace("Session.", ""); sessionKey = sessionKey.Trim(); string value = Conversion.TryCastString(SessionHelper.GetSessionKey(sessionKey)); expression = expression.Replace(word, value); } else if (word.StartsWith("{Resources.", StringComparison.OrdinalIgnoreCase)) { string res = RemoveBraces(word); string[] resource = res.Split('.'); string key = resource[2]; string fullyQualifiedResourceClassName = assembly.GetName().Name + "." + resource[0] + "." + resource[1]; expression = expression.Replace(word, LocalizationHelper.GetResourceString(assembly, fullyQualifiedResourceClassName, key)); } else if (word.StartsWith("{DataSource", StringComparison.OrdinalIgnoreCase) && word.ToLower(CultureInfo.InvariantCulture).Contains("runningtotalfieldvalue")) { string res = RemoveBraces(word); string[] resource = res.Split('.'); int dataSourceIndex = Conversion.TryCastInteger(resource[0].ToLower(CultureInfo.InvariantCulture).Replace("datasource", "").Replace("[", "").Replace("]", "")); int index = Conversion.TryCastInteger(resource[1].ToLower(CultureInfo.InvariantCulture).Replace("runningtotalfieldvalue", "").Replace("[", "").Replace("]", "")); if (dataSourceIndex >= 0 && index >= 0) { if (dataTableCollection != null && dataTableCollection[dataSourceIndex] != null) { expression = expression.Replace(word, GetSum(dataTableCollection[dataSourceIndex], index).ToString(CultureInfo.InvariantCulture)); } } } else if (word.StartsWith("{Barcode", StringComparison.OrdinalIgnoreCase)) { string res = RemoveBraces(word).Replace("Barcode(", "").Replace(")", ""); string barCodeValue = res; if (res.StartsWith("DataSource")) { barCodeValue = ParseDataSource("{" + res + "}", dataTableCollection); } string barCodeFormat = ConfigurationHelper.GetReportParameter("BarCodeFormat"); string barCodeDisplayValue = ConfigurationHelper.GetReportParameter("BarCodeDisplayValue"); string barCodeFontSize = ConfigurationHelper.GetReportParameter("BarCodeFontSize"); string barCodeWidth = ConfigurationHelper.GetReportParameter("BarCodeWidth"); string barCodeHeight = ConfigurationHelper.GetReportParameter("BarCodeHeight"); string barCodeQuite = ConfigurationHelper.GetReportParameter("BarCodeQuite"); string barCodeFont = ConfigurationHelper.GetReportParameter("BarCodeFont"); string barCodeTextAlign = ConfigurationHelper.GetReportParameter("BarCodeTextAlign"); string barCodeBackgroundColor = ConfigurationHelper.GetReportParameter("BarCodeBackgroundColor"); string barCodeLineColor = ConfigurationHelper.GetReportParameter("BarCodeLineColor"); string imageSource = "<img class='reportEngineBarCode' data-barcodevalue='{0}' alt='{0}' value='{0}' data-barcodeformat='{1}' data-barcodedisplayvalue='{2}' data-barcodefontsize='{3}' data-barcodewidth='{4}' data-barcodeheight='{5}' data-barcodefont='{6}' data-barcodetextalign='{7}' data-barcodebackgroundcolor='{8}' data-barcodelinecolor='{9}' data-barcodequite={10} />"; imageSource = string.Format(CultureInfo.InvariantCulture, imageSource, barCodeValue, barCodeFormat, barCodeDisplayValue, barCodeFontSize, barCodeWidth, barCodeHeight, barCodeFont, barCodeTextAlign, barCodeBackgroundColor, barCodeLineColor, barCodeQuite); expression = expression.Replace(word, imageSource).ToString(CultureInfo.InvariantCulture); } else if (word.StartsWith("{QRCode", StringComparison.OrdinalIgnoreCase)) { string res = RemoveBraces(word).Replace("QRCode(", "").Replace(")", ""); string qrCodeValue = res; if (res.StartsWith("DataSource")) { qrCodeValue = ParseDataSource("{" + res + "}", dataTableCollection); } string qrCodeRender = ConfigurationHelper.GetReportParameter("QRCodeRender"); string qrCodeBackgroundColor = ConfigurationHelper.GetReportParameter("QRCodeBackgroundColor"); string qrCodeForegroundColor = ConfigurationHelper.GetReportParameter("QRCodeForegroundColor"); string qrCodeWidth = ConfigurationHelper.GetReportParameter("QRCodeWidth"); string qrCodeHeight = ConfigurationHelper.GetReportParameter("QRCodeHeight"); string qrCodeTypeNumber = ConfigurationHelper.GetReportParameter("QRCodeTypeNumber"); string qrCodeDiv = "<div class='reportEngineQRCode' data-qrcodevalue={0} data-qrcoderender='{1}' data-qrcodebackgroundcolor='{2}' data-qrcodeforegroundcolor='{3}' data-qrcodewidth='{4}' data-qrcodeheight='{5}' data-qrcodetypenumber='{6}'></div>"; qrCodeDiv = string.Format(CultureInfo.InvariantCulture, qrCodeDiv, qrCodeValue, qrCodeRender, qrCodeBackgroundColor, qrCodeForegroundColor, qrCodeWidth, qrCodeHeight, qrCodeTypeNumber); expression = expression.Replace(word, qrCodeDiv).ToString(CultureInfo.InvariantCulture); } } return(expression); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); //LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService); //View contentView = inflater.Inflate(Resource.Layout.Product, null, false); //drawerLayout.AddView(contentView); SetContentView(Resource.Layout.Product); RecieptDTO user = JsonConvert.DeserializeObject <RecieptDTO>(Intent.GetStringExtra("RecieptData")); //var extras = Intent.GetParcelableExtra("RecieptData") ?? String.Empty; string textRecieptName = user.Name; textRecieptID = user.RecieptID.ToString(); TextView txtRecieptName = FindViewById <TextView>(Resource.Id.recieptTxt); TextView txtProductName = FindViewById <TextView>(Resource.Id.editProductName); TextView txtProductQuantity = FindViewById <TextView>(Resource.Id.editProductQuantity); txtRecieptName.Text = textRecieptName; SessionHelper sessionHelper = new SessionHelper(this); string Username = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY); string UserID = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY); string AuthToken = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY); ImageButton btnAddProduct = FindViewById <ImageButton>(Resource.Id.btnAddProduct); JsonValue jsonProduct = await HttpRequestHelper <ProductEntity> .GetRequest(ServiceTypes.GetProducts, "/" + AuthToken + "/" + textRecieptID); ParseRecieptJSON(jsonProduct); Button btnSendReceipt = FindViewById <Button>(Resource.Id.btnSendReceipt); btnSendReceipt.Click += BtnSendReceipt_Click; btnAddProduct.Click += async(sender, e) => { progress = new Android.App.ProgressDialog(this); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetMessage("Adding product... Please wait..."); progress.SetCancelable(false); progress.Show(); try { ProductDTO productDTO = new ProductDTO(); productDTO.AddedOn = DateTime.Now.ToString(); productDTO.Name = txtProductName.Text; productDTO.Quantity = txtProductQuantity.Text; productDTO.RecieptID = Convert.ToInt32(textRecieptID); ProductEntity productEntity = new ProductEntity { AuthToken = AuthToken, productInfo = productDTO }; JsonValue json = await HttpRequestHelper <ProductEntity> .POSTreq(ServiceTypes.AddProduct, productEntity); ParseJSON(json); JsonValue jsonProduct1 = await HttpRequestHelper <ProductEntity> .GetRequest(ServiceTypes.GetProducts, "/" + AuthToken + "/" + textRecieptID); ParseRecieptJSON(jsonProduct1); progress.Hide(); } catch (Exception ex) { } }; }