예제 #1
0
        /// <summary>
        /// 返回注释信息
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="para">参数</param>
        /// <returns></returns>
        private string GetNote(string name, string para)
        {
            // 读取XML
            XDocument document = XDocument.Load(_assembly.GetName().Name + ".xml");

            // 根据name寻找节点
            var item = document.Descendants("member").Where(c => c.Attribute("name").Value == name).FirstOrDefault();

            if (item == null)
            {
                return(ToolString.RemoveCharAfter(name, "("));
            }

            // 若参数名称为空
            if (string.IsNullOrWhiteSpace(para))
            {
                return((item.Element("summary")?.Value + "").Replace("\n", "").Trim());
            }
            ;

            // 返回参数注释
            return((item.Elements("param").Where(c => c.Attribute("name").Value == para).FirstOrDefault()?.Value + "").Replace("\n", "").Trim());
        }
예제 #2
0
        /// <summary>
        /// 报告分组
        /// </summary>
        /// <param name="tigerPath">文件夹</param>
        /// <param name="group">分组条件,多个用','分割</param>
        /// <param name="max">文件夹最大占用</param>
        /// <returns></returns>
        public Result ReportGroup(string tigerPath, string group, double max)
        {
            return(RunFun(logpath =>
            {
                string res = "分组" + DateTime.Now.Millisecond + "\\";
                tigerPath = ToolFile.GetAbsolutelyPath(tigerPath);

                DirectoryInfo dir = new DirectoryInfo(tigerPath);

                // 移除所有文件夹
                while (dir.GetDirectories().Length > 0)
                {
                    Directory.Delete(dir.GetDirectories()[0].FullName, true);
                }

                List <string> groupList = group.Split(',').Where(c => !string.IsNullOrWhiteSpace(c)).ToList();

                Dictionary <string, long> dic = new Dictionary <string, long>();

                List <Task> taskList = new List <Task>();

                for (int i = 0; i < dir.GetFiles().Length; i++)
                {
                    WriteLog(logpath, i + "");

                    string path = tigerPath + res;
                    FileInfo field = dir.GetFiles()[i];

                    List <string> nameList = field.Name.Replace("." + ToolFile.GetSuffix(field.Name), "").Split('_').Where(c => !string.IsNullOrWhiteSpace(c)).ToList();

                    if (nameList.Count != 2)
                    {
                        WriteLog(logpath, field.Name);
                        continue;
                    }
                    DataRow dr = GetEntryInfo(nameList[1]);

                    foreach (var item in groupList)
                    {
                        if (dr.Table.Columns.Contains(item))
                        {
                            path += dr[item] + "\\";
                        }
                    }

                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    else
                    {
                        if (dic.Keys.Contains(path) && max > 0)
                        {
                            double memory = dic[path] * 1.0;
                            if (max * 1024 * 1024 < memory + field.Length)
                            {
                                path = ToolString.RemoveCharAfter(path, "\\", true) + "(" + dic.Keys.Where(c => c.Contains(path)).Count() + ")\\";
                                Directory.CreateDirectory(path);
                            }
                        }
                    }

                    if (dic.Keys.Contains(path))
                    {
                        dic[path] += field.Length;
                    }
                    else
                    {
                        dic.Add(path, field.Length);
                    }


                    taskList.Add(Task.Run(() =>
                    {
                        File.Copy(field.FullName, path + field.Name, true);
                    }));
                }

                Task.WaitAll(taskList.ToArray());

                dir = new DirectoryInfo(tigerPath + res);

                foreach (var key in dic.Keys)
                {
                    WriteLog(logpath, (dic[key] * 1.0 / 1020 / 1024) + "M\t" + key);
                }

                return Res;
            }));
        }