Ejemplo n.º 1
0
        //修改制定计划的名称
        public bool RenamePlanName(string OldPlanName, string NewPlanName)
        {
            //判断计划文件是否存在,如果不存在则新建
            if (!IsExist())
            {
                NewIndexFile();
            }

            //判断计划是否重名,如果重名则需要进行名称修改
            cXmlIO xmlPlan = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml");

            DataView d = xmlPlan.GetData("descendant::Plans");

            if (d != null)
            {
                for (int i = 0; i < d.Count; i++)
                {
                    if (NewPlanName == d[i].Row["PlanName"].ToString())
                    {
                        xmlPlan = null;
                        throw new cSoukeyException("已经存在此计划,重命名失败");
                        return(false);
                    }
                }
            }

            xmlPlan.EditNodeValue("Plans", "PlanName", OldPlanName, "PlanName", NewPlanName);
            xmlPlan.Save();
            xmlPlan = null;

            return(true);
        }
Ejemplo n.º 2
0
        private void ModifyPlanRunTime(Int64 PlanID, int RunTime)
        {
            cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml");

            xmlConfig.EditNodeValue("Plans", "ID", PlanID.ToString(), "RunTimeCount", RunTime.ToString());
            xmlConfig.Save();
            xmlConfig = null;
        }
Ejemplo n.º 3
0
        private void ModifyPlanState(Int64 PlanID, cGlobalParas.PlanState pState)
        {
            cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml");

            xmlConfig.EditNodeValue("Plans", "ID", PlanID.ToString(), "PlanState", ((int)pState).ToString());
            xmlConfig.Save();
            xmlConfig = null;
        }
Ejemplo n.º 4
0
        private void ModifyPlanState(Int64 PlanID, cGlobalParas.PlanState pState)
        {
            cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml");

            xmlConfig.EditNodeValue("Plans", "ID", PlanID.ToString () ,"PlanState",((int)pState).ToString  ());
            xmlConfig.Save ();
            xmlConfig =null;
        }
Ejemplo n.º 5
0
        private void ModifyPlanRunTime(Int64 PlanID, int RunTime)
        {
            cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml");

            xmlConfig.EditNodeValue("Plans", "ID", PlanID.ToString(), "RunTimeCount", RunTime.ToString ());
            xmlConfig.Save();
            xmlConfig = null;
        }
Ejemplo n.º 6
0
        //根据taskid修改任务的名称
        public bool RenameTask(string TClass, string OldTaskName, string NewTaskName)
        {
            try
            {
                //根据任务分类获取任务的所属路径
                cTaskClass tc         = new cTaskClass();
                string     tClassPath = "";

                //判断新的任务路径是否存在,如果存在则报错
                if (TClass == "")
                {
                    tClassPath = Program.getPrjPath() + "tasks";
                }
                else
                {
                    tClassPath = tc.GetTaskClassPathByName(TClass);
                }

                tc = null;

                if (File.Exists(tClassPath + "\\" + NewTaskName + ".xml"))
                {
                    throw new cSoukeyException("您修改的任务名称已经存在,请重新修改!");
                }

                cTaskIndex xmlTasks = new cTaskIndex();

                if (TClass == "")
                {
                    xmlTasks.GetTaskDataByClass();
                }
                else
                {
                    xmlTasks.GetTaskDataByClass(TClass);
                }

                //开始初始化此分类下的任务
                int count = xmlTasks.GetTaskClassCount();

                for (int i = 0; i < count; i++)
                {
                    if (xmlTasks.GetTaskName(i) == NewTaskName)
                    {
                        xmlTasks = null;
                        throw new cSoukeyException("您修改的任务名称已经存在,请重新修改!");
                    }
                }
                xmlTasks = null;

                //开始修改任务的名称
                //先开始修改index.xml的名称
                cXmlIO xmlIndex = new cXmlIO(tClassPath + "\\index.xml");
                xmlIndex.EditNodeValue("TaskIndex", "Name", OldTaskName, "Name", NewTaskName);
                xmlIndex.Save();
                xmlIndex = null;

                //开始修改任务的名称
                cXmlIO xmlTask = new cXmlIO(tClassPath + "\\" + OldTaskName + ".xml");
                xmlTask.EditNodeValue("Task/BaseInfo/Name", NewTaskName);
                xmlTask.Save();
                xmlTask = null;

                File.SetAttributes(tClassPath + "\\" + OldTaskName + ".xml", System.IO.FileAttributes.Normal);
                File.Move(tClassPath + "\\" + OldTaskName + ".xml", tClassPath + "\\" + NewTaskName + ".xml");
            }
            catch (System.Exception ex)
            {
                throw ex;
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        //����taskid�޸����������
        public bool RenameTask(string TClass,string OldTaskName, string NewTaskName)
        {
            try
            {
                //������������ȡ���������·��
                cTaskClass tc = new cTaskClass();
                string tClassPath = "";

                //�ж��µ�����·���Ƿ���ڣ���������򱨴�
                if (TClass == "")
                {
                    tClassPath = Program.getPrjPath() + "tasks";
                }
                else
                {
                    tClassPath = tc.GetTaskClassPathByName(TClass);
                }

                tc = null;

                if (File.Exists(tClassPath + "\\" + NewTaskName + ".xml"))
                    throw new cSoukeyException("���޸ĵ����������Ѿ����ڣ��������޸ģ�");

                cTaskIndex xmlTasks = new cTaskIndex();

                if (TClass == "")
                {
                    xmlTasks.GetTaskDataByClass();
                }
                else
                {
                    xmlTasks.GetTaskDataByClass(TClass);
                }

                //��ʼ��ʼ���˷����µ�����
                int count = xmlTasks.GetTaskClassCount();

                for (int i = 0; i < count; i++)
                {
                    if (xmlTasks.GetTaskName(i) == NewTaskName)
                    {
                        xmlTasks = null;
                        throw new cSoukeyException("���޸ĵ����������Ѿ����ڣ��������޸ģ�");
                    }
                }
                xmlTasks = null;

                //��ʼ�޸����������
                //�ȿ�ʼ�޸�index.xml������
                cXmlIO xmlIndex = new cXmlIO(tClassPath + "\\index.xml");
                xmlIndex.EditNodeValue("TaskIndex", "Name", OldTaskName, "Name", NewTaskName);
                xmlIndex.Save();
                xmlIndex = null;

                //��ʼ�޸����������
                cXmlIO xmlTask = new cXmlIO(tClassPath + "\\" + OldTaskName + ".xml");
                xmlTask.EditNodeValue("Task/BaseInfo/Name", NewTaskName);
                xmlTask.Save();
                xmlTask = null;

                File.SetAttributes(tClassPath + "\\" + OldTaskName + ".xml", System.IO.FileAttributes.Normal);
                File.Move(tClassPath + "\\" + OldTaskName + ".xml", tClassPath + "\\" + NewTaskName + ".xml");
            }
            catch (System.Exception ex)
            {
                throw ex;
                return false;
            }

            return true;
        }
Ejemplo n.º 8
0
        //���������������������������½�һ�����࣬����ԭ�з��������
        //Ǩ�ƹ��������޸�������Ϣ�����񣬲�ɾ��ԭ������
        public bool RenameTaskClass(string TClassName, string NewTClassName)
        {
            try
            {
                int OldTaskClassID=0;
                string OldPath = GetTaskClassPathByName(TClassName);
                string NewPath = OldPath.Substring(0, OldPath.IndexOf(TClassName)) + NewTClassName;

                //�ж��µ�����·���Ƿ���ڣ���������򱨴�
                if (Directory.Exists (NewPath ))
                    throw new cSoukeyException("����������·���Ѿ����ڣ��������޸�����������ƣ�");

                //ת�����·��
                string NewRelativePath = cTool.GetRelativePath(NewPath);

                int tCount = GetTaskClassCount();

                //��Ҫ�ж��½�������������Ƿ��Ѿ�����
                for (int i = 0; i < tCount; i++)
                {
                    if (TaskClass[i].Row["Name"].ToString() == NewTClassName)
                    {
                        throw new cSoukeyException("��������Ѿ����ڣ�");
                    }

                     if (TaskClass[i].Row["Name"].ToString() == TClassName)
                    {
                         //��ȡԭ�з����ID
                         OldTaskClassID=GetTaskClassID (i);
                    }
                }

                if (OldTaskClassID == 0)
                {
                    throw new cSoukeyException("δ���ҵ���Ҫ�޸ķ������Ϣ�������޸�ʧ�ܣ�");
                }

                //��ʼ�޸���������µ�����������������
                cTaskIndex xmlTasks = new cTaskIndex();
                xmlTasks.GetTaskDataByClass(TClassName);

                //��ʼ��ʼ���˷����µ�����
                int count = xmlTasks.GetTaskClassCount();

                cXmlIO txml;

                for (int i = 0; i < count; i++)
                {
                    txml = new cXmlIO(OldPath + "\\" + xmlTasks.GetTaskName(i) + ".xml");
                    txml.EditNodeValue("Task/BaseInfo/Class", NewTClassName);
                    txml.Save();
                    txml = null;
                }

                xmlTasks = null;

                //��ʼ�޸�taskclass.xml�ļ��е��������������Ϣ
                xmlConfig.EditNodeValue("TaskClasses", "id", OldTaskClassID.ToString (), "Name", NewTClassName);
                xmlConfig.EditNodeValue("TaskClasses", "id", OldTaskClassID.ToString (), "Path", NewRelativePath);
                xmlConfig.Save();
                xmlConfig = null;

                //��ʼ���޸���������ʵ��·��
                File.SetAttributes(OldPath, System.IO.FileAttributes.Normal);
                Directory.Move(OldPath, NewPath);
                //Directory.Delete(OldPath);

            }
            catch (System.Exception ex)
            {
                throw ex;
                return false;
            }

            return true;
        }
Ejemplo n.º 9
0
        //任务分类改名,任务分类改名就是新建一个分类,并把原有分类的任务都
        //迁移过来,并修改任务信息的任务,并删除原有内容
        public bool RenameTaskClass(string TClassName, string NewTClassName)
        {
            try
            {
                int    OldTaskClassID = 0;
                string OldPath        = GetTaskClassPathByName(TClassName);
                string NewPath        = OldPath.Substring(0, OldPath.IndexOf(TClassName)) + NewTClassName;

                //判断新的任务路径是否存在,如果存在则报错
                if (Directory.Exists(NewPath))
                {
                    throw new cSoukeyException("新任务分类的路径已经存在,请重新修改任务分类名称!");
                }

                //转换相对路径
                string NewRelativePath = cTool.GetRelativePath(NewPath);

                int tCount = GetTaskClassCount();

                //需要判断新建立的任务分类是否已经存在
                for (int i = 0; i < tCount; i++)
                {
                    if (TaskClass[i].Row["Name"].ToString() == NewTClassName)
                    {
                        throw new cSoukeyException("任务分类已经存在!");
                    }

                    if (TaskClass[i].Row["Name"].ToString() == TClassName)
                    {
                        //获取原有分类的ID
                        OldTaskClassID = GetTaskClassID(i);
                    }
                }

                if (OldTaskClassID == 0)
                {
                    throw new cSoukeyException("未能找到需要修改分类的信息,名称修改失败!");
                }

                //开始修改任务分类下的所有任务的所属分类
                cTaskIndex xmlTasks = new cTaskIndex();
                xmlTasks.GetTaskDataByClass(TClassName);

                //开始初始化此分类下的任务
                int count = xmlTasks.GetTaskClassCount();

                cXmlIO txml;

                for (int i = 0; i < count; i++)
                {
                    txml = new cXmlIO(OldPath + "\\" + xmlTasks.GetTaskName(i) + ".xml");
                    txml.EditNodeValue("Task/BaseInfo/Class", NewTClassName);
                    txml.Save();
                    txml = null;
                }

                xmlTasks = null;

                //开始修改taskclass.xml文件中的任务分类索引信息
                xmlConfig.EditNodeValue("TaskClasses", "id", OldTaskClassID.ToString(), "Name", NewTClassName);
                xmlConfig.EditNodeValue("TaskClasses", "id", OldTaskClassID.ToString(), "Path", NewRelativePath);
                xmlConfig.Save();
                xmlConfig = null;

                //开始将修改任务分类的实际路径
                File.SetAttributes(OldPath, System.IO.FileAttributes.Normal);
                Directory.Move(OldPath, NewPath);
                //Directory.Delete(OldPath);
            }
            catch (System.Exception ex)
            {
                throw ex;
                return(false);
            }

            return(true);
        }