Beispiel #1
0
        public static TaskInfo GetTask(string taskid, string taskname)
        {
            try
            {
                XmlDocument objXmlDoc;
                TaskInfo task = new TaskInfo();

                if (taskid == null || taskid == string.Empty)
                    return null;

                objXmlDoc = GetTaskConfigFile(taskid, taskname);
                if (objXmlDoc == null)
                    return null;

                task.TaskId = taskid;
                task.TaskName = taskname;

                //root node
                XmlNode objTaskNode = objXmlDoc.SelectSingleNode(Constants.CONFIG_ROOT + Constants.CHAR_SLASH + Constants.TASK_TASK);
                if (objTaskNode == null)
                    return null;

                XmlNode objNode;
                DataView dv;
                /*------------------------------Code Generator-----------------------------------*/
                objNode = objTaskNode.SelectSingleNode(Constants.COMP_CODEGENERATOR);
                if (objNode != null)
                {
                    XmlNode nodeDbServer = objNode.SelectSingleNode(Constants.COMP_CODEGENERATOR_DBSERVER);
                    task.DatabaseServer.ServerName = DataConvert.GetString(nodeDbServer.SelectSingleNode(Constants.COMP_CODEGENERATOR_SERVERNAME).InnerText);
                    task.DatabaseServer.DatabaseName = DataConvert.GetString(nodeDbServer.SelectSingleNode(Constants.COMP_CODEGENERATOR_DATABASENAME).InnerText);
                    task.DatabaseServer.ConnectionString = DataConvert.GetString(nodeDbServer.SelectSingleNode(Constants.COMP_CODEGENERATOR_CONNECTIONSTRING).InnerText);
                    task.Solution = DataConvert.GetString(objNode.SelectSingleNode(Constants.COMP_CODEGENERATOR_SOLUTION).InnerText);
                    task.Project = DataConvert.GetString(objNode.SelectSingleNode(Constants.COMP_CODEGENERATOR_PROJECT).InnerText);
                    task.Template = DataConvert.GetString(objNode.SelectSingleNode(Constants.COMP_CODEGENERATOR_TEMPLATE).InnerText);
                    task.NameSpacePrefix = DataConvert.GetString(objNode.SelectSingleNode(Constants.COMP_CODEGENERATOR_NAMESPACEPREFIX).InnerText);
                    task.NameSpaceSuffix = DataConvert.GetString(objNode.SelectSingleNode(Constants.COMP_CODEGENERATOR_NAMESPACESUFFIX).InnerText);
                    /*------------------------------Tables-----------------------------------*/
                    dv = GetData(objXmlDoc, Constants.CONFIG_ROOT + Constants.CHAR_SLASH + Constants.TASK_TASK + Constants.CHAR_SLASH + Constants.COMP_CODEGENERATOR + Constants.CHAR_SLASH + Constants.COMP_CODEGENERATOR_TABLES);

                    Collection<TableInfo> tables = new Collection<TableInfo>();

                    for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                    {
                        TableInfo table = new TableInfo();
                        table.TableName = DataConvert.GetString(dv.Table.Rows[ix][0]);
                        tables.Add(table);
                    }
                    task.Tables = tables;
                    /*------------------------------Modules-----------------------------------*/
                    dv = GetData(objXmlDoc, Constants.CONFIG_ROOT + Constants.CHAR_SLASH + Constants.TASK_TASK + Constants.CHAR_SLASH + Constants.COMP_CODEGENERATOR + Constants.CHAR_SLASH + Constants.COMP_CODEGENERATOR_MODULES);

                    Collection<ModuleInfo> modules = new Collection<ModuleInfo>();

                    for (int ix = 0; ix < dv.Table.Rows.Count; ix++)
                    {
                        ModuleInfo module = new ModuleInfo();
                        module.ModuleName = DataConvert.GetString(dv.Table.Rows[ix][0]);
                        modules.Add(module);
                    }
                    task.Modules = modules;
                }
                /*------------------------------Code Generator-----------------------------------*/               

                /*------------------------------Miscellaneous-----------------------------------*/
                objNode = objTaskNode.SelectSingleNode(Constants.TASK_NODE_MISCELLANEOUS);
                if (objNode != null)
                {
                    if (objNode.SelectSingleNode(Constants.TASK_MISCELLANEOUS_WRITELOGTOFILE) != null)
                        task.WriteLogToFile = DataConvert.GetBool(objNode.SelectSingleNode(Constants.TASK_MISCELLANEOUS_WRITELOGTOFILE).InnerText);
                    else
                        task.WriteLogToFile = false;
                }
                /*------------------------------Miscellaneous-----------------------------------*/

                

                return task;
            }
            catch (Exception ex)
            {
                Log4Helper.Write("ConfigCtrl.GetTask", taskname + "(" + taskid.ToString() + ")", ex, LogSeverity.Fatal);
                throw;
            }
        }
Beispiel #2
0
 public static Collection<ModuleInfo> GetModules(string path)
 {
     Collection<ModuleInfo> modules = new Collection<ModuleInfo>();
     string[] files = Directory.GetFiles(path);
     if (files != null)
     {
         for (int ix = 0; ix < files.Length; ix++)
         {
             ModuleInfo module = new ModuleInfo();
             module.FullName = files[ix];
             module.ModuleName = Path.GetFileNameWithoutExtension(files[ix]);
             modules.Add(module);
         }
     }
     return modules;
 }