Beispiel #1
0
        public void MainWork()
        {
            TemplateDAL    templateDal    = new TemplateDAL();
            TestProjectDAL testProjectDal = new TestProjectDAL();
            int            tid            = 0;
            string         filePath       = @"D:\程序运行目录\Temp_XML";//获取这个 文件夹 下面的 所有的xml 文件,得到文件名, 文件名就是 tid

            DirectoryInfo directInfo = new DirectoryInfo(filePath);

            if (directInfo.Exists)
            {
                FileInfo[] fileAttr = directInfo.GetFiles("*.xml");

                StringBuilder sb = new StringBuilder();
                foreach (FileInfo fileInfo in fileAttr)
                {
                    int.TryParse(fileInfo.Name.Replace(".xml", ""), out tid);
                    if (tid > 0)
                    {
                        string      xml         = File.ReadAllText(fileInfo.FullName, Encoding.UTF8);
                        XmlTemplate xmlTemplate = new XmlTemplate(xml);
                        if (xmlTemplate.SiteName.ToLower() == "blog")
                        {
                            sb.Append("" + tid + ",");
                        }
                        //Console.WriteLine(tid);
                        //testProjectDal.InserttestProject(1,1,tid,0);
                        //templateDal.ReadTemplateService(tid, cateId);
                    }
                }

                Console.WriteLine(sb.ToString());
            }
        }
Beispiel #2
0
 /**
  * Método para actualizar un nuevo registro
  */
 public static void update(Template template)
 {
     try {
         List <templates_tasks> list = template.tasks.Select(x => new templates_tasks {
             name             = x.name,
             description      = x.description,
             task_status_code = x.task_status_code,
         }).ToList();
         TemplateDAL.update(template.id, template.name, template.description, template.state, list, template.userId);
     } catch (Exception e) {
         throw e;
     }
 }
Beispiel #3
0
        //Source used here
        // https://www.codeproject.com/Articles/19911/Dynamically-Invoke-A-Method-Given-Strings-with-Met

        public static string InvokeStringToMethod(string typeName, string methodName, string stringParam, TemplateDTO templateDTO, int templateId)
        {
            // Get the Type for the class
            Type        calledType  = Type.GetType(typeName);
            TemplateDAL templateDAL = new TemplateDAL();

            // Invoke the method itself. The string returned by the method winds up in s.
            // Note that stringParam is passed via the last parameter of InvokeMember,
            // as an array of Objects.

            var methodInfo = calledType.GetMethod(methodName);
            var s          = methodInfo.Invoke(
                templateDAL,
                BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod,
                null, new object[] { stringParam, templateDTO, templateId },
                null);

            // Return the string that was returned by the called method.
            return(s.ToString());
        }
Beispiel #4
0
 /**
  * Método para obtener la lista de datos realizando el mapeo desde la capa de datos
  */
 public static List <Template> fetchAll()
 {
     try {
         return(TemplateDAL.fetchAll().Select(x => new Template {
             id = long.Parse(x.id + ""),
             name = x.name,
             description = x.description,
             state = int.Parse(x.state + ""),
             tasks = TemplateTaskDAL.fetchAll().Where(z => z.template_id == x.id).Select(y => new TemplateTask {
                 id = long.Parse(y.id + ""),
                 name = y.name,
                 description = y.description,
                 task_status_code = y.task_status_code,
                 template_id = long.Parse(y.template_id + "")
             }).ToList(),
             userId = long.Parse(x.user_id + "")
         }).ToList());
     } catch (Exception e) {
         throw e;
     }
 }
Beispiel #5
0
        /**
         * Método para crear un nuevo registro
         */
        public static void insert(Template Template)
        {
            try {
                if (TemplateDAL.exists(Template.name))
                {
                    throw new ExistsException();
                }
                else
                {
                    List <templates_tasks> list = Template.tasks.Select(x => new templates_tasks {
                        name             = x.name,
                        description      = x.description,
                        task_status_code = x.task_status_code,
                        end_date         = x.endDate,
                    }).ToList();

                    TemplateDAL.insert(Template.name, Template.description, list, Template.userId);
                }
            } catch (Exception e) {
                throw e;
            }
        }
Beispiel #6
0
        public static List <Template> fetchAllByUnit(decimal unit_id)
        {
            try {
                List <Template> list = new List <Template>();

                var mTemplates = TemplateDAL.fetchAllByUnit(unit_id).ToList();

                foreach (templates item in mTemplates)
                {
                    Template model = new Template();
                    model.id          = long.Parse(item.id + "");
                    model.name        = item.name;
                    model.description = item.description;
                    model.n_tasks     = TemplateTaskDAL.fetchAllByTemplateId(item.id).Count();
                    model.userId      = long.Parse(item.user_id + "");
                    list.Add(model);
                }

                return(list);
            } catch (Exception e) {
                throw e;
            }
        }
Beispiel #7
0
        public static void start(decimal id, decimal userId)
        {
            try {
                var template = TemplateDAL.fetchAll().Where(x => x.id == id).FirstOrDefault();
                var tasks    = TemplateTaskDAL.fetchAll().Where(x => x.template_id == template.id).ToList();

                decimal processId = ProcessDAL.insert(template.name, template.description, DateTime.Now, userId);

                foreach (templates_tasks ts in tasks)
                {
                    tasks model = new tasks();
                    model.name            = ts.name;
                    model.description     = ts.description;
                    model.date_end        = ts.end_date;
                    model.task_status     = ts.task_status_code;
                    model.creator_user_id = decimal.Parse(userId + "");
                    model.process_id      = processId;

                    TaskDAL.createTask(model);
                }
            } catch (Exception e) {
                throw e;
            }
        }