示例#1
0
文件: Form1.cs 项目: jxsgood/WEBCNG
 void JJB_SJ_锁定站点数据(object sender, Even_更新站点数据 e)
 {
     textBox1.AppendText(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
     textBox1.AppendText(" 锁定执行=" + e.ok);
     textBox1.AppendText(" 信息:" + e.mes + "\r\n");
 }
示例#2
0
        public bool FF_锁定站点数据(int zd, DateTime time)
        {
            string zdIP = "";
            string zdName = "";
            Even_更新站点数据 e = new Even_更新站点数据();
            switch (zd)
            {
                case 2: zdIP = "192.168.173.3"; zdName = "南高"; break;//南高
                case 3: zdIP = "192.168.172.23"; zdName = "江阳西路"; break;//江阳西路
                case 4: zdIP = "192.168.171.3"; zdName = "麻柳沱"; break;  //麻柳沱
                default:
                    break;
            }
            DAL Zdal = new DAL(zdIP);//用于连接站点数据库

            if (Zdal.TestCon(3) == false)//先测试连接,失败就返回
            {
                e.ok = false;
                e.mes = zdName + " 更新失败";
            }
            else
            {
                string SQL = "UPDATE [CNGMS].[dbo].[endtime] SET [endtime] ='{0}' WHERE id=1";
                SQL = string.Format(SQL, time.ToString());
                Zdal.RunSql(SQL);

                //string path = Sys.GetRunPath() + "\\CngSystem.xml";
                //Sys.xmlAdd(path, "服务器站点更新", "锁定时间为", time.ToString());
                e.mes = zdName + " 更新成功   锁定时间:" + time.ToString();
                e.ok = true;
            }

            if (this.SJ_锁定站点数据 != null)
            {//触发事件
                this.SJ_锁定站点数据(this, e);
            }
            return e.ok;
        }
示例#3
0
文件: Form1.cs 项目: jxsgood/WEBCNG
        void JJB_SJ_更新站点数据(object sender, Even_更新站点数据 e)
        {
            if (textBox1.TextLength > 1000) { textBox1.Text = ""; }

            textBox1.AppendText(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
            textBox1.AppendText(" 更新执行=" + e.ok);
            textBox1.AppendText(" 信息:" + e.mes + "\r\n");
            //textBox1.AppendText(" 更新数量="+e.n.ToString() + "\r\n");
            if (chK_SQL.Checked)
            {
                textBox1.AppendText(" SQL=" + e.zxSql + "\r\n");
            }
        }
示例#4
0
        /// <summary>
        /// 更新站点交接班记录
        /// </summary>
        /// <param name="zd">站点编号</param>
        public void FF_更新交接班记录(int zd)
        {
            string zdIP = "";
            string zdName = "";
            Even_更新站点数据 e = new Even_更新站点数据();
            switch (zd)
            {
                case 2: zdIP = "192.168.173.3"; zdName = "南高"; break;//南高
                case 3: zdIP = "192.168.172.23"; zdName = "江阳西路"; break;//江阳西路
                case 4: zdIP = "192.168.171.3"; zdName = "麻柳沱"; break;  //麻柳沱
                default:
                    break;
            }
            DAL Zdal = new DAL(zdIP);//用于连接站点数据库
            if (Zdal.TestCon(3) == false)//先测试连接,失败就返回
            {
                e.ok = false;
                e.mes = string.Format("连接站点={0} 失败", zdName.ToString());
                Sys.addLogErrToFiles(zdIP, "连接测试失败");

            }
            else
            {
                string path = Sys.GetRunPath() + "\\CngSystem.xml";
                //timeS 用于存放上次 成功获取数据的时间
                string timeS = Sys.xmlRead(path, "服务器站点更新", zdName.ToString(), DateTime.Now.AddDays(-2).ToString());//如果没找到事件,返回 当前时间-2天
                timeS = Convert.ToDateTime(timeS).AddMinutes(-15).ToString();// 时间点再 推后 15分钟
                string SQL = "SELECT * FROM [CNGMS].[dbo].[bztj] where 更新时间>'" + timeS + "'"; //查找是否有新数据
                DataTable dt = Zdal.RunSqlDataTable(SQL);
                e.ok = true;
                e.n = dt.Rows.Count;
                if (e.n <= 0)
                {//没有数据
                    Sys.xmlAdd(path, "服务器站点更新", zdName.ToString(), DateTime.Now.ToString());
                    e.mes = string.Format("连接站点={0} 未找到数据", zdName.ToString());
                }
                else
                {//找到新数据
                    DAL Sdal = new DAL();
                    foreach (DataRow dr in dt.Rows)
                    {

                        string drtime = dr["日期"].ToString();
                        string drbz = dr["班组"].ToString();

                        //查找服务器 是否已有对应数据
                        SQL = "select id FROM [CNGQT].[dbo].[CW_每班统计] where [站点]={0} and [日期]='{1}' and [班组]='{2}'";
                        SQL = string.Format(SQL, zd.ToString(), drtime, drbz);
                        string id = Sdal.RunSqlGetID(SQL);
                        bool ok = (id != null);//找到记录为真,进行更新,未找到记录为 假 进行插入操作

                        SQL = zdTOserver(dr, ok, zd, id);//返回 SQL文本

                        Sys.DebugMes(SQL);
                        Sdal.RunSql(SQL);
                        e.zxSql = SQL;

                    }
                }

                if (e.ok)
                {
                    Sys.xmlAdd(path, "服务器站点更新", zdName.ToString(), DateTime.Now.ToString());
                    e.ok = true;
                    e.mes = string.Format("连接站点={0} 更新数据={1}", zdName.ToString(), e.n.ToString());
                }

            }

            if (this.SJ_更新站点数据 != null)
            {//触发事件
                this.SJ_更新站点数据(this, e);
            }
        }