Files
BeWoPlaner/BeWo/DebugConfig.cs

130 lines
2.9 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.IO;
namespace BeWo
{
public enum DebugConfigMode
{
SimpleAutoLogin,
FeatureCustomerWohnhilfe,
FeatureWohnheimWohneinheit,
FeatureAuswertungenQuittierungsbelege,
FeatureDakota
}
public class DebugConfig
{
private static readonly string config_file_name = "DebugConfig.txt";
public static DebugConfig CurrentConfig { get; } = LoadCurrentDebugConfig();
public static string ServerUrl { get; set; } = "http://localhost:3777/Host";
public DebugConfigMode DebugConfigMode { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Profilename { get; set; }
public bool AutoLogin { get; set; }
public UIContext? SelectView { get; set; }
/// <summary>
/// Beschreibt den Index der jeweils gewählten View (UIContext)
///
/// Z.b.:
/// Customer:
/// - Details: 0
/// - ...: 1
/// - ...: 2
/// - ...: 3
/// - VermittlungArbeit: 4
/// - Wohnhilfe: 5
/// </summary>
public int? SelectIndex { get; set; }
private static DebugConfig LoadCurrentDebugConfig()
{
#if DEBUG
try
{
var path = AppDomain.CurrentDomain.BaseDirectory;
var project_path = Directory.GetParent(path).Parent.Parent.FullName;
var config_path = Path.Combine(project_path, config_file_name);
if (!File.Exists(config_path))
return null;
var current_config = File.ReadAllText(config_path);
if (string.IsNullOrWhiteSpace(current_config))
return null;
var name2config = new Dictionary<string, DebugConfig>
{
{
"SimpleAutoLogin",
new DebugConfig()
{
DebugConfigMode = DebugConfigMode.SimpleAutoLogin,
AutoLogin = true
}
},
{
"FeatureCustomerWohnhilfe",
new DebugConfig()
{
DebugConfigMode = DebugConfigMode.FeatureCustomerWohnhilfe,
AutoLogin = true,
SelectView = UIContext.Customer,
SelectIndex = 5
}
},
{
"FeatureWohnheimWohneinheit",
new DebugConfig()
{
DebugConfigMode = DebugConfigMode.FeatureWohnheimWohneinheit,
AutoLogin = true,
SelectView = UIContext.Wohnheim
}
},
{
"FeatureAuswertungenQuittierungsbelege",
new DebugConfig()
{
DebugConfigMode = DebugConfigMode.FeatureAuswertungenQuittierungsbelege,
AutoLogin = true,
SelectView = UIContext.Report
}
},
{
"FeatureDakota",
new DebugConfig()
{
DebugConfigMode = DebugConfigMode.FeatureDakota,
AutoLogin = true,
SelectView = UIContext.Finance,
SelectIndex = 8,
Username = "m1",
Password = "bewobewo",
Profilename = "5000000000"
}
}
};
if (name2config.TryGetValue(current_config, out DebugConfig current))
{
return current;
}
}
catch (Exception)
{
}
#endif
return null;
}
}
}