private JackTime2Run.JackJob GeneJob() { JackTime2Run.JackJob job = new JackTime2Run.JackJob(); job.Name = txt_name.Text; job.Cron = txt_cron.Text; job.TypeName = txt_typename.Text; job.SearchPath = txt_searchpath.Text; job.AppConfig = txt_appconfig.Text; job.Method = txt_method.Text; job.SrcCodeFilePath = txt_srccodepath.Text; job.LogWhen = txt_logwhen.SelectedIndex.ToString(); job.JobType = txt_jobtype.SelectedIndex.ToString(); job.Enable = txt_enable.SelectedIndex.ToString(); List <string> linesList = new List <string>(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (i == dataGridView1.Rows.Count - 1 && (dataGridView1.Rows[i].Cells[0].Value ?? "").ToString() == "") { break; } linesList.Add((dataGridView1.Rows[i].Cells[0].Value ?? "").ToString()); } job.Paras = linesList.ToArray(); return(job); }
private void button2_Click(object sender, EventArgs e) { try { if (!Vali()) { return; } JackTime2Run.JackJob job = GeneJob(); JackTime2Run.NamePipeSrvClient client = new JackTime2Run.NamePipeSrvClient(); if (!client.UpdateJob(job)) { MessageBox.Show("执行失败,服务异常,请查看日志[" + AppDomain.CurrentDomain.BaseDirectory + "log\\SrvManage" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".log]", "服务异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { this.Close(); } } catch (Exception ex) { if (ex is System.ServiceModel.EndpointNotFoundException) { MessageBox.Show("连接失败,请检查是否启动了服务JackTime2Run!", "连接失败", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("执行失败,失败信息:" + ex.ToString(), "执行失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }