Example #1
0
        private TargetServerInfoViewModel AliveServer()
        {
            CALCULATION_SERVER_STATUS_Table_DAOManager daoM = new CALCULATION_SERVER_STATUS_Table_DAOManager();

            daoM.SERVER_STATUS_ = "idle";

            daoM.select(DataBaseConnectManager.ConnectionFactory(DataBaseConnectManager.ConnectionString_));

            TargetServerInfoViewModel tsivm = new TargetServerInfoViewModel();

            //tsivm.buildFromDAO(daoM.DAOList_[0]);

            return(tsivm);
        }
Example #2
0
        private InstrumentData getInstrumentData()
        {
            CALCULATION_QUEUE_INFO_Table_DAOManager daoM = new CALCULATION_QUEUE_INFO_Table_DAOManager();

            daoM.select(DataBaseConnectManager.ConnectionFactory(DataBaseConnectManager.ConnectionString_));

            InstrumentData instrumentData = new InstrumentData();

            instrumentData.InstrumentCode_ = daoM.DAOList_[0].INST_CODE_;
            instrumentData.InstrumentType_ = daoM.DAOList_[0].INST_TYPE_;
            //instrumentData.InstrumentXml_= daoM.DAOList_[0].INST_MSGXML;

            return(instrumentData);
        }
        public override void DoJob()
        {
            //this.buildInstrumentInfo();

            // db queue insert

            CALCULATION_SERVER_STATUS_Table_DAO dao = new CALCULATION_SERVER_STATUS_Table_DAO();

            dao.SERVER_NAME_        = this.MessageViewModel_.MessageHeaderViewModel_.Item_code_;
            dao.SERVER_IP_          = "";
            dao.SERVER_PORT_        = "13212";
            dao.SERVER_CORENUM_     = "2";
            dao.SERVER_STATUS_      = "alive";
            dao.SERVER_USE_         = "use";
            dao.SERVER_DESCRIPTION_ = "haha test cal server";
            dao.SERVER_ALIVETIME_   = DateTime.Now.ToString("yyyyMMddffffff");

            string connectionStr = DataBaseConnectManager.ConnectionString_;

            if (dao.SERVER_STATUS_ == "regist")
            {
                dao.insert(DataBaseConnectManager.ConnectionFactory(connectionStr));
            }
            else if (dao.SERVER_STATUS_ == "start")
            {
                dao.update(DataBaseConnectManager.ConnectionFactory(connectionStr));
            }
            else if (dao.SERVER_STATUS_ == "stop")
            {
                dao.update(DataBaseConnectManager.ConnectionFactory(connectionStr));
            }
            else if (dao.SERVER_STATUS_ == "deRegist")
            {
                dao.update(DataBaseConnectManager.ConnectionFactory(connectionStr));
            }
            else
            {
            }

            //string fileName = this.InstrumentCode_;

            //File.WriteAllText(fileName, this.InstrumentXml_);

            //Console.WriteLine("File Saved. , name : {0} : ", fileName);

            //AsynchronousSocketListener.InstrumentQueue_.Enqueue(this);
        }
        public void select(DbConnection conn)
        {
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }

            DataTable tb = new DataTable();

            this.DAOList_ = new List <CALCULATION_SERVER_STATUS_Table_DAO>();

            DbCommand dbCommand = conn.CreateCommand();

            string selectQuery = CALCULATION_SERVER_STATUS_Table_DAOManager.SelectQuery_;



            //selectQuery = selectQuery.Replace("@KeyColumnValue@", this.KeyColumn_);

            dbCommand.CommandText = selectQuery;

            //DbDataAdapter dataAdapter = new DbDataAdapter(dbCommand, conn);
            DbDataAdapter dataAdapter = DataBaseConnectManager.CreateDataAdapter(dbCommand, conn);

            dataAdapter.Fill(tb);

            DataRow[] dr       = tb.Select();
            int       rowCount = dr.Length;

            foreach (DataRow item in dr)
            {
                CALCULATION_SERVER_STATUS_Table_DAO dao = new CALCULATION_SERVER_STATUS_Table_DAO();

                dao.SERVER_NAME_        = item[0].ToString();
                dao.SERVER_IP_          = item[1].ToString();
                dao.SERVER_PORT_        = item[2].ToString();
                dao.SERVER_STATUS_      = item[3].ToString();
                dao.SERVER_CORENUM_     = item[4].ToString();
                dao.SERVER_USE_         = item[5].ToString();
                dao.SERVER_ALIVETIME_   = item[6].ToString();
                dao.SERVER_DESCRIPTION_ = item[7].ToString();

                this.DAOList_.Add(dao);
            }
        }
Example #5
0
        public void select(DbConnection conn)
        {
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }

            DataTable tb = new DataTable();

            this.DAOList_ = new List <CALCULATION_QUEUE_INFO_Table_DAO>();

            DbCommand dbCommand = conn.CreateCommand();

            string selectQuery = CALCULATION_QUEUE_INFO_Table_DAOManager.SelectQuery_;



            //selectQuery = selectQuery.Replace("@KeyColumnValue@", this.KeyColumn_);

            dbCommand.CommandText = selectQuery;

            //DbDataAdapter dataAdapter = new DbDataAdapter(dbCommand, conn);
            DbDataAdapter dataAdapter = DataBaseConnectManager.CreateDataAdapter(dbCommand, conn);

            dataAdapter.Fill(tb);

            DataRow[] dr       = tb.Select();
            int       rowCount = dr.Length;

            foreach (DataRow item in dr)
            {
                CALCULATION_QUEUE_INFO_Table_DAO dao = new CALCULATION_QUEUE_INFO_Table_DAO();

                dao.INST_CODE_         = item[0].ToString();
                dao.INST_TYPE_         = item[1].ToString();
                dao.INST_NAME_         = item[2].ToString();
                dao.PARA_DATE_         = item[3].ToString();
                dao.CALCULATION_STATE_ = item[4].ToString();

                this.DAOList_.Add(dao);
            }
        }
        //public void buildInstrumentInfo()
        //{
        //    //this.xmlDoc_.LoadXml(this.InstrumentXml_);

        //    this.InstrumentType_ = "testType";
        //    this.InstrumentCode_ = "testCode";
        //    this.ReferenceDate_ = "testRefDate";
        //}

        public override void DoJob()
        {
            //this.buildInstrumentInfo();

            // db queue insert

            CALCULATION_QUEUE_INFO_Table_DAO dao = new CALCULATION_QUEUE_INFO_Table_DAO();

            GridCalculationViewModel gcvm = this.MessageViewModel_.MessageBodyViewModel_ as GridCalculationViewModel;

            dao.INST_CODE_ = gcvm.Inst_code_;
            dao.INST_NAME_ = gcvm.Inst_name_;
            dao.INST_TYPE_ = gcvm.Inst_type_;
            dao.PARA_DATE_ = gcvm.Para_refDate_;

            dao.CALCULATION_STATE_ = "regist";

            string connectionStr = DataBaseConnectManager.ConnectionString_;

            if (dao.CALCULATION_STATE_ == "regist")
            {
                dao.insert(DataBaseConnectManager.ConnectionFactory("sqlCe", connectionStr));
                File.WriteAllText(gcvm.Inst_code_ + ".xml", gcvm.InnerXml_);
            }
            else if (dao.CALCULATION_STATE_ == "deRegist")
            {
                dao.delete(DataBaseConnectManager.ConnectionFactory("sqlCe", connectionStr));
            }
            else
            {
            }


            //string fileName = this.InstrumentCode_;

            //File.WriteAllText(fileName, this.InstrumentXml_);

            //Console.WriteLine("File Saved. , name : {0} : ", fileName);

            //AsynchronousSocketListener.InstrumentQueue_.Enqueue(this);
        }