Пример #1
0
        public cCheckPlan()
        {
            if (!File.Exists(Program.getPrjPath() + "tasks\\plan\\plan.xml"))
            {
                cPlans cs = new cPlans();
                cs.NewIndexFile();
                cs = null;
            }

            try
            {
                m_runTasks = new List<cPlan>();

                IniCheckPlan();

                //��ʼ�������ļ�������,�������ļ��仯���ϸ�����������Ϣ
                m_FileMonitor = new cFileMonitor(Program.getPrjPath() + "tasks\\plan\\plan.xml");
                m_FileMonitor.ReloadPlanFile += this.On_Reload;

                //ϵͳĬ��Ϊ����ļ�����
                StartListenPlanFile();
            }
            catch (System.Exception ex)
            {
                if (e_ListenErrorEvent != null)
                {
                    e_ListenErrorEvent(this, new cListenErrorEventArgs(ex.Message));
                }
            }
        }
Пример #2
0
        private bool RenamePlanName(string OldName, string NewName)
        {
            cPlans p = new cPlans();

            try
            {
                p.RenamePlanName ( OldName, NewName);
            }
            catch (System.Exception ex)
            {
                p = null;
                MessageBox.Show(rm.GetString("Info65") + ex.Message, rm.GetString("MessageboxInfo"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            p = null;

            return true;
        }
Пример #3
0
        //��������ִ�мƻ�
        private void LoadTaskPlan()
        {
            ShowTaskPlan();

            cPlans p = new cPlans();

            p.LoadPlans();

            string runPlan = "";

            int count = 0;

            if (p.Plans == null || p.Plans.Count == 0)
            {
                count = 0;
            }
            else
            {
                count = p.Plans.Count;
            }

            for (int i = 0; i < count; i++)
            {

                switch (p.Plans[i].RunTaskPlanType)
                {
                    case (int)cGlobalParas.RunTaskPlanType .Ones :
                        runPlan =  p.Plans[i].RunOnesTime ;
                        break;
                    case (int)cGlobalParas.RunTaskPlanType.DayOnes :
                        runPlan = rm.GetString ("Everyday") + " " + p.Plans[i].RunDayTime;
                        break;
                    case (int)cGlobalParas.RunTaskPlanType.DayTwice :
                        runPlan = rm.GetString ("AM") + " " + p.Plans[i].RunAMTime + "  " + rm.GetString ("PM") + " " + p.Plans[i].RunPMTime + " " + rm.GetString("Run"); ;
                        break;
                    case (int)cGlobalParas.RunTaskPlanType.Weekly :
                        runPlan = rm.GetString ("Weekly") + " ";

                        string rWeekly = p.Plans[i].RunWeekly;
                        foreach (string sc in rWeekly.Split(','))
                        {
                            string ss = sc.Trim();
                            switch (ss)
                            {
                                case "0":
                                    runPlan += rm.GetString ("W0") + " ";
                                    break;
                                case "1":
                                    runPlan += rm.GetString("W1") + " ";
                                    break;
                                case "2":
                                    runPlan += rm.GetString("W2") + " ";
                                    break;
                                case "3":
                                    runPlan += rm.GetString("W3") + " ";
                                    break;
                                case "4":
                                    runPlan += rm.GetString("W4") + " ";
                                    break;
                                case "5":
                                    runPlan += rm.GetString("W5") + " ";
                                    break;
                                case "6":
                                    runPlan += rm.GetString("W6") + " ";
                                    break;
                                default :
                                    break;
                            }
                        }

                        runPlan += " " + p.Plans[i].RunWeeklyTime ;
                        break;
                    case (int)cGlobalParas.RunTaskPlanType.Custom :
                        runPlan = rm.GetString ("Info15") + " " + p.Plans[i].FirstRunTime + " " + rm.GetString ("Info16") + " " + p.Plans[i].RunInterval ;

                        break;
                }

                if (p.Plans[i].IsDisabled == true)
                {
                    string strDisabled = "";
                    if (p.Plans[i].DisabledType ==(int) cGlobalParas.PlanDisabledType.RunTime)
                        strDisabled = rm.GetString ("Run") + p.Plans[i].DisabledTime ;
                    else
                        strDisabled = rm.GetString ("Info17") + p.Plans[i].DisabledDateTime ;

                    if ( p.Plans[i].PlanState==(int)cGlobalParas.PlanState.Enabled )

                        dataTask.Rows.Add(imageList1.Images["taskplan"], p.Plans[i].PlanID, p.Plans[i].PlanState, this.treeMenu.SelectedNode.Name,
                            p.Plans[i].PlanName, cGlobalParas.ConvertName(p.Plans[i].PlanState), cGlobalParas.ConvertName(p.Plans[i].DisabledType ),
                            strDisabled, runPlan,
                            p.Plans[i].NextRunTime, p.Plans[i].PlanRemark);
                    else
                        dataTask.Rows.Add(imageList1.Images["disabledplan"], p.Plans[i].PlanID, p.Plans[i].PlanState, this.treeMenu.SelectedNode.Name,
                            p.Plans[i].PlanName, cGlobalParas.ConvertName(p.Plans[i].PlanState), cGlobalParas.ConvertName(p.Plans[i].DisabledType),
                            strDisabled, runPlan,
                            p.Plans[i].NextRunTime, p.Plans[i].PlanRemark);
            }
                else
                {
                    dataTask.Rows.Add(imageList1.Images["taskplan"], p.Plans[i].PlanID, p.Plans[i].PlanState, this.treeMenu.SelectedNode.Name,
                         p.Plans[i].PlanName, cGlobalParas.ConvertName(p.Plans[i].PlanState), rm.GetString("Info18"),
                        "", runPlan,
                        p.Plans[i].NextRunTime, p.Plans[i].PlanRemark);
                }

            }

            p = null;

            this.dataTask.Sort(this.dataTask.Columns[4], ListSortDirection.Ascending);

            this.dataTask.ClearSelection();
        }
Пример #4
0
        private bool DelPlan()
        {
            if (this.dataTask.SelectedRows.Count == 0)
            {
                return false;
            }

            if (this.dataTask.SelectedRows.Count == 1)
            {
                if (MessageBox.Show(rm.GetString ("Info24") + this.dataTask.SelectedCells[4].Value.ToString() + "\r\n"
                    + rm.GetString("Info25"), rm.GetString("MessageboxQuaere"),
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return false;
                }
            }
            else
            {
                if (MessageBox.Show(rm.GetString("Info26"), rm.GetString("MessageboxQuaere"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return false;
                }
            }

            try
            {
                cPlans ps = new cPlans();

                for (int index = 0; index < this.dataTask.SelectedRows.Count; index++)
                {
                    ps.DelPlan (this.dataTask.SelectedRows[index].Cells[1].Value.ToString());
                }

                ps = null;

                return true;

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(rm.GetString("Info27") + ex.Message, rm.GetString("MessageboxError"), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return false;
            }
        }
        //��Ӧ�������������¼�
        private void OnAddRunTask(object sender, cAddRunTaskEventArgs e)
        {
            //�������Ӻ󣬻��Զ�����
            m_rTask.AddTask(e.RunTask);

            //�жϴ˼ƻ��Ƿ���ڣ�������ڣ����޸ļƻ���״̬
            cPlans cp = new cPlans();
            cp.IfEnabled(Int64.Parse ( e.RunTask.PlanID),false);
            cp = null;
        }
        private Int64 SaveTaskPlan()
        {
            cPlan NewPlan = new cPlan();

            Int64 Nid = GetNewID();

            if (Nid == 0)
            {
                throw new cSoukeyException(rm.GetString ("Error21"));
            }

            NewPlan.PlanID = Nid;
            NewPlan.PlanName = this.txtPlanName.Text;
            NewPlan.PlanRemark = this.txtPlanDemo.Text;

            //ϵͳ�Զ��жϵ�ǰ�����״̬
            if (this.cboxIsDisabled.Checked == true)
            {
                if (this.raNumber.Checked == true)
                {
                    if (this.DisabledRunNum.Value == 1 && DateTime.Compare(DateTime.Now,this.RunOnceTime.Value) > 0)
                        NewPlan.PlanState =(int) cGlobalParas.PlanState.Disabled;
                    else
                        NewPlan.PlanState = (int)cGlobalParas.PlanState.Enabled;

                }
                else if (this.raDateTime.Checked == true)
                {
                    if (DateTime.Compare(DateTime.Now, this.DisabledDateTime.Value) < 0)
                        NewPlan.PlanState = (int)cGlobalParas.PlanState.Disabled;
                    else
                        NewPlan.PlanState = (int)cGlobalParas.PlanState.Enabled;
                }
            }
            else
            {
                NewPlan.PlanState = (int)cGlobalParas.PlanState.Enabled;
            }

            if (this.cboxIsRun.Checked == true)
                NewPlan.IsOverRun = true;
            else
                NewPlan.IsOverRun = false;

            if (this.cboxIsDisabled.Checked ==true )
                NewPlan.IsDisabled =true ;
            else
                NewPlan .IsDisabled =false ;

            if (this.raNumber.Checked ==true )
                NewPlan.DisabledType =(int) cGlobalParas.PlanDisabledType.RunTime ;
            else if (this.raDateTime .Checked ==true )
                NewPlan.DisabledType =(int) cGlobalParas.PlanDisabledType .RunDateTime ;

            NewPlan.DisabledTime =int.Parse (this.DisabledRunNum .Value.ToString () );
            NewPlan.DisabledDateTime = this.DisabledDateTime.Value;

            cTaskPlan tp;
            for (int i = 0; i < this.listTask.Items.Count; i++)
            {
                tp = new cTaskPlan();
                tp.RunTaskType = cGlobalParas.ConvertID(this.listTask.Items[i].Text);

                if (cGlobalParas.ConvertID(this.listTask.Items[i].Text)==(int)cGlobalParas.RunTaskType.DataTask )
                    tp.RunTaskName = cGlobalParas.ConvertID ( this.listTask.Items[i].SubItems[1].Text.ToString()).ToString ();
                else
                    tp.RunTaskName =this.listTask.Items[i].SubItems[1].Text.ToString();

                tp.RunTaskPara = this.listTask.Items[i].SubItems[2].Text.ToString();

                NewPlan.RunTasks.Add(tp);
            }

            if (this.raOneTime.Checked == true)
                NewPlan.RunTaskPlanType = (int) cGlobalParas.RunTaskPlanType.Ones;
            else if (this.raDay.Checked == true)
            {
                if (this.raRunones.Checked == true)
                    NewPlan.RunTaskPlanType = (int)cGlobalParas.RunTaskPlanType.DayOnes;
                else if (this.raRuntwice.Checked == true)
                    NewPlan.RunTaskPlanType = (int)cGlobalParas.RunTaskPlanType.DayTwice;
            }
            else if (this.raWeekly.Checked == true)
            {
                NewPlan.RunTaskPlanType = (int)cGlobalParas.RunTaskPlanType.Weekly;
            }
            else if (this.raCustom.Checked == true)
            {
                NewPlan.RunTaskPlanType = (int)cGlobalParas.RunTaskPlanType.Custom;
            }

            NewPlan.EnabledDateTime = this.EnabledDate.Value.ToLongDateString ();
            NewPlan.RunOnesTime = this.RunOnceTime.Value.ToString () ;
            NewPlan.RunDayTime = this.RunDayOnesTime.Value.ToLongTimeString();
            NewPlan.RunAMTime = this.RunDayTwice1Time.Value.ToLongTimeString();
            NewPlan.RunPMTime = this.RunDayTwice2Time.Value.ToLongTimeString();
            NewPlan.RunWeeklyTime = this.RunWeeklyTime.Value.ToLongTimeString();
            NewPlan.FirstRunTime = this.FirstRunTime.Value.ToLongTimeString();
            NewPlan.RunInterval = this.udRunInterval.Value.ToString();

            string runWeekly = "";

            if (this.cboxSunday.Checked ==true )
                runWeekly ="0";
            if (this.cboxMonday.Checked == true)
                runWeekly += ",1";
            if (this.cboxTuesday.Checked == true)
                runWeekly += ",2";
            if (this.cboxWednesday.Checked == true)
                runWeekly += ",3";
            if (this.cboxThursday.Checked == true)
                runWeekly += ",4";
            if (this.cboxFriday.Checked == true)
                runWeekly += ",5";
            if (this.cboxSturday.Checked == true)
                runWeekly += ",6";

            NewPlan.RunWeekly = runWeekly;

            cPlans p = new cPlans();

            if (this.FormState == cGlobalParas.FormState.New )
            {
                p.InsertPlan(NewPlan);
            }
            else if (this.FormState == cGlobalParas.FormState.Edit)
            {
                p.EditPlan(NewPlan);
            }

            p = null;

            return Nid;
        }
        public void LoadPlan(Int64 PlanID)
        {
            cPlans ps = new cPlans();

            cPlan p=ps.GetSinglePlan(PlanID);

            this.txtPlanName.Text = p.PlanName;
            this.txtPlanID.Text = p.PlanID.ToString ();
            this.txtPlanDemo.Text = p.PlanRemark;

            this.txtPlanState.Text = cGlobalParas.ConvertName(p.PlanState);

            if (p.IsOverRun == true)
                this.cboxIsRun.Checked = true;
            else
                this.cboxIsRun.Checked = false;

            if (p.IsDisabled == true)
                this.cboxIsDisabled.Checked = true;
            else
                this.cboxIsDisabled.Checked = false;

            if (p.DisabledType == (int)cGlobalParas.PlanDisabledType.RunTime)
                this.raNumber.Checked = true;
            else if (p.DisabledType == (int)cGlobalParas.PlanDisabledType.RunDateTime)
                this.raDateTime.Checked = true;

            this.DisabledRunNum.Value = p.DisabledTime;
            this.DisabledDateTime.Value = p.DisabledDateTime;

            ListViewItem litem;

            for (int i = 0; i < p.RunTasks.Count; i++)
            {
                litem = new ListViewItem();
                litem.Text = cGlobalParas.ConvertName ( p.RunTasks[i].RunTaskType);
                if (p.RunTasks[i].RunTaskType == (int)cGlobalParas.RunTaskType.DataTask)
                    litem.SubItems.Add(cGlobalParas.ConvertName(int.Parse (p.RunTasks[i].RunTaskName)));
                else
                    litem.SubItems.Add(p.RunTasks[i].RunTaskName);
                litem.SubItems.Add(p.RunTasks[i].RunTaskPara);

                this.listTask.Items.Add(litem);
            }

            this.EnabledDate.Value = DateTime.Parse (p.EnabledDateTime);

            switch (p.RunTaskPlanType)
            {
                case (int)cGlobalParas.RunTaskPlanType .Ones :
                    this.raOneTime.Checked = true;
                    this.RunOnceTime.Value = DateTime.Parse (p.RunOnesTime);
                    break;
                case (int)cGlobalParas.RunTaskPlanType.DayOnes :
                    this.raDay.Checked = true;
                    this.raRunones.Checked = true;
                    this.RunDayOnesTime.Value = DateTime.Parse (p.RunDayTime);
                    break;
                case (int)cGlobalParas.RunTaskPlanType.DayTwice :
                    this.raDay.Checked = true;
                    this.raRuntwice.Checked = true;
                    this.RunDayTwice1Time.Value =DateTime.Parse ( p.RunAMTime);
                    this.RunDayTwice2Time.Value = DateTime.Parse (p.RunPMTime);
                    break;
                case (int)cGlobalParas.RunTaskPlanType.Weekly :
                    this.raWeekly.Checked = true;
                    this.RunWeeklyTime.Value =DateTime.Parse ( p.RunWeeklyTime);
                    string rWeekly = p.RunWeekly;
                    foreach (string sc in rWeekly.Split(','))
                    {
                        string ss = sc.Trim();
                        switch (ss)
                        {
                            case "0":
                                this.cboxSunday.Checked = true;
                                break;
                            case "1":
                                this.cboxMonday.Checked = true;
                                break;
                            case "2":
                                this.cboxTuesday.Checked = true;
                                break;
                            case "3":
                                this.cboxWednesday.Checked = true;
                                break;
                            case "4":
                                this.cboxThursday.Checked = true;
                                break;
                            case "5":
                                this.cboxFriday.Checked = true;
                                break;
                            case "6":
                                this.cboxSunday.Checked = true;
                                break;
                            default :
                                break;
                        }
                    }
                    break;
                case (int)cGlobalParas.RunTaskPlanType.Custom :
                    this.raCustom.Checked = true;
                    this.FirstRunTime.Value = DateTime.Parse(p.FirstRunTime );
                    this.udRunInterval.Value = decimal.Parse( p.RunInterval);
                    break;
            }

            p = null;
            ps = null;
        }
Пример #8
0
        private void AutoState()
        {
            cPlans cp=new cPlans ();

            for (int i = 0; i < m_runTasks.Count; i++)
            {
                if (m_runTasks[i].IsDisabled == true)
                    cp.IfEnabled(m_runTasks[i].PlanID,true);
            }

            cp = null;
        }