Пример #1
0
 public EventSourceService(DaoRepository daoRepository, AppConf appConf, ILogger logger) : base(daoRepository, appConf)
 {
     SupportedEvents = new HashSet <string>();
     Logger          = logger ?? appConf?.Logger ?? Log.Default;
     DaoRepository?.AddType <EventMessage>();
     _listeners = new Dictionary <string, HashSet <EventSubscription> >();
 }
        protected override void OnStart(string[] args)
        {
            // Send start message to text log and event viewer
            clLogger.WriteErrorLog("GoDaddy DNS Service Started");
            clLogger.WriteEventLog("GoDaddy DNS Service Started", EventLogEntryType.Information);
            System.Threading.Thread.Sleep(1000);

            // init classes
            clGetPubIP = new GetPubIP();
            // pull data from App.config
            ConfigObj = new AppConf(
                ConfigurationManager.AppSettings["APIKey"],
                ConfigurationManager.AppSettings["SecretKey"],
                ConfigurationManager.AppSettings["WebAddressURL"],
                ConfigurationManager.AppSettings["GoDaddyDomain"],
                ConfigurationManager.AppSettings["ServiceUpdateRate"],
                ConfigurationManager.AppSettings["TTL"],
                ConfigurationManager.AppSettings["DisableEventLogging"],
                ConfigurationManager.AppSettings["DisableLogfileLogging"]
                );

            // init timer
            // setup service timer loop, multiply value by 60000(ms)
            Timer timer1 = null;

            timer1          = new Timer();
            timer1.Interval = ConfigObj.ServiceUpdateRate * 60000;
            timer1.Elapsed += new ElapsedEventHandler(timer1_tick);
            timer1.Enabled  = true;
        }
Пример #3
0
        /// <summary>
        /// Determines if the file referenced by RelativePath exists in the specified application
        /// </summary>
        /// <param name="appConf"></param>
        /// <returns></returns>
        public bool FileExists(AppConf appConf)
        {
            Args.ThrowIfNull(appConf, "appConf");
            Args.ThrowIfNull(appConf.AppRoot, "appConf.AppRoot");

            return(appConf.AppRoot.FileExists(RelativePath));
        }
Пример #4
0
 public DnsAgent(AppConf options, Rules rules, string listenOn, DnsMessageCache cache)
 {
     _options  = options;
     Rules     = rules ?? new Rules();
     _listenOn = listenOn;
     Cache     = cache ?? new DnsMessageCache();
 }
Пример #5
0
 public async void Run(GetPubIP GetPubIP, GoDaddyAPIClient gd_API, AppConf ConfigObj)
 {
     try
     {
         ArrayList arList = gd_API.API_GetARecordAsync(ConfigObj.GoDaddyURI).Result;
         if (arList[2].Equals(true))
         {
             if (!GetPubIP.GetIP(ConfigObj.WebAddressURL).Equals(arList[1].ToString(), StringComparison.Ordinal))
             {
                 await gd_API.API_UpdateARecordAsync(ConfigObj.GoDaddyURI, GetPubIP.GetIP(ConfigObj.WebAddressURL), ConfigObj.TTL);
             }
             else
             {
                 clLogger.WriteErrorLog("No IP Change detected");
                 clLogger.WriteEventLog("No IP Change detected", EventLogEntryType.Information);
             }
         }
     }
     catch (ProtocolException e)
     {
         clLogger.WriteErrorLog(e);
         clLogger.WriteEventLog(e);
     }
     catch (System.SystemException e)
     {
         clLogger.WriteErrorLog(e);
         clLogger.WriteEventLog(e);
     }
 }
Пример #6
0
 public HtmlRenderer(ExecutionRequest request, ContentResponder contentResponder)
     : base(request, contentResponder, "text/html", ".htm", ".html")
 {
     this.AppName          = AppConf.AppNameFromUri(request.Request.Url);
     this.ContentResponder = contentResponder;
     this.ExecutionRequest = request;
 }
Пример #7
0
        public SystemEventService(DaoRepository daoRepository, AppConf appConf, ILogger logger, ISmtpSettingsProvider smtpSettingsProvider) : base(daoRepository, appConf, logger)
        {
            SupportedEvents.Add("Error");
            SupportedEvents.Add("Fatal");

            SmtpSettingsProvider = smtpSettingsProvider;
        }
Пример #8
0
        private static ServiceRegistry GetServiceRegistry(CoreClient coreClient)
        {
            SQLiteDatabase    loggerDb   = DataSettings.Current.GetSysDatabase("TestServicesRegistry_DaoLogger2");
            ILogger           logger     = new DaoLogger2(loggerDb);
            IDatabaseProvider dbProvider = new DataSettingsDatabaseProvider(DataSettings.Current, logger);

            coreClient.UserRegistryService.DatabaseProvider        = dbProvider;
            coreClient.UserRegistryService.ApplicationNameProvider = new DefaultConfigurationApplicationNameProvider();
            AppConf             conf      = new AppConf(BamConf.Load(ServiceConfig.ContentRoot), ServiceConfig.ProcessName.Or(RegistryName));
            SystemLoggerService loggerSvc = new SystemLoggerService(conf);

            dbProvider.SetDatabases(loggerSvc);
            loggerSvc.SetLogger();

            return((ServiceRegistry)(new ServiceRegistry())
                   .For <IDatabaseProvider>().Use(dbProvider)
                   .For <IUserManager>().Use(coreClient.UserRegistryService)
                   .For <DataSettings>().Use(DataSettings.Current)
                   .For <ILogger>().Use(logger)
                   .For <IDaoLogger>().Use(logger)
                   .For <AppConf>().Use(conf)
                   .For <SystemLoggerService>().Use(loggerSvc)
                   .For <SystemLogReaderService>().Use <SystemLogReaderService>()
                   .For <TestReportService>().Use <TestReportService>()
                   .For <SmtpSettingsProvider>().Use(DataSettingsSmtpSettingsProvider.Default)
                   .For <NotificationService>().Use <NotificationService>());
        }
Пример #9
0
 public ProxyableService(ApplicationRepositoryResolver repoResolver, AppConf appConf)
 {
     AppConf            = appConf;
     RepositoryResolver = repoResolver;
     Logger             = appConf?.Logger ?? Log.Default;
     DiagnosticName     = GetType().Name;
 }
Пример #10
0
        public bool FileExists(AppConf appConf, out string absolutePath)
        {
            Args.ThrowIfNull(appConf, "appConf");
            Args.ThrowIfNull(appConf.AppRoot, "appConf.AppRoot");

            return(appConf.AppRoot.FileExists(RelativePath, out absolutePath));
        }
Пример #11
0
 public ProxyableService(DaoRepository repository, AppConf appConf)
 {
     AppConf            = appConf;
     DaoRepository      = repository;
     Repository         = repository;
     Logger             = appConf?.Logger ?? Log.Default;
     RepositoryResolver = new DefaultRepositoryResolver(repository);
 }
Пример #12
0
 public AsyncCallbackService(AsyncCallbackRepository repo, AppConf conf) : base(repo, conf)
 {
     HostPrefix = new HostPrefix {
         HostName = Machine.Current.DnsName, Port = RandomNumber.Between(49152, 65535)
     };
     AsyncCallbackRepository = repo;
     _pendingRequests        = new ConcurrentDictionary <string, Action <AsyncExecutionResponse> >();
 }
Пример #13
0
        public FormMain(AppConf appConf)
        {
            InitializeComponent();

            this.Raiz   = new Root();
            this.Path   = null;
            this.Config = appConf;
        }
Пример #14
0
 public ProxyableService(DaoRepository repository, AppConf appConf, IRepositoryResolver repositoryResolver = null)
 {
     AppConf            = appConf;
     DaoRepository      = repository;
     Repository         = repository;
     Logger             = appConf?.Logger ?? Log.Default;
     RepositoryResolver = repositoryResolver ?? new DefaultRepositoryResolver(repository);
     DiagnosticName     = GetType().Name;
 }
Пример #15
0
 protected ProxyableService()
 {
     AppConf            = new AppConf();
     RepositoryResolver = new ApplicationRepositoryResolver();
     Logger             = Log.Default;
     Repository         = new DaoRepository();
     RepositoryResolver = new DefaultRepositoryResolver(Repository);
     DiagnosticName     = GetType().Name;
 }
Пример #16
0
        public void CanLogActivity()
        {
            AppConf appConf          = new AppConf("TestApp");
            string  testActivityName = "TestActivityName_".RandomLetters(8);

            Activity.Add(appConf, testActivityName, "This is a test message: {0}", "arg value");
            Thread.Sleep(1500);
            Expect.IsGreaterThan(Activity.Retrieve(testActivityName).ToArray().Length, 0);
        }
Пример #17
0
        public ViewModel <T> GetViewModel <T>(AppConf appConf)
        {
            string name = System.IO.Path.GetFileNameWithoutExtension(FileSystemPath);

            return(new ViewModel <T>()
            {
                Name = name, ActionProvider = GetActionProvider <T>(appConf)
            });
        }
Пример #18
0
        private void AppendTemplatesFromDirectory(DirectoryInfo appDust, StringBuilder templates)
        {
            string domAppName = AppConf.DomApplicationIdFromAppName(this.AppContentResponder.AppConf.Name);

            Logger.AddEntry("AppDustRenderer::Compiling directory {0}", appDust.FullName);
            string appCompiledTemplates = DustScript.CompileTemplates(appDust, "*.dust", SearchOption.AllDirectories, domAppName + ".", Logger);

            templates.Append(appCompiledTemplates);
        }
Пример #19
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            AppConf  appConf  = AppConf.Get();
            FormMain formMain = new FormMain(appConf);

            formMain.WindowState = appConf.window.fullsreen ? FormWindowState.Maximized : FormWindowState.Normal;
            Application.Run(formMain);
        }
        public static S3FileDescriptor FromFile(AppConf appConf, FileInfo fileInfo)
        {
            S3ChunkDescriptor s3ChunkDescriptor = S3ChunkDescriptor.ForFile(appConf.GetApplicationName(), fileInfo);

            return(new S3FileDescriptor
            {
                S3ChunkDescriptorKey = s3ChunkDescriptor.CompositeKey,
                FullPath = fileInfo.FullName,
                Hash = fileInfo.Sha256()
            });
        }
Пример #21
0
 public TranslationService(
     IRepository genericRepo,
     DaoRepository daoRepo,
     AppConf appConf,
     ILanguageDetector languageDetector,
     ITranslationProvider translationProvider,
     IIsoLanguageTranslationProvider isoLanguageTranslationProvider) : base(genericRepo, daoRepo, appConf)
 {
     LanguageDetector               = languageDetector;
     TranslationProvider            = translationProvider;
     IsoLanguageTranslationProvider = isoLanguageTranslationProvider;
 }
Пример #22
0
        public WriteEventService(
            IRepository genericRepo,
            DaoRepository daoRepo,
            AppConf appConf,
            MetricsService metricsEvents,
            SystemEventService notificationEvents) : base(genericRepo, daoRepo, appConf)
        {
            _metricsEvents      = metricsEvents;
            _notificationEvents = notificationEvents;

            daoRepo.AddType <ExternalEventSubscriptionDescriptor>();
        }
Пример #23
0
        public ViewModel GetViewModel(AppConf appConf)
        {
            string    name   = System.IO.Path.GetFileNameWithoutExtension(FileSystemPath);
            ViewModel result = new ViewModel
            {
                Name           = name,
                ActionProvider = GetActionProvider(appConf) ?? new object(),
                ViewModelId    = ViewModelId
            };

            return(result);
        }
Пример #24
0
 public CoreApplicationRegistrationService(CoreApplicationRegistryServiceConfig config, AppConf conf, ApplicationRegistrationRepository coreRepo, ILogger logger)
 {
     CoreRegistryRepository = coreRepo;
     CoreRegistryRepository.WarningsAsErrors = false;
     config.DatabaseProvider.SetDatabases(this);
     CompositeRepository = new CompositeRepository(CoreRegistryRepository, config.WorkspacePath);
     _cacheManager       = new CacheManager(100000000);
     _apiKeyResolver     = new ApiKeyResolver(this, this);
     AppConf             = conf;
     Config        = config;
     Logger        = logger;
     HashAlgorithm = HashAlgorithms.SHA256;
 }
Пример #25
0
 public ApplicationRegistrationService(DataSettings dataSettings, AppConf conf, ApplicationRegistrationRepository coreRepo, ILogger logger)
 {
     ApplicationRegistrationRepository = coreRepo;
     ApplicationRegistrationRepository.WarningsAsErrors = false;
     dataSettings.SetDatabases(this);
     CompositeRepository = new CompositeRepository(ApplicationRegistrationRepository, dataSettings);
     _cacheManager       = new CacheManager(100000000);
     _apiKeyResolver     = new ApiKeyResolver(this, this);
     AppConf             = conf;
     DataSettings        = dataSettings;
     Logger        = logger;
     HashAlgorithm = HashAlgorithms.SHA256;
 }
Пример #26
0
        private void readConfig()
        {
            XmlSerializer ser = new XmlSerializer(typeof(AppConf));

            try
            {
                using (FileStream fs = File.OpenRead(Application.StartupPath + "\\config.xml"))
                    appConf = (AppConf)ser.Deserialize(fs);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error loading config: " + ex.ToString());
            }
        }
Пример #27
0
 public ServiceRegistryService(
     IFileService fileservice,
     IAssemblyService assemblyService,
     ServiceRegistryRepository repo,
     DaoRepository daoRepo,
     AppConf appConf,
     DataSettings dataSettings = null) : base(daoRepo, appConf)
 {
     FileService = fileservice;
     ServiceRegistryRepository = repo;
     AssemblyService           = assemblyService;
     DataSettings          = dataSettings ?? DataSettings.Current;
     AssemblySearchPattern = DefaultConfiguration.GetAppSetting("AssemblySearchPattern", "*.dll");
     _scanResults          = new Dictionary <Type, List <ServiceRegistryContainerRegistrationResult> >();
 }
Пример #28
0
        public void WriteBooks(AppConf appConfig)
        {
            AppName = appConfig.Name;
            FireEvent(AppInitializing, new WebBookEventArgs(appConfig));
            Fs appFs = appConfig.AppRoot;
            // get all the pages
            AppMetaManager manager   = new AppMetaManager(appConfig.BamConf);
            List <string>  pageNames = new List <string>(manager.GetPageNames(appConfig.Name));

            WritePageList(appFs, pageNames.ToArray());
            // read all the pages
            pageNames.Each(pageName =>
            {
                FireEvent(WritingBook, new WebBookEventArgs(appConfig));
                CurrentPage = pageName;
                // create a new book for every page
                WebBook book = new WebBook {
                    Name = pageName
                };
                string content = appFs.ReadAllText("pages", "{0}.html"._Format(pageName));
                // get all the [data-navigate-to] and a elements
                CQ cq          = CQ.Create(content);
                CQ navElements = cq["a, [data-navigate-to]"];
                navElements.Each(nav =>
                {
                    // create a WebBookPage for each target
                    string href  = nav.Attributes["href"];
                    string navTo = nav.Attributes["data-navigate-to"];
                    string url   = string.IsNullOrEmpty(navTo) ? href : navTo;
                    if (!string.IsNullOrEmpty(url))
                    {
                        url           = url.Contains('?') ? url.Split('?')[0] : url;
                        string layout = nav.Attributes["data-layout"];
                        layout        = string.IsNullOrEmpty(layout) ? "basic" : layout;
                        if (pageNames.Contains(url))
                        {
                            book.Pages.Add(new WebBookPage {
                                Name = url, Layout = layout
                            });
                        }
                    }
                });
                WriteBook(appFs, book);
                FireEvent(WroteBook, new WebBookEventArgs(appConfig));
            });
            FireEvent(AppInitialized, new WebBookEventArgs(appConfig));
        }
Пример #29
0
        protected internal WebBook GetBookByAppAndPage(string appName = "localhost", string pageName = "home")
        {
            AppConf appConf = BamConf[appName];
            WebBook result  = new WebBook();

            if (appConf != null)
            {
                string booksDir = "books";
                string bookFile = "{0}.json"._Format(pageName);
                Fs     appRoot  = appConf.AppRoot;
                if (appRoot.FileExists(booksDir, bookFile))
                {
                    result = appRoot.ReadAllText(booksDir, bookFile).FromJson <WebBook>();
                }
            }
            return(result);
        }
Пример #30
0
        public virtual ViewModel Load(AppConf appConf)
        {
            if (_viewModels == null)
            {
                _viewModels = new Dictionary <string, ViewModel>();
            }
            if (string.IsNullOrEmpty(ActionProvider))
            {
                ParseActionProviderName(appConf);
            }
            if (!_viewModels.ContainsKey(ViewModelId))
            {
                _viewModels.Add(ViewModelId, GetViewModel(appConf));
            }

            return(_viewModels[ViewModelId]);
        }
Пример #31
0
 /* Charge la configuration de l'application */
 public void loadAppConfig(string path)
 {
     _AppConfig = getAppConfigFile (path);
 }
Пример #32
0
    /* Retourne une instance de type AppConf pour récupérer le nom du dernier fichier de configuration utilisé
     * Ce fichier se trouve à l'adresse path et sera créé si il n'existe pas
     */
    public AppConf getAppConfigFile(string path)
    {
        //Création du fichier de configuration de l'application la première fois
        if (!File.Exists (path)) {
            _AppConfig = new AppConf();
            if(_ConfigsList.Count>0)
                _AppConfig.LastConfName = ((Conf)_ConfigsList[_ConfigsList.Count - 1]).Name;
            _AppConfig.saveConfig(path);
        }

        AppConf res = null;
        XmlSerializer xs = new XmlSerializer(typeof(AppConf));
        using (StreamReader rd = new StreamReader(path))
        {
            res = xs.Deserialize(rd) as AppConf;
        }
        return res;
    }