public bool GetAppSetting(string name, bool defaultvalue) { bool result = defaultvalue; object enabled = ConfigurationManager.AppSettings[name]; if (enabled != null) { if (!bool.TryParse(enabled.ToString(), out result)) { EventLogManager.WriteEntry(string.Format("Configuration setting {0}=\"{1}\" is invalid.", name, enabled.ToString()), EventLogEntryType.Warning); } } return(result); }
public void RevokeCertificate(X509Certificate2 cert) { if (cert == null) { throw new ArgumentNullException("cert", "Certificate cannot be null"); } message = String.Format("Client {0} with certificate[Subject {1}] has been revoked.Revocation list updated.", (Thread.CurrentPrincipal.Identity as WindowsIdentity).Name, cert.Subject); evntType = EventLogEntryType.SuccessAudit; EventLogManager.WriteEntryCMS(message, evntType, Convert.ToInt32(IDType.RevokeSuccess)); AddToRevocationList(cert); DeleteLocalCertificate(cert); NotifyAllClients(cert); }
private void UpdateFailure(MimeDSNRecipient r) { ISession session = SnCore.Data.Hibernate.Session.Factory.OpenSession(); try { EventLogManager.WriteEntry(string.Format("Searching for {0}.", r.FinalRecipientEmailAddress)); UpdateFailureEmails(r, session); UpdateFailureInvitations(r, session); } finally { session.Close(); } }
public override void OnActionExecuting(HttpActionContext actionContext) { base.OnActionExecuting(actionContext); bool authenticated = false; string message = "Access denied."; string apiKey = null; try { // Is there an api key header present? if (actionContext.Request.Headers.Contains("x-api-key")) { // Get the api key from the header. apiKey = actionContext.Request.Headers.GetValues("x-api-key").FirstOrDefault(); // Make sure it's not null and it's 32 characters or we're wasting our time. if (apiKey != null && apiKey.Length == 32) { // Attempt to look up the api user. APIUser apiUser = APIUserManager.GetByAPIKey(apiKey); // Did we find one and double check the api key. if (apiUser != null && apiUser.APIKey == apiKey) { // Genuine API user. authenticated = true; } } } } catch (Exception ex) { // Set appropriate message. message = "An error occurred while trying to authenticate this request."; EventLogManager.Log("AUTH_EXCEPTION", EventLogSeverity.Info, null, ex); } // If authentication failure occurs, return a response without carrying on executing actions. if (!authenticated) { EventLogManager.Log("AUTH_BAD_APIKEY", EventLogSeverity.Warning, string.Format("Authentication failed for API key: {0}.", apiKey)); actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.Forbidden, message); } }
public override void OnActionExecuting(HttpActionContext actionContext) { base.OnActionExecuting(actionContext); bool authenticated = false; string message = "Access denied."; string apiKey = null; try { apiKey = actionContext.Request.GetApiKey(); EventLogManager.Log("api-key is", EventLogSeverity.Info, apiKey); // Make sure it's not null and it's 32 characters or we're wasting our time. if (apiKey != null && apiKey.Length == 32) { EventLogManager.Log("Find APIUSER using key", EventLogSeverity.Info, apiKey); // Attempt to look up the api user. APIUser apiUser = APIUserManager.FindAndPrepare(apiKey); EventLogManager.Log("APIUSER.prepared ", EventLogSeverity.Info, apiUser.Prepared.ToString()); // Did we find one and is it ready to use? if (apiUser != null && apiUser.Prepared) { EventLogManager.Log("Authenticated URI: ", EventLogSeverity.Info, "True: " + actionContext.Request.RequestUri); // Genuine API user. authenticated = true; } } } catch (Exception ex) { // Set appropriate message. message = "An error occurred while trying to authenticate this request."; EventLogManager.Log("AUTH_EXCEPTION", EventLogSeverity.Info, null, ex); } // If authentication failure occurs, return a response without carrying on executing actions. if (!authenticated) { EventLogManager.Log("AUTH_BAD_APIKEY", EventLogSeverity.Warning, string.Format("Authentication failed for API key: {0}.", apiKey)); actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.Forbidden, message); } }
private void OnProductionNotAvailable() { PlayerResources.OnResourceChanged += CheckIfNecessaryInputResourcesAreAvailable; //PlayerResources.OnMoneyChanged += (x) => CheckIfNecessaryInputResourcesAreAvailable(); enabled = false; ToggleBuildingEffects(false); if (OnNotEnoughInputResourcesAvailable != null) { OnNotEnoughInputResourcesAvailable(this); } int missingID; PlayerResources.Instance.HasResourcesAmount(data.Resourceinput, data.Resourceinputamount, out missingID); EventLogManager.AddNewResourceUnavailableLog(this, missingID); }
public async Task <HttpResponseMessage> AddPackages(string sessionGuid) { if (!SessionManager.SessionExists(sessionGuid)) { // Session doesn't exist. return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid session.")); } try { // Does the request contain multipart/form-data? if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } // Get the api key from the header. string apiKey = Request.Headers.GetValues("x-api-key").FirstOrDefault(); // Get the api user. APIUser apiUser = APIUserManager.FindAndPrepare(apiKey); // Receive files. MultipartMemoryStreamProvider provider = await Request.Content.ReadAsMultipartAsync(); foreach (HttpContent file in provider.Contents) { string filename = file.Headers.ContentDisposition.FileName.Replace("\"", ""); using (MemoryStream ms = new MemoryStream(await file.ReadAsByteArrayAsync())) { using (Stream ds = Crypto.Decrypt(ms, apiUser.EncryptionKey)) { SessionManager.AddPackage(sessionGuid, ds, filename); } } } } catch (Exception ex) { EventLogManager.Log("REMOTE_EXCEPTION", EventLogSeverity.Warning, null, ex); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.Created)); }
public static ActionResult RemoveEventLogs(Session session) { try { session.Log("Beginning the uninstall of the event log source."); EventLogManager.RemoveSource(); session.Log("Uninstall of the event log source was successful."); return(ActionResult.Success); } catch (Exception e) { session.Log(e.Message + "\n" + e.StackTrace); return(ActionResult.Failure); } }
private void SellTradeOffer(int tradeAcceptant, int resourceID, int amount) { resourcesAmountForTrade[resourceID] -= amount; if (resourcesAmountForTrade[resourceID] < 0) { resourcesAmountForTrade[resourceID] = 0; } float value = resourcesCostForTrade[resourceID] * amount; TradeOffer tradeOffer = new TradeOffer(this, resourceID, amount, value); MarketPlace.OnTradeOfferSold(tradeOffer); if (isLocalPlayer) { EventLogManager.AddNewTradeOfferSoldLog(tradeOffer); } }
//Read from register (instalation path, connection settings) private void Initialization() { cmSettings = ConnectionSettingsManager.GetCMSettings(); crmSettings = ConnectionSettingsManager.GetCRMSettings(); try { cmRepo = new CMRepository(cmSettings); crmRepo = new CRMRepository(crmSettings); } catch (Exception) { EventLogManager.WriteMessage(new Message() { Description = "Connection settings error", Type = "Error", Time = DateTime.Now }, EventType.Error); } }
public void RunSyndication(ISession session, ManagedSecurityContext sec) { IQuery query = session.CreateSQLQuery( "SELECT {AccountFeed.*} FROM AccountFeed" + " WHERE (NOT EXISTS ( SELECT AccountFeedItem_Id FROM AccountFeedItem item WHERE item.AccountFeed_Id = AccountFeed.AccountFeed_Id ))" + " OR ( AccountFeed.LastError NOT LIKE '' )" + " OR ( DATEDIFF(hour, AccountFeed.Updated, getutcdate()) > AccountFeed.UpdateFrequency )" + " ORDER BY AccountFeed.Updated ASC") .AddEntity("AccountFeed", typeof(AccountFeed)); IList <AccountFeed> list = query.List <AccountFeed>(); foreach (AccountFeed feed in list) { if (IsStopping) { break; } try { ManagedAccountFeed m_feed = new ManagedAccountFeed(session, feed); if (IsDebug) { EventLogManager.WriteEntry(string.Format("Syndication service updating {0} ({1}).", feed.Name, feed.Id), EventLogEntryType.Information); } m_feed.Update(sec); m_feed.UpdateImages(sec); m_feed.UpdateMedias(sec); } catch (ThreadAbortException) { throw; } catch (Exception ex) { feed.LastError = ex.Message; session.Save(feed); } session.Flush(); Thread.Sleep(1000 * InterruptInterval); } }
void SyncList() { //delete this sleep time Thread.Sleep(30000); while (true) { //Read refresh rate from registry try { refreshRate = Convert.ToInt64(ServiceSettingsManager.GetRefreshRate()); //In minut if (refreshRate == 0) { throw new Exception(); } } catch { refreshRate = 2; } refreshRate = refreshRate * 60000; Stopwatch watch = Stopwatch.StartNew(); try { syncCrmCm = new SyncCrmCm(); syncCrmCm.Sync(); } catch (Exception e) { EventLogManager.WriteMessage(new Message() { Description = e.Message.ToString(), System = "Sync", Time = DateTime.Now }, EventType.Error); } watch.Stop(); long elapsedMs = watch.ElapsedMilliseconds; long timeToSleep = refreshRate - elapsedMs; if (timeToSleep > 0) { Thread.Sleep(Convert.ToInt32(timeToSleep)); } } }
public static void Start() { //obsolete timer start tmrObsoleteLicenses.Interval = 300000; tmrObsoleteLicenses.Elapsed += TmrObsoleteLicenses_Elapsed; tmrObsoleteLicenses.Start(); //online licenses LicenseServerOnlineCatalogManager.OnCatalogLicensesFetched += OnCatalogLicensesFetched; ConnectionManager.Start(11006, false); ConnectionManager.AtumClientLicenseRequest += ConnectionManager_AtumClientLicenseRequest; ConnectionManager.AtumClientRemoveLicenseRequest += ConnectionManager_AtumClientRemoveLicenseRequest; AvailableLicenses = new AvailableLicenses(); //check if previous license file exists then preload them if (File.Exists(DAL.ApplicationSettings.Settings.LocalLicenseFilePath)) { var offlineLicenses = OnlineCatalogLicenses.FromLicenseFile(); if (offlineLicenses != null) { foreach (var offlineLicense in offlineLicenses) { if (offlineLicense.Activated && offlineLicense.Amount > 0 && offlineLicense.ExpirationDate >= DateTime.Now) { AvailableLicenses.Add(new AvailableLicense() { Activated = offlineLicense.Activated, LicenseGUID = offlineLicense.LicenseGUID, ExpirationDate = offlineLicense.ExpirationDate, LicenseType = offlineLicense.LicenseType, Amount = offlineLicense.Amount }); } } } EventLogManager.WriteToEventLog("Offline license(s) found", "Amount " + AvailableLicenses.Count); } }
public void Deploy() { // Do the install. JavaScriptSerializer jsonSer = new JavaScriptSerializer(); SessionDataController dc = new SessionDataController(); // Set as started. Session.Status = SessionStatus.InProgess; dc.Update(Session); // Install in order. foreach (KeyValuePair <int, InstallJob> keyPair in OrderedInstall) { // Get install job. InstallJob job = keyPair.Value; // Attempt install. job.Install(); // Log package installs. foreach (PackageJob package in job.Packages) { string log = string.Format("Package successfully installed: {0} @ {1}, session: {2}.", package.Name, package.VersionStr, Session.Guid); EventLogManager.Log("PACKAGE_INSTALLED", EventLogSeverity.Info, log); } // Make sorted list serialisable. SortedList <string, InstallJob> serOrderedInstall = new SortedList <string, InstallJob>(); foreach (KeyValuePair <int, InstallJob> pair in OrderedInstall) { serOrderedInstall.Add(pair.Key.ToString(), pair.Value); } // After each install job, update response. Session.Response = jsonSer.Serialize(serOrderedInstall); dc.Update(Session); } // Done. Session.Status = SessionStatus.Complete; dc.Update(Session); }
public List <Catalogo> ListadoCatAccionesPLD() { List <Catalogo> result = null; try { result = (new CatalogosLogic()).ListadoCatAccionesPLD(); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en CatalogoServices.ListadoCatAccionesPLD: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en CatalogoServices.ListadoCatAccionesPLD: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
/// <summary> /// Obtiene los datos de la persona /// </summary> /// <param name="intEmpresaID"></param> /// <param name="sintTipoEmpresaID"></param> /// <returns></returns> public List <Empresa> ListarDatosPersona(Int32 @intEmpresaID, Int16 @sintTipoEmpresaID) { List <Empresa> result = new List <Empresa>(); try { result = (new EmpresaLogic()).ListarDatosPersona(@intEmpresaID, @sintTipoEmpresaID); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en EmpresaServices.ListarDatosPersona: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en EmpresaServices.ListarDatosPersona: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
/// <summary> /// Permite realizar el alta, modificación y baja de la empresa /// </summary> /// <param name="empresa"></param> /// <param name="tinOpcion"></param> /// <returns></returns> public Resultado setEmpresa(Empresa empresa, short tinOpcion) { Resultado result = new Resultado(); try { result = (new EmpresaLogic()).setEmpresa(empresa, tinOpcion); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en EmpresaServices.setEmpresa: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en EmpresaServices.setEmpresa: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
/// <summary> /// Permite realizar el alta, modificación o baja de los datos de domicilio /// </summary> /// <param name="direccion"></param> /// <param name="tinOpcion"></param> /// <returns></returns> public Resultado setDomicilio(Direccion direccion, short tinOpcion) { Resultado result = new Resultado(); try { result = (new DireccionLogic()).setDomicilio(direccion, tinOpcion); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en DireccionServices.setDomicilio: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en DireccionServices.setDomicilio: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
public VerificadorPLD ServicioVerificadorPLD(BitacoraPLD parametros) { VerificadorPLD result = null; try { result = (new VerificadorPLDLogic()).ServicioVerificadorPLD(parametros); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en VerificadorPLDServices.ServicioVerificadorPLD: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en VerificadorPLDServices.ServicioVerificadorPLD: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
public List <BitacoraPLD> ListadoBusquedaBitacoraPLD(string vchUsuario, int?intSistema) { List <BitacoraPLD> result = null; try { result = (new BitacoraLogic()).ListadoBusquedaBitacoraPLD(vchUsuario, intSistema); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en BitacoraPLDServices.ListadoBusquedaBitacoraPLD: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en BitacoraPLDServices.ListadoBusquedaBitacoraPLD: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
public void Start() { if (!IsEnabled) { EventLogManager.WriteEntry(string.Format("Service {0} is disabled.", this.GetType().Name), EventLogEntryType.Information); return; } else { EventLogManager.WriteEntry(string.Format("Service {0} is starting.", this.GetType().Name), EventLogEntryType.Information); } mThread = new Thread(ThreadProc); mThread.Name = this.GetType().Name; mThread.Start(this); }
public List <Catalogo> ListaBusquedaInteligenteTipoTipificacion(string strDatos) { List <Catalogo> result = null; try { result = (new CatalogosLogic()).ListaBusquedaInteligenteTipoTipificacion(strDatos); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en CatalogoServices.ListaBusquedaInteligenteTipoTipificacion: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en CatalogoServices.ListaBusquedaInteligenteTipoTipificacion: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
/// <summary> /// Devuelve la lista de datos de personas /// </summary> /// <param name="intDireccionID"></param> /// <param name="intMunicipioID"></param> /// <param name="intEstadoID"></param> /// <param name="intLocalidadID"></param> /// <param name="intTipoDomicilioID"></param> /// <returns></returns> public List <Direccion> ListarDatosPersona(Int32 @intDireccionID, Int32 @intMunicipioID, Int32 @intEstadoID, Int32 @intLocalidadID, Int32 @intTipoDomicilioID) { List <Direccion> result = new List <Direccion>(); try { result = (new DireccionLogic()).ListarDatosPersona(@intDireccionID, @intMunicipioID, @intEstadoID, @intLocalidadID, @intTipoDomicilioID); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en DireccionServices.ListarDatosPersona: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en DireccionServices.ListarDatosPersona: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
public List <TipoLista> ListarTipoListaPLD() { List <TipoLista> result = null; try { result = (new ListaNegraLogic()).ListarTipoListaPLD(); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en ListaNegraServices.ListarTipoListaPLD: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en ListaNegraServices.ListarTipoListaPLD: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
protected override void OnStart(string[] args) { EventLogManager.WriteMessage(new Message() { Description = "Service Start", Type = "Service", Time = DateTime.Now }, EventType.Test); try { syncTestThread = new SyncThread(); syncTestThread.Run(); } catch (Exception e) { EventLogManager.WriteMessage(new Message() { Description = "On Start Method: " + e.Message.ToString(), Type = "Service", Time = DateTime.Now }, EventType.Test); } }
/// <summary> /// Obitiene la lista de la relación de dirección y empresa /// </summary> /// <param name="intPersonaDomEmpreID"></param> /// <param name="intPersonaID"></param> /// <param name="intDireccionID"></param> /// <param name="intEmpresaID"></param> /// <returns></returns> public List <Persona> ListarRelPersonaDireccionEmpresa(Int32 @intPersonaDomEmpreID, Int32 @intPersonaID, Int32 @intDireccionID, Int32 @intEmpresaID) { List <Persona> result = new List <Persona>(); try { result = (new PersonaLogic()).ListarRelPersonaDireccionEmpresa(@intPersonaDomEmpreID, @intPersonaID, @intDireccionID, @intEmpresaID); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en PersonaServices.ListarRelPersonaDireccionEmpresa: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en EmpresaServices.ListarRelPersonaDireccionEmpresa: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
public void Delete(Form subject) { try { var db = new ApplicationDbContext(); var form = db.Forms.Where(s => s.FormID == subject.FormID).SingleOrDefault(); db.Forms.Remove(form); db.SaveChanges(); ErrorLabel.Text = String.Empty; } catch (DbEntityValidationException ex) { ErrorLabel.Visible = true; ErrorLabel.Text = EventLogManager.LogError(ex); } catch (Exception exp) { ErrorLabel.Visible = false; ErrorLabel.Text = exp.Message; } }
public List <SistemasPLD> ListarSistemasPLD() { List <SistemasPLD> result = null; try { result = (new ListaNegraLogic()).ListarSistemasPLD(); } catch (Exception ex) { #if (DEBUG) Console.WriteLine("Error en ListaNegraServices.ListarSistemasPLD: " + ex.Message); #else EventLogManager.LogErrorEntry("Error en BitacoraInterfacesService.ListaRelCatTipoListNegAccion: " + ex.Message); //TODO: Codificar envío de notificación de error al EventLog #endif } return(result); }
private static void TmrObsoleteLicenses_Elapsed(object sender, ElapsedEventArgs e) { if (AvailableLicenses != null) { lock (AvailableLicenses) { foreach (var availableLicense in AvailableLicenses) { for (var activityIndex = availableLicense.Activities.Count - 1; activityIndex >= 0; activityIndex--) { if (availableLicense.Activities[activityIndex].EndsOn < DateTime.Now) { EventLogManager.WriteToEventLog("Removed obsolete license activity", availableLicense.LicenseType.ToString() + ":" + availableLicense.Activities[activityIndex].Computername); availableLicense.Activities.RemoveAt(activityIndex); } } } } } }
public void Delete(WorkflowStateTransition subject) { try { var db = new ApplicationDbContext(); var workflowStateTransition = db.WorkflowStateTransitions.Where(s => s.WorkflowStateTransitionID == subject.WorkflowStateTransitionID).SingleOrDefault(); db.WorkflowStateTransitions.Remove(workflowStateTransition); db.SaveChanges(); ErrorLabel.Text = String.Empty; } catch (DbEntityValidationException ex) { ErrorLabel.Visible = true; ErrorLabel.Text = EventLogManager.LogError(ex); } catch (Exception exp) { ErrorLabel.Visible = true; ErrorLabel.Text = exp.Message; } }