public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(Id); stringBuilder.AppendLine(Name); stringBuilder.AppendLine(Status); stringBuilder.AppendLine(Created.ToLongDateString()); stringBuilder.AppendLine(LastModified.ToLongDateString()); stringBuilder.AppendLine(ProjectId); return(stringBuilder.ToString()); }
/// <summary> Save this template scheme to the Template XML file </summary> /// <param name="FileName"> Name of Template XML file </param> /// <returns> TRUE if successful, otherwise FALSE </returns> public bool Save_Template_XML(string FileName) { try { StringBuilder resultBuilder = new StringBuilder(); // Add header and the start main tag resultBuilder.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n"); resultBuilder.Append("\r\n"); resultBuilder.Append("<!-- Begin the XML for this input template -->\r\n"); resultBuilder.Append("<input_template>\r\n"); resultBuilder.Append("\r\n"); // Add the administrative information about this template resultBuilder.Append("\t<!-- Define the information about this input template -->\r\n"); // Write each of the titles for this page foreach (KeyValuePair <Template_Language, string> thisEntry in allTitles) { // If this language is known, write it if (thisEntry.Key != Template_Language.Unknown) { resultBuilder.Append("\t<name language=\"" + Template_Language_Convertor.ToCode(thisEntry.Key) + "\">" + thisEntry.Value + "</name>\r\n"); } } // Finish out the administrative section if (Notes.Length > 0) { resultBuilder.Append("\t<notes>" + Notes + "</notes>\r\n"); } resultBuilder.Append("\t<dateCreated>" + DateCreated.ToLongDateString() + "</dateCreated>\r\n"); if (LastModified.CompareTo(DateCreated) > 0) { resultBuilder.Append("\t<lastModified>" + LastModified.ToLongDateString() + "</lastModified>\r\n"); } if (Creator.Length > 0) { resultBuilder.Append("\t<creator>" + Creator + "</creator>\r\n"); } resultBuilder.Append("\r\n"); // Write the information which describes all the inputs resultBuilder.Append("\t<!-- This defines the inputs which are available for the user -->\r\n"); resultBuilder.Append("\t<inputs>\r\n"); resultBuilder.Append(inputs.To_Template_XML()); resultBuilder.Append("\t</inputs>\r\n"); resultBuilder.Append("\r\n"); // Add all the constant information resultBuilder.Append("\t<!-- This defines the constants which can not be edited by the user -->\r\n"); resultBuilder.Append("\t<constants>\r\n"); resultBuilder.Append(constants.To_Template_XML("\t\t")); resultBuilder.Append("\t</constants>\r\n"); resultBuilder.Append("\r\n"); // Close the main tag resultBuilder.Append("</input_template>\r\n"); resultBuilder.Append("<!-- End of input template XML -->\r\n"); // Write this out to a file StreamWriter writer = new StreamWriter(FileName, false, Encoding.UTF8); writer.Write(resultBuilder.ToString()); writer.Flush(); writer.Close(); // Return true return(true); } catch { return(false); } }