Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                Trace.Listeners.Add(new ConsoleTraceListener());

                tracer = new AppTraceListener(@"C:\Logs\HelloIndigoClient");

                if (args.Length > 0 && args[0].ToUpper() == "ECHO")
                {
                    Client.EchoClient client = new Client.EchoClient();
                    client.Run();
                }
                else
                {
                    Client.LibraryClient <AppConfigProvider> client
                        = new Client.LibraryClient <AppConfigProvider>();
                    client.Run();
                }
            }
            catch (Exception exp)
            {
                Trace.WriteLine(exp.ToString());
            }
            finally
            {
                tracer.Close();
            }
        }
Ejemplo n.º 2
0
        private static void initializeTracer()
        {
            IDataStoreProvider provider = ConfigProviderBase.Open();

#if _AZURE
            iconfig = new KeyedDataStore(new CloudSettingsProvider(provider));
#else
            iconfig = new KeyedDataStore(provider);
#endif
            _logPath = (iconfig["LogPath"] as string) ?? @"C:\Logs\HelloIndigo";
#if _AZURE
            // Running in the Cloud; look for the local drive
            if (!Path.IsPathRooted(_logPath) &&
                RoleEnvironment.IsAvailable &&
                !RoleEnvironment.IsEmulated)
            {
                LocalResource localResource = RoleEnvironment.GetLocalResource("LogFiles");
                _logPath = Path.Combine(localResource.RootPath, _logPath);
            }
#endif
            tracer = new AppTraceListener(_logPath);
        }
Ejemplo n.º 3
0
        static SubscriberService()
        {
            try
            {
                IDataStoreProvider provider = ConfigProviderBase.Open();
                GlobalCache.LoadConfigurationSettings(provider, true);

                string logPath = (GlobalCache.GetResolvedString("LogPath") ?? @"C:\Logs\HelloIndigo");

#if _AZURE
                // Running in the Cloud; look for the local drive
                if (!Path.IsPathRooted(logPath) &&
                    RoleEnvironment.IsAvailable &&
                    !RoleEnvironment.IsEmulated)
                {
                    LocalResource localResource = RoleEnvironment.GetLocalResource("LogFiles");
                    logPath = Path.Combine(localResource.RootPath, logPath);
                }
#endif
                tracer = new AppTraceListener(logPath);

                // Resolve streams out of resource fork.
                StreamFactory.Register("res", (path, args) =>
                {
                    Assembly assembly   = Assembly.GetExecutingAssembly();
                    string resourcePath = string.Format("{0}.{1}",
                                                        assembly.GetName().Name,
                                                        path);
                    Trace.WriteLine(string.Format("StreamFactory::Create(res://{0})", resourcePath));
                    Stream result = assembly.GetManifestResourceStream(resourcePath);
                    return(result);
                });
            }
            catch (Exception exp)
            {
                Trace.WriteLine(exp.ToString());
            }
        }
Ejemplo n.º 4
0
        internal static void Initialize()
        {
            AppTraceListener.Initialize();

            try
            {
#if DEBUG
                WPFClient.Config.ApiKey = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\eartrumpet.bugsnag.apikey");
#endif

                WPFClient.Config.StoreOfflineErrors = true;
                WPFClient.Config.AppVersion         = App.Current.HasIdentity() ? Package.Current.Id.Version.ToVersionString() : "DevInternal";
                WPFClient.Start();

                WPFClient.Config.BeforeNotify(OnBeforeNotify);

                Task.Factory.StartNew(WPFClient.SendStoredReports);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            AppTraceListener tracer = null;

            Trace.Listeners.Add(new ConsoleTraceListener());
            try
            {
                tracer = new AppTraceListener(@"C:\Logs\HelloIndigoConsoleHost");

                var parameters = new KeyedDataStore(System.Environment.CommandLine.CommandLineParser(new Dictionary <string, object>(),
                                                                                                     StringFunction.DictionaryNotFoundOptions.AddKey));

                bool debugFlag = false;
                parameters.get("debug", ref debugFlag);
                if (debugFlag)
                {
                    Debugger.Break();
                }

                string typeName    = parameters["Service"] as string;
                var    serviceType = TypeHandler.GetReferencedTypeByName(typeName, "HelloIndigo", "HelloIndigoService");
                if (serviceType == null)
                {
                    throw new Exception(string.Format("Type [{0}] not available", typeName));
                }

                using (System.ServiceModel.ServiceHost host
                           = new System.ServiceModel.ServiceHost(serviceType))
                {
                    host.Open();

                    int i = 0;

                    i = 0;
                    Trace.WriteLine(string.Format("+ BaseAddresses +"));
                    foreach (Uri baseAddress in host.BaseAddresses)
                    {
                        Trace.WriteLine(string.Format("  [{0}] = {1}",
                                                      i++, baseAddress.AbsoluteUri));
                    }
                    Trace.WriteLine(string.Format("- BaseAddresses -"));

                    i = 0;
                    Trace.WriteLine(string.Format("Service : {0}", host.Description.ConfigurationName));
                    Trace.WriteLine(string.Format("+ EndPoints +"));
                    foreach (var ep in host.Description.Endpoints)
                    {
                        Trace.WriteLine(string.Format("  [{0}] = {1} {2} {3}",
                                                      i++, ep.Address.Uri, ep.Binding.Name, ep.Contract.Name));
                    }
                    Trace.WriteLine(string.Format("- EndPoints -"));


                    Console.WriteLine(string.Format("Press ENTER to terminate '{0}'", host.Description.ConfigurationName));
                    Console.ReadLine();
                }
            }
            catch (Exception exp)
            {
                Trace.WriteLine(exp.ToString());
            }
            finally
            {
                if (tracer != null)
                {
                    tracer.Close();
                }
            }
        }