Exemple #1
0
        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);
        }
Exemple #2
0
        public List <SMSModel> GetNotSynchSMS(SettingsSchemaModel model, int code)
        {
            var listOfSMS = SMSAnalyzer.GetSMSaboveCode(model.BankName, code);
            var parsedSMS = SMSAnalyzer.ParseSMSBody(listOfSMS, model);

            return(parsedSMS);
        }
Exemple #3
0
        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);
 }
Exemple #5
0
        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;
        }
Exemple #6
0
 public SettingsPage(SettingsSchemaModel schema) : this()
 {
     this.schema = schema;
     BindPage();
 }
Exemple #7
0
 public void AddSettingsSchema(SettingsSchemaModel schema)
 {
     sqlconnection.InsertWithChildren(schema, recursive: true);
 }
Exemple #8
0
 public void UpdateSettingsSchema(SettingsSchemaModel schema)
 {
     sqlconnection.Update(schema);
 }
Exemple #9
0
 public KeyProfitWordPage(SettingsSchemaModel schema) : this()
 {
     BindingContext = new KeyProfitWordViewModel(schema, this);
 }