Beispiel #1
0
 private void log(Task_t job, int[] logwhen, Hashtable ht, ref string Info)
 {
     Info += "[出错]\r\n" + (ht["Data"] ?? "").ToString();
     if (logwhen.Contains(job.LogWhen))
     {
         //失败或一定记录时
         WriteLog(Info);
     }
 }
Beispiel #2
0
 private void RunExe(ref string Info, Task_t job, Type[] types, object[] paras)
 {
     Info += "[程序集搜索路径:" + job.SearchPath + "][加载exe:" + job.TypeName + "]";
     try
     {
         Hashtable ht = MainUtil.InvokeExe(job.SearchPath, job.TypeName, paras.Select(p => (string)p).ToArray <string>());
         if (!(bool)ht["Success"])
         {
             Info += "[出错]\r\n" + (ht["Data"] ?? "").ToString();
             if (job.LogWhen == 0 || job.LogWhen == 2)
             {
                 //失败或一定记录时
                 WriteLog(Info);
             }
             return;
         }
         else
         {
             Info += "[成功]\r\n";
             if (job.LogWhen == 1 || job.LogWhen == 0)
             {
                 //成功时记录
                 WriteLog(Info);
             }
         }
     }
     catch (Exception ex)
     {
         if (job.LogWhen == 0 || job.LogWhen == 2)
         {
             //失败或一定记录时
             WriteLog(Info + "\r\n" + ex.ToString());
         }
         return;
     }
 }
Beispiel #3
0
 private void RunCSharp(ref string Info, Task_t job, Type[] types, object[] paras)
 {
     Info += "[程序集搜索路径:" + job.SearchPath + "][编译文件:" + job.TypeName + "][执行类:" + job.TypeName + "][执行方法:" + job.Method + "]";
     try
     {
         Hashtable ht = MainUtil.InvokeSrc(job.SearchPath, job.SrcCodeFilePath, job.TypeName, job.Method, types, paras);
         if (!(bool)ht["Success"])
         {
             Info += "[出错]\r\n" + (ht["Data"] ?? "").ToString();
             if (job.LogWhen == 0 || job.LogWhen == 2)
             {
                 //失败或一定记录时
                 WriteLog(Info);
             }
             return;
         }
         else
         {
             Info += "[成功]\r\n";
             if (job.LogWhen == 1 || job.LogWhen == 0)
             {
                 //成功时记录
                 WriteLog(Info);
             }
         }
     }
     catch (Exception ex)
     {
         if (job.LogWhen == 0 || job.LogWhen == 2)
         {
             //失败或一定记录时
             WriteLog(Info + "\r\n" + ex.ToString());
         }
         return;
     }
 }
Beispiel #4
0
        public void ExeJob(Task_t job)
        {
            string Info    = "";
            string jobtype = "未知类型";

            switch (job.Type)
            {
            case "DLL":
            {
                jobtype = "dll调用";
                break;
            }

            case "CS":
            {
                jobtype = "编译CS文件";
                break;
            }

            case "EXE":
            {
                jobtype = "exe调用";
                break;
            }

            default:
            {
                break;
            }
            }
            Info += "[任务名:" + job.Name + "][任务类型:" + jobtype + "]";

            //处理调用时的参数,默认没有参数
            Type[]   types      = new Type[] { };
            object[] paras      = new object[] { };
            string[] parastring = new string[] { };
            if (job.Paras != null && job.Paras.Split(',').Length > 0)
            {
                parastring = job.Paras.Split(',');
                //有参数情况,参数默认是一个字符串数组
                types    = new Type[] { typeof(string[]) };
                paras    = new object[1];
                paras[0] = new string[parastring.Length];
                for (int i = 0; i < parastring.Length; i++)
                {
                    (paras[0] as string[])[i] = parastring[i];
                }
            }
            switch (job.Type)
            {
            case "DLL":
                RunDll(ref Info, job, types, paras);
                break;

            case "CS":
                RunCSharp(ref Info, job, types, paras);
                break;

            case "EXE":
                RunExe(ref Info, job, types, paras);
                break;

            default:
                break;
            }
        }