Example #1
0
        public static bool SendAllotment()
        {
            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();

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

                Dictionary<string, Allotment> mapAllotment = new Dictionary<string, Allotment>();
                while (sqlReader.Read())
                {
                    int AllotmentId = Convert.ToInt32(sqlReader["AllotmentId"]);
                    string stockCode = sqlReader["StockCode"].ToString();
                    int stockMarket = Convert.ToInt32(sqlReader["stockMarket"]);

                    double Scheme = Convert.ToDouble(sqlReader["Scheme"]);
                    double Price = Convert.ToDouble(sqlReader["Price"]);

                    DateTime RecordDate = Convert.ToDateTime(sqlReader["RecordDate"]);
                    DateTime PayBeginDate = Convert.ToDateTime(sqlReader["PayBeginDate"]);
                    DateTime PayEndDate = Convert.ToDateTime(sqlReader["PayEndDate"]);
                    DateTime ExecuteDate = Convert.ToDateTime(sqlReader["ExecuteDate"]);

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

                    Allotment currAllotment = new Allotment();
                    currAllotment.Initialize();
                    currAllotment.StockCode = stockCode;
                    currAllotment.Market = (StockMarket)stockMarket;

                    currAllotment.Scheme = Scheme;
                    currAllotment.Price = Price;

                    currAllotment.RecordDate = RecordDate;
                    currAllotment.PayBeginDate = PayBeginDate;
                    currAllotment.PayEndDate = PayEndDate;
                    currAllotment.ExecuteDate = ExecuteDate;

                    currAllotment.SendFlag = sendFlag;

                    mapAllotment[stockCode] = currAllotment;

                }
                sqlReader.Close();
                Loger.Debug("mapAllotment count = " + mapAllotment.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, Allotment> t_mapAllotment = new Dictionary<string, Allotment>(mapAllotment);
                foreach (var data in t_mapAllotment)
                {
                    Allotment t_Allotment = new Allotment();
                    t_Allotment = data.Value;
                    zns.Interface.RI_Result RetSetAllotment = 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];
                        RetSetAllotment = rmt.SetExAllotments("", t_Allotment.StockCode, (zns.Interface.RI_Market)t_Allotment.Market,
                        t_Allotment.Scheme, t_Allotment.Price,
                        t_Allotment.RecordDate, t_Allotment.PayBeginDate, t_Allotment.PayEndDate, t_Allotment.ExecuteDate,
                        true);
                        Loger.Debug("StockCode = " + data.Value.StockCode + "\t" + "status = " + RetSetAllotment);
                    }
                    t_Allotment.SendFlag = 1;
                    mapAllotment[data.Key] = t_Allotment;
                }

                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 SendAllotment()
        {
            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();
                }

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

                Dictionary <string, Allotment> mapAllotment = new Dictionary <string, Allotment>();
                while (sqlReader.Read())
                {
                    int    AllotmentId = Convert.ToInt32(sqlReader["AllotmentId"]);
                    string stockCode   = sqlReader["StockCode"].ToString();
                    int    stockMarket = Convert.ToInt32(sqlReader["stockMarket"]);

                    double Scheme = Convert.ToDouble(sqlReader["Scheme"]);
                    double Price  = Convert.ToDouble(sqlReader["Price"]);

                    DateTime RecordDate   = Convert.ToDateTime(sqlReader["RecordDate"]);
                    DateTime PayBeginDate = Convert.ToDateTime(sqlReader["PayBeginDate"]);
                    DateTime PayEndDate   = Convert.ToDateTime(sqlReader["PayEndDate"]);
                    DateTime ExecuteDate  = Convert.ToDateTime(sqlReader["ExecuteDate"]);

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

                    Allotment currAllotment = new Allotment();
                    currAllotment.Initialize();
                    currAllotment.StockCode = stockCode;
                    currAllotment.Market    = (StockMarket)stockMarket;

                    currAllotment.Scheme = Scheme;
                    currAllotment.Price  = Price;

                    currAllotment.RecordDate   = RecordDate;
                    currAllotment.PayBeginDate = PayBeginDate;
                    currAllotment.PayEndDate   = PayEndDate;
                    currAllotment.ExecuteDate  = ExecuteDate;

                    currAllotment.SendFlag = sendFlag;

                    mapAllotment[stockCode] = currAllotment;
                }
                sqlReader.Close();
                Loger.Debug("mapAllotment count = " + mapAllotment.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, Allotment> t_mapAllotment = new Dictionary <string, Allotment>(mapAllotment);
                foreach (var data in t_mapAllotment)
                {
                    Allotment t_Allotment = new Allotment();
                    t_Allotment = data.Value;
                    zns.Interface.RI_Result RetSetAllotment = 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];
                        RetSetAllotment = rmt.SetExAllotments("", t_Allotment.StockCode, (zns.Interface.RI_Market)t_Allotment.Market,
                                                              t_Allotment.Scheme, t_Allotment.Price,
                                                              t_Allotment.RecordDate, t_Allotment.PayBeginDate, t_Allotment.PayEndDate, t_Allotment.ExecuteDate,
                                                              true);
                        Loger.Debug("StockCode = " + data.Value.StockCode + "\t" + "status = " + RetSetAllotment);
                    }
                    t_Allotment.SendFlag   = 1;
                    mapAllotment[data.Key] = t_Allotment;
                }

                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();
                }
            }
        }