Example #1
0
        public static bool SendBonus()
        {
            string strConn = "";
            SqlConnection sqlConn = null;
            SqlCommand sqlCmd = null;
            SqlDataReader sqlReader = null;
            try
            {
                Loger.Debug("\r\n\r\n>>> 开始发送股权登记公告 <<<");

                strConn = BaseConfig.ConnPlay;
                sqlConn = new SqlConnection(strConn.Trim());

                if (sqlConn.State == ConnectionState.Closed)
                    sqlConn.Open();

                sqlCmd = new SqlCommand("DELETE FROM BonusList", sqlConn);
                sqlCmd.ExecuteNonQuery();

                AcquireStockExRightsWS.AcquireStockExRights exRightsWS = new AcquireStockExRightsWS.AcquireStockExRights();
                DataSet dsExrights = exRightsWS.StockExRights();
                DataTable dtExrights = dsExrights.Tables[0];
                int nRow = 0;
                string strSqlInsert = string.Empty;
                foreach (DataRow row in dtExrights.Rows)
                {
                    if ((DateTime.Parse(row["GQDJR"].ToString())).Date != DateTime.Now.Date)
                        continue;

                    strSqlInsert = @"insert BonusList (StockCode, stockMarket, SendBonus, TransferBonus, BonusIssue, BonusRegDate, BonusExeDate, SendFlag )
                                        values (@StockCode, @stockMarket, @SendBonus, @TransferBonus, @BonusIssue, @BonusRegDate, @BonusExeDate, @SendFlag) ";
                    sqlCmd = new SqlCommand(strSqlInsert, sqlConn);
                    sqlCmd.Parameters.Add("@StockCode", SqlDbType.VarChar, 6).Value = row["GPDM"].ToString();
                    sqlCmd.Parameters.Add("@stockMarket", SqlDbType.Int).Value = (int)GetMarketCode(row["GPDM"].ToString());

                    double m_SendBonus=0.00d;
                    if (double.TryParse(row["SHGBL"].ToString(), out m_SendBonus))
                    {
                        m_SendBonus= Convert.ToDouble(row["SHGBL"].ToString());
                    }
                    sqlCmd.Parameters.Add("@SendBonus", SqlDbType.Float).Value = m_SendBonus;

                    double m_TransferBonus = 0.00d;
                    if (double.TryParse(row["ZZGBL"].ToString(), out m_TransferBonus))
                    {
                        m_TransferBonus = Convert.ToDouble(row["ZZGBL"].ToString());
                    }
                    sqlCmd.Parameters.Add("@TransferBonus", SqlDbType.Float).Value = m_TransferBonus;

                    decimal m_BonusIssue = 0.00M;
                    if (decimal.TryParse(row["SHPXBL"].ToString(), out m_BonusIssue))
                    {
                        m_BonusIssue = Convert.ToDecimal(row["SHPXBL"].ToString());
                    }
                    sqlCmd.Parameters.Add("@BonusIssue", SqlDbType.Money).Value = m_BonusIssue;

                    sqlCmd.Parameters.Add("@BonusRegDate", SqlDbType.SmallDateTime).Value = DateTime.Parse(row["GQDJR"].ToString());
                    sqlCmd.Parameters.Add("@BonusExeDate", SqlDbType.SmallDateTime).Value = DateTime.Parse(row["CQCXR"].ToString());
                    sqlCmd.Parameters.Add("@SendFlag", SqlDbType.Bit).Value = 0;

                    sqlCmd.ExecuteNonQuery();

                    nRow++;

                    Loger.Debug("SHGBL = " + m_SendBonus + "\t" + "ZZGBL = " + m_TransferBonus + "\t" + "SHGBL = " + m_BonusIssue + "\t" + "BonusRegDate = " + DateTime.Parse(row["GQDJR"].ToString()) + "\t");
                }
                Loger.Debug("get bonus data from AcquireStockExRights, count = " + nRow);

                // string strSql = @"SELECT * FROM BonusList where BonusRegDate = @BonusRegDate";
                string strSqlSelect = @"SELECT * FROM BonusList ";
                sqlCmd = new SqlCommand(strSqlSelect, sqlConn);
                sqlCmd.Parameters.Add("@BonusRegDate", SqlDbType.SmallDateTime).Value = DateTime.Today.ToString("yyyy-MM-dd");
                sqlReader = sqlCmd.ExecuteReader();

                Dictionary<string, Bonus> mapBonus = new Dictionary<string, Bonus>();
                while (sqlReader.Read())
                {
                    int bonusId = Convert.ToInt32(sqlReader["BonusId"]);
                    string stockCode = sqlReader["StockCode"].ToString();
                    int stockMarket = Convert.ToInt32(sqlReader["stockMarket"]);

                    double sendBonus = Convert.ToDouble(sqlReader["SendBonus"]);
                    double transferBonus = Convert.ToDouble(sqlReader["TransferBonus"]);
                    double bonusIssue = Convert.ToDouble(sqlReader["BonusIssue"]);

                    DateTime bonusRegDate = Convert.ToDateTime(sqlReader["BonusRegDate"]);
                    DateTime bonusExeDate = Convert.ToDateTime(sqlReader["BonusExeDate"]);

                    int sendFlag = Convert.ToInt32(sqlReader["SendFlag"]);

                    Bonus currBonus = new Bonus();
                    currBonus.Initialize();
                    currBonus.StockCode = stockCode;
                    currBonus.Market = (StockMarket)stockMarket;
                    currBonus.SendBonus = sendBonus;
                    currBonus.TransferBonus = transferBonus;
                    currBonus.BonusIssue = bonusIssue;
                    currBonus.BonusRegDate = bonusRegDate;
                    currBonus.BonusExeDate = bonusExeDate;
                    currBonus.SendFlag = sendFlag;

                    mapBonus[stockCode] = currBonus;

                }
                sqlReader.Close();
                Loger.Debug("mapBonus count = " + mapBonus.Count);

                zns.ITransactionRemotingProvider[] znRmtIobj = new zns.ITransactionRemotingProvider[BaseConfig.mapNotifySrv.Count];
                for (int i = 0; i < BaseConfig.mapNotifySrv.Count; i++)
                {
                    znRmtIobj[i] = Activator.GetObject(typeof(zns.ITransactionRemotingProvider), BaseConfig.mapNotifySrv[i].ri) as zns.ITransactionRemotingProvider;
                }

                Dictionary<string, Bonus> t_mapBonus = new Dictionary<string, Bonus>(mapBonus);
                foreach (var data in t_mapBonus)
                {
                    Bonus t_Bonus = new Bonus();
                    t_Bonus = data.Value;
                    zns.Interface.RI_Result RetSetExRights = zns.Interface.RI_Result.Success;
                    for (int i = 0; i < BaseConfig.mapNotifySrv.Count; i++)
                    {
                        znRmtIobj[i] = Activator.GetObject(typeof(zns.ITransactionRemotingProvider), BaseConfig.mapNotifySrv[i].ri) as zns.ITransactionRemotingProvider;
                        zns.ITransactionRemotingProvider rmt = znRmtIobj[i];
                        RetSetExRights = rmt.SetExRights("@!pH@2^!@8", t_Bonus.StockCode, (zns.Interface.RI_Market)t_Bonus.Market,
                             t_Bonus.SendBonus, t_Bonus.TransferBonus, t_Bonus.BonusIssue,
                             t_Bonus.BonusRegDate, t_Bonus.BonusExeDate, true);
                        Loger.Debug("StockCode = " + data.Value.StockCode + "\t" + "status = " + RetSetExRights);
                    }
                    t_Bonus.SendFlag = 1;
                    mapBonus[data.Key] = t_Bonus;
                }

                Loger.Debug("<<< 股权登记公告发送完成 >>>");
                return true;
            }
            catch (Exception err)
            {
                Loger.Debug(err);

                if (sqlReader != null && !sqlReader.IsClosed)
                    sqlReader.Close();
                return false;
            }
            finally
            {
                if (sqlConn.State != ConnectionState.Closed)
                    sqlConn.Close();
            }
        }
Example #2
0
        public static bool SendBonus()
        {
            string        strConn   = "";
            SqlConnection sqlConn   = null;
            SqlCommand    sqlCmd    = null;
            SqlDataReader sqlReader = null;

            try
            {
                Loger.Debug("\r\n\r\n>>> 开始发送股权登记公告 <<<");

                strConn = BaseConfig.ConnPlay;
                sqlConn = new SqlConnection(strConn.Trim());

                if (sqlConn.State == ConnectionState.Closed)
                {
                    sqlConn.Open();
                }

                sqlCmd = new SqlCommand("DELETE FROM BonusList", sqlConn);
                sqlCmd.ExecuteNonQuery();

                AcquireStockExRightsWS.AcquireStockExRights exRightsWS = new AcquireStockExRightsWS.AcquireStockExRights();
                DataSet   dsExrights   = exRightsWS.StockExRights();
                DataTable dtExrights   = dsExrights.Tables[0];
                int       nRow         = 0;
                string    strSqlInsert = string.Empty;
                foreach (DataRow row in dtExrights.Rows)
                {
                    if ((DateTime.Parse(row["GQDJR"].ToString())).Date != DateTime.Now.Date)
                    {
                        continue;
                    }

                    strSqlInsert = @"insert BonusList (StockCode, stockMarket, SendBonus, TransferBonus, BonusIssue, BonusRegDate, BonusExeDate, SendFlag ) 
                                        values (@StockCode, @stockMarket, @SendBonus, @TransferBonus, @BonusIssue, @BonusRegDate, @BonusExeDate, @SendFlag) ";
                    sqlCmd       = new SqlCommand(strSqlInsert, sqlConn);
                    sqlCmd.Parameters.Add("@StockCode", SqlDbType.VarChar, 6).Value = row["GPDM"].ToString();
                    sqlCmd.Parameters.Add("@stockMarket", SqlDbType.Int).Value      = (int)GetMarketCode(row["GPDM"].ToString());

                    double m_SendBonus = 0.00d;
                    if (double.TryParse(row["SHGBL"].ToString(), out m_SendBonus))
                    {
                        m_SendBonus = Convert.ToDouble(row["SHGBL"].ToString());
                    }
                    sqlCmd.Parameters.Add("@SendBonus", SqlDbType.Float).Value = m_SendBonus;

                    double m_TransferBonus = 0.00d;
                    if (double.TryParse(row["ZZGBL"].ToString(), out m_TransferBonus))
                    {
                        m_TransferBonus = Convert.ToDouble(row["ZZGBL"].ToString());
                    }
                    sqlCmd.Parameters.Add("@TransferBonus", SqlDbType.Float).Value = m_TransferBonus;

                    decimal m_BonusIssue = 0.00M;
                    if (decimal.TryParse(row["SHPXBL"].ToString(), out m_BonusIssue))
                    {
                        m_BonusIssue = Convert.ToDecimal(row["SHPXBL"].ToString());
                    }
                    sqlCmd.Parameters.Add("@BonusIssue", SqlDbType.Money).Value = m_BonusIssue;

                    sqlCmd.Parameters.Add("@BonusRegDate", SqlDbType.SmallDateTime).Value = DateTime.Parse(row["GQDJR"].ToString());
                    sqlCmd.Parameters.Add("@BonusExeDate", SqlDbType.SmallDateTime).Value = DateTime.Parse(row["CQCXR"].ToString());
                    sqlCmd.Parameters.Add("@SendFlag", SqlDbType.Bit).Value = 0;

                    sqlCmd.ExecuteNonQuery();

                    nRow++;

                    Loger.Debug("SHGBL = " + m_SendBonus + "\t" + "ZZGBL = " + m_TransferBonus + "\t" + "SHGBL = " + m_BonusIssue + "\t" + "BonusRegDate = " + DateTime.Parse(row["GQDJR"].ToString()) + "\t");
                }
                Loger.Debug("get bonus data from AcquireStockExRights, count = " + nRow);

                // string strSql = @"SELECT * FROM BonusList where BonusRegDate = @BonusRegDate";
                string strSqlSelect = @"SELECT * FROM BonusList ";
                sqlCmd = new SqlCommand(strSqlSelect, sqlConn);
                sqlCmd.Parameters.Add("@BonusRegDate", SqlDbType.SmallDateTime).Value = DateTime.Today.ToString("yyyy-MM-dd");
                sqlReader = sqlCmd.ExecuteReader();

                Dictionary <string, Bonus> mapBonus = new Dictionary <string, Bonus>();
                while (sqlReader.Read())
                {
                    int    bonusId     = Convert.ToInt32(sqlReader["BonusId"]);
                    string stockCode   = sqlReader["StockCode"].ToString();
                    int    stockMarket = Convert.ToInt32(sqlReader["stockMarket"]);

                    double sendBonus     = Convert.ToDouble(sqlReader["SendBonus"]);
                    double transferBonus = Convert.ToDouble(sqlReader["TransferBonus"]);
                    double bonusIssue    = Convert.ToDouble(sqlReader["BonusIssue"]);

                    DateTime bonusRegDate = Convert.ToDateTime(sqlReader["BonusRegDate"]);
                    DateTime bonusExeDate = Convert.ToDateTime(sqlReader["BonusExeDate"]);

                    int sendFlag = Convert.ToInt32(sqlReader["SendFlag"]);

                    Bonus currBonus = new Bonus();
                    currBonus.Initialize();
                    currBonus.StockCode     = stockCode;
                    currBonus.Market        = (StockMarket)stockMarket;
                    currBonus.SendBonus     = sendBonus;
                    currBonus.TransferBonus = transferBonus;
                    currBonus.BonusIssue    = bonusIssue;
                    currBonus.BonusRegDate  = bonusRegDate;
                    currBonus.BonusExeDate  = bonusExeDate;
                    currBonus.SendFlag      = sendFlag;

                    mapBonus[stockCode] = currBonus;
                }
                sqlReader.Close();
                Loger.Debug("mapBonus count = " + mapBonus.Count);

                zns.ITransactionRemotingProvider[] znRmtIobj = new zns.ITransactionRemotingProvider[BaseConfig.mapNotifySrv.Count];
                for (int i = 0; i < BaseConfig.mapNotifySrv.Count; i++)
                {
                    znRmtIobj[i] = Activator.GetObject(typeof(zns.ITransactionRemotingProvider), BaseConfig.mapNotifySrv[i].ri) as zns.ITransactionRemotingProvider;
                }

                Dictionary <string, Bonus> t_mapBonus = new Dictionary <string, Bonus>(mapBonus);
                foreach (var data in t_mapBonus)
                {
                    Bonus t_Bonus = new Bonus();
                    t_Bonus = data.Value;
                    zns.Interface.RI_Result RetSetExRights = zns.Interface.RI_Result.Success;
                    for (int i = 0; i < BaseConfig.mapNotifySrv.Count; i++)
                    {
                        znRmtIobj[i] = Activator.GetObject(typeof(zns.ITransactionRemotingProvider), BaseConfig.mapNotifySrv[i].ri) as zns.ITransactionRemotingProvider;
                        zns.ITransactionRemotingProvider rmt = znRmtIobj[i];
                        RetSetExRights = rmt.SetExRights("@!pH@2^!@8", t_Bonus.StockCode, (zns.Interface.RI_Market)t_Bonus.Market,
                                                         t_Bonus.SendBonus, t_Bonus.TransferBonus, t_Bonus.BonusIssue,
                                                         t_Bonus.BonusRegDate, t_Bonus.BonusExeDate, true);
                        Loger.Debug("StockCode = " + data.Value.StockCode + "\t" + "status = " + RetSetExRights);
                    }
                    t_Bonus.SendFlag   = 1;
                    mapBonus[data.Key] = t_Bonus;
                }

                Loger.Debug("<<< 股权登记公告发送完成 >>>");
                return(true);
            }
            catch (Exception err)
            {
                Loger.Debug(err);

                if (sqlReader != null && !sqlReader.IsClosed)
                {
                    sqlReader.Close();
                }
                return(false);
            }
            finally
            {
                if (sqlConn.State != ConnectionState.Closed)
                {
                    sqlConn.Close();
                }
            }
        }