Exemplo n.º 1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         lp.CronExpression1 = this.tbcron1.Text.Trim();
         lp.CronExpression2 = this.tbcron2.Text.Trim();
         lp.SqlConnStr      = this.tbsqlconnstr.Text.Trim();
         if (!SQLbll.IsConn(lp.SqlConnStr))
         {
             MessageBox.Show("数据库连接失败:" + lp.SqlConnStr);
             return;
         }
         lp.CronExpressionTaocan      = this.tbcronTaocan.Text.Trim();
         lp.CronExpressionTaocanClose = this.tbcronTaocanClose.Text.Trim();
         lp.EprIdBnetAccount          = this.tbEpridBnetaccount.Text.Trim();
         lp.UID = this.tbUid.Text.Trim();
         lp.PWD = this.tbPwd.Text.Trim();
         lp.Save();
         lp.Reload();
         MessageBox.Show("成功!");
     }
     catch (Exception ex)
     {
         MessageBox.Show("失败" + ex);
     }
 }
Exemplo n.º 2
0
        //补单
        private void btnStart_Click(object sender, EventArgs e)
        {
            DateTime dtnow     = DateTime.Now;
            int      yy        = dtnow.Year;
            int      mm        = dtnow.Month;
            int      dd        = dtnow.Day;
            string   file      = this.tbFile.Text.Trim();
            string   billparam = this.tbBill.Text.Trim();

            billparam.Replace(",", ",");
            billparam.Replace(";", ",");
            string[]      parray = billparam.Split('\n');
            List <string> strLst = new List <string>();
            List <string> sqlLst = new List <string>();

            foreach (string s in parray)
            {
                string[] saray = s.Split(',');
                if (saray.Length > 2)
                {
                    int len = int.Parse(saray[2]);
                    for (int i = 0; i < len; i++)
                    {
                        string t = string.Format("{0}|{1}|0|1|0|0|{2}", saray[0], saray[1], dtnow.ToString("yyyy/MM/dd H:mm:ss", DateTimeFormatInfo.InvariantInfo));
                        strLst.Add(t);
                    }
                    object        obj     = SQLbll.ExecuteScalar(string.Format("select Id from jy15.gdkltx.dbo.t_eprinfo where BnetId='{0}'", saray[0]));
                    BnetInfoModel bimodel = SQLbll.GetBnetInfo(saray[0], saray[1]);
                    int           eprid   = 0;
                    if (obj != null && bimodel != null)
                    {
                        eprid = int.Parse(obj.ToString());
                        object[] objarray = { eprid, saray[0], saray[1], len, 0, 0, yy, mm, dd, 1, dtnow + ":补推", bimodel.Price, 0, bimodel.TaoCanType };
                        string   sql      = string.Format("Insert into jy15.gdkltx.dbo.t_billdaystat(EprId,BnetId,BnetAccount,CTcount,CUcount,CMcount,YY,MM,DD,AreaId,memo,Price,InitialNum,TaoCanType) values({0},'{1}','{2}',{3},{4},{5},{6},{7},{8},{9},'{10}',{11},{12},'{13}')", objarray);
                        sqlLst.Add(sql);
                    }
                }
            }
            if (strLst.Count > 0)
            {
                if (string.IsNullOrEmpty(file))
                {
                    file = Application.StartupPath + "\\补推.txt";
                }
                bool bsz = MyFileOptions.WriteFileTXT(strLst, file);
                if (bsz)
                {
                    if (sqlLst != null)
                    {
                        SQLbll.BatchExec(sqlLst);
                    }
                }
                MessageBox.Show(bsz.ToString());
            }
            else
            {
                MessageBox.Show("失败");
            }
        }
Exemplo n.º 3
0
        //启动
        private void toolStripBtnStart_Click(object sender, EventArgs e)
        {
            lp = new LocalParams();
            if (lp == null)
            {
                MessageBox.Show("LocalParams为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(lp.CronExpression1) || string.IsNullOrEmpty(lp.CronExpression2))
            {
                MessageBox.Show("请设置QZ运行表达示。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(lp.SqlConnStr))
            {
                MessageBox.Show("请设置数据库连接字符串。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!SQLbll.IsConn(lp.SqlConnStr))
            {
                MessageBox.Show("数据库连接字符串无效。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            CreateJob cjob = new CreateJob();

            if (!cjob.CheckCronExpression(lp.CronExpression1))
            {
                MessageBox.Show(string.Format("表达试[{0}]无效", lp.CronExpression1), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!cjob.CheckCronExpression(lp.CronExpression2))
            {
                MessageBox.Show(string.Format("表达试[{0}]无效", lp.CronExpression2), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            /*
             * if (!cjob.CheckCronExpression(lp.CronExpressionTaocan))
             * {
             *  MessageBox.Show(string.Format("表达试[{0}]无效", lp.CronExpressionTaocan), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  return;
             * }
             *
             * if (!cjob.CheckCronExpression(lp.CronExpressionTaocanClose))
             * {
             *  MessageBox.Show(string.Format("表达试[{0}]无效", lp.CronExpressionTaocanClose), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  return;
             * }
             * */

            // [秒] [分] [小时] [日] [月] [周] [年],日和周必须互斥,不能都指明特定的数字或*,必须有一个是?; *号就是每的意思;?代表不确定; - 表示区间; ,表示多个值
            // 0 58 9 23 * ?,每年每月23号9点58分0秒执行
            // 0 0/1 * * * ?,第分钟执行一次
            // 0 0 * * * ?,每小时一次
            // 0 15 10 15 * ? 每月15日上午10:15触发
            // 0 15 10 L * ?  每月最后一天的10点15分触发
            string     cron  = "0 28 15 * * ?";
            IScheduler sched = cjob.CreateSched(lp.CronExpression1, "trigger1", "group1", typeof(CreateBillJob));

            if (sched != null)
            {
                schList.Add(sched);
                sched.Start();
            }
            else
            {
                MessageBox.Show(string.Format("表达试[{0}] CreateBillJob初始化失败!", lp.CronExpression1), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IScheduler sched2 = cjob.CreateSched(lp.CronExpression2, "trigger2", "group2", typeof(CreateEmptyBillJob));

            if (sched2 != null)
            {
                schList.Add(sched2);
                sched2.Start();
            }
            else
            {
                MessageBox.Show("提示", string.Format("表达试[{0}] CreateBillJob初始化失败!", lp.CronExpression2), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            /*
             * IScheduler sched3 = cjob.CreateSched(lp.CronExpressionTaocan, "trigger3", "group3", typeof(CreateTaoCanBillJob));
             * if (sched3 != null)
             * {
             *  schList.Add(sched3);
             *  sched3.Start();
             * }
             * else
             * {
             *  MessageBox.Show("提示", string.Format("表达试[{0}] CreateTaoCanBillJob初始化失败!", lp.CronExpressionTaocan), MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  return;
             * }
             */

            /*
             * IScheduler sched4 = cjob.CreateSched(lp.CronExpressionTaocanClose, "trigger4", "group4", typeof(CreateTaoCanCloseBillJob));
             * if (sched4 != null)
             * {
             *  schList.Add(sched4);
             *  sched4.Start();
             * }
             * else
             * {
             *  MessageBox.Show("提示", string.Format("表达试[{0}] CreateTaoCanCloseBillJob初始化失败!", lp.CronExpressionTaocanClose), MessageBoxButtons.OK, MessageBoxIcon.Error);
             *  return;
             * }
             */

            this.toolStripBtnStart.Enabled  = false;
            this.toolStripStatusLabel2.Text = DateTime.Now.ToString("yyyy/MM/dd H:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);// string.Format("{0:yyyy\\/MM\\/dd HH:mm:ss}", DateTime.Now);//2005/11/5 14:23:20 这种格式更适合老外的格式;
        }