public PrincipalTenancyContextProvider() { try { _log = ClassLogger.Create(this.GetType()); this.principalContextProvider = (Catalog.Factory.Resolve <IContextProvider>( PrincipalTenancyContextProviderConfiguration.PrincipalContextFactoryKey) ?? Catalog.Factory.Resolve <IContextProvider>("TenancyContext")) ?? Catalog.Factory.Resolve <IContextProvider>(); } catch (Exception ex) { if (ex.InnerException != null) { _log.Error(ex.ToString() + " \n InnerException: " + ex.InnerException.ToString()); } else { _log.Error(ex.ToString()); } Console.WriteLine(ex.ToString()); } this.cachedTenancies = Catalog.Preconfigure().Add(CachedDataLocalConfig.OptionalMaximumCacheSize, 5000).Add( CachedDataLocalConfig.OptionalGroomExpiredData, true).Add( CachedDataLocalConfig.OptionalDefaultExpirationTimeSeconds, 600).Add( CachedDataLocalConfig.OptionalCacheHitRenewsExpiration, true).ConfiguredCreate( () => new InMemoryCachedData <string, string>()); }
public frmMain() { InitializeComponent(); // init config helper config = new ConfigHelper(); config.clientId = Properties.Settings.Default.ClientId; config.graphEndpoint = Properties.Settings.Default.GraphEndpoint; config.redirectUri = Properties.Settings.Default.RedirectUri; // init config values redirectUri = new Uri(config.redirectUri); authority = String.Format(CultureInfo.InvariantCulture, config.aadInstance, "common"); clientId = config.clientId; graphApiEndpoint = config.graphEndpoint; // create log and token cache objects applogger = new ClassLogger("restfuloutlook-app.log"); sdklogger = new ClassLogger("restfuloutlook-graphsdk.log"); user = new LoggedOnUserHelper(); fc = new FileCache(Environment.CurrentDirectory); // init button state btnMailAPI.Enabled = false; btnGraphAPI.Enabled = false; btnContactsAPI.Enabled = false; btnCalendarAPI.Enabled = false; btnReportingService.Enabled = false; btnUserPhotoAPI.Enabled = false; }
private static void DistributeDefaultApplications(IDocumentSession coreSession, IEnumerable <Tenant> tenants) { var log = ClassLogger.Create(typeof(ApplicationManager)); var applications = new List <Application>(); var query = (from apps in coreSession.Query <Application>() select apps).ToList(); if (query.Any()) { applications.AddRange(query); } foreach (var tenant in tenants) { using (var session = DocumentStoreLocator.Resolve(tenant.Site)) { var q = (from apps in session.Query <Application>() select apps).ToList(); if (!q.Any()) { Storage(ref applications); foreach (var app in applications) { session.Store(app); log.InfoFormat("The {0} Application has been Stored in {1} Tenant sucessfully", app.Name, tenant.Name); } } session.SaveChanges(); } } }
public WorkflowStateMachine(WorkflowContext ctx, StateMachine <string, string> inner, string activationTrigger) { _ctx = ctx; _machine = inner; _activationTrigger = activationTrigger; _log = ClassLogger.Create(GetType()); }
private void Initialize(WorkflowHost host, string templateData) { _log = ClassLogger.Create(GetType()); _dblog = DebugOnlyLogger.Create(_log); _host = host; _workspaceContainerName = WorkflowShared.WorkflowInstanceWorkspaceName(Id); Workspace = Catalog.Preconfigure() .Add(WorkspaceLocalConfig.WorkspaceName, _workspaceContainerName) .ConfiguredResolve <IWorkspace>(_workflowWorkspaceKey); if (null == _wfLock) { _wfLock = ConstructLock(Id); } SpecifyUsingTemplate(templateData); var instance = new WorkflowInstanceInfo { Id = Id, TemplateName = Name, LastActivity = DateTime.UtcNow, NextActivationTime = DateTime.UtcNow, Status = WorkflowStatus.Active.ToString(), }; _instanceData.Store(instance); }
public PayPalIPNGateway() { _accountBroker = Catalog.Factory.Resolve <IAccountTypeBroker>(); _log = ClassLogger.Create(GetType()); _dblog = DebugOnlyLogger.Create(_log); _config = Catalog.Factory.Resolve <IConfig>(); }
public SvcInstaller() { var processInstaller = new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem }; var conf = new Config(); var serviceInstaller = new ServiceInstaller { ServiceName = conf.ServiceName, DisplayName = conf.DisplayName, StartType = conf.ServiceStartMode, Description = conf.Description }; try { serviceInstaller.ServicesDependedOn = conf.ServicesDependedOn; } catch (Exception ex) { ClassLogger.Error(ex); } try { serviceInstaller.DelayedAutoStart = conf.DelayedAutoStart; } catch (Exception ex) { ClassLogger.Error(ex); } Installers.AddRange(new Installer[] { serviceInstaller, processInstaller }); }
public AzureFilesBlobContainer() { _log = ClassLogger.Create(GetType()); _dblog = DebugOnlyLogger.Create(_log); var config = Catalog.Factory.Resolve <IConfig>(SpecialFactoryContexts.Routed); _containerName = config[BlobContainerLocalConfig.ContainerName]; EntityAccess access = (EntityAccess)Enum.Parse(typeof(EntityAccess), config.Get(BlobContainerLocalConfig.OptionalAccess, EntityAccess.Private.ToString())); _contentType = config.Get(BlobContainerLocalConfig.OptionalContentType, "application/raw"); _account = Client.FromConfig(); _client = _account.CreateCloudBlobClient(); _client.RetryPolicy = RetryPolicies.Retry(3, TimeSpan.FromSeconds(5)); var blobContainerPermissions = new BlobContainerPermissions { PublicAccess = AzureEntityAccessTranslator.Translate(access) }; _blobContainerPermissions = blobContainerPermissions; _container = _client.GetContainerReference(_containerName.ToLowerInvariant()); if (_container.CreateIfNotExist()) { _container.SetPermissions(_blobContainerPermissions); } }
private bool HandleInternalMessage(Peer toPassTo, LidgrenTransferPacket packet) { if (packet.isEncrypted) { if (toPassTo.EncryptionRegister.HasKey(packet.EncryptionMethodByte)) { if (!packet.Decrypt(toPassTo.EncryptionRegister[packet.EncryptionMethodByte])) { ClassLogger.LogError("Failed to decrypt package from Peer ID: " + toPassTo.UniqueConnectionId + " with EncryptionByte: " + packet.EncryptionMethodByte); return(false); } } } PacketBase deserializedPacketBase = InternalPacketConstructor(packet); switch (packet.OperationType) { case Packet.OperationType.Request: return(this.ProcessInternalRequest((InternalPacketCode)packet.PacketCode, deserializedPacketBase, toPassTo)); case Packet.OperationType.Response: return(this.ProcessInternalResponse((InternalPacketCode)packet.PacketCode, deserializedPacketBase, toPassTo)); case Packet.OperationType.Event: throw new LoggableException("GladNet currently does not support internal events.", null, LogType.Error); default: return(false); } }
private bool ProcessEncryptionResponse(Peer peer, PacketBase packet) { EncryptionRequest eq = packet as EncryptionRequest; if (eq == null) { ClassLogger.LogError("Recieved encryption request with null packet."); return(false); } if (!peer.EncryptionRegister.HasKey(eq.EncryptionByteType)) { ClassLogger.LogError("Recieved an encryption request response from the server for ByteType: {0} but the client is unaware of that type." , eq.EncryptionByteType); return(false); } //TODO: Verify that this is working. Callback at one point was not working. //This will set the server's init info. In the case of the default, for example, it will set the Diffiehelmman public key. //With this the server and client have established a shared secret and can now pass messages, with the IV, to eachother securely. //In the case of a custom method it is User defined and should be referenced. bool result = peer.EncryptionRegister[eq.EncryptionByteType].SetNetworkInitRequiredData(eq.EncryptionInitInfo); Action callback = peer.EncryptionRegister[eq.EncryptionByteType].OnEstablished; if (callback != null) { callback(); } return(result); }
private bool EncryptionRegisterFromWire(Peer toPassTo, PacketBase packet) { EncryptionRequest eq = packet as EncryptionRequest; if (eq == null) { ClassLogger.LogError("Recieved encryption request with null packet."); return(false); } if (!EncryptionFactory.ContainsKey(eq.EncryptionByteType)) { ClassLogger.LogError("Failed to establish encryption from Peer ID: " + toPassTo.UniqueConnectionId + " with EncryptionByte: " + eq.EncryptionByteType); return(false); } EncryptionBase newEncryptionObj = EncryptionFactory[eq.EncryptionByteType](); toPassTo.EncryptionRegister.Register(newEncryptionObj, eq.EncryptionByteType); bool result = toPassTo.EncryptionRegister[eq.EncryptionByteType] .SetNetworkInitRequiredData(eq.EncryptionInitInfo); if (result) { EncryptionRequest encryptionResponse = new EncryptionRequest(eq.EncryptionByteType, newEncryptionObj.NetworkInitRequiredData()); toPassTo.SendMessage(Packet.OperationType.Response, encryptionResponse, (byte)InternalPacketCode.EncryptionRequest, Packet.DeliveryMethod.ReliableUnordered, 0, 0, true); } return(false); }
public AccountController() { _accountBusinessLogic = new AccountBusinessLogic(); _navigationBusinessLogic = new NavigationBusinessLogic(); _log = ClassLogger.Create(this.GetType()); _applicationAlert = Catalog.Factory.Resolve <IApplicationAlert>(); }
public void MaybeReconfigureLogging(LoggingConfiguration _newConfig) { if (_newConfig.ClassFilter != null && _newConfig.ClassFilter != _cachedConfiguration.ClassFilter) { ClassLogger.SetLoggingForClasses(_newConfig.ClassFilter); _cachedConfiguration.ClassFilter = _newConfig.ClassFilter; } if (_newConfig.File != null && _newConfig.File != _cachedConfiguration.File) { SetLoggingPath(_newConfig.File); _cachedConfiguration.File = _newConfig.File; } if (string.IsNullOrEmpty(_newConfig.File) && _newConfig.File != _cachedConfiguration.File) { SetLoggingPath(_componentFile); _cachedConfiguration.File = _componentFile; } if (_newConfig.LogLevel != -1 && _newConfig.LogLevel != _cachedConfiguration.LogLevel) { TurnOnLogging(_newConfig.LogLevel); _cachedConfiguration.LogLevel = _newConfig.LogLevel; } }
public DocumentDistributedMutex() { _log = ClassLogger.Create(GetType()); _dblog = DebugOnlyLogger.Create(_log); var config = Catalog.Factory.Resolve <IConfig>(SpecialFactoryContexts.Routed); _name = config[DistributedMutexLocalConfig.Name].ToLowerInvariant(); var seconds = config.Get <int>(DistributedMutexLocalConfig.UnusedExpirationSeconds); if (seconds < 15) { seconds = 15; } _expireUnused = TimeSpan.FromSeconds(seconds); _renewWait = TimeSpan.FromSeconds(seconds - 5); _cts = new CancellationTokenSource(); _cancelGrooming = new CancellationTokenSource(); _cancelGroomingToken = _cancelGrooming.Token; _groomingTask = Task.Factory.StartNew(GroomExpired, _cancelGroomingToken); _acquirer = Guid.NewGuid(); CreateIfNotExists(); }
/// <summary> /// Is called if the connection attempt resulted in a failure the remote connection point was unreachable or did not respond. /// </summary> /// <param name="response">Response information that may have been gathered upon the failure.</param> protected virtual void OnConnectionFailure(ConnectionResponse response) { #if DEBUGBUILD //TODO: Add information to the debug logger string for the response. ClassLogger.LogDebug("Failed to connect to a server."); #endif //Just fail silently if not overidden. }
/// <summary> /// Deserialize the object from XML storage /// </summary> /// <param name="xmlData"></param> public override void FromXml(System.Xml.XmlNode xmlData) { DateTime Start = Debug.ExecStart; base.FromXml(xmlData); this._Path = xmlData.SelectSingleNode(XmlPropPath).InnerText; ClassLogger.Log(LogLevel.Trace, String.Format("{0} Execution Time: {1}", Debug.FunctionName, Debug.GetExecTime(Start)), ""); }
public void Initialize(CancellationToken token) { _log = ClassLogger.Create(GetType()); _dblog = DebugOnlyLogger.Create(_log); _ct = token; Compose(); }
public LocalMessageBus() { _log = ClassLogger.Create(GetType()); _dblog = DebugOnlyLogger.Create(_log); var source = new CancellationTokenSource(); _ct = source.Token; }
public AccountTypeBrokerBase() { _log = ClassLogger.Create(GetType()); _dblog = DebugOnlyLogger.Create(_log); _config = Catalog.Factory.Resolve <IConfig>(); _sender = _config[SendEmailSettings.EmailReplyAddress]; _authCode = string.Empty; }
/// <summary> /// use the expiration metadata attribute to remove expired containers. /// </summary> /// <param name="prefix"> </param> /// <param name="ct"> </param> public static void GroomExpiredContainers(string prefix = null, CancellationToken?ct = null) { ILog log = ClassLogger.Create(typeof(AzureStorageAssistant)); DebugOnlyLogger dblog = DebugOnlyLogger.Create(log); try { var account = CloudStorageAccount.FromConfigurationSetting(CommonConfiguration.DefaultStorageConnection.ToString()); var bc = account.CreateCloudBlobClient(); if (ct.HasValue) { ct.Value.ThrowIfCancellationRequested(); } IEnumerable <CloudBlobContainer> containers; if (!string.IsNullOrEmpty(prefix)) { containers = bc.ListContainers(prefix); } else { containers = bc.ListContainers(); } if (ct.HasValue) { ct.Value.ThrowIfCancellationRequested(); } Parallel.ForEach(containers, c => { c.FetchAttributes(); if (ct.HasValue) { ct.Value.ThrowIfCancellationRequested(); } if (c.Metadata.AllKeys.Contains(BlobMetaPropertyExpired)) { DateTime expirationTime = DateTime.Parse(c.Metadata[BlobMetaPropertyExpired], CultureInfo.InvariantCulture); if (DateTime.UtcNow > expirationTime) { c.Delete(); } } }); } catch (Exception ex) { log.Warn(ex.Message); log.Warn(ex.ToString()); throw; } }
public override bool InterceptInstead(Invocation invocation, object target, ShapeableExpando extensions, out object resultData) { _log = ClassLogger.Create(target.GetType()); var msg = string.Format("Intercept the method {0}, with name {1}.", invocation.Kind, invocation.Name); _log.Info(msg); resultData = null; return(true); }
public NewMessageForm(ref GraphServiceClient olClient, ref ClassLogger appLogger, ref ClassLogger sdkLogger) { InitializeComponent(); graphClient = olClient; applogger = appLogger; sdklogger = sdkLogger; toRecipients = new List <Recipient>(); ccRecipients = new List <Recipient>(); bccRecipients = new List <Recipient>(); }
public NewEventForm(ref GraphServiceClient olClient, ref ClassLogger appLogger, ref ClassLogger sdkLogger) { InitializeComponent(); graphClient = olClient; applogger = appLogger; sdklogger = sdkLogger; // add 1/2 hour to the dtpend time dtpEndTime.Value = dtpEndTime.Value.AddMinutes(30); }
public NewContactForm(ref GraphServiceClient olClient, ref ClassLogger appLogger, ref ClassLogger sdkLogger) { InitializeComponent(); graphClient = olClient; applogger = appLogger; sdklogger = sdkLogger; emailAddresses = new List <EmailAddress>(); businessPhones = new List <string>(); homePhones = new List <string>(); }
public void Run() { ClassLogger.Configure(); DeclareWorkflow(); CreateHost(); InstantiateWorkflow(); DriveWorkflow(); Report(); }
public virtual bool DispatchMessage(Peer toPassTo, NetIncomingMessage msg, bool isInternal) { if (msg == null) { throw new LoggableException("When dispatched NetBuffer was found to be null.", null, LogType.Error); } LidgrenTransferPacket packet = this.BuildTransferPacket(msg); if (toPassTo == null) { return(false); } if (!this.SerializerRegister.HasKey(packet.SerializerKey)) { ClassLogger.LogError("Recieved a packet that cannot be handled due to not having a serializer registered with byte code: " + packet.SerializerKey); return(false); } if (packet == null) { ClassLogger.LogError("Lidgren packet built to null."); return(false); } if (toPassTo == null) { ClassLogger.LogError("When attempted to dispatch the Peer passed was found to be null."); return(false); } #if UNITYDEBUG || DEBUG this.ClassLogger.LogDebug("About to handle packet. Encrypted: " + packet.isEncrypted.ToString() + " EncryptionCode: " + packet.EncryptionMethodByte); #endif if (!isInternal) { if (packet.isEncrypted) { return(DispatchEncryptedMessage(toPassTo, packet, msg.DeliveryMethod)); } else { return(Dispatch(toPassTo, packet, msg.DeliveryMethod)); } } else { return(HandleInternalMessage(toPassTo, packet)); } }
private IEnumerable <DirectoryFile> ScanFolder() { List <DirectoryFile> fileList = new List <DirectoryFile>(); string[] fileListString = Directory.GetFiles(FolderName); foreach (var file in fileListString) { DirectoryFile newFile = new DirectoryFile { FileName = file, FolderName = FolderName }; ClassLogger.Info(file.Substring(FolderName.Length + 1, 3).ToUpper()); string extension = Path.GetExtension(file); switch (extension.ToUpper()) { case ".OFX": newFile.DirectoryFileType = FileType.Expense; break; case ".CSV": switch (file.Substring(FolderName.Length + 1, 3).ToUpper()) { case "INV": newFile.DirectoryFileType = FileType.Invoice; break; case "EXP": newFile.DirectoryFileType = FileType.Expense; break; case "BAN": newFile.DirectoryFileType = FileType.Expense; break; default: newFile.DirectoryFileType = FileType.Invalid; break; } break; default: newFile.DirectoryFileType = FileType.Invalid; break; } if (!(newFile.DirectoryFileType == FileType.Invalid)) { fileList.Add(newFile); } } return(fileList); }
public RavenGlobalConfig() { var cf = Catalog.Factory.Resolve <IConfig>(SpecialFactoryContexts.Routed); var company = cf[ApplicationTopologyLocalConfig.CompanyKey]; var product = cf[ApplicationTopologyLocalConfig.ApplicationKey]; _reg = new ApplicationNodeRegistry(company, product); _log = ClassLogger.Create(GetType()); _dbLog = DebugOnlyLogger.Create(_log); _updateCycle = Catalog.Factory.Resolve <IRecurrence <object> >(); }
/// <summary> /// Internally called by the app when a shutdown request has been recieved. /// </summary> internal void InternalOnShutdown() { #if DEBUGBUILD ClassLogger.LogDebug("Server shutdown requested."); #endif OnShutdown(); //Do not stop polling the server until the application is about to stop. //In case it is desired to send a final message to clients and subservers we flush the network queue //So these messages can hopefully be sent before shutdown. this.lidgrenServerObj.FlushSendQueue(); isReady = false; }
public override bool InterceptBefore(Invocation invocation, object target, ShapeableExpando extensions, out object resultData) { _log = ClassLogger.Create(target.GetType()); var msg = string.Format("Intercept the method {0}, with name{1}", invocation.Kind, invocation.Name); if (invocation.Arguments.Length > 0) { msg += string.Format(" that has the following parameters:{0}", invocation.Arguments); } _log.Info(msg); resultData = null; return(true); }