/// <summary> /// Set the background task running /// </summary> public void Execute() { var threadStart = new ThreadStart(StartThreadHere); _lastKeepAliveActionTime = new LastUpdateTime(); var thread = new Thread(threadStart); thread.Start(); }
public override string ToString() { Console.Out.WriteLine(UserId + "" + FileId + "" + UniqueId + "" + Path + "" + Name + "" + Size + "" + LastUpdateTime.ToString("yyyy-MM-dd HH:mm:ss") + "" + RemoveYN); return(String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}", UserId, FileId, UniqueId, Path, Name, Size, LastUpdateTime.ToString("yyyy-MM-dd HH:mm:ss"), RemoveYN)); }
public int CompareTo(object obj) { var or = obj as OrderRecord; if (or == null) { throw new ArgumentException("Object is not an OrderRecord"); } if (Side != or.Side) { throw new ArgumentException("Trying to sort orders from different market sides"); } if (Symbol != or.Symbol) { throw new ArgumentException("Trying to sort orders with different symbols"); } if (Price != or.Price) { return(Side == MarketSide.Ask ? Price.CompareTo(or.Price) : or.Price.CompareTo(Price)); } if (LastUpdateTime != or.LastUpdateTime) { return(LastUpdateTime.CompareTo(or.LastUpdateTime)); } return(String.Compare(OrderID, or.OrderID, StringComparison.Ordinal)); }
/// <summary> /// Set the background task running /// </summary> public void Execute() { var threadStart = new ThreadStart(StartThreadHere); _lastKeepAliveActionTime = new LastUpdateTime(); var thread = new Thread(threadStart); thread.Start(); }
public void DownloadProgressChangedHandler(object sender, EventArgs e) { if (DateTime.UtcNow > LastUpdateTime.AddSeconds(1)) { CalcuclateDownloadSpeed(); CalculateAverageRate(); UpdateDownlpadDisplay(); LastUpdateTime = DateTime.UtcNow; } }
private void UpgradeProperties() { if (DateTime.Now > LastUpdateTime.AddSeconds(1)) { OnPropertyChanged("SpeedString"); OnPropertyChanged("TotalUsedTimeString"); LastUpdateTime = DateTime.Now; } OnPropertyChanged("SizeString"); OnPropertyChanged("Progress"); }
/// <summary> /// Returns true if CommonPerson instances are equal /// </summary> /// <param name="other">Instance of CommonPerson to be compared</param> /// <returns>Boolean</returns> public bool Equals(CommonPerson other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( LastUpdateTime == other.LastUpdateTime || LastUpdateTime != null && LastUpdateTime.Equals(other.LastUpdateTime) ) && ( FirstName == other.FirstName || FirstName != null && FirstName.Equals(other.FirstName) ) && ( LastName == other.LastName || LastName != null && LastName.Equals(other.LastName) ) && ( MiddleNames == other.MiddleNames || MiddleNames != null && MiddleNames.SequenceEqual(other.MiddleNames) ) && ( Prefix == other.Prefix || Prefix != null && Prefix.Equals(other.Prefix) ) && ( Suffix == other.Suffix || Suffix != null && Suffix.Equals(other.Suffix) ) && ( OccupationCode == other.OccupationCode || OccupationCode != null && OccupationCode.Equals(other.OccupationCode) )); }
public override int GetHashCode() { int hash = 1; if (Result != 0) { hash ^= Result.GetHashCode(); } if (lastUpdateTime_ != null) { hash ^= LastUpdateTime.GetHashCode(); } hash ^= quoteList_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
/// <summary> /// Thread entry point /// </summary> void StartThreadHere() { //Run a loop until we are told to sleep while(!_exitThreadLatch.Value) { Thread.Sleep(2000); //Sleep for at least 2 seconds (arbitrary number to make sure we don't needlessly run) //If we have not been told to exit AND our the keep-alive task has not run within the desired interaval, //then run it if((!_exitThreadLatch.Value) && ((DateTime.Now - _lastKeepAliveActionTime.Timestamp) > _keepAliveInterval)) { PerformKeepAliveTask(); //Update the last run keep-alive time _lastKeepAliveActionTime = new LastUpdateTime(); } } //Exit thread }
/// <summary> /// Thread entry point /// </summary> void StartThreadHere() { //Run a loop until we are told to sleep while (!_exitThreadLatch.Value) { Thread.Sleep(2000); //Sleep for at least 2 seconds (arbitrary number to make sure we don't needlessly run) //If we have not been told to exit AND our the keep-alive task has not run within the desired interaval, //then run it if ((!_exitThreadLatch.Value) && ((DateTime.Now - _lastKeepAliveActionTime.Timestamp) > _keepAliveInterval)) { PerformKeepAliveTask(); //Update the last run keep-alive time _lastKeepAliveActionTime = new LastUpdateTime(); } } //Exit thread }
public void MergeFrom(GetQuoteListResponse other) { if (other == null) { return; } if (other.Result != 0) { Result = other.Result; } if (other.lastUpdateTime_ != null) { if (lastUpdateTime_ == null) { LastUpdateTime = new global::Google.Protobuf.WellKnownTypes.Timestamp(); } LastUpdateTime.MergeFrom(other.LastUpdateTime); } quoteList_.Add(other.quoteList_); _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (LastUpdateTime != null) { hashCode = hashCode * 59 + LastUpdateTime.GetHashCode(); } if (FirstName != null) { hashCode = hashCode * 59 + FirstName.GetHashCode(); } if (LastName != null) { hashCode = hashCode * 59 + LastName.GetHashCode(); } if (MiddleNames != null) { hashCode = hashCode * 59 + MiddleNames.GetHashCode(); } if (Prefix != null) { hashCode = hashCode * 59 + Prefix.GetHashCode(); } if (Suffix != null) { hashCode = hashCode * 59 + Suffix.GetHashCode(); } if (OccupationCode != null) { hashCode = hashCode * 59 + OccupationCode.GetHashCode(); } return(hashCode); } }
public override string GetDisplayText(string childInfo, bool verbose) { string lastUpdateTime = (LastUpdateTime == DateTime.MinValue) ? "Never" : LastUpdateTime.ToString("yyyy-MM-dd HH:mm"); int trackedMessageCount = 0; foreach (TargetDisplayData target in _targetDisplays) { trackedMessageCount += target.MessageIDs.Count; } string info = $"Last update time: {lastUpdateTime}"; info += $"\r\nTracked Display Messages: {trackedMessageCount}"; info += $"\r\n{childInfo}"; return(base.GetDisplayText(info, verbose)); }
/// <summary> /// Serializes this instance of <see cref="ImageMetadata" /> into a <see cref="Carbon.Json.JsonNode" />. /// </summary> /// <param name="container">The <see cref="Carbon.Json.JsonObject"/> container to serialize this object into. If the caller /// passes in <c>null</c>, a new instance will be created and returned to the caller.</param> /// <param name="serializationMode">Allows the caller to choose the depth of the serialization. See <see cref="Microsoft.Rest.ClientRuntime.SerializationMode"/>.</param> /// <returns> /// a serialized instance of <see cref="ImageMetadata" /> as a <see cref="Carbon.Json.JsonNode" />. /// </returns> public Carbon.Json.JsonNode ToJson(Carbon.Json.JsonObject container, Microsoft.Rest.ClientRuntime.SerializationMode serializationMode) { container = container ?? new Carbon.Json.JsonObject(); bool returnNow = false; BeforeToJson(ref container, ref returnNow); if (returnNow) { return(container); } if (serializationMode.HasFlag(Microsoft.Rest.ClientRuntime.SerializationMode.IncludeReadOnly)) { AddIf(null != Name ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(Name) : null, "name", container.Add); } if (null != Categories) { foreach (var __x in Categories) { AddIf(null != __x.Value ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(__x.Value) : null, (__w) => container.Add(__x.Key, __w)); } } if (serializationMode.HasFlag(Microsoft.Rest.ClientRuntime.SerializationMode.IncludeReadOnly)) { AddIf(null != CreationTime ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(CreationTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK", System.Globalization.CultureInfo.InvariantCulture)) : null, "creation_time", container.Add); } if (serializationMode.HasFlag(Microsoft.Rest.ClientRuntime.SerializationMode.IncludeReadOnly)) { AddIf(null != Kind ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(Kind) : null, "kind", container.Add); } if (serializationMode.HasFlag(Microsoft.Rest.ClientRuntime.SerializationMode.IncludeReadOnly)) { AddIf(null != LastUpdateTime ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(LastUpdateTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK", System.Globalization.CultureInfo.InvariantCulture)) : null, "last_update_time", container.Add); } AddIf(null != OwnerReference ? (Carbon.Json.JsonNode)OwnerReference.ToJson(null) : null, "owner_reference", container.Add); AddIf(null != ProjectReference ? (Carbon.Json.JsonNode)ProjectReference.ToJson(null) : null, "project_reference", container.Add); AddIf(null != SpecHash ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(SpecHash) : null, "spec_hash", container.Add); AddIf(null != SpecVersion ? (Carbon.Json.JsonNode) new Carbon.Json.JsonNumber((int)SpecVersion) : null, "spec_version", container.Add); AddIf(null != Uuid ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(Uuid) : null, "uuid", container.Add); AfterToJson(ref container); return(container); }
public bool IsTimeout(double timeoutMilliseconds) { return(DateTime.Now > LastUpdateTime.AddMilliseconds(timeoutMilliseconds)); }
// public static List<Tuple<double, double, int>> HeightmapValues = new List<Tuple<double, double, int>>(); public static void Draw(CanvasAnimatedDrawEventArgs args) { Strings.Clear(); try { Strings.Add("Type: " + Mouse.TileTypeString); } catch (Exception e) { } Strings.Add("Max delta X: " + MaxDeltaX.ToString("F")); Strings.Add("Max delta Y: " + MaxDeltaY.ToString("F")); Strings.Add("Mouse: " + Mouse.CoordinatesString); Strings.Add("Mouse (chunk): " + Mouse.ChunkString); Strings.Add("Mouse (tile): " + Mouse.TileString); Strings.Add("Mouse (absolute tile): " + Mouse.AbsoluteTileString); Strings.Add("Mouse left: " + (Mouse.LeftButtonDown ? "DOWN" : "UP")); Strings.Add("Mouse right: " + (Mouse.RightButtonDown ? "DOWN" : "UP")); Strings.Add("Draw: " + LastDrawTime.ToString() + "ms"); Strings.Add("Draw mouse: " + LastDrawMouseTime.ToString() + "ms"); Strings.Add("Draw debug: " + LastDrawDebugTime.ToString() + "ms"); Strings.Add("Draw map: " + LastDrawMapTime.ToString() + "ms"); Strings.Add("Update: " + LastUpdateTime.ToString() + "ms"); Strings.Add("Debug update: " + LastDebugUpdateTime.ToString() + "ms"); Strings.Add("Full loop: " + LastFullLoopTime.ToString() + "ms"); Strings.Add("Full loop (max): " + MaxFullLoopTime.ToString() + "ms"); Strings.Add("Total frames: " + TotalFrames.ToString()); Strings.Add("Slow frames: " + SlowFrames.ToString()); Strings.Add("Camera offset: " + Camera.CoordinatesString()); Strings.Add("Camera offset (chunk): " + Camera.ChunkPositionString()); Strings.Add("Camera offset (tile): " + Camera.ChunkTilePositionString()); Strings.Add("Draw mode: " + Debug.DrawMode.ToString()); if (Map.DebugChunkCount > 0) { Strings.Add("Chunk count: " + TotalChunkCount.ToString()); Strings.Add("Chunks on screen: " + OnScreenChunkCount.ToString()); lock (DebugCollectionsLock) { Strings.Add("Average chunk load time: " + ChunkLoadTimes.Average().ToString("F") + "ms"); Strings.Add("Last chunk load time: " + ChunkLoadTimes.Last().ToString() + "ms"); Strings.Add("Average heightmap load time: " + HeightMapTimes.Average().ToString("F") + "ms"); Strings.Add("Last heightmap load time: " + HeightMapTimes.Last().ToString("F") + "ms"); } } ProcessMemoryUsageReport report = ProcessDiagnosticInfo.GetForCurrentProcess().MemoryUsage.GetReport(); Strings.Add("Working set: " + (report.WorkingSetSizeInBytes / 1000000).ToString() + "MB"); if (ChunkSizeMB != null) { Strings.Add(ChunkSizeMB); } //args.DrawingSession.DrawText("Folder: " + Windows.Storage.ApplicationData.Current.LocalFolder.Path, new Vector2(10, 10), Colors.White); int x = 1500; int y = 20; int width = 410; int height = (Strings.Count + 1) * 20; Color backgroundColor = Colors.CornflowerBlue; Color borderColor = Colors.White; args.DrawingSession.FillRectangle(new Windows.Foundation.Rect(x - 5, y - 5, width, height), backgroundColor); args.DrawingSession.DrawRoundedRectangle(new Windows.Foundation.Rect(x - 5, y - 5, width, height), 3, 3, borderColor); foreach (string str in Strings) { args.DrawingSession.DrawText(str, new Vector2(x, y), Colors.White); y += 20; } if (TimedStrings.Count > 0) { y += 50; height = (TimedStrings.Count + 1) * 20; args.DrawingSession.FillRectangle(new Windows.Foundation.Rect(x - 5, y - 5, width, height), backgroundColor); args.DrawingSession.DrawRoundedRectangle(new Windows.Foundation.Rect(x - 5, y - 5, width, height), 3, 3, borderColor); lock (Debug.DebugCollectionsLock) { foreach (TimedString str in TimedStrings) { str.Draw(args, new Vector2(x, y)); y += 20; } } } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (LastUpdateTime != null) { hashCode = hashCode * 59 + LastUpdateTime.GetHashCode(); } if (AgentFirstName != null) { hashCode = hashCode * 59 + AgentFirstName.GetHashCode(); } if (AgentLastName != null) { hashCode = hashCode * 59 + AgentLastName.GetHashCode(); } if (AgentRole != null) { hashCode = hashCode * 59 + AgentRole.GetHashCode(); } if (BusinessName != null) { hashCode = hashCode * 59 + BusinessName.GetHashCode(); } if (LegalName != null) { hashCode = hashCode * 59 + LegalName.GetHashCode(); } if (ShortName != null) { hashCode = hashCode * 59 + ShortName.GetHashCode(); } if (Abn != null) { hashCode = hashCode * 59 + Abn.GetHashCode(); } if (Acn != null) { hashCode = hashCode * 59 + Acn.GetHashCode(); } if (IsACNCRegistered != null) { hashCode = hashCode * 59 + IsACNCRegistered.GetHashCode(); } if (IndustryCode != null) { hashCode = hashCode * 59 + IndustryCode.GetHashCode(); } if (OrganisationType != null) { hashCode = hashCode * 59 + OrganisationType.GetHashCode(); } if (RegisteredCountry != null) { hashCode = hashCode * 59 + RegisteredCountry.GetHashCode(); } if (EstablishmentDate != null) { hashCode = hashCode * 59 + EstablishmentDate.GetHashCode(); } return(hashCode); } }
/// <summary> /// Serializes this instance of <see cref="UserMetadata" /> into a <see cref="Carbon.Json.JsonNode" />. /// </summary> /// <param name="container">The <see cref="Carbon.Json.JsonObject"/> container to serialize this object into. If the caller /// passes in <c>null</c>, a new instance will be created and returned to the caller.</param> /// <param name="serializationMode">Allows the caller to choose the depth of the serialization. See <see cref="Microsoft.Rest.ClientRuntime.SerializationMode"/>.</param> /// <returns> /// a serialized instance of <see cref="UserMetadata" /> as a <see cref="Carbon.Json.JsonNode" />. /// </returns> public Carbon.Json.JsonNode ToJson(Carbon.Json.JsonObject container, Microsoft.Rest.ClientRuntime.SerializationMode serializationMode) { container = container ?? new Carbon.Json.JsonObject(); bool returnNow = false; BeforeToJson(ref container, ref returnNow); if (returnNow) { return(container); } if (serializationMode.HasFlag(Microsoft.Rest.ClientRuntime.SerializationMode.IncludeReadOnly)) { AddIf(null != Name ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(Name) : null, "name", container.Add); } /* serializeToContainerMember (wildcard) doesn't support 'application/json' C:\Users\hugo1\Documents\autorest\autorest.incubator\dist\csharp\schema\wildcard.js*/ if (serializationMode.HasFlag(Microsoft.Rest.ClientRuntime.SerializationMode.IncludeReadOnly)) { AddIf(null != CreationTime ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(CreationTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK", System.Globalization.CultureInfo.InvariantCulture)) : null, "creation_time", container.Add); } if (serializationMode.HasFlag(Microsoft.Rest.ClientRuntime.SerializationMode.IncludeReadOnly)) { AddIf(null != Kind ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(Kind) : null, "kind", container.Add); } if (serializationMode.HasFlag(Microsoft.Rest.ClientRuntime.SerializationMode.IncludeReadOnly)) { AddIf(null != LastUpdateTime ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(LastUpdateTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK", System.Globalization.CultureInfo.InvariantCulture)) : null, "last_update_time", container.Add); } AddIf(null != OwnerReference ? (Carbon.Json.JsonNode)OwnerReference.ToJson(null) : null, "owner_reference", container.Add); AddIf(null != ProjectReference ? (Carbon.Json.JsonNode)ProjectReference.ToJson(null) : null, "project_reference", container.Add); AddIf(null != SpecHash ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(SpecHash) : null, "spec_hash", container.Add); AddIf(null != SpecVersion ? (Carbon.Json.JsonNode) new Carbon.Json.JsonNumber((int)SpecVersion) : null, "spec_version", container.Add); AddIf(null != Uuid ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(Uuid) : null, "uuid", container.Add); AfterToJson(ref container); return(container); }
private void FrmWeixinRobot_Load(object sender, EventArgs e) { dvList.AutoGenerateColumns = false; txtLastTime.Text = LastUpdateTime.ToString("yyyy-MM-dd HH:mm"); }
/// <summary> /// Serializes this instance of <see cref="Task" /> into a <see cref="Carbon.Json.JsonNode" />. /// </summary> /// <param name="container">The <see cref="Carbon.Json.JsonObject"/> container to serialize this object into. If the caller /// passes in <c>null</c>, a new instance will be created and returned to the caller.</param> /// <param name="serializationMode">Allows the caller to choose the depth of the serialization. See <see cref="Microsoft.Rest.ClientRuntime.SerializationMode"/>.</param> /// <returns> /// a serialized instance of <see cref="Task" /> as a <see cref="Carbon.Json.JsonNode" />. /// </returns> public Carbon.Json.JsonNode ToJson(Carbon.Json.JsonObject container, Microsoft.Rest.ClientRuntime.SerializationMode serializationMode) { container = container ?? new Carbon.Json.JsonObject(); bool returnNow = false; BeforeToJson(ref container, ref returnNow); if (returnNow) { return(container); } AddIf(null != ApiVersion ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(ApiVersion) : null, "api_version", container.Add); AddIf(null != ClusterReference ? (Carbon.Json.JsonNode)ClusterReference.ToJson(null) : null, "cluster_reference", container.Add); AddIf(null != CompletionTime ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(CompletionTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK", System.Globalization.CultureInfo.InvariantCulture)) : null, "completion_time", container.Add); AddIf(null != CreationTime ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(CreationTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK", System.Globalization.CultureInfo.InvariantCulture)) : null, "creation_time", container.Add); if (null != EntityReferenceList) { var __w = new Carbon.Json.XNodeArray(); foreach (var __x in EntityReferenceList) { AddIf(__x?.ToJson(null), __w.Add); } container.Add("entity_reference_list", __w); } AddIf(null != ErrorCode ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(ErrorCode) : null, "error_code", container.Add); AddIf(null != ErrorDetail ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(ErrorDetail) : null, "error_detail", container.Add); AddIf(null != LastUpdateTime ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(LastUpdateTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK", System.Globalization.CultureInfo.InvariantCulture)) : null, "last_update_time", container.Add); AddIf(null != LogicalTimestamp ? (Carbon.Json.JsonNode) new Carbon.Json.JsonNumber((long)LogicalTimestamp) : null, "logical_timestamp", container.Add); AddIf(null != OperationType ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(OperationType) : null, "operation_type", container.Add); AddIf(null != ParentTaskReference ? (Carbon.Json.JsonNode)ParentTaskReference.ToJson(null) : null, "parent_task_reference", container.Add); AddIf(null != PercentageComplete ? (Carbon.Json.JsonNode) new Carbon.Json.JsonNumber((int)PercentageComplete) : null, "percentage_complete", container.Add); AddIf(null != ProgressMessage ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(ProgressMessage) : null, "progress_message", container.Add); AddIf(null != StartTime ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(StartTime?.ToString(@"yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK", System.Globalization.CultureInfo.InvariantCulture)) : null, "start_time", container.Add); AddIf(null != Status ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(Status) : null, "status", container.Add); if (null != SubtaskReferenceList) { var __r = new Carbon.Json.XNodeArray(); foreach (var __s in SubtaskReferenceList) { AddIf(__s?.ToJson(null), __r.Add); } container.Add("subtask_reference_list", __r); } AddIf(null != Uuid ? (Carbon.Json.JsonNode) new Carbon.Json.JsonString(Uuid) : null, "uuid", container.Add); AfterToJson(ref container); return(container); }
public List <Email> GetEmails() { if (Global.isSyncing) { Log.Append("Error: Existing sync in progress"); return(new List <Email>()); } Global.isSyncing = true; int errorLevel = 0; Log.Append(String.Format("Getting new emails (since {1}) from '{0}'...", Email, LastUpdateTime.ToShortDateString())); // Generate the list of uids from current emails stored for current user (used to check if email already exists) List <string> ExistingUID = Global.EmailList.Where(x => x.To == Email && x.MailDate >= LastUpdateTime.AddDays(-5)).Select(y => y.UID).ToList(); List <Email> newEmails = new List <Email>(); int emailSyncCount = 0; using (var client = new MailKit.Net.Imap.ImapClient()) { try { //For demo-purposes, accept all SSL certificates client.ServerCertificateValidationCallback = (s, c, h, e) => true; #region Connect using receiving parameters try { client.Connect(ReceivingProtocol, Convert.ToInt32(ReceivingPort), true); } catch { Log.Append(String.Format("ERROR: Failed to connect to {0} using {1}:{2}", Email, ReceivingProtocol, ReceivingPort)); return(new List <Email>()); } #endregion // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. client.AuthenticationMechanisms.Remove("XOAUTH2"); #region Login using credentials try { client.Authenticate(Email, Password); } catch { Log.Append(String.Format("ERROR: Failed to login using user credentials for '{0}'", Email)); return(new List <Email>()); } #endregion #region Inbox // The Inbox folder is always available on all IMAP servers... var inbox = client.Inbox; inbox.Open(FolderAccess.ReadOnly); Log.Append(" Checking 'Inbox'"); var query = SearchQuery.DeliveredAfter(LastUpdateTime); foreach (var uid in inbox.Search(query)) { try { if (Readiness.CheckTerminationStatus(true)) { break; } string workingID = Global.GetAttachmentID(); try { // Verify that this email does not exist. if (!ExistingUID.Contains(uid.ToString())) { MimeMessage message = inbox.GetMessage(uid); var date = message.Date.ToString(); Email email = new Email() { UID = uid.ToString(), ID = workingID, MailDate = Convert.ToDateTime(date), From = message.From.ToString(), To = Email, Subject = message.Subject, }; emailSyncCount++; email.CreateEmailMsgFile(message); email.RetrieveMsg(); Global.AppendEmail(email); newEmails.Add(email); } } catch { Log.Append(String.Format("ERROR: Email can't be processed with ID={0}", workingID)); } } catch (Exception ex) { errorLevel++; Log.Append(String.Format("ERROR [Inbox]: {0}", ex)); // Undetermined error from automated system } } #endregion #region Subfolders var personal = client.GetFolder(client.PersonalNamespaces[0]); foreach (var folder in personal.GetSubfolders(false)) { Log.Append(String.Format(" Checking folder '{0}'", folder.Name)); if (folder.Name.ToLower() != "sent") { if (Readiness.CheckTerminationStatus(true)) { break; } try { folder.Open(FolderAccess.ReadOnly); query = SearchQuery.DeliveredAfter(LastUpdateTime); foreach (var uid in folder.Search(query)) { if (Readiness.CheckTerminationStatus()) { return(newEmails); } // Verify that this email does not exist. if (!ExistingUID.Contains(uid.ToString())) { MimeMessage message = folder.GetMessage(uid); var date = message.Date.ToString(); Email email = new Email() { UID = uid.ToString(), ID = Global.GetAttachmentID(), MailDate = Convert.ToDateTime(date), From = message.From.ToString(), To = Email, Subject = message.Subject, }; emailSyncCount++; email.CreateEmailMsgFile(message); email.RetrieveMsg(); Global.AppendEmail(email); newEmails.Add(email); } } } catch { Log.Append(String.Format(" Sub folder IMAP retrieval error for folder=\"{0}\"", folder.Name)); } } } #endregion client.Disconnect(true); } catch (Exception ex) { errorLevel++; Log.Append(String.Format("ERROR [Overall]: {0}", ex)); } } Log.Append(String.Format("{0} emails synced.", emailSyncCount)); if (errorLevel <= 0) { LastUpdateTime = DateTime.Now; Log.Append("Complete!"); } GetEmailCount(); Global.SaveSettings(); Global.ExportEmailFile(); Global.isSyncing = false; // Sort by date Global.EmailList = Global.EmailList.OrderByDescending(x => x.MailDate).ToList(); return(newEmails); }
private bool Equals(Article other) { bool authorsEquals = Authors.Count == other.Authors.Count; if (!authorsEquals) { return(false); } for (int i = 0; i < Authors.Count; i++) { authorsEquals = Authors[i].Equals(other.Authors[i]); if (!authorsEquals) { return(false); } } return(string.Equals(Id, other.Id) && string.Equals(Source, other.Source) && string.Equals(Subject, other.Subject) && string.Equals(Title, other.Title) && PublishDate.Equals(other.PublishDate) && LastUpdateTime.Equals(other.LastUpdateTime) && Content.Equals(other.Content) && authorsEquals && string.Equals(Summary, other.Summary)); }
public override string ToString() { return(string.Format("{0} - {1} - {2}", Name.PadRight(20), LastTradePrice.ToString().PadRight(10), LastUpdateTime.ToString("MM/dd/yyyy HH:mm:ss.fff"))); }
/// <summary> /// Returns true if CommonOrganisation instances are equal /// </summary> /// <param name="other">Instance of CommonOrganisation to be compared</param> /// <returns>Boolean</returns> public bool Equals(CommonOrganisation other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( LastUpdateTime == other.LastUpdateTime || LastUpdateTime != null && LastUpdateTime.Equals(other.LastUpdateTime) ) && ( AgentFirstName == other.AgentFirstName || AgentFirstName != null && AgentFirstName.Equals(other.AgentFirstName) ) && ( AgentLastName == other.AgentLastName || AgentLastName != null && AgentLastName.Equals(other.AgentLastName) ) && ( AgentRole == other.AgentRole || AgentRole != null && AgentRole.Equals(other.AgentRole) ) && ( BusinessName == other.BusinessName || BusinessName != null && BusinessName.Equals(other.BusinessName) ) && ( LegalName == other.LegalName || LegalName != null && LegalName.Equals(other.LegalName) ) && ( ShortName == other.ShortName || ShortName != null && ShortName.Equals(other.ShortName) ) && ( Abn == other.Abn || Abn != null && Abn.Equals(other.Abn) ) && ( Acn == other.Acn || Acn != null && Acn.Equals(other.Acn) ) && ( IsACNCRegistered == other.IsACNCRegistered || IsACNCRegistered != null && IsACNCRegistered.Equals(other.IsACNCRegistered) ) && ( IndustryCode == other.IndustryCode || IndustryCode != null && IndustryCode.Equals(other.IndustryCode) ) && ( OrganisationType == other.OrganisationType || OrganisationType != null && OrganisationType.Equals(other.OrganisationType) ) && ( RegisteredCountry == other.RegisteredCountry || RegisteredCountry != null && RegisteredCountry.Equals(other.RegisteredCountry) ) && ( EstablishmentDate == other.EstablishmentDate || EstablishmentDate != null && EstablishmentDate.Equals(other.EstablishmentDate) )); }
public void Display() { Console.WriteLine("Last Update Time: {0}\nContent: {1}\n", LastUpdateTime.ToString(), Content); }