public void SetDefaultScheme() { var keyProfitWordDB = new KeyProfitWordDB(sqlconnection); var SMSDB = new SMSDB(sqlconnection); var res = GetDefaultScheme(); if (res != null) { return; } var model = new SettingsSchemaModel() { SchemaName = "Default Schema", ShowAllMessages = true, //BankName = "Bank Name", Use = true, PatternForAmount = @"Suma:\s+(-?\d+(?:\.\d+)?)\sUAH", UserSchema = false, KeyProfitWords = new List <KeyProfitWordModel>() { new KeyProfitWordModel() { Name = "Popovnennya" }, new KeyProfitWordModel() { Name = "Zarahuvannia" } } }; sqlconnection.InsertWithChildren(model, recursive: true); }
public List <SMSModel> GetNotSynchSMS(SettingsSchemaModel model, int code) { var listOfSMS = SMSAnalyzer.GetSMSaboveCode(model.BankName, code); var parsedSMS = SMSAnalyzer.ParseSMSBody(listOfSMS, model); return(parsedSMS); }
public static List <SMSModel> ParseSMSBody(List <SMSModel> listOfSMS, SettingsSchemaModel model) { var parsedList = new List <SMSModel>(); try { bool financeSMS; string profitWordsPattern = string.Empty; if (model.KeyProfitWords != null) { foreach (var wordItem in model.KeyProfitWords) { profitWordsPattern += wordItem.Name + "|"; } } if (!string.IsNullOrEmpty(profitWordsPattern)) { profitWordsPattern = profitWordsPattern.Remove(profitWordsPattern.Length - 1); } foreach (var item in listOfSMS) { financeSMS = false; Match matchKeyWords = Regex.Match(item.Body, profitWordsPattern); if (matchKeyWords.Success) { financeSMS = true; } Match match = Regex.Match(item.Body, model.PatternForAmount); if (match.Success) { item.Type = financeSMS ? SmsType.Profit : SmsType.Expense; double res; double.TryParse(match.Groups[1].Value, NumberStyles.Currency, CultureInfo.InvariantCulture.NumberFormat, out res); item.Amount = res; } else { item.Type = SmsType.Another; } item.Date = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddMilliseconds(Convert.ToInt64(item.UnixDate)); item.Checked = true; parsedList.Add(item); } } catch (Exception ex) { } return(parsedList); }
public KeyProfitWordViewModel(SettingsSchemaModel schema, ContentPage _page) { Items = new ObservableCollection <KeyProfitWordModel>(schema.KeyProfitWords); IsUserSchema = schema.UserSchema; schemaId = schema.Id; page = _page; BtnAddClick = new Command(AddClick, CanAddClick); }
public SettingsSchemaViewModel(SettingsSchemaModel schemaModel) { id = schemaModel.Id; var schema = DBHelper.Instance().SettingsSchemaDB.GetSettingsSchema(id); Addresses = DBHelper.Instance().AddressesDB.GetAddresses(); schemaName = schema.SchemaName; showAllMessages = schema.ShowAllMessages; bankName = schema.BankName; keyProfitWords = schema.KeyProfitWords; patternForAmount = schema.PatternForAmount; userSchema = schema.UserSchema; use = schema.Use; BtnSave = new Command(Save, CanSave); ClickProfitWords = new Command(ClickProfitWord); IsChanged = false; }
public SettingsPage(SettingsSchemaModel schema) : this() { this.schema = schema; BindPage(); }
public void AddSettingsSchema(SettingsSchemaModel schema) { sqlconnection.InsertWithChildren(schema, recursive: true); }
public void UpdateSettingsSchema(SettingsSchemaModel schema) { sqlconnection.Update(schema); }
public KeyProfitWordPage(SettingsSchemaModel schema) : this() { BindingContext = new KeyProfitWordViewModel(schema, this); }