Ejemplo n.º 1
0
        private string GetTransferPayee(TransactionItem trans, DestinationAccountTypes accountType)
        {
            QifFilterSettings settings = QifFilterSettings.GetCurrent();
            string            result   = string.Empty;


            Match  match       = Regex.Match(trans.Category, @"\[(\w*)]");
            string accountName = match.Groups[1].ToString();


            foreach (TransfersInfo item in settings.TranfersRules.ListTransferInfo)
            {
                if (item.AccountName == accountName && item.DestAccountType == accountType)
                {
                    if (trans.Amount.Contains("-"))
                    {
                        result = item.WithdrawalPayee;
                    }
                    else
                    {
                        result = item.DepositPayee;
                    }
                    tag = item.Tag;
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            if (!File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MercantilRules.xml")))
            {
                MercantilRules mercantilRules = new MercantilRules();

                XmlSerializer mySerializer = new XmlSerializer(typeof(MercantilRules));
                // To write to a file, create a StreamWriter object.
                StreamWriter myWriter = new StreamWriter("MercantilRules.xml");
                mySerializer.Serialize(myWriter, mercantilRules);
                myWriter.Close();
            }

            if (!File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "QifFilterSettings.xml")))
            {
                QifFilterSettings settings     = new QifFilterSettings();
                XmlSerializer     mySerializer = new XmlSerializer(typeof(QifFilterSettings));

                StreamWriter myWriter = new StreamWriter("QifFilterSettings.xml");
                mySerializer.Serialize(myWriter, settings);
                myWriter.Close();
            }

            Application.Run(new frmMenu());
            //Application.Run(new frmQifFilter());
            //Application.Run(new frmTestFormat());
        }
Ejemplo n.º 3
0
        public static QifFilterSettings GetCurrent()
        {
            if (current == null)
            {
                string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "QifFilterSettings.xml");

                bool wasDeserialized = true;

                try
                {
                    if (File.Exists(filePath))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(QifFilterSettings));
                        using (FileStream stream = new FileStream(filePath, FileMode.Open))
                        {
                            current = (QifFilterSettings)serializer.Deserialize(stream);
                        }
                    }
                    else
                    {
                        wasDeserialized = false;
                    }
                }
                catch
                {
                    wasDeserialized = false;
                }
                finally
                {
                    if (!wasDeserialized)
                    {
                        current = new QifFilterSettings();
                    }
                }
            }

            return(current);
        }