laatzen/Common/modbus_master_csharp/Base/AppConst.cs

112 lines
3.6 KiB
C#

using XYLEM.Base.Files;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
namespace XYLEM.Base
{
internal static class AppConst
{
static ProgramLogCSVFileClass _Logger = new ProgramLogCSVFileClass();
internal static ProgramLogCSVFileClass Logger { get { return _Logger; } }
internal static bool IsBeta
{
get
{
return true;
//return false;
}
}
//
// Summary:
// Gets the product version associated with this application.
//
// Returns:
// The product version.
internal static string ProductVersion
{
get { return "1.0.0.1"; }
}
/// <summary>
/// Return application MJK No.
/// Have to be manuel changed by programmer for every application to fit install!
/// </summary>
/// <returns>return ex. "840126" </returns>
internal static string ProductMainMJKNo()
{
return "MJK_MAGFLUX_MODBUS";
}
/// <summary>
/// Return MJK Programs standard folder in My documents.
/// </summary>
/// <returns>return ex. "c:\...\My Documents\MJK Automation\" </returns>
internal static string ProgramsUserFolderRootPath()
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MJK Automation\\");
}
/// <summary>
/// Return application folder in My documents.
/// Have to be manuel changed by programmer for every application to fit install!
/// </summary>
/// <returns>return ex. "c:\...\My Documents\MJK Automation\840126\" </returns>
internal static string ProgramUserFolderRootPath()
{
return Path.Combine(ProgramsUserFolderRootPath(), ProductMainMJKNo() + "\\");
}
/// <summary>
/// Return application folder to use for user files.
/// Have to be manuel changed by programmer for every application to fit install!
/// </summary>
/// <returns>return ex. "c:\...\My Documents\MJK Automation\- UserFileSave\" </returns>
internal static string UserFileSavePath()
{
return Path.Combine(ProgramsUserFolderRootPath(), "- UserFileSave\\");
}
/// <summary>
/// Return application folder to use for program user settings .
/// Have to be manual changed by programmer for every application to fit install!
/// </summary>
/// <returns>return ex. "c:\...\My Documents\MJK Automation\840126\UserSettings\" </returns>
internal static string UserFileSettingsPath()
{
return Path.Combine(ProgramUserFolderRootPath(), "UserSettings\\");
}
/// <summary>
/// Try Create UserFileSavePath and SettingPath
/// </summary>
internal static void CreateStandardUserFolders()
{
try
{
if (!Directory.Exists(UserFileSavePath()))
{
Directory.CreateDirectory(UserFileSavePath());
}
if (!Directory.Exists(ProgramUserFolderRootPath()))
{
Directory.CreateDirectory(ProgramUserFolderRootPath());
}
}
catch (Exception ex)
{
Logger.AddToProgramLogFile(true, "Error creating default user folders ", ex.Message);
}
}
}
}