Ejemplo n.º 1
0
 ///<summary>
 ///添加方法,返回Boolean类型,为true表示操作成功,否则操作失败
 ///生成时间:2011-6-1 20:36:02
 ///</summary>
 public Boolean AddJsn(Jsn jsn)
 {
     MySqlParameter[] param = new MySqlParameter[] {
         new MySqlParameter("?UserName", jsn.UserName),
         new MySqlParameter("?sn", jsn.Sn),
         new MySqlParameter("?isdate", jsn.Isdate),
         new MySqlParameter("?cuser", jsn.Cuser),
         new MySqlParameter("?ctime", jsn.Ctime)
     };
     return(MySqlHelper.ExecuteNonQuery(SQL_INSERT, param) > 0);
 }
Ejemplo n.º 2
0
 ///<sumary>
 ///修改信息
 ///时间:2011-6-1 20:36:15
 ///</sumary>
 public static Boolean UpdateJsn(Jsn jsn)
 {
     try
     {
         return(jsnService.UpdateJsn(jsn));
     }
     catch (Exception ex)
     {
         //可以记录到异常日志
         return(false);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Program main function entry.
        /// </summary>
        /// <param name="args">Program arguments.</param>
        /// <seealso cref="Program"/>
        internal static void Main(string[] args)
        {
            try
            {
                if (args == null || args.Length < 2)
                {
                    return;
                }
                string xmlPath            = args[0];
                var    folderDestination  = args[1];
                string folderDestionation = args.ElementAtOrDefault(1);
                var    dict = new Dictionary <string, string>();

                string markdownPath = args.ElementAtOrDefault(1);

                if (string.IsNullOrWhiteSpace(markdownPath))
                {
                    // replace extension with `md` extension
                    markdownPath = Path.ChangeExtension(xmlPath, ".md");
                }
                var document = XDocument.Load(xmlPath);

                // paso 1, sacar información desde la misma ruta que el xmlpath, del csproj.
                var baseXmlPath = Path.GetDirectoryName(xmlPath);

                // obtengo archivo del proyecto.
                var proj = Path.Combine(baseXmlPath, $"{Path.GetFileNameWithoutExtension(xmlPath)}.csproj");

                // cargo el proyecto
                var projDocument        = XDocument.Load(proj);
                var rootProject         = projDocument.Root;
                var propertyGroups      = rootProject.Element("PropertyGroup");
                var package_title       = propertyGroups.Element("title").Value;
                var idPackage           = propertyGroups.Element("id").Value;
                var package_description = propertyGroups.Element("description").Value;
                var package_summary     = propertyGroups.Element("summary").Value;
                var main_icon           = propertyGroups.Element("iconUrl").Value;
                var nuget_url           = propertyGroups.Element("nugetUrl").Value;
                var devops_url          = propertyGroups.Element("devopsUrl").Value;
                var github_url          = propertyGroups.Element("RepositoryUrl").Value;
                var relasebadge_url     = propertyGroups.Element("releaseBadgeUrl").Value;
                var mainMarkdown        = Path.Combine(baseXmlPath, $"{folderDestionation}/{idPackage}/index.md");
                var baseMarkdown        = Path.GetDirectoryName(mainMarkdown);

                Directory.CreateDirectory(baseMarkdown);

                File.WriteAllText(mainMarkdown, MainPagePackage(package_title, package_description, package_summary, main_icon, nuget_url, github_url, devops_url, relasebadge_url));

                dict.Add("Descripción", $"/{folderDestionation}/{idPackage}/");

                var members        = document.Root.Element("members");
                var elementMembers = members.Elements("member");
                var types          = elementMembers.Where(s => s.Attributes().Any(a => a.Value.Contains("T:")));

                var namespaces = types.Where(s => s.Attribute("name").Value.ToLower().Contains("namespace"));


                foreach (var m in namespaces)
                {
                    // las member names comienzan con T:elnombre de la clase
                    var splt    = m.Attribute("name").Value.Split(":")[1].ToLower().Replace(".namespace", "").Split(".");
                    var nsms    = splt.Join(".");
                    var summary = m.Element("summary").Value;
                    var title   = nsms.Split(".").Last();
                    var md      = Path.Combine(baseMarkdown, $"{nsms}/index.md");
                    var fld     = Path.GetDirectoryName(md);
                    Directory.CreateDirectory(fld);
                    File.WriteAllText(md, MainNamespace(title, nsms, summary));
                    dict.Add(nsms, $"/{folderDestionation}/{idPackage}/{nsms}/");
                }
                var typesWithoutNamespace = types.Where(s => !s.Attribute("name").Value.ToLower().Contains("namespace"));

                var converter = new Converter(document);

                var markdown = converter.ToMarkdown();

                foreach (var item in markdown)
                {
                    var folder = Path.Combine(baseMarkdown, $"{item.Key}/");
                    Directory.CreateDirectory(folder);
                    var file = Path.Combine(folder, "index.md");
                    File.WriteAllText(file, item.Value);
                    dict.Add(item.Key, $"/{folderDestionation}/{idPackage}/{item.Key}/");
                }

                // generate json

                var ordered = dict.OrderBy(s => s.Value);

                var jsn = new Jsn
                {
                    title = package_title,
                    path  = $"/{folderDestionation}/{idPackage}/",
                    pages = dict.Select(d => new Jsn
                    {
                        title = d.Key.Split(".").Last().Replace("_T", "<T>"),
                        path  = d.Value,
                    }).ToList(),
                };



                File.WriteAllText(Path.Combine(baseMarkdown, "menu.json"), Serialize(jsn));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                // Ignore errors. Do not impact on project build
                return;
            }
        }