private bool PreLoading(string hostConfigFilePath) { HostConfigFileName = Path.Combine(hostConfigFilePath, NTServiceHostConfig.NTServiceHostConfigFileName); ConfigMgt = new ConfigManager <NTServiceHostConfig>(HostConfigFileName); if (ConfigMgt.Load()) { LogControler.BaseDirectory = hostConfigFilePath; Log = new LogControler(HostName, ConfigMgt.Config.LogConfig); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(HostName); Log.Write("Load config succeeded. " + ConfigMgt.FileName); return(true); } else { LogControler.BaseDirectory = hostConfigFilePath; LogConfig logCfg = new LogConfig(); logCfg.LogType = LogType.Debug; Log = new LogControler(HostName, logCfg); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(HostName); Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastError); return(false); } }
internal void PreLoading(EntityInitializeArgument arg) { AppArgument = arg; Log = new LogControler(arg.GetLogFileName(AppName), arg.LogConfig); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName); Log.Write(arg.ToLog()); string FileName = ConfigHelper.GetFullPath(Path.Combine(arg.ConfigFilePath, SOAPServerConfig.SOAPServerConfigFileName)); ConfigMgr = new ConfigManager <SOAPServerConfig>(FileName); if (ConfigMgr.Load()) { ConfigMgr.Config._context = this; Log.Write("Load config succeeded. " + ConfigMgr.FileName); } else { Log.Write(LogType.Error, "Load config failed. " + ConfigMgr.FileName); Log.Write(LogType.Error, ConfigMgr.LastError.ToString()); if (System.Windows.Forms.MessageBox.Show("Cannot load " + AppName + " configuration file. \r\n" + ConfigMgr.FileName + "\r\n\r\nDo you want to create a configuration file with default setting and continue?", AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CreateDefaultConfig(); ConfigMgr.Config._context = this; CreateDefaultConfigFiles(); } } }
internal static bool PreLoading() { EntityInitializeArgument arg = new EntityInitializeArgument(); arg.ConfigFilePath = Application.StartupPath; arg.Description = "WinForm GUI"; arg.LogConfig = new LogConfig(); arg.LogConfig.LogType = LogType.Debug; arg.LogConfig.DurationDay = 7; if (PreLoading(arg)) { return(true); } if (System.Windows.Forms.MessageBox.Show("Cannot load " + AppName + " configuration file. \r\n" + ConfigMgt.FileName + "\r\n\r\nDo you want to create a configuration file with default setting and continue?", AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return(false); } ConfigMgt.Config = new MonitorConfig(); if (ConfigMgt.Save()) { Log.Write("Save config succeeded. " + ConfigMgt.FileName); return(true); } else { Log.Write(LogType.Error, "Save config failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastError); return(false); } }
internal static bool PreLoading(EntityInitializeArgument arg) { Log = new LogControler(AppName, arg.LogConfig); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName); Log.Write(arg.ToLog()); ConfigPath = arg.ConfigFilePath; string FileName = ConfigHelper.GetFullPath(Path.Combine(arg.ConfigFilePath, MonitorConfig.ConfigFileName)); ConfigMgt = new ConfigManager <MonitorConfig>(FileName); if (ConfigMgt.Load()) { Log.Write("Load config succeeded. " + ConfigMgt.FileName); return(true); } else { Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName); Log.Write(LogType.Error, ConfigMgt.LastError.ToString()); return(false); } }
internal static void PreLoading() { LogConfig lcfg = new LogConfig(); lcfg.DumpData = true; lcfg.LogType = LogType.Debug; Log = new LogControler(AppName, lcfg); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName); string FileName = ConfigHelper.GetFullPath(HL7GatewayConfigConfig.ConfigFileName); ConfigMgr = new ConfigManager <HL7GatewayConfigConfig>(FileName); if (ConfigMgr.Load()) { Log.Write("Load config succeeded. " + ConfigMgr.FileName); } else { Log.Write(LogType.Error, "Load config failed. " + ConfigMgr.FileName); Log.Write(LogType.Error, ConfigMgr.LastError.ToString()); if (System.Windows.Forms.MessageBox.Show("Cannot load " + AppName + " configuration file. \r\n" + ConfigMgr.FileName + "\r\n\r\nDo you want to create a configuration file with default setting and continue?", AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CreateDefaultConfig(); } } }
//private static bool createDefaultConfigSilently; internal static bool PreLoading(string[] args) { //Log = new LogControler(AppName); //LogHelper.EnableApplicationLogging(Log); //LogHelper.EnableXmlLogging(Log); //Log.WriteAppStart(AppName, args); ConfigMgt = new ConfigManager <EntityConfigHostConfig>(EntityConfigHostConfig.ConfigHostConfigFileName); if (ConfigMgt.Load()) { Log = new LogControler(AppName, ConfigMgt.Config.LogConfig); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName, args); Log.Write("Load config succeeded. " + ConfigMgt.FileName); LoadSolutionDir(); return(true); } else { Log = new LogControler(AppName); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName, args); Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastError); if (//createDefaultConfigSilently || MessageBox.Show("Cannot load " + AppName + " configuration file. \r\n" + ConfigMgt.FileName + "\r\n\r\nDo you want to create a configuration file with default setting and continue?", AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ConfigMgt.Config = new EntityConfigHostConfig(); ConfigMgt.Config.LogConfig.HostName = "ConfigGUI"; if (ConfigMgt.Save()) { Log.Write("Create config file succeeded. " + ConfigMgt.FileName); return(true); } else { Log.Write(LogType.Error, "Create config file failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastError); return(false); } } return(false); } }
internal static bool PreLoading() { //Log = new LogControler(AppName); //LogHelper.EnableApplicationLogging(Log); //LogHelper.EnableXmlLogging(Log); //Log.WriteAppStart(AppName); string filePath = Path.Combine(GetSolutionRoot(), AppConfigFileName); //20091217 ConfigMgt = new ConfigManager <SolutionConfig>(filePath); //ConfigMgt = new ConfigManager<SolutionConfig>(AppConfigFileName); if (ConfigMgt.Load()) { Log = new LogControler(AppName, ConfigMgt.Config.LogConfig); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName); Log.Write("Load config succeeded. " + ConfigMgt.FileName); return(true); } else { Log = new LogControler(AppName); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName); Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastError); if (MessageBox.Show("Cannot load " + AppName + " configuration file. \r\n" + ConfigMgt.FileName + "\r\n\r\nDo you want to create a configuration file with default setting and continue?", AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ConfigMgt.Config = SolutionConfig.GetDefault();// new SolutionConfig(); if (ConfigMgt.Save()) { Log.Write("Create config file succeeded. " + ConfigMgt.FileName); return(true); } else { Log.Write(LogType.Error, "Create config file failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastError); return(false); } } return(false); } }
internal static bool PreLoading() { //Log = new LogControler(AppName); //LogHelper.EnableApplicationLogging(Log); //LogHelper.EnableXmlLogging(Log); //Log.WriteAppStart(AppName); ConfigMgt = new ConfigManager <NTServiceHostConfig>(AppConfigFileName); if (ConfigMgt.Load()) { Log = new LogControler(AppName, ConfigMgt.Config.LogConfig); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName); Log.Write("Load config succeeded. " + ConfigMgt.FileName); License = new LicenseManager <LicenseConfig>(AppLicenseFileName); License.EnabledCrypto = true; if (License.Load()) { Log.Write("Load license succeeded. " + License.FileName); return(true); } else { //CreateReceiverDefaultLicense(); Log.Write(LogType.Error, "Load license failed. " + License.FileName); Log.Write(License.LastError); return(false); } } else { Log = new LogControler(AppName); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName); Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastError); return(false); } }
public void CreateDefaultConfig() { try { CSBrokerOutboundConfig cfg = new CSBrokerOutboundConfig(); ConfigMgr.Config = cfg; if (!ConfigMgr.Save()) { Log.Write(ConfigMgr.LastError); } } catch (Exception err) { Log.Write(err); } return; }
internal void CreateDefaultConfig() { try { SOAPServerConfig cfg = new SOAPServerConfig(); ConfigMgr.Config = cfg; if (!ConfigMgr.Save()) { Log.Write(ConfigMgr.LastError); } } catch (Exception err) { Log.Write(err); } return; }
internal static void CreateDefaultConfig() { try { MessagePipeConfig cfg = new MessagePipeConfig(); ConfigMgr.Config = cfg; if (!ConfigMgr.Save()) { Log.Write(ConfigMgr.LastError); } } catch (Exception err) { Log.Write(err); } return; }
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { try { Log.Write(LogType.Error, "Failed to resolve: " + args.Name); string fname = args.Name.Substring(0, args.Name.IndexOf(',')) + ".dll"; string fpath = ConfigHelper.DismissDotDotInThePath(EntityLoader.LoadingAssemblyFileName); fpath = Path.GetDirectoryName(fpath); fname = Path.Combine(fpath, fname); Log.Write(LogType.Error, "Try to resolve: " + fname); return(Assembly.LoadFile(fname)); } catch (Exception err) { Log.Write(err); return(null); } }
static bool PreLoading(string[] args) { Log = new LogControler(AppName); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); LogWapper = new GWLoggingWapper(Log); Log.WriteAppStart(AppName); // initialize config ConfigMgt = new ConfigMgt <ManagerConfig>(); ConfigMgt.FileName = Application.StartupPath + "\\" + ManagerConfig.FileName; if (ConfigMgt.Load(LogWapper)) { Log = new LogControler(AppName, ConfigMgt.Config.LogType); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); LogWapper = new GWLoggingWapper(Log); Program.ConfigMgt.Config.RefreshConfigInfo(); Log.Write("Load config succeeded. " + ConfigMgt.FileName); } else { Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastErrorInfor); if (MessageBox.Show("Cannot load " + AppName + " config file. \r\n" + ConfigMgt.FileName + "\r\n\r\nDo you want to create a config file with default setting?", AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ConfigMgt.Config = ManagerConfig.CreateDefaultConfig(); Program.ConfigMgt.Config.RefreshConfigInfo(); if (ConfigMgt.Save(LogWapper)) { Log.Write("Create config file succeeded. " + ConfigMgt.FileName); } else { Log.Write(LogType.Error, "Create config file failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastErrorInfor); } } Log.WriteAppExit(AppName); return(false); } return(true); }
public void PreLoading(EntityInitializeArgument arg) { AppArgument = arg; Log = new LogControler(arg.GetLogFileName(AppName), arg.LogConfig); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); SocketHelper.EnableSocketLogging(Log, arg.LogConfig.DumpData); Log.WriteAppStart(AppName); Log.Write(arg.ToLog()); string FileName = ConfigHelper.GetFullPath(Path.Combine(arg.ConfigFilePath, HL7InboundConfig.HL7InboundConfigFileName)); ConfigMgr = new ConfigManager <HL7InboundConfig>(FileName); if (ConfigMgr.Load()) { ConfigMgr.Config._contextForDump = this; ConfigMgr.Config._contextForTemplate = this; ConfigMgr.Config._contextForTemplate2 = this; Log.Write("Load config succeeded. " + ConfigMgr.FileName); } else { Log.Write(LogType.Error, "Load config failed. " + ConfigMgr.FileName); Log.Write(LogType.Error, ConfigMgr.LastError.ToString()); if (System.Windows.Forms.MessageBox.Show("Cannot load " + AppName + " configuration file. \r\n" + ConfigMgr.FileName + "\r\n\r\nDo you want to create a configuration file with default setting and continue?", AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CreateDefaultConfig(); //CreateDefaultHL7AckTempalte(); // the templates are packed in the PublishTempaltes folder when build ConfigMgr.Config._contextForDump = this; ConfigMgr.Config._contextForTemplate = this; ConfigMgr.Config._contextForTemplate2 = this; } } }
/// <summary> /// The NT Service should maintain the entity folder in a list /// and search through the list when loading dll files. /// This is a simple solution. /// More complex and accurate solution is /// identifying the dll requesting entity by using the StakeTrace class. /// /// Currently, we fixed this bug by using the simple solution, /// which depend on the assumption of dll files in different entity folders /// with the same name should be also the same version. /// /// In future version, as a replacement of EntityLoader.LoadingAssemblyFileNames, /// use StackFrame or StackTrace to get current calling context, /// and load additional assembly from the exact folder, /// so as to support that some message entity may /// load additional assembly at runtime. /// /// http://www.itwis.com/html/net/c/20090304/3505.html /// http://www.kuqin.com/dotnet/20080420/7078.html /// </summary> /// <param name="sender"></param> /// <param name="args"></param> /// <returns></returns> private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { try { Log.Write(LogType.Warning, "Failed to resolve: " + args.Name); string fn = ""; int index = args.Name.IndexOf(','); if (index < 0) { fn = args.Name; } else { fn = args.Name.Substring(0, index); } //string fname = fn + ".dll"; //string fpath = ConfigHelper.DismissDotDotInThePath(EntityLoader.LoadingAssemblyFileName); //fpath = Path.GetDirectoryName(fpath); //fname = Path.Combine(fpath, fname); //Log.Write(LogType.Warning, "Try to resolve: " + fname); //return Assembly.LoadFile(fname); string filename = null; for (int i = EntityLoader.LoadingAssemblyFileNames.Count - 1; i >= 0; i--) { string fname = fn + ".dll"; string fpath = ConfigHelper.DismissDotDotInThePath(EntityLoader.LoadingAssemblyFileNames[i]); fpath = Path.GetDirectoryName(fpath); fname = Path.Combine(fpath, fname); if (File.Exists(fname)) { filename = fname; break; } } Log.Write(LogType.Warning, "Try to resolve: " + filename); return(Assembly.LoadFile(filename)); } catch (Exception err) { Log.Write(err); return(null); } }
internal static void PreLoading(EntityInitializeArgument arg) { Log = new LogControler(AppName, arg.LogConfig); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName); Log.Write(arg.ToLog()); string FileName = ConfigHelper.GetFullPath(Path.Combine(arg.ConfigFilePath, ServiceConfig.FileName)); ConfigMgt = new ConfigManager <ServiceConfig>(FileName); if (ConfigMgt.Load()) { Log.Write("Load config succeeded. " + ConfigMgt.FileName); } else { Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName); Log.Write(LogType.Error, ConfigMgt.LastError.ToString()); //if (System.Windows.Forms.MessageBox.Show("Cannot load " + AppName + " configuration file. \r\n" + // ConfigMgr.FileName + "\r\n\r\nDo you want to create a configuration file with default setting and continue?", // AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) //{ ConfigMgt.Config = new ServiceConfig(); if (ConfigMgt.Save()) { Log.Write("Save config succeeded. " + ConfigMgt.FileName); } else { Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastError); } //} } }
static void Main() { //Directory.Delete(@"D:\temp\a"); //throw exception if folder not empty //return; //SortedDictionary<int, string> dic = new SortedDictionary<int, string>(); //dic.Add(-2, "a"); //dic.Add(-1, "b"); //dic.Add(-3, "c"); //StringBuilder sb = new StringBuilder(); //foreach (KeyValuePair<int, string> p in dic) //{ // sb.AppendLine(p.Key.ToString() + "_" + p.Value); //} //MessageBox.Show(sb.ToString()); //return; //List<string> alist = new List<string>(); //alist.Capacity = 3; //alist.Add("a"); //alist.Add("b"); //alist.Add("c"); //alist.Add("d"); //alist.Add("e"); ////alist.Add("f"); //MessageBox.Show(alist.Count.ToString() + "//" + alist.Capacity.ToString()); //return; //string path = Path.GetDirectoryName(@"c:\..\..\aaa"); //string path = Path.GetDirectoryName(Path.GetDirectoryName(@"c:\a")); //MessageBox.Show("'" + path + "'"); //return; //string folder = Path.GetFileName(@"C:\asd\aa"); //MessageBox.Show(folder); //return; //Test_Path(); //return; //XObjectManager.OnError += new XObjectExceptionHandler(XObjectManager_OnError); //Test_Body(); //return; Log = new LogControler(AppName); LogHelper.EnableApplicationLogging(Log); LogHelper.EnableXmlLogging(Log); Log.WriteAppStart(AppName); ConfigMgt = new ConfigManager <NTServiceHostConfig>(AppConfigFileName); if (ConfigMgt.Load()) { Log.Write("Load config succeeded. " + ConfigMgt.FileName); } else { Log.Write(LogType.Error, "Load config failed. " + ConfigMgt.FileName); Log.Write(ConfigMgt.LastError); MessageBox.Show("Cannot load configuration file."); return; } //Test_Header(); //Test_Message(); //Test_SubscribeCriteria(); //Test_EntityContract(); //Test_EntityConfig(); //Test_ConfigMgt(); //return; //AppDomain.CurrentDomain.AppendPrivatePath(@"D:\ClearCase\10095177_GCGateway_view_dev_mobile\gcgateway\XDS-Gateway\SRC\Messaging\DemoFileAdapter\bin\Debug"); //string str = AppDomain.CurrentDomain.RelativeSearchPath; //str = AppDomain.CurrentDomain.DynamicDirectory; System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new Form1()); Log.WriteAppExit(AppName); }
public void Write(string msg) { _log.Write(msg); }