Ejemplo n.º 1
0
        public long GetLastNumberDocument()
        {
            MySqlData myCon = new MySqlData();
            long      value = myCon.GetNumberLines();

            return(value);
        }
Ejemplo n.º 2
0
 public DaemonMySql(RpcConfig bitsharesConfig, RpcConfig bitcoinConfig,
                    string bitsharesAccount, string adminUsernames,
                    string databaseName, string databaseUser, string databasePassword)
     : base(bitsharesConfig, bitcoinConfig, bitsharesAccount, adminUsernames)
 {
     m_dataAccess = new MySqlData(databaseName, databaseUser, databasePassword);
 }
Ejemplo n.º 3
0
        public static MySqlProviderAdapter GetInstance(string name)
        {
            if (name == ProviderName.MySqlConnector)
            {
                if (_mysqlConnectorInstance == null)
                {
                    lock (_mysqlConnectorSyncRoot)
                        if (_mysqlConnectorInstance == null)
                        {
                            _mysqlConnectorInstance = MySqlConnector.CreateAdapter();
                        }
                }

                return(_mysqlConnectorInstance);
            }
            else
            {
                if (_mysqlDataInstance == null)
                {
                    lock (_mysqlDataSyncRoot)
                        if (_mysqlDataInstance == null)
                        {
                            _mysqlDataInstance = MySqlData.CreateAdapter();
                        }
                }

                return(_mysqlDataInstance);
            }
        }
Ejemplo n.º 4
0
 public MysqlAuthenticator(string database, string databaseUser, string password,
                           int allowedThreadId)
     : base()
 {
     m_database = new MySqlData(database, databaseUser, password);
     //m_bitsharesAccount = bitsharesAccount;
 }
Ejemplo n.º 5
0
        public void Update(string item, string parameter, string newData)
        {
            var updateData = new List <Tuple <string, string> >();

            updateData.Add(new Tuple <string, string>(parameter, newData));
            MySqlData.Update(parameter, item, updateData);
        }
Ejemplo n.º 6
0
        public List <QueueTransaction> Search(string searchInput, bool updateFromDataBase = true)
        {
            var transactions = new List <QueueTransaction>();
            var columns      = new List <string>
            {
                "Id",
                "Codigo",
                "CategoriaProducto",
                "Descripcion",
                "PrecioVendido",
                "UnidadesVendidas",
                "TotalVendido",
                "FechaVenta",
                "Cliente",
                "Vendedor",
                "FacturaRequerida",
                "NumeroPedido"
            };

            //Return empty list if invalid inputs are entered for the search
            if (string.IsNullOrWhiteSpace(searchInput))
            {
                return(transactions);
            }


            if (updateFromDataBase || allFields == null)
            {
                allFields = MySqlData.SelectAll(columns).AsEnumerable();
            }
            if (searchInput == "*")
            {
                foreach (var row in allFields)
                {
                    var transaction = new QueueTransaction(base.FilePath, MySqlData)
                    {
                        Id                 = Int32.Parse(row["Id"].ToString()),
                        ProductCode        = row["Codigo"].ToString(),
                        ProductCategory    = row["CategoriaProducto"].ToString(),
                        ProductDescription = row["Descripcion"].ToString(),
                        PriceSold          = Decimal.Parse(row["PrecioVendido"].ToString()),
                        UnitsSold          = Int32.Parse(row["UnidadesVendidas"].ToString()),
                        TotalAmountSold    = Decimal.Parse(row["TotalVendido"].ToString()),
                        Date               = Convert.ToDateTime(row["FechaVenta"].ToString()),
                        Customer           = row["Cliente"].ToString(),
                        Seller             = row["Vendedor"].ToString(),
                        OrderNumber        = Int32.Parse(row["NumeroPedido"].ToString())
                    };
                    FiscalReceiptRequired = row["FacturaRequerida"].ToString() == "Si";
                    transactions.Add(transaction);
                }
                return(transactions);
            }
            return(transactions);
        }
Ejemplo n.º 7
0
        public TestBase()
        {
            m_database = new Database(kDatabaseName, kDatabaseUser, kDatabasePassword, Thread.CurrentThread.ManagedThreadId);

            RedisWrapper.Initialise("test");

            m_data       = new MySqlData(kDatabaseName, kDatabaseUser, kDatabasePassword);
            m_currencies = m_data.GetAllCurrencies();

            m_defaultSymbolPair = CurrencyHelpers.GetMarketSymbolPair(m_currencies["bitBTC"], m_currencies[kBtc]);
            m_alternateMarket   = CurrencyHelpers.GetMarketSymbolPair(m_currencies["bitGOLD"], m_currencies[kBtc]);

            Thread thread = new Thread(() =>
            {
                string bitsharesUrl      = "http://localhost:65066/rpc";
                string bitsharesUser     = "******";
                string bitsharesPassword = "******";
                string bitsharesAccount  = "gatewaytest";

                string bitcoinUrl      = "http://localhost:18332";
                string bitcoinUser     = "******";
                string bitcoinPassword = "******";
                bool bitcoinUseTestNet = true;

                string database         = kDatabaseName;
                string databaseUser     = kDatabaseUser;
                string databasePassword = kDatabasePassword;

                string apiListen = kApiRoot;

                // create a scheduler so we can be sure of thread affinity
                AsyncPump scheduler = new AsyncPump(Thread.CurrentThread, OnException);

                m_api = new MetaDaemonApi(new RpcConfig {
                    m_url = bitsharesUrl, m_rpcUser = bitsharesUser, m_rpcPassword = bitsharesPassword
                },
                                          new RpcConfig {
                    m_url = bitcoinUrl, m_rpcUser = bitcoinUser, m_rpcPassword = bitcoinPassword, m_useTestnet = bitcoinUseTestNet
                },
                                          bitsharesAccount,
                                          database, databaseUser, databasePassword,
                                          apiListen, null, null, "gatewayclient", "http://192.168.0.2:1235/", "192.168.0.2", scheduler);

                m_api.m_ApiServer.m_HttpServer.m_DdosProtector.m_Enabled = false;

                scheduler.RunWithUpdate(m_api.Start, m_api.Update, 1);

                Console.WriteLine("meta thread exiting...");
            });

            thread.Start();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Register queue transaction
        /// </summary>
        public void Insert()
        {
            var colValPairs = new List <Tuple <string, string> >();

            colValPairs.Add(new Tuple <string, string>("Codigo", ProductCode));
            colValPairs.Add(new Tuple <string, string>("CategoriaProducto", ProductCategory));
            colValPairs.Add(new Tuple <string, string>("Descripcion", ProductDescription));
            colValPairs.Add(new Tuple <string, string>("PrecioVendido", PriceSold.ToString()));
            colValPairs.Add(new Tuple <string, string>("UnidadesVendidas", UnitsSold.ToString()));
            colValPairs.Add(new Tuple <string, string>("TotalVendido", TotalAmountSold.ToString()));
            colValPairs.Add(new Tuple <string, string>("FechaVenta", Utilities.FormatDateForMySql(DateTime.Now)));
            colValPairs.Add(new Tuple <string, string>("Cliente", Customer));
            colValPairs.Add(new Tuple <string, string>("Vendedor", Seller));
            colValPairs.Add(new Tuple <string, string>("FacturaRequerida", FiscalReceiptRequiredString));
            colValPairs.Add(new Tuple <string, string>("NumeroPedido", OrderNumber.ToString()));
            MySqlData.Insert(colValPairs);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Проверка введенного пароля с хешем из базы
        /// </summary>
        /// <returns></returns>
        public bool CheckPassword()
        {
            bool            returnValue = false;
            MySqlData       myCon       = new MySqlData();
            MySqlDataReader dataReader  = myCon.GetUserData(this.login);

            while (dataReader.Read())
            {
                MD5    mD5hash = MD5.Create();
                string hash    = GetMd5Hash(mD5hash, password);
                if (VerifyMd5Hash(mD5hash, dataReader["Password"].ToString(), hash))
                {
                    returnValue = true;
                }
            }
            myCon.CloseConnection();
            return(returnValue);
        }
Ejemplo n.º 10
0
        private void MySqlDemo_Load(object sender, EventArgs e)
        {
            try
            {
                string    sCon       = "server=192.168.1.137;database=union_resource;User ID=root;Password=root;CharSet=utf8;";
                MySqlData _MySqlData = new MySqlData(sCon);
                string    _sql       = "select RingCode, Name, Forlisten, ForSend from union_resource.t_mp3list; limit 1,10";
                string[]  _arr       = new string[1] {
                    "0"
                };
                DataSet _ds   = _MySqlData.getDs(_sql, _arr);
                string  sTemp = "";
                MessageBox.Show(_ds.Tables[0].Columns[0].ColumnName);
                for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
                {
                    for (int j = 0; j < _ds.Tables[0].Columns.Count; j++)
                    {
                        sTemp += "---" + _ds.Tables[0].Rows[i][j].ToString();
                    }
                    sTemp += "\n";
                }
                MessageBox.Show(sTemp);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }

            /*
             * MySqlDataGridVw.DataSource = _ds;
             *
             * // Automatically resize the visible rows.
             * MySqlDataGridVw.AutoSizeRowsMode =
             *  DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
             *
             * // Set the DataGridView control's border.
             * MySqlDataGridVw.BorderStyle = BorderStyle.Fixed3D;
             *
             * // Put the cells in edit mode when user enters them.
             * MySqlDataGridVw.EditMode = DataGridViewEditMode.EditOnEnter;
             * */
        }
Ejemplo n.º 11
0
        public bool FullUpdate()
        {
            var columns = new List <string>
            {
                "Id",
                "Codigo",
                "CategoriaProducto",
                "Descripcion",
                "PrecioVendido",
                "UnidadesVendidas",
                "TotalVendido",
                "FechaVenta",
                "Cliente",
                "Vendedor",
                "FacturaRequerida",
                "NumeroPedido"
            };

            if (MySqlData != null)
            {
                var data = new List <Tuple <string, string> >()
                {
                    new Tuple <string, string>(columns[1], this.ProductCode),
                    new Tuple <string, string>(columns[2], this.ProductCategory),
                    new Tuple <string, string>(columns[3], this.ProductDescription),
                    new Tuple <string, string>(columns[4], this.PriceSold.ToString()),
                    new Tuple <string, string>(columns[5], this.UnitsSold.ToString()),
                    new Tuple <string, string>(columns[6], this.TotalAmountSold.ToString()),
                    new Tuple <string, string>(columns[7], Utilities.FormatDateForMySql(this.Date)),
                    new Tuple <string, string>(columns[8], this.Customer),
                    new Tuple <string, string>(columns[9], this.Seller),
                    new Tuple <string, string>(columns[10], this.FiscalReceiptRequiredString),
                    new Tuple <string, string>(columns[11], this.OrderNumber.ToString())
                };
                MySqlData.Update("Id", this.Id.ToString(), data);
            }

            return(true);
        }
Ejemplo n.º 12
0
        /// <summary>	Executes the push transactions action. </summary>
        ///
        /// <remarks>	Paul, 20/02/2015. </remarks>
        ///
        /// <param name="newTrans">	The new transaction. </param>
        /// <param name="database">	The database. </param>
        void OnPushTransactions(List <TransactionsRow> newTrans, MySqlData database)
        {
            Dictionary <string, uint> lastSeen = new Dictionary <string, uint>();

            try
            {
                database.BeginTransaction();

                foreach (TransactionsRow r in newTrans)
                {
                    // this may have problems with partial transactions
                    database.InsertTransaction(r.symbol_pair, r.deposit_address, r.order_type, r.received_txid, r.sent_txid, r.amount, r.price, r.fee, r.status, r.date, r.notes, TransactionPolicy.REPLACE);

                    if (lastSeen.ContainsKey(r.symbol_pair))
                    {
                        lastSeen[r.symbol_pair] = Math.Max(r.uid, lastSeen[r.symbol_pair]);
                    }
                    else
                    {
                        lastSeen[r.symbol_pair] = r.uid;
                    }
                }

                // keep the site upto date with last seen transastion uids
                foreach (KeyValuePair <string, uint> kvp in lastSeen)
                {
                    database.UpdateLastSeenTransactionForSite(kvp.Key, kvp.Value);
                }

                database.EndTransaction();
            }
            catch (Exception)
            {
                database.RollbackTransaction();
                throw;
            }
        }
Ejemplo n.º 13
0
        /// <summary>	Aggregate result tasks. </summary>
        ///
        /// <remarks>	Paul, 19/02/2015. </remarks>
        ///
        /// <typeparam name="T">	Generic type parameter. </typeparam>
        /// <param name="c">		The RequestContext to process. </param>
        /// <param name="post">     true to post. </param>
        /// <param name="dummy">	The dummy. </param>
        ///
        /// <returns>	A Task&lt;T&gt;[]. </returns>
        Task <T>[] AggregateResultTasks <T>(string url, string postArgs, string getArgs, bool post, MySqlData database)
        {
            List <MarketRow> allMarkets = database.GetAllMarkets();

            // get all unique daemon urls
            List <string> allDaemons = allMarkets.Select <MarketRow, string>(r => r.daemon_url).Distinct().ToList();

            Task <T>[] allTasks = new Task <T> [allDaemons.Count()];

            // execute the get on each one
            for (int i = 0; i < allTasks.Length; i++)
            {
                if (post)
                {
                    allTasks[i] = Rest.JsonApiCallAsync <T>(ApiUrl(allDaemons[i], url), postArgs);
                }
                else
                {
                    allTasks[i] = Rest.JsonApiGetAsync <T>(ApiUrl(allDaemons[i], url) + (getArgs.Length > 0?"?" + getArgs:""));
                }
            }

            return(allTasks);
        }
Ejemplo n.º 14
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string    sCon       = "server=192.168.1.157;database=es_mediaresource;User ID=root;Password=root;CharSet=utf8;";
                MySqlData _MySqlData = new MySqlData(sCon);
                string[]  arrType    = new string[2] {
                    "mp3", "photo"
                };
                string[] arrTypeHttpFolder = new string[2] {
                    "http://r01.mmstoon.com/mp3/", "http://p01.mmstoon.com/mmsimg/comm/"
                };
                string[] arrSql = new string[2] {
                    "select RingCode, ForSend from union_resource.t_mp3list", "select PhotoCode, ComImg from union_resource.t_photolist"
                };
                string[] arrSqlDealName = new string[2] {
                    "Update union_resource.t_mp3list Set ForSend = @P2, Forlisten = @P2 Where RingCode = @P1", "Update union_resource.t_photolist Set Style128_128 = @P2,ComImg = @P2 Where PhotoCode = @P1"
                };
                string[] arrSqlDealFlag = new string[2] {
                    "Update union_resource.t_mp3list Set Checked = 3 Where RingCode = @P1", "Update union_resource.t_photolist Set Checked = 3 Where PhotoCode = @P1"
                };
                string sLocalFolder = textBox1.Text.Trim();
                if (sLocalFolder != "")
                {
                    //下载处理
                    for (int i = 0; i < arrType.Length; i++)
                    {
                        MsgDtlHandle("正在下载" + arrType[i] + "...");
                        DataSet _ds = _MySqlData.getDs(arrSql[i], null);
                        for (int j = 0; j < _ds.Tables[0].Rows.Count; j++)
                        {
                            DataRow _curRow = _ds.Tables[0].Rows[j];
                            MsgDtlHandle("正在下载" + arrTypeHttpFolder[i] + _curRow[1].ToString() + "...");
                            //类型目录
                            string sLocalPath = "";
                            sLocalPath = sLocalFolder + "\\" + arrType[i];

                            string sRetFileName = "";

                            Boolean blnDownFlag = false;
                            blnDownFlag = FileDown.DownFile(arrTypeHttpFolder[i], _curRow[1].ToString(), sLocalPath, 3, "", true, out sRetFileName);

                            //文件数据处理
                            //成功
                            if (blnDownFlag)
                            {
                                //更新数据库文件名
                                string sFileName = "";
                                if (_curRow[1].ToString().IndexOf("/") > 0)
                                {
                                    string[] arrTemp = _curRow[1].ToString().Split(new string[1] {
                                        "/"
                                    }, StringSplitOptions.RemoveEmptyEntries);
                                    sFileName = _curRow[1].ToString().Replace(arrTemp[arrTemp.Length - 1], sRetFileName);
                                    //Console.WriteLine(_curRow[1].ToString() + "--->" + sFileName);
                                }
                                else
                                {
                                    sFileName = sRetFileName;
                                }
                                _MySqlData.ExecuteNonQuery(arrSqlDealName[i], new string[2] {
                                    _curRow[0].ToString(), sFileName
                                });
                                MsgDtlHandle("完成下载:" + arrTypeHttpFolder[i] + _curRow[1].ToString());
                            }
                            //失败
                            else
                            {
                                //更新数据状态为文件缺失
                                _MySqlData.ExecuteNonQuery(arrSqlDealFlag[i], new string[1] {
                                    _curRow[0].ToString()
                                });
                                MsgDtlHandle(FileDown.ErrMsg + "|--|" + _curRow[0].ToString() + "|--|" + _curRow[0].ToString() + "\n");
                                //Console.WriteLine("没有找到文件");
                            }
                            //Console.WriteLine(sRetFileName);
                        }
                    }

                    _MySqlData.closeConn();
                    MsgDtlHandle("全部下载任务完成!");
                }
            }
            catch (Exception ex)
            {
                MsgDtlHandle(ex.Message);
            }
        }
 public SalesReportsMySqlImporter(IUserInterfaceHandlerIO io)
 {
     var password = io.GetPassword();
     this.mySqlHandler = new MySqlData(password);
 }
Ejemplo n.º 16
0
        //MySqlData m_database;

        public BestPriceMarketOrders(Dictionary <int, BitsharesAsset> allAssets, List <BitsharesMarket> allMarkets, MySqlData database)
        {
            m_allAssets  = allAssets;
            m_allMarkets = allMarkets;
        }
Ejemplo n.º 17
0
        public SalesReportsMySqlImporter(IUserInterfaceHandlerIO io)
        {
            var password = io.GetPassword();

            this.mySqlHandler = new MySqlData(password);
        }
Ejemplo n.º 18
0
 public void DeleteOrder()
 {
     MySqlData.Delete("NumeroPedido", OrderNumber.ToString());
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Delete queue transaction
 /// </summary>
 public void Delete(int id)
 {
     MySqlData.Delete("Id", id.ToString());
 }