/* ****************** * Send tab actions: * ****************** */ private void Send(object obj) { _user.Send(CategoryName); var manager = new AlertsManager(); manager.Show("Wysłano", Alerts.Success); }
private void Login(object obj) { var manager = new AlertsManager(); try { Database.Instance.Connect(); var gateway = new UsersGateway(); if (gateway.IsValid(_nick, _password, Database.Instance)) { var user = new User(_nick); OnUserLogged(user); Visible = false; } else { manager.Show("Niepoprawna nazwa użytkownika lub hasło.", Alerts.Warning); } } catch (Exception) { manager.Show("Problem z połączeniem z internetem.", Alerts.Warning); } }
/* *********************** * My categories actions: * *********************** */ private void Load(object obj) { _user.LoadCardsDB(obj as string); FlierKey = _user.Cards[0][0]; var manager = new AlertsManager(); manager.Show("Załadowano pomyślnie", Alerts.Success); }
public CrcMismatchException(string message, long specifiedCrc, long calculatedCrc, bool isCriticalError, Exception innerException) : base(message, innerException) { this.SpecifiedCrc = specifiedCrc; this.CalculatedCrc = calculatedCrc; this.IsCriticalError = isCriticalError; if (isCriticalError) { TimeSpan?nullable = null; AlertsManager.AlertOrLogException(string.Format("Hit CrcMismatchException with message:{0} SpecifiedCrc:{1} CalculatedCrc:{2}", message, specifiedCrc, calculatedCrc), message, nullable); return; } IStringDataEventStream error = Logger <IRestProtocolHeadLogger> .Instance.Error; object[] objArray = new object[] { message, specifiedCrc, calculatedCrc }; error.Log("Hit CrcMismatchException with message:{0} SpecifiedCrc:{1} CalculatedCrc:{2}", objArray); }
/// /// GET all Alerts [Alert_Manager_2020] /// public List <AlertsManager> get_AlertsManagerDB() { List <AlertsManager> alert_list_manager = new List <AlertsManager>(); SqlConnection con = null; try { con = connect("DBConnectionString"); String query = "SELECT * FROM [Alert_Manager_2020]"; SqlCommand cmd = new SqlCommand(query, con); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // the connection will close as reading completes while (dr.Read()) { AlertsManager alert_to_add = new AlertsManager(); alert_to_add.AlertID = Convert.ToInt32(dr["Alert_id"]); alert_to_add.Type = (string)dr["type"]; alert_to_add.Date = Convert.ToDateTime(dr["date"]); alert_to_add.Description = (string)dr["description"]; alert_to_add.Notes = (string)dr["notes"]; alert_list_manager.Add(alert_to_add); } return(alert_list_manager); } catch (Exception ex) { throw (ex); } finally { if (con != null) { con.Close(); } } }
public HttpResponseMessage Delete([FromBody] string alert_id) // delete from tbl ased on alert_id { int numEffected = 0; AlertsManager al = new AlertsManager(); try { numEffected = al.delete_line(Convert.ToInt32(alert_id)); if (numEffected > 0) { return(Request.CreateResponse(HttpStatusCode.OK, numEffected)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not Found")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
[HttpPut] // edit batch DATE OR BeerType public HttpResponseMessage Put(object[] st) // { int numEffected = 0; AlertsManager al = new AlertsManager(); try { numEffected = al.Update(Convert.ToInt32(st[0]), (string)st[1]); if (numEffected > 0) { return(Request.CreateResponse(HttpStatusCode.OK, numEffected)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not Found")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
protected override void EncodeEntry(Uri requestUrl, ListBlobsOperationContext lboc, IListBlobResultsBlobProperties blobProps, XmlWriter xmlWriter) { string str; string httpString; string eTag; if (!blobProps.IsActualBlob) { xmlWriter.WriteStartElement("BlobPrefix"); this.WriteElementString(xmlWriter, "Name", blobProps.BlobName); } else { xmlWriter.WriteStartElement("Blob"); this.WriteElementString(xmlWriter, "Name", blobProps.BlobName); if (lboc.IsIncludingSnapshots && blobProps.Snapshot != DateTime.MaxValue) { this.WriteElementString(xmlWriter, "Snapshot", HttpUtilities.ConvertSnapshotDateTimeToHttpString(blobProps.Snapshot)); } if (lboc.ListingAcrossContainers) { NephosAssertionException.Assert(!string.IsNullOrEmpty(blobProps.ContainerName), string.Concat("XStore didn't return us valid ContainerName for this blob ", blobProps.BlobName, " when we are listing blobs across the account")); this.WriteElementString(xmlWriter, "ContainerName", blobProps.ContainerName); } if (lboc.IsIncludingUrlInResponse) { string empty = string.Empty; if (lboc.ListingAcrossContainers) { empty = string.Concat("/", blobProps.ContainerName); } string str1 = string.Concat(HttpRequestAccessorCommon.TrimEndSlash(requestUrl.GetLeftPart(UriPartial.Path)), empty); string str2 = HttpRequestAccessorCommon.TrimRootContainerNameFromEnd(str1, true); string str3 = string.Concat(str2, "/", blobProps.BlobName); if (lboc.IsIncludingSnapshots && blobProps.Snapshot != DateTime.MaxValue) { str3 = string.Concat(str3, HttpUtilities.GetSnapshotQueryParameterStringForUrl(blobProps.Snapshot)); } this.WriteElementString(xmlWriter, "Url", str3); } if (lboc.IsUsingPropertiesElement) { xmlWriter.WriteStartElement("Properties"); } string str4 = (lboc.IsUsingPropertiesElement ? "Last-Modified" : "LastModified"); string str5 = (lboc.IsUsingPropertiesElement ? "Content-Length" : "Size"); string str6 = (lboc.IsUsingPropertiesElement ? "Content-Type" : "ContentType"); string str7 = (lboc.IsUsingPropertiesElement ? "Content-Encoding" : "ContentEncoding"); string str8 = (lboc.IsUsingPropertiesElement ? "Content-Language" : "ContentLanguage"); string str9 = (lboc.IsUsingPropertiesElement ? "Cache-Control" : "CacheControl"); string str10 = (lboc.IsUsingPropertiesElement ? "Content-MD5" : "ContentMD5"); bool value = blobProps.LastModifiedTime.Value > DateTimeConstants.MinimumBlobLastModificationTime; if (value) { XmlWriter xmlWriter1 = xmlWriter; string str11 = str4; if (blobProps.LastModifiedTime.HasValue) { httpString = HttpUtilities.ConvertDateTimeToHttpString(blobProps.LastModifiedTime.Value); } else { httpString = null; } this.WriteElementString(xmlWriter1, str11, httpString); XmlWriter xmlWriter2 = xmlWriter; if (blobProps.LastModifiedTime.HasValue) { DateTime?lastModifiedTime = blobProps.LastModifiedTime; eTag = BasicHttpProcessor.GetETag(lastModifiedTime.Value, this.shouldEncloseEtagsInQuotes); } else { eTag = null; } this.WriteElementString(xmlWriter2, "Etag", eTag); } XmlWriter xmlWriter3 = xmlWriter; string str12 = str5; if (blobProps.ContentLength.HasValue) { str = blobProps.ContentLength.Value.ToString(CultureInfo.InvariantCulture); } else { str = null; } this.WriteElementString(xmlWriter3, str12, str); if (value) { this.WriteElementString(xmlWriter, str6, blobProps.ContentType); this.WriteElementString(xmlWriter, str7, blobProps.ContentEncoding); this.WriteElementString(xmlWriter, str8, blobProps.ContentLanguage); if (lboc.IsIncludingCrc64InResponse) { this.WriteElementString(xmlWriter, "Content-CRC64", blobProps.ContentCrc64); } if (lboc.IsUsingPropertiesElement) { this.WriteElementString(xmlWriter, str10, blobProps.ContentMD5); } if (lboc.IsIncludingCacheControlInResponse) { this.WriteElementString(xmlWriter, str9, blobProps.CacheControl); } if (lboc.IsIncludingContentDispositionInResponse) { this.WriteElementString(xmlWriter, "Content-Disposition", blobProps.ContentDisposition); } } if (lboc.IsIncludingBlobTypeInResponse) { if (blobProps.SequenceNumber.HasValue) { long num = blobProps.SequenceNumber.Value; this.WriteElementString(xmlWriter, "x-ms-blob-sequence-number", num.ToString()); } this.WriteElementString(xmlWriter, "BlobType", blobProps.BlobType); } if (lboc.IsIncludingLeaseStatusInResponse && blobProps.Snapshot == DateTime.MaxValue) { this.WriteElementString(xmlWriter, "LeaseStatus", blobProps.LeaseStatus); if (lboc.IsIncludingLeaseStateAndDurationInResponse) { if (!string.IsNullOrEmpty(blobProps.LeaseState)) { this.WriteElementString(xmlWriter, "LeaseState", blobProps.LeaseState); } if (!string.IsNullOrEmpty(blobProps.LeaseDuration)) { this.WriteElementString(xmlWriter, "LeaseDuration", blobProps.LeaseDuration); } } } if (lboc.IsIncludingCopyPropertiesInResponse) { if (!string.IsNullOrEmpty(blobProps.CopyId)) { this.WriteElementString(xmlWriter, "CopyId", blobProps.CopyId); } if (!string.IsNullOrEmpty(blobProps.CopySource)) { this.WriteElementString(xmlWriter, "CopySource", (this.obfuscateSourceUri ? HttpUtilities.ObfuscateSourceUri(blobProps.CopySource) : blobProps.CopySource)); } if (!string.IsNullOrEmpty(blobProps.CopyStatus)) { this.WriteElementString(xmlWriter, "CopyStatus", blobProps.CopyStatus); } if (!string.IsNullOrEmpty(blobProps.CopyStatusDescription)) { this.WriteElementString(xmlWriter, "CopyStatusDescription", blobProps.CopyStatusDescription); } if (!string.IsNullOrEmpty(blobProps.CopyProgress)) { this.WriteElementString(xmlWriter, "CopyProgress", blobProps.CopyProgress); } if (blobProps.CopyCompletionTime.HasValue && !string.IsNullOrEmpty(blobProps.CopyStatus) && !blobProps.CopyStatus.Equals("pending", StringComparison.OrdinalIgnoreCase)) { DateTime?copyCompletionTime = blobProps.CopyCompletionTime; this.WriteElementString(xmlWriter, "CopyCompletionTime", HttpUtilities.ConvertDateTimeToHttpString(copyCompletionTime.Value)); } } if (lboc.IsIncludingIncrementalCopy && blobProps.IsIncrementalCopy) { this.WriteElementString(xmlWriter, "IncrementalCopy", "true"); if (blobProps.LastCopySnapshot.HasValue && !string.IsNullOrEmpty(blobProps.CopyStatus) && blobProps.CopyStatus.Equals("success", StringComparison.OrdinalIgnoreCase)) { if (blobProps.LastCopySnapshot.Value <= DateTimeConstants.MinimumIncrementalCopySnapshotTime) { AlertsManager.AlertOrLogException("LastCopySnapshot set to Minimum value, while a valid timestamp was expected.", null, null); } DateTime?lastCopySnapshot = blobProps.LastCopySnapshot; this.WriteElementString(xmlWriter, "CopyDestinationSnapshot", HttpUtilities.ConvertSnapshotDateTimeToHttpString(lastCopySnapshot.Value)); } } if (lboc.IsIncludingEncryption) { this.WriteElementString(xmlWriter, "ServerEncrypted", (!blobProps.IsBlobEncrypted.HasValue || !blobProps.IsBlobEncrypted.Value ? "false" : "true")); } if (lboc.IsUsingPropertiesElement) { xmlWriter.WriteEndElement(); } if (value && lboc.IsFetchingMetadata) { MetadataEncoding.WriteMetadataToXml(xmlWriter, blobProps.Metadata, true, lboc.RequestVersion); } } xmlWriter.WriteEndElement(); }
public ListContainersResultContainerProperties(IBaseBlobContainer container) { long num; if (container == null) { throw new ArgumentNullException("container"); } this.containerName = container.ContainerName; NephosAssertionException.Assert(container.LastModificationTime.HasValue); this.lastModifiedTime = container.LastModificationTime; if (container.ApplicationMetadata != null) { this.applicationMetadata = new NameValueCollection(); try { MetadataEncoding.Decode(container.ApplicationMetadata, this.applicationMetadata); } catch (MetadataFormatException metadataFormatException1) { MetadataFormatException metadataFormatException = metadataFormatException1; CultureInfo invariantCulture = CultureInfo.InvariantCulture; object[] objArray = new object[] { this.containerName }; throw new NephosStorageDataCorruptionException(string.Format(invariantCulture, "Error decoding application metadata for container {0}", objArray), metadataFormatException); } } if (container.LeaseInfo != null) { if (container.LeaseInfo.Type == LeaseType.ReadWrite && container.LeaseInfo.Duration.HasValue) { TimeSpan?duration = container.LeaseInfo.Duration; TimeSpan zero = TimeSpan.Zero; if ((duration.HasValue ? duration.GetValueOrDefault() <= zero : true)) { goto Label1; } this.leaseStatus = "locked"; goto Label0; } Label1: this.leaseStatus = "unlocked"; Label0: if (container.LeaseInfo.State.HasValue) { this.leaseState = LeaseStateStrings.LeaseStates[(int)container.LeaseInfo.State.Value]; if (container.LeaseInfo.State.Equals(Microsoft.Cis.Services.Nephos.Common.Storage.LeaseState.Leased)) { TimeSpan?nullable = container.LeaseInfo.Duration; TimeSpan timeSpan = TimeSpan.FromSeconds(4294967295); if ((!nullable.HasValue ? true : nullable.GetValueOrDefault() != timeSpan)) { this.leaseDuration = "fixed"; } else { this.leaseDuration = "infinite"; } } } } if (container.ServiceMetadata != null) { NameValueCollection nameValueCollection = new NameValueCollection(); try { MetadataEncoding.Decode(container.ServiceMetadata, nameValueCollection); } catch (MetadataFormatException metadataFormatException3) { MetadataFormatException metadataFormatException2 = metadataFormatException3; CultureInfo cultureInfo = CultureInfo.InvariantCulture; object[] objArray1 = new object[] { this.containerName }; throw new NephosStorageDataCorruptionException(string.Format(cultureInfo, "Error decoding service metadata for container {0}", objArray1), metadataFormatException2); } this.containerQuotaInGB = (long)RealServiceManager.MaxShareQuotaInGBPriorToLargeFileShareFeature; string str = nameValueCollection.Get(RealServiceManager.XSmbContainerQuotaMetadataName); if (str != null) { if (!long.TryParse(str, out num) || num < (long)RealServiceManager.MinShareQuotaInGB || num > this.containerQuotaInGB) { TimeSpan?nullable1 = null; AlertsManager.AlertOrLogException(string.Format("Invalid XsmbContainerQuota retrieved from servicemetadata for account {0}: {1}", this.accountNameForLogging, str), "InvalidXSMBContainerQuota", nullable1); } else { this.containerQuotaInGB = num; } } string str1 = nameValueCollection.Get("PublicAccess"); string str2 = nameValueCollection.Get("PublicAccess1"); if (str1 != null) { this.publicAccessLevel = str1; return; } if (str2 != null) { this.publicAccessLevel = str2; } } }
public List <AlertsManager> Get() { AlertsManager almanager = new AlertsManager(); return(almanager.get_AlertsManager()); }
public void ProcessAlertNotifications(string usersFile, string alertWhenAddToContactListNotification, string alertWhenDNDNotification) { List <string> usersList = new List <string>(); try { usersList = FileAccess.GetUsersFileData(usersFile); } catch (Exception ex) { Log.WriteLogEntry("ERROR", String.Format("Error while reading Users file: {0}", ex.Message), "Error while reading Users file."); CleanupEnvironment(); Program.CloseApplicationOnError(); } NotifyAdditionToContactListType notifyAdditionToContactList = NotifyAdditionToContactListType.NoChange; switch (alertWhenAddToContactListNotification.ToLowerInvariant()) { case "": notifyAdditionToContactList = NotifyAdditionToContactListType.NoChange; break; case "yes": notifyAdditionToContactList = NotifyAdditionToContactListType.Yes; break; case "no": notifyAdditionToContactList = NotifyAdditionToContactListType.No; break; default: // Should not happen Log.WriteLogEntry("ERROR", "Incorrect value for NotifyAdd parameter."); CleanupEnvironment(); Program.CloseApplicationOnError(); break; } AlertsWhenDoNotDisturbType alertsWhenDoNotDisturb = AlertsWhenDoNotDisturbType.NoChange; switch (alertWhenDNDNotification.ToLowerInvariant()) { case "": alertsWhenDoNotDisturb = AlertsWhenDoNotDisturbType.NoChange; break; case "noalerts": alertsWhenDoNotDisturb = AlertsWhenDoNotDisturbType.NoAlerts; break; case "allalerts": alertsWhenDoNotDisturb = AlertsWhenDoNotDisturbType.DisplayAllAlerts; break; case "alertsfromworkgroup": alertsWhenDoNotDisturb = AlertsWhenDoNotDisturbType.DisplayAlertsFromHighPresence; break; default: // Should not happen Log.WriteLogEntry("ERROR", "Incorrect value for NotifyWhenDND parameter."); CleanupEnvironment(); Program.CloseApplicationOnError(); break; } if (usersList.Count > 0) { ucmaPlatform.StartupPlatform(); ucmaEndpoint = new Endpoint(ucmaPlatform.CollabPlatform); AlertsManager alertsManager = new AlertsManager(ucmaEndpoint); foreach (string user in usersList) { Log.WriteLogEntry("INFO", String.Format("Processing user {0}...", user.ToLowerInvariant()), String.Format("Processing user {0}...", user.ToLowerInvariant())); try { alertsManager.SetAlertNotificationSetting(user, notifyAdditionToContactList, alertsWhenDoNotDisturb); } catch (RegisterException rex) { Log.WriteLogEntry("ERROR", String.Format("Error while processing user {0}: {1}. Inner Exception: {2}. Diag Info: {3}.", user.ToLowerInvariant(), rex.Message, (rex.InnerException == null ? "N/A" : rex.InnerException.Message), (String.IsNullOrEmpty(rex.DiagnosticInformation.ToString()) ? "N/A" : rex.DiagnosticInformation.ToString())), String.Format("Error while processing user {0}", user.ToLowerInvariant())); } catch (Exception ex) { Log.WriteLogEntry("ERROR", String.Format("Error while processing user {0}: {1}. Inner Exception: {2}", user.ToLowerInvariant(), ex.Message, (ex.InnerException == null ? "N/A" : ex.InnerException.Message)), String.Format("Error while processing user {0}", user.ToLowerInvariant())); } } } else { Log.WriteLogEntry("WARNING", "Users file is empty or invalid. No action will be performed."); } }