public void Test_DeliveryRecord() { var node = new Node ("Node"); var mbox = new MailBox ("Address"); node.Attach (mbox); var wld = new World (); wld.AddChild (node); wld.Update (16); wld.PostOffice.Post (node, "Address", "Hello World"); wld.Update (33); wld.PostOffice.Deliver (); var po = wld.PostOffice; Assert.AreEqual (1, po.DeliveryRecordCount); Assert.AreEqual (1, po.DeliveryRecords.Count()); var rec = po.DeliveryRecords.ElementAt (0); Assert.AreEqual (33, rec.Time); Assert.AreEqual ("Node", rec.From); Assert.AreEqual ("Address", rec.Address); Assert.AreEqual ("Hello World", rec.LetterType); }
public void ShouldReturnFalseIfNoMessages() { var mailbox = new MailBox<string>(); string message; Assert.That(mailbox.TryGetNextMessage(out message), Is.False); }
public void Test_Deliver() { var node = new Node ("Node"); var mbox = new MailBox ("Address"); node.Attach (mbox); var received = false; Node from = null; string address = ""; string letter = ""; mbox.Action += (frm, addr, let) => { received = true; from = frm; address = addr; letter = (string)let; }; var wld = new World (); wld.AddChild (node); wld.PostOffice.Post (node, "Address", "Hello World"); wld.PostOffice.Deliver (); Assert.AreEqual (true, received); Assert.AreEqual (node, from); Assert.AreEqual ("Address", address); Assert.AreEqual ("Hello World", letter); }
private void UploadToDocuments(AttachmentStream file, string contentType, MailBox mailbox, ILogger log) { try { var uploadedFileId = ApiHelper.UploadToDocuments(file.FileStream, file.FileName, contentType, mailbox.EMailInFolder, true); log.Debug("ApiHelper.UploadToDocuments() -> uploadedFileId = {0}", uploadedFileId); } catch (ApiHelperException ex) { if (ex.StatusCode == HttpStatusCode.NotFound || ex.StatusCode == HttpStatusCode.Forbidden) { log.Info("ApiHelper.UploadToDocuments() EMailIN folder '{0}' is unreachable. Try to unlink EMailIN...", mailbox.EMailInFolder); SetMailboxEmailInFolder(mailbox.TenantId, mailbox.UserId, mailbox.MailBoxId, null); mailbox.EMailInFolder = null; CreateUploadToDocumentsFailureAlert(mailbox.TenantId, mailbox.UserId, mailbox.MailBoxId, (ex.StatusCode == HttpStatusCode.NotFound) ? UploadToDocumentsErrorType .FolderNotFound : UploadToDocumentsErrorType .AccessDenied); throw; } log.Error("SaveEmailInData->ApiHelper.UploadToDocuments(fileName: '{0}', folderId: {1}) Exception:\r\n{2}\r\n", file.FileName, mailbox.EMailInFolder, ex.ToString()); } }
void Update () { MovePlayer(); //Pickup and Throw Mails if (Input.GetKeyDown(KeyCode.Space) && (gameManager.mailsToPickup[positionIndex] != null || !emptyHands)) { if (emptyHands) { caughtMail = gameManager.mailsToPickup[positionIndex]; caughtMail.transform.parent = transform; caughtMailBoxScript = caughtMail.GetComponent<MailBox>(); caughtMailBoxScript.Pickup(); emptyHands = false; } else { caughtMailBoxScript.Throw(); emptyHands = true; } } if(caughtMail != null) { //p+0.196 } }
public static Node Create(string name, Vector3 pos) { var cmp = new MyRecver (); var spr = new Sprite (64, 64); spr.AddTexture (Resource.GetDefaultTexture ()); spr.Color = Color.Cyan; var label1 = new Label (); label1.Text = name; label1.SetOffset (4, 16); var label2 = new Label (); label2.Text = "None"; label2.SetOffset (0, -24); var mbox = new MailBox (name); var node = new Node (name); node.Attach (cmp); node.Attach (spr); node.Attach (label1); node.Attach (label2); node.Attach (mbox); node.Translation = pos; return node; }
protected BaseWorker(MailBoxManager mailBoxManager, MailBox mailBox, TasksConfig tasksConfig, CancellationToken cancelToken, ILogger log = null) { this.mailBoxManager = mailBoxManager; _mailBox = mailBox; this.log = log ?? new NullLogger(); _lastTimeItemChecked = DateTime.UtcNow; _maxMessagesPerSession = tasksConfig.MaxMessagesPerSession; this.tasksConfig = tasksConfig; _signalrServiceClient = new SignalrServiceClient(); _needSignal = false; this.cancelToken = cancelToken; if (tasksConfig.ShowActiveUpLogs) { Logger.Log4NetLogger = log4net.LogManager.GetLogger(string.Format("Task_{0}->ActiveUp", Task.CurrentId)); Logger.Disabled = false; } else { Logger.Log4NetLogger = null; Logger.Disabled = true; } }
public static Node Create(Vector3 pos) { var cmp = new MySprite (); var spr = new Sprite (64, 64); spr.AddTexture (new Texture ("media/Box-64x64.png")); var col = new CollisionObject (); col.Shape = new BoxShape (spr.Width / 2, spr.Height / 2, 100); col.SetOffset (spr.Width / 2, spr.Height / 2, 0); var mbox1 = new MailBox ("MouseSelect"); var mbxo2 = new MailBox ("MouseDeselect"); var node = new Node ("MySprite"); node.Attach (cmp); node.Attach (spr); node.Attach (col); node.Attach (mbox1); node.Attach (mbxo2); node.Translation = pos; return node; }
public void SaveEmailInData(MailBox mailbox, MailMessageItem message, ILogger log) { if (string.IsNullOrEmpty(mailbox.EMailInFolder)) return; try { foreach (var attachment in message.Attachments) { using (var file = AttachmentManager.GetAttachmentStream(attachment)) { log.Debug("SaveEmailInData->ApiHelper.UploadToDocuments(fileName: '{0}', folderId: {1})", file.FileName, mailbox.EMailInFolder); UploadToDocuments(file, attachment.contentType, mailbox, log); } } } catch (Exception e) { _log.Error("SaveEmailInData(tenant={0}, userId='{1}', messageId={2}) Exception:\r\n{3}\r\n", mailbox.TenantId, mailbox.UserId, message.Id, e.ToString()); } }
private MailBox CreateMailboxObject(MailBox initialValue) { MailBox mbox = mailBoxManager.CreateMailBox(TenantId, Username, initialValue.Name, initialValue.EMail, initialValue.UseSsl, initialValue.MailBoxId); mbox.Account = initialValue.Account; mbox.Name = initialValue.Name; mbox.Password = initialValue.Password; mbox.SmtpAccount = initialValue.SmtpAccount; mbox.SmtpPassword = initialValue.SmtpPassword; if (initialValue.Port != 0) { mbox.Port = initialValue.Port; } if (!string.IsNullOrEmpty(initialValue.Server)) { mbox.Server = initialValue.Server; } if (initialValue.SmtpPort != 0) { mbox.SmtpPort = initialValue.SmtpPort; } if (!string.IsNullOrEmpty(initialValue.SmtpServer)) { mbox.SmtpServer = initialValue.SmtpServer; } mbox.SmtpAuth = initialValue.SmtpAuth; mbox.UseSsl = initialValue.UseSsl; mbox.ServerLoginDelay = initialValue.ServerLoginDelay; return mbox; }
public static Node Create(string name, string texture, Vector3 pos) { var cmp = new MyTarget (); var spr = new Sprite (64, 128); spr.AddTexture (new Texture (texture)); var col = new CollisionObject (); col.Shape = new BoxShape (spr.Width/2, spr.Height/2, 100); col.SetOffset (spr.Width/2, spr.Height/2, 0); var mbox1 = new MailBox ("MouseSelect"); var mbox2 = new MailBox ("MouseDeselect"); var node = new Node (name); node.Attach (cmp); node.Attach (col); node.Attach (spr); node.Attach (mbox1); node.Attach (mbox2); node.Translation = pos; return node; }
public static Node Create(Vector3 pos) { var name = "GameClear"; var cmp = new MyGameClear (); var spr = new Sprite (200, 160); spr.AddTexture (new Texture ("media/GameClear.png")); var clip = new SoundClip ("SoundClip"); clip.AddTrack (new SoundEffectTrack ("media/Announce.ogg")); clip.Volume = 0.3f; var mbox = new MailBox (name); var node = new Node (name); node.Attach (cmp); node.Attach (spr); node.Attach(mbox); node.UserData.Add (clip.Name, clip); node.Drawable = false; node.Translation = pos; return node; }
public abstract void HandleRetrievedMessage(MailBox mailbox, Message message, MailMessageItem message_item, int folder_id, string uidl, string md5_hash, bool unread, int[] tags_ids);
public MailQueueItem(MailBox account) { if (account == null) throw new ArgumentNullException("account"); Account = account; Priority = 0; _lastTimeItemChecked = DateTime.UtcNow; _log = LoggerFactory.GetLogger(LoggerFactory.LoggerType.Nlog, "MailQueueItem"); }
public void ShouldReturnMessageWhenOneAvailable() { var mailbox = new MailBox<string>(); mailbox.AddMessage("hi"); string message; Assert.That(mailbox.TryGetNextMessage(out message)); Assert.That(message, Is.EqualTo("hi")); }
private static void Main(string[] args) { var options = new Options(); if (CommandLine.Parser.Default.ParseArgumentsStrict(args, options, () => Logger.Info("Bad command line parameters."))) { try { if (Boolean.Parse(WebConfigurationManager.AppSettings["mailbox.settigs"])) { var mbox = new MailBox { EMail = new MailAddress(options.Email), Password = WebConfigurationManager.AppSettings["mailbox.password"], Account = WebConfigurationManager.AppSettings["mailbox.account"], Port = int.Parse(WebConfigurationManager.AppSettings["mailbox.port"]), Server = WebConfigurationManager.AppSettings["mailbox.server"], SmtpAccount = WebConfigurationManager.AppSettings["mailbox.smtp_account"], SmtpPassword = WebConfigurationManager.AppSettings["mailbox.smtp_password"], SmtpPort = int.Parse(WebConfigurationManager.AppSettings["mailbox.smtp_port"]), SmtpServer = WebConfigurationManager.AppSettings["mailbox.smtp_server"], SmtpAuth = Boolean.Parse(WebConfigurationManager.AppSettings["mailbox.smtp_auth"]), Imap = Boolean.Parse(WebConfigurationManager.AppSettings["mailbox.imap"]), IncomingEncryptionType = (EncryptionType)int.Parse(WebConfigurationManager.AppSettings["mailbox.incoming_encryption_type"]), OutcomingEncryptionType = (EncryptionType)int.Parse(WebConfigurationManager.AppSettings["mailbox.outcoming_encryption_type"]), AuthenticationTypeIn = (SaslMechanism) int.Parse(WebConfigurationManager.AppSettings["mailbox.auth_type_in"]), AuthenticationTypeSmtp = (SaslMechanism) int.Parse(WebConfigurationManager.AppSettings["mailbox.auth_type_smtp"]), }; Logger.Info("Create account"); CreateAccount(mbox); } else { Logger.Info("Create simple account"); CreateAccountSimple(options.Email, options.Password); } Logger.Info("[SUCCESS] test passed"); } catch (Exception) { Logger.Info("[Error] test not passed"); } } Console.WriteLine(); Console.WriteLine("Any key to exit..."); Console.ReadKey(); }
public ConnectionHandler(SimulationState ss) { // NETWORK & OPERATION tcpListener = new TcpListener(IPAddress.Parse("127.0.0.1"), 8888); connectionHandlerThread = new Thread(new ThreadStart(this.run)); connectionHandlerThread.IsBackground = true; // SIMULATION quit = false; simulationState = ss; agentConnections = new List<AgentConnection>(); instantiationResults = new MailBox<bool>(false); }
public void ShouldReturnMessagesInOrderTheyWereAdded() { var mailbox = new MailBox<string>(); mailbox.AddMessage("one"); mailbox.AddMessage("two"); string message; Assert.That(mailbox.TryGetNextMessage(out message)); Assert.That(message, Is.EqualTo("one")); Assert.That(mailbox.TryGetNextMessage(out message)); Assert.That(message, Is.EqualTo("two")); }
public Initialization2() { var tsDir = new TsDir(); //var tsOption = new TsOption(tsDir); //var manageDir = tsDir.Src + "\\TestDir"; //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory()); var optionDef = tsDir.Src + "\\Option.def"; //Docs Docs = new List<string>(); var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932)); foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind))) { var tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower()); bool hit = false; foreach (var l in lines) { if (l.IndexOf(tag) == 0) { Docs.Add(l.Substring(tag.Length)); hit = true; break; } } if (!hit) { Docs.Add(""); } } Kernel = new Kernel(null, null, null, null); Logger = Kernel.CreateLogger("LOG", true, null); domainList = new List<string>() { "example.com" }; MlAddr = new MlAddr(mlName, domainList); var mailQueue = new MailQueue(tsDir.Src + "TestDir"); var oneOption = new Option(Kernel,"",""); var mailBox = new MailBox(Kernel, oneOption); MailSave = new MailSave(Kernel,mailBox,Logger,mailQueue,"",domainList); MlOption = CreateMlOption(); //MlUserList = CreateMlUsers(); Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList); //30件のメールを保存 for (int i = 0; i < 30; i++) { var mail = new Mail(null); mail.Init(Encoding.ASCII.GetBytes("\r\n"));//区切り行(ヘッダ終了) mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1)); mail.Init(Encoding.ASCII.GetBytes("1\r\n"));//本文 mail.Init(Encoding.ASCII.GetBytes("2\r\n"));//本文 mail.Init(Encoding.ASCII.GetBytes("3\r\n"));//本文 Ml.Save(mail); } }
public static MailQueueItem CreateItemForAccount(MailBox account, MailItemManager manager) { var item = new MailQueueItem(account); item.GetStoredMessagesUidlMd5 += manager.GetStoredMessagesUIDL_MD5; item.OnRetrieveNewMessage += manager.OnRetrieveNewMessage; item.OnUpdateUidl += manager.OnUpdateUidl; item.OnAuthSucceed += manager.OnAuthSucceed; item.OnAuthFailed += manager.OnAuthFailed; item.OnDone += manager.OnDone; item.OnTimeCheckedUpdate += manager.OnCheckedTimeUpdate; item.OnGetOrCreateTags += manager.OnGetOrCreateTags; item.OnUpdateMessagesTags += manager.OnUpdateMessagesTags; return item; }
public override void HandleRetrievedMessage(MailBox mailbox, Message message , MailMessageItem message_item, int folder_id, string uidl, string md5_hash, bool unread, int[] tags_ids) { if (string.IsNullOrEmpty(mailbox.EMailInFolder)) return; try { foreach (var attachment in message_item.Attachments) { using (var file = AttachmentManager.GetAttachmentStream(attachment)) { log.Debug("EmailInMessageHandler HandleRetrievedMessage file name: {0}, folder id: {1}", file.FileName, mailbox.EMailInFolder); var uploaded_file_id = FilesUploader.UploadToFiles(file.FileStream, file.FileName, attachment.contentType, mailbox.EMailInFolder, new Guid(mailbox.UserId), log); if (uploaded_file_id < 0) { log.Error("EmailInMessageHandler HandleRetrievedMessage uploaded_file_id < 0"); } } } } catch (WebException we) { var status_code = ((HttpWebResponse) we.Response).StatusCode; if (status_code == HttpStatusCode.NotFound || status_code == HttpStatusCode.Forbidden) { MailBoxManager.CreateUploadToDocumentsFailureAlert(mailbox.TenantId, mailbox.UserId, mailbox.MailBoxId, (status_code == HttpStatusCode.NotFound) ? MailBoxManager.UploadToDocumentsErrorType .FolderNotFound : MailBoxManager.UploadToDocumentsErrorType .AccessDenied); MailBoxManager.SetMailboxEmailInFolder(mailbox.TenantId, mailbox.UserId, mailbox.MailBoxId, null); mailbox.EMailInFolder = null; } throw; } }
private string GetAccessToken(MailBox mail_box) { var service_type = (AuthorizationServiceType)mail_box.ServiceType; switch (service_type) { case AuthorizationServiceType.Google: var granted_access = new GoogleOAuth2Authorization() .RequestAccessToken(mail_box.RefreshToken); if (granted_access != null) return granted_access.AccessToken; break; } return ""; }
public void Test_Action() { var mbox = new MailBox ("Address"); var recv = 0; mbox.Action += new MailBoxAction ((from, adress, letter) => { recv += 1; }); mbox.Action += new MailBoxAction ((from, adress, letter) => { recv += 1; }); // 登録済みアクションの起動 mbox.OnMailBox (null, "address", null); Assert.AreEqual (2, recv); }
public static Node Create(Vector3 pos) { var cmp = new MyHUD (); var label = new Label (); label.Text = "No message"; var mbox = new MailBox ("HUD"); var node = new Node ("HUD"); node.Attach (cmp); node.Attach (label); node.Attach (mbox); node.Translation = pos; return node; }
private void _sendMessage(Message aMsg, MailBox aDest) { int failedSendCounter = 0; try { aMsg.Send(aDest); failedSendCounter = 0; } catch (Exception) { failedSendCounter++; App.Trace("Counter ->" + failedSendCounter.ToString()); if (failedSendCounter == 10) { terminateFlag = true; } } }
public static Node Create(Vector3 pos) { var cmp = new MyFaceWindow (); var spr = new Sprite (128, 128); spr.AddTexture (Resource.GetDefaultTexture ()); var mbox = new MailBox ("CharacterChanged"); var node = new Node ("FaceWindow"); node.Attach (cmp); node.Attach (spr); node.Attach (mbox); node.Translation = pos; return node; }
public AccountInfo(int id, string address, string name, bool enabled, bool quotaError, MailBox.AuthProblemType authError, SignatureDto signature, bool oauthConnection, string emailInFolder, bool isTeamlabMailbox, bool isSharedDomainMailbox) { Id = id; Email = address; Name = name; Enabled = enabled; QuotaError = quotaError; AuthError = authError == MailBox.AuthProblemType.TooManyErrors; Signature = signature; Aliases = new List<MailAddressInfo>(); Groups = new List<MailAddressInfo>(); OAuthConnection = oauthConnection; EMailInFolder = emailInFolder; IsTeamlabMailbox = isTeamlabMailbox; IsSharedDomainMailbox = isSharedDomainMailbox; }
public static Node Create(Node target, Color color) { var cmp = new MyRaderDot (); cmp.target = target; var spr = new Sprite (2, 2); spr.Color = color; var mbox = new MailBox ("IamDestroyed"); var node = new Node ("RaderDot"); node.Attach (cmp); node.Attach (spr); node.Attach (mbox); node.DrawPriority = -3; return node; }
public SimulationState(string ConfigurationFilePath, GameObject gold = null, GameObject potion = null) { config = new SimulationConfig(); agentIDs = new Dictionary<string, int> (); agents = new Dictionary<int, AgentState>(); //objects = new Dictionary<int, ObjectState>(); objects = new Dictionary<string, EObject> (); inns = new Dictionary<string, Inn> (); graves = new Dictionary<string, Grave> (); nodeToInn = new Dictionary<int, Inn>(); readyActionQueue = new MailBox <Action> (true); perceptRequests = new MailBox <PerceptRequest> (true); instantiateRequests = new MailBox <InstantiateRequest>(true); stdout = new MailBox <string> (true); goldPrefab = gold; potionPrefab = potion; _delta = 0.1f; }
public static Node Create(Vector3 pos) { var cmp = new MyLogger (); var mbox = new MailBox ("Logger"); var node = new Node (); node.Attach (cmp); node.Attach (mbox); for (var i = 0; i < lineCount; i++) { var line = new Label ("No Message"); line.SetOffset (0, 16 * i); node.Attach (line); } node.Translation = pos; return node; }
public void CleanupMailboxData(MailBox mailbox, bool totalRemove) { if (!mailbox.IsRemoved) { throw new Exception("Mailbox is not removed."); } var deleteMailboxQuery = new SqlDelete(MailboxTable.Name) .Where(MailboxTable.Columns.Id, mailbox.MailBoxId) .Where(MailboxTable.Columns.Tenant, mailbox.TenantId) .Where(MailTable.Columns.User, mailbox.UserId); var deleteMailboxMessagesQuery = new SqlDelete(MailTable.Name) .Where(MailTable.Columns.MailboxId, mailbox.MailBoxId) .Where(MailTable.Columns.Tenant, mailbox.TenantId) .Where(MailTable.Columns.User, mailbox.UserId); var deleteMailboxAttachmentsQuery = new SqlDelete(AttachmentTable.Name) .Where(AttachmentTable.Columns.IdMailbox, mailbox.MailBoxId) .Where(AttachmentTable.Columns.IdTenant, mailbox.TenantId); using (var db = GetDb()) { using (var tx = db.BeginTransaction(IsolationLevel.ReadUncommitted)) { db.ExecuteNonQuery(deleteMailboxAttachmentsQuery); db.ExecuteNonQuery(deleteMailboxMessagesQuery); db.ExecuteNonQuery(deleteMailboxQuery); if (totalRemove) { var deleteFoldersQuery = new SqlDelete(FolderTable.Name) .Where(MailTable.Columns.Tenant, mailbox.TenantId) .Where(MailTable.Columns.User, mailbox.UserId); db.ExecuteNonQuery(deleteFoldersQuery); var deleteContactInfoQuery = new SqlDelete(ContactInfoTable.Name) .Where(ContactInfoTable.Columns.User, mailbox.UserId) .Where(ContactInfoTable.Columns.Tenant, mailbox.TenantId); db.ExecuteNonQuery(deleteContactInfoQuery); var deleteContactsQuery = new SqlDelete(ContactsTable.Name) .Where(ContactsTable.Columns.User, mailbox.UserId) .Where(ContactsTable.Columns.Tenant, mailbox.TenantId); db.ExecuteNonQuery(deleteContactsQuery); var deleteDisplayImagesQuery = new SqlDelete(DisplayImagesTable.Name) .Where(DisplayImagesTable.Columns.User, mailbox.UserId) .Where(DisplayImagesTable.Columns.Tenant, mailbox.TenantId); db.ExecuteNonQuery(deleteDisplayImagesQuery); } tx.Commit(); } } }
public AvatarState(Dictionary serialized) : base(serialized) { string nameKey = NameKey; string characterIdKey = CharacterIdKey; string levelKey = LevelKey; string expKey = ExpKey; string inventoryKey = LegacyInventoryKey; string worldInformationKey = LegacyWorldInformationKey; string updatedAtKey = UpdatedAtKey; string agentAddressKey = AgentAddressKey; string questListKey = LegacyQuestListKey; string mailBoxKey = MailBoxKey; string blockIndexKey = BlockIndexKey; string dailyRewardReceivedIndexKey = DailyRewardReceivedIndexKey; string actionPointKey = ActionPointKey; string stageMapKey = StageMapKey; string monsterMapKey = MonsterMapKey; string itemMapKey = ItemMapKey; string eventMapKey = EventMapKey; string hairKey = HairKey; string lensKey = LensKey; string earKey = EarKey; string tailKey = TailKey; string combinationSlotAddressesKey = CombinationSlotAddressesKey; string rankingMapAddressKey = RankingMapAddressKey; if (serialized.ContainsKey(LegacyNameKey)) { nameKey = LegacyNameKey; characterIdKey = LegacyCharacterIdKey; levelKey = LegacyLevelKey; updatedAtKey = LegacyUpdatedAtKey; agentAddressKey = LegacyAgentAddressKey; mailBoxKey = LegacyMailBoxKey; blockIndexKey = LegacyBlockIndexKey; dailyRewardReceivedIndexKey = LegacyDailyRewardReceivedIndexKey; actionPointKey = LegacyActionPointKey; stageMapKey = LegacyStageMapKey; monsterMapKey = LegacyMonsterMapKey; itemMapKey = LegacyItemMapKey; eventMapKey = LegacyEventMapKey; hairKey = LegacyHairKey; earKey = LegacyEarKey; tailKey = LegacyTailKey; combinationSlotAddressesKey = LegacyCombinationSlotAddressesKey; rankingMapAddressKey = LegacyRankingMapAddressKey; } name = serialized[nameKey].ToDotnetString(); characterId = (int)((Integer)serialized[characterIdKey]).Value; level = (int)((Integer)serialized[levelKey]).Value; exp = (long)((Integer)serialized[expKey]).Value; updatedAt = serialized[updatedAtKey].ToLong(); agentAddress = serialized[agentAddressKey].ToAddress(); mailBox = new MailBox((List)serialized[mailBoxKey]); blockIndex = (long)((Integer)serialized[blockIndexKey]).Value; dailyRewardReceivedIndex = (long)((Integer)serialized[dailyRewardReceivedIndexKey]).Value; actionPoint = (int)((Integer)serialized[actionPointKey]).Value; stageMap = new CollectionMap((Dictionary)serialized[stageMapKey]); serialized.TryGetValue((Text)monsterMapKey, out var value2); monsterMap = value2 is null ? new CollectionMap() : new CollectionMap((Dictionary)value2); itemMap = new CollectionMap((Dictionary)serialized[itemMapKey]); eventMap = new CollectionMap((Dictionary)serialized[eventMapKey]); hair = (int)((Integer)serialized[hairKey]).Value; lens = (int)((Integer)serialized[lensKey]).Value; ear = (int)((Integer)serialized[earKey]).Value; tail = (int)((Integer)serialized[tailKey]).Value; combinationSlotAddresses = serialized[combinationSlotAddressesKey].ToList(StateExtensions.ToAddress); RankingMapAddress = serialized[rankingMapAddressKey].ToAddress(); if (serialized.ContainsKey(inventoryKey)) { inventory = new Inventory((List)serialized[inventoryKey]); } if (serialized.ContainsKey(worldInformationKey)) { worldInformation = new WorldInformation((Dictionary)serialized[worldInformationKey]); } if (serialized.ContainsKey(questListKey)) { questList = new QuestList((Dictionary)serialized[questListKey]); } PostConstructor(); }
private void Awake() { _container = new SerializeContainer(); _shipManager = new SimulatedShipManager(this, _container); _hangarManager = new SimulatedHangarManager(this, _container); _POIsManager = new SimulatedPOIsManager(this, _container); _marketManager = new SimulatedMarketManager(this, _container); //creer un peu de données mais ne rien envoyer au model puor le moment Character Andre = new Character(1); Andre.Name = "Andre"; Andre.Loaded = true; Andre.Corp = -1; _container._characters.Add(1, Andre); MailBox m1 = new MailBox(1); m1.Loaded = true; _container._mailBoxs.Add(1, m1); Station albanel = new Station(1); albanel.Name = "Albanel"; albanel.Loaded = true; _container._stations.Add(1, albanel); Station normandin = new Station(2); normandin.Name = "Normandin"; normandin.Loaded = true; _container._stations.Add(2, normandin); Station dolbeau = new Station(3); dolbeau.Name = "Dolbeau"; dolbeau.Loaded = true; _container._stations.Add(3, dolbeau); Station saintMethod = new Station(4); saintMethod.Name = "Saint-Methode"; saintMethod.Loaded = true; _container._stations.Add(4, saintMethod); Station mistassini = new Station(5); mistassini.Name = "Mistassini"; mistassini.Loaded = true; _container._stations.Add(5, mistassini); Station saintFelicien = new Station(6); saintFelicien.Name = "Saint-Félicien"; saintFelicien.Loaded = true; _container._stations.Add(saintFelicien.ID, saintFelicien); Station chambord = new Station(7); chambord.Name = "Chambord"; chambord.Loaded = true; _container._stations.Add(chambord.ID, chambord); _routes.AddRoute(1, 2, 800.0f); _routes.AddRoute(1, 3, 800.0f); _routes.AddRoute(2, 4, 800.0f); _routes.AddRoute(3, 4, 800.0f); _routes.AddRoute(3, 5, 200.0f); _routes.AddRoute(4, 6, 1200.0f); _routes.AddRoute(6, 7, 1200.0f); }
public PopBeforeSmtp(bool usePopBeforeSmtp, int timePopBeforeSmtp, MailBox mailBox) { _usePopBeforeSmtp = usePopBeforeSmtp; _timePopBeforeSmtp = timePopBeforeSmtp; _mailBox = mailBox; }
public override void ProcessStatusCommand(StatusCommand cmd) { MailBox mailbox = store.GetMailbox(cmd.MailBox); if (mailbox == null) { this.Session.AppendResponse( new ServerStatusResponse( cmd.Tag, ServerStatusResponseType.NO, "STATUS fail. Mailbox not found.") ); return; } StatusResponse response = new StatusResponse(mailbox.Path); foreach (var item in cmd.StatusDataItems) { switch (item) { case StatusCommand.StatusItem.MESSAGES: response.StatusItems.Add( new StatusResponseItem( StatusCommand.StatusItem.MESSAGES, mailbox.Exist.ToString() )); break; case StatusCommand.StatusItem.RECENT: response.StatusItems.Add( new StatusResponseItem( StatusCommand.StatusItem.RECENT, mailbox.Recent.ToString() )); break; case StatusCommand.StatusItem.UIDVALIDITY: response.StatusItems.Add( new StatusResponseItem( StatusCommand.StatusItem.UIDVALIDITY, mailbox.UidValidity.ToString() )); break; case StatusCommand.StatusItem.UIDNEXT: response.StatusItems.Add( new StatusResponseItem( StatusCommand.StatusItem.UIDNEXT, mailbox.UidNext.ToString() )); break; case StatusCommand.StatusItem.UNSEEN: response.StatusItems.Add( new StatusResponseItem( StatusCommand.StatusItem.UNSEEN, store.GetUnseenMailCount(mailbox).ToString() )); break; default: break; } } this.Session.AppendResponse(response); this.Session.AppendResponse( new ServerStatusResponse(cmd.Tag, ServerStatusResponseType.OK, "STATUS completed") ); }
public MailQueueItem GetItem() { MailQueueItem result = null; try { while (true) { if (!_noTasks) { _log.Debug("Getting new Item..."); } MailBox mbox = null; var locked_in_this_thread = false; lock (SyncObject) { if (!_isGetMailboxRunning) { _isGetMailboxRunning = true; locked_in_this_thread = true; } } try { if (locked_in_this_thread && _isGetMailboxRunning) { mbox = _manager.GetMailboxForProcessing(_settings.ActivityTimeout); } } finally { if (locked_in_this_thread && _isGetMailboxRunning) { _isGetMailboxRunning = false; } } if (mbox == null) { if (!_noTasks) { _log.Debug("Nothing to do."); } _noTasks = true; break; } var absence = false; var type = HttpRuntime.Cache.Get(mbox.TenantId.ToString(CultureInfo.InvariantCulture)); if (type == null) { absence = true; try { type = _manager.GetTariffType(mbox.TenantId); } catch (Exception e) { _log.Error("Collector.GetItem() -> GetTariffType Exception: {0}", e.ToString()); type = MailBoxManager.TariffType.Active; } } else if (mbox.Active && (MailBoxManager.TariffType)type != MailBoxManager.TariffType.Active) { HttpRuntime.Cache.Remove(mbox.TenantId.ToString(CultureInfo.InvariantCulture)); absence = true; type = MailBoxManager.TariffType.Active; } TimeSpan delay; switch ((MailBoxManager.TariffType)type) { case MailBoxManager.TariffType.LongDead: delay = _settings.LongDeadAccountDelay; break; case MailBoxManager.TariffType.Overdue: delay = _settings.OverdueAccountDelay; break; default: delay = TimeSpan.FromDays(1); break; } if (absence) { HttpRuntime.Cache.Insert(mbox.TenantId.ToString(CultureInfo.InvariantCulture), type, null, DateTime.UtcNow.Add(delay), Cache.NoSlidingExpiration); } _noTasks = false; _log.Info("MailboxId: {0} is being processed. EMail: '{1}' User: '******' TenanntId: {3} ", mbox.MailBoxId, mbox.EMail.Address, mbox.UserId, mbox.TenantId); if ((MailBoxManager.TariffType)type == MailBoxManager.TariffType.LongDead || (MailBoxManager.TariffType)type == MailBoxManager.TariffType.Overdue) { _log.Info("Tenant {0} is not paid. Stop processing MailboxId: {1} EMail: '{2}'.", mbox.TenantId, mbox.MailBoxId, mbox.EMail.Address); _manager.SetNextLoginDelayedFor(mbox, delay); } else { _log.Debug("CreateItemForAccount()..."); result = MailItemQueueFactory.CreateItemForAccount(mbox, _itemManger); break; } } } catch (Exception e) { _log.Error("Collector.GetItem() Exception: {0}", e.ToString()); } return(result); }
public bool Add(MailBox obj) { throw new NotImplementedException(); }
public MailAccountData CreateAccountSimple(string email, string password) { if (string.IsNullOrEmpty(email)) { throw new ArgumentException(@"Empty email", "email"); } Thread.CurrentThread.CurrentCulture = CurrentCulture; Thread.CurrentThread.CurrentUICulture = CurrentCulture; string errorText = null; MailBox mbox = null; var domain = email.Substring(email.IndexOf('@') + 1); var mailboxSettings = MailBoxManager.GetMailBoxSettings(domain); if (mailboxSettings == null) { errorText = GetFormattedTextError(new ItemNotFoundException("Unknown mail provider settings.")); } else { try { var testMailboxes = mailboxSettings.ToMailboxList(email, password, TenantId, Username); var results = new List <LoginResult>(); foreach (var mb in testMailboxes) { LoginResult loginResult; using (var client = new MailClient(mb, CancellationToken.None, 5000, SslCertificatesErrorPermit, _log)) { loginResult = client.TestLogin(); } results.Add(loginResult); if (loginResult.IngoingSuccess && loginResult.OutgoingSuccess) { mbox = mb; break; } } if (mbox == null) { var i = 0; foreach (var loginResult in results) { errorText += string.Format("#{0}:<br>", ++i); if (!loginResult.IngoingSuccess) { errorText += GetFormattedTextError(loginResult.IngoingException, loginResult.Imap ? ServerType.Imap : ServerType.Pop3, false) + "<br>"; // exImap is ImapConnectionTimeoutException } if (!loginResult.OutgoingSuccess) { errorText += GetFormattedTextError(loginResult.OutgoingException, ServerType.Smtp, false) + "<br>"; // exSmtp is SmtpConnectionTimeoutException); } } } } catch (Exception ex) { errorText = GetFormattedTextError(ex); } } if (!string.IsNullOrEmpty(errorText)) { throw new Exception(errorText); } try { if (mbox == null) { throw new Exception(); } mbox.InServerId = MailBoxManager.SaveMailServerSettings(mbox.EMail, new MailServerSettings { AccountName = mbox.Account, AccountPass = mbox.Password, AuthenticationType = mbox.AuthenticationTypeIn, EncryptionType = mbox.IncomingEncryptionType, Port = mbox.Port, Url = mbox.Server }, mbox.Imap ? "imap" : "pop3", AuthorizationServiceType.Unknown); mbox.SmtpServerId = MailBoxManager.SaveMailServerSettings(mbox.EMail, new MailServerSettings { AccountName = mbox.SmtpAccount, AccountPass = mbox.SmtpPassword, AuthenticationType = mbox.AuthenticationTypeSmtp, EncryptionType = mbox.OutcomingEncryptionType, Port = mbox.SmtpPort, Url = mbox.SmtpServer }, "smtp", AuthorizationServiceType.Unknown); MailBoxManager.SaveMailBox(mbox); MailBoxManager.CachedAccounts.Clear(Username); if (IsSignalRAvailable) { MailBoxManager.UpdateUserActivity(TenantId, Username); } var account = new AccountInfo(mbox.MailBoxId, mbox.EMailView, mbox.Name, mbox.Enabled, mbox.QuotaError, MailBox.AuthProblemType.NoProblems, new MailSignature(mbox.MailBoxId, TenantId, "", false), new MailAutoreply(mbox.MailBoxId, TenantId, false, false, false, DateTime.MinValue, DateTime.MinValue, String.Empty, String.Empty), false, mbox.EMailInFolder, false, false); return(account.ToAddressData().FirstOrDefault()); } catch (Exception ex) { //TODO: change AttachmentsUnknownError to common unknown error text errorText = GetFormattedTextError(ex, MailApiResource.AttachmentsUnknownError); } throw new Exception(errorText); }
private void SetDelayExpires(MailBox mailbox) { var expires = DateTime.UtcNow + TimeSpan.FromSeconds(mailbox.ServerLoginDelay); _mailBoxManager.SetEmailLoginDelayExpires(mailbox.EMail.ToString(), expires); }
public TaskData(MailBox mailBox, Task task) { Mailbox = mailBox; Task = task; }
public MailAccountData CreateAccount(string name, string email, string account, string password, int port, string server, string smtp_account, string smtp_password, int smtp_port, string smtp_server, bool smtp_auth, bool imap, bool restrict, EncryptionType incoming_encryption_type, EncryptionType outcoming_encryption_type, SaslMechanism auth_type_in, SaslMechanism auth_type_smtp) { string errorText = null; var mbox = new MailBox { Name = name, EMail = new MailAddress(email), Account = account, Password = password, Port = port, Server = server, SmtpAccount = smtp_account, SmtpPassword = smtp_password, SmtpPort = smtp_port, SmtpServer = smtp_server, SmtpAuth = smtp_auth, Imap = imap, Restrict = restrict, TenantId = TenantId, UserId = Username, BeginDate = restrict ? DateTime.Now.Subtract(new TimeSpan(MailBox.DefaultMailLimitedTimeDelta)) : new DateTime(MailBox.DefaultMailBeginTimestamp), IncomingEncryptionType = incoming_encryption_type, OutcomingEncryptionType = outcoming_encryption_type, AuthenticationTypeIn = auth_type_in, AuthenticationTypeSmtp = auth_type_smtp }; LoginResult loginResult; using (var client = new MailClient(mbox, CancellationToken.None, 5000, SslCertificatesErrorPermit, _log)) { loginResult = client.TestLogin(); } if (!loginResult.IngoingSuccess) { errorText = GetFormattedTextError(loginResult.IngoingException, mbox.Imap ? ServerType.Imap : ServerType.Pop3, false); // exImap is ImapConnectionTimeoutException } if (!loginResult.OutgoingSuccess) { if (!string.IsNullOrEmpty(errorText)) { errorText += "\r\n"; } errorText += GetFormattedTextError(loginResult.OutgoingException, ServerType.Smtp, false); // exSmtp is SmtpConnectionTimeoutException); } if (!string.IsNullOrEmpty(errorText)) { throw new Exception(errorText); } try { mbox.InServerId = MailBoxManager.SaveMailServerSettings(mbox.EMail, new MailServerSettings { AccountName = mbox.Account, AccountPass = mbox.Password, AuthenticationType = mbox.AuthenticationTypeIn, EncryptionType = mbox.IncomingEncryptionType, Port = mbox.Port, Url = mbox.Server }, imap ? "imap" : "pop3", AuthorizationServiceType.Unknown); mbox.SmtpServerId = MailBoxManager.SaveMailServerSettings(mbox.EMail, new MailServerSettings { AccountName = mbox.SmtpAccount, AccountPass = mbox.SmtpPassword, AuthenticationType = mbox.AuthenticationTypeSmtp, EncryptionType = mbox.OutcomingEncryptionType, Port = mbox.SmtpPort, Url = mbox.SmtpServer }, "smtp", AuthorizationServiceType.Unknown); MailBoxManager.SaveMailBox(mbox); MailBoxManager.CachedAccounts.Clear(Username); if (IsSignalRAvailable) { MailBoxManager.UpdateUserActivity(TenantId, Username); } var accountInfo = new AccountInfo(mbox.MailBoxId, mbox.EMailView, mbox.Name, mbox.Enabled, mbox.QuotaError, MailBox.AuthProblemType.NoProblems, new MailSignature(mbox.MailBoxId, TenantId, "", false), new MailAutoreply(mbox.MailBoxId, TenantId, false, false, false, DateTime.MinValue, DateTime.MinValue, String.Empty, String.Empty), false, mbox.EMailInFolder, false, false); return(accountInfo.ToAddressData().FirstOrDefault()); } catch (Exception ex) { //TODO: change AttachmentsUnknownError to common unknown error text errorText = GetFormattedTextError(ex, MailApiResource.AttachmentsUnknownError); } throw new Exception(errorText); }
private MailMessageItem SaveToDraft(int tenant_id, string username, MailSendItem item, int mail_id, out string mime_message_id, out string in_reply_to, MailBox mbox) { item.DisplayName = mbox.Name; var embeded_attachments_for_saving = item.ChangeEmbededAttachmentLinksForStoring(tenant_id, username, mail_id, manager); var message_item = item.ToMailMessageItem(tenant_id, username); message_item.IsNew = false; message_item.Folder = MailFolder.Ids.drafts; mime_message_id = mail_id == 0 ? manager.CreateMessageId() : manager.GetMimeMessageIdByMessageId(mail_id); in_reply_to = item.ReplyToId != 0 ? manager.GetMimeMessageIdByMessageId(item.ReplyToId) : ""; if (!string.IsNullOrEmpty(mime_message_id)) { message_item.MessageId = mime_message_id; } if (!string.IsNullOrEmpty(in_reply_to)) { message_item.InReplyTo = in_reply_to; } message_item.ChainId = message_item.MessageId; var need_to_restore_attachments_from_fck_location = mail_id == 0 && message_item.Attachments.Any(); if (need_to_restore_attachments_from_fck_location) { message_item.Attachments.ForEach(attachment => manager.StoreAttachmentCopy(tenant_id, username, attachment, item.StreamId)); } manager.StoreMailBody(mbox.TenantId, mbox.UserId, message_item); var previous_mailbox_id = mail_id == 0 ? mbox.MailBoxId : manager.GetMailInfo(tenant_id, username, mail_id, false, false).MailboxId; mail_id = manager.MailSave(mbox, message_item, mail_id, message_item.Folder, message_item.Folder, string.Empty, string.Empty, false); message_item.Id = mail_id; if (previous_mailbox_id != mbox.MailBoxId) { manager.UpdateChain(message_item.ChainId, message_item.Folder, previous_mailbox_id, tenant_id, username); } if (mail_id > 0 && need_to_restore_attachments_from_fck_location) { foreach (var attachment in message_item.Attachments) { var new_id = manager.SaveAttachment(tenant_id, mail_id, attachment); attachment.fileId = new_id; } } if (mail_id > 0 && embeded_attachments_for_saving.Any()) { manager.SaveAttachments(tenant_id, mail_id, embeded_attachments_for_saving); } manager.UpdateChain(message_item.ChainId, message_item.Folder, mbox.MailBoxId, mbox.TenantId, mbox.UserId); if (previous_mailbox_id != mbox.MailBoxId) { manager.UpdateCrmLinkedMailboxId(message_item.ChainId, tenant_id, previous_mailbox_id, mbox.MailBoxId); } return(message_item); }
//Todo: Remove useless parameters from this method private void AddNotificationAlertToMailbox(int tenant_id, string username, MailSendItem item, MailMessageItem result_message, Exception ex, MailBox mbox) { try { var sb_message = new StringBuilder(1024); var message_delivery = new MailSendItem { Subject = MailApiResource.DeliveryFailureSubject }; message_delivery.To.Add(item.From); message_delivery.From = MailBoxManager.MAIL_DAEMON_EMAIL; message_delivery.Important = true; message_delivery.StreamId = manager.CreateNewStreamId(); sb_message.Append(@"<style> .button.blue:hover { color: white; background: #57A7D3; background: linear-gradient(top, #78BFE8, #57A7D3 50%, #57A7D3 51%, #3F96C3); background: -o-linear-gradient(top, #78BFE8, #57A7D3 50%, #57A7D3 51%, #3F96C3); background: -moz-linear-gradient(top, #78BFE8, #57A7D3 50%, #57A7D3 51%, #3F96C3); background: -webkit-linear-gradient(top, #78BFE8, #57A7D3 50%, #57A7D3 51%, #3F96C3); border: 1px solid #5EAAD5; } .button.blue { color: white; background: #3D96C6; background: linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76A6); background: -o-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76A6); background: -moz-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76A6); background: -webkit-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76A6); border-width: 1px; border-style: solid; border-color: #4DA9DC #4098C9 #2D7399 #4098C9; } .button, .button:visited, .button:hover, .button:active { display: inline-block; font-weight: normal; text-align: center; text-decoration: none; vertical-align: middle; cursor: pointer; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; touch-callout: none; -o-touch-callout: none; -moz-touch-callout: none; -webkit-touch-callout: none; user-select: none; -o-user-select: none; -moz-user-select: none; -webkit-user-select: none; font-size: 12px; line-height: 14px; padding: 2px 12px 3px; color: white; background: #3D96C6; background: linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76A6); background: -o-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76A6); background: -moz-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76A6); background: -webkit-linear-gradient(top, #59B1E2, #3D96C6 50%, #3D96C6 51%, #1A76A6); border-width: 1px; border-style: solid; border-color: #4DA9DC #4098C9 #2D7399 #4098C9; } body { color: #333; font: normal 12px Arial, Tahoma,sans-serif; } </style>"); sb_message.AppendFormat("<div style=\"max-width:500px;\"><p style=\"color:gray;\">{0}</p>", MailApiResource.DeliveryFailureAutomaticMessage); sb_message.AppendFormat("<p>{0}</p>", MailApiResource.DeliveryFailureMessageIdentificator .Replace("{subject}", item.Subject) .Replace("{date}", DateTime.Now.ToString(CultureInfo.InvariantCulture))); sb_message.AppendFormat("<div><p>{0}:</p><ul style=\"color:#333;\">", MailApiResource.DeliveryFailureRecipients); item.To.ForEach(rcpt => sb_message.AppendFormat("<li>{0}</li>", HttpUtility.HtmlEncode(rcpt))); item.Cc.ForEach(rcpt => sb_message.AppendFormat("<li>{0}</li>", HttpUtility.HtmlEncode(rcpt))); item.Bcc.ForEach(rcpt => sb_message.AppendFormat("<li>{0}</li>", HttpUtility.HtmlEncode(rcpt))); sb_message.AppendFormat("</ul>"); sb_message.AppendFormat("<p>{0}</p>", MailApiResource.DeliveryFailureRecommendations .Replace("{account_name}", "<b>" + item.From + "</b>")); sb_message.AppendFormat( "<a id=\"delivery_failure_button\" mailid={0} class=\"button blue\" style=\"margin-right:8px;\">", result_message.Id); sb_message.Append(MailApiResource.DeliveryFailureBtn + "</a></div>"); sb_message.AppendFormat("<p>{0}</p>", MailApiResource.DeliveryFailureFAQInformation .Replace("{url_begin}", "<a id=\"delivery_failure_faq_link\" target=\"blank\" href=\"#gmail\">") .Replace("{url_end}", "</a>")); var last_dot_index = ex.Message.LastIndexOf('.'); var smtp_response = ex.Message; if (last_dot_index != -1 && last_dot_index != smtp_response.Length) { try { smtp_response = smtp_response.Remove(last_dot_index + 1, smtp_response.Length - last_dot_index - 1); } catch (Exception) { } } sb_message.AppendFormat( "<p style=\"color:gray;\">" + MailApiResource.DeliveryFailureReason + ": \"{0}\"</p></div>", smtp_response); message_delivery.HtmlBody = sb_message.ToString(); // SaveToDraft To Inbox var notify_message_item = message_delivery.ToMailMessageItem(tenant_id, username); notify_message_item.MessageId = manager.CreateMessageId(); notify_message_item.ChainId = notify_message_item.MessageId; notify_message_item.IsNew = true; notify_message_item.IsFromCRM = false; notify_message_item.IsFromTL = false; manager.StoreMailBody(mbox.TenantId, mbox.UserId, notify_message_item); // ReSharper disable UnusedVariable var id_mail = manager.MailSave(mbox, notify_message_item, 0, MailFolder.Ids.inbox, MailFolder.Ids.inbox, string.Empty, string.Empty, false); // ReSharper restore UnusedVariable manager.CreateDeliveryFailureAlert(mbox.TenantId, mbox.UserId, item.Subject, item.From, (Int32)result_message.Id); } catch { //TODO: add log here } }
private void SendChallengeResponse(long player, bool accepted, string reason = null) { MailBox.Send(new MessageEnvelope(new ChallengeRequestResponseMessage(accepted, reason), player)); }
public MailBox CreateAccount(string name, string email, string account, string password, int port, string server, string smtp_account, string smtp_password, int smtp_port, string smtp_server, bool smtp_auth, bool imap, bool restrict, EncryptionType incoming_encryption_type, EncryptionType outcoming_encryption_type, SaslMechanism auth_type_in, SaslMechanism auth_type_smtp) { string error_text = null; var mbox = new MailBox { Name = name, EMail = new MailAddress(email), Account = account, Password = password, Port = port, Server = server, SmtpAccount = smtp_account, SmtpPassword = smtp_password, SmtpPort = smtp_port, SmtpServer = smtp_server, SmtpAuth = smtp_auth, Imap = imap, Restrict = restrict, TenantId = TenantId, UserId = Username, BeginDate = restrict ? DateTime.Now.Subtract(new TimeSpan(MailBox.DefaultMailLimitedTimeDelta)) : new DateTime(MailBox.DefaultMailBeginTimestamp), IncomingEncryptionType = incoming_encryption_type, OutcomingEncryptionType = outcoming_encryption_type, AuthenticationTypeIn = auth_type_in, AuthenticationTypeSmtp = auth_type_smtp }; try { MailServerHelper.Test(mbox); } catch (ImapConnectionException ex_imap) { error_text = GetFormattedTextError(ex_imap, ServerType.Imap, ex_imap is ImapConnectionTimeoutException); } catch (Pop3ConnectionException ex_pop3) { error_text = GetFormattedTextError(ex_pop3, ServerType.Pop3, ex_pop3 is Pop3ConnectionTimeoutException); } catch (SmtpConnectionException ex_smtp) { error_text = GetFormattedTextError(ex_smtp, ServerType.Smtp, ex_smtp is SmtpConnectionTimeoutException); } catch (Exception ex) { error_text = GetFormattedTextError(ex); } if (!string.IsNullOrEmpty(error_text)) { throw new Exception(error_text); } try { mbox.InServerId = MailBoxManager.SaveMailServerSettings(mbox.EMail, new MailServerSettings { AccountName = mbox.Account, AccountPass = mbox.Password, AuthenticationType = mbox.AuthenticationTypeIn, EncryptionType = mbox.IncomingEncryptionType, Port = mbox.Port, Url = mbox.Server }, imap ? "imap" : "pop3", AuthorizationServiceType.Unknown); mbox.SmtpServerId = MailBoxManager.SaveMailServerSettings(mbox.EMail, new MailServerSettings { AccountName = mbox.SmtpAccount, AccountPass = mbox.SmtpPassword, AuthenticationType = mbox.AuthenticationTypeSmtp, EncryptionType = mbox.OutcomingEncryptionType, Port = mbox.SmtpPort, Url = mbox.SmtpServer }, "smtp", AuthorizationServiceType.Unknown); MailBoxManager.SaveMailBox(mbox); return(mbox); } catch (Exception ex) { //TODO: change AttachmentsUnknownError to common unknown error text error_text = GetFormattedTextError(ex, MailApiResource.AttachmentsUnknownError); } throw new Exception(error_text); }
public void OnAuthFailed(MailBox mailbox, string response_line) { SetDelayExpires(mailbox); _mailBoxManager.SetAuthError(mailbox, true); }
public MailBox CreateAccountSimple(string email, string password) { if (string.IsNullOrEmpty(email)) { throw new ArgumentException("Empty email", "email"); } string error_text = null; MailBox mbox = null; try { mbox = MailBoxManager.SearchMailboxSettings(email, password, Username, TenantId); } catch (ImapConnectionException ex_imap) { error_text = GetFormattedTextError(ex_imap, ServerType.Imap, ex_imap is ImapConnectionTimeoutException); } catch (Pop3ConnectionException ex_pop) { error_text = GetFormattedTextError(ex_pop, ServerType.Pop3, ex_pop is Pop3ConnectionTimeoutException); } catch (SmtpConnectionException ex_smtp) { error_text = GetFormattedTextError(ex_smtp, ServerType.Smtp, ex_smtp is SmtpConnectionTimeoutException); } catch (ItemNotFoundException ex_provider) { error_text = GetFormattedTextError(ex_provider); } catch (Exception ex) { error_text = GetFormattedTextError(ex); } if (!string.IsNullOrEmpty(error_text)) { throw new Exception(error_text); } try { if (mbox == null) { throw new Exception(); } mbox.InServerId = MailBoxManager.SaveMailServerSettings(mbox.EMail, new MailServerSettings { AccountName = mbox.Account, AccountPass = mbox.Password, AuthenticationType = mbox.AuthenticationTypeIn, EncryptionType = mbox.IncomingEncryptionType, Port = mbox.Port, Url = mbox.Server }, mbox.Imap ? "imap" : "pop3", AuthorizationServiceType.Unknown); mbox.SmtpServerId = MailBoxManager.SaveMailServerSettings(mbox.EMail, new MailServerSettings { AccountName = mbox.SmtpAccount, AccountPass = mbox.SmtpPassword, AuthenticationType = mbox.AuthenticationTypeSmtp, EncryptionType = mbox.OutcomingEncryptionType, Port = mbox.SmtpPort, Url = mbox.SmtpServer }, "smtp", AuthorizationServiceType.Unknown); MailBoxManager.SaveMailBox(mbox); return(mbox); } catch (Exception ex) { //TODO: change AttachmentsUnknownError to common unknown error text error_text = GetFormattedTextError(ex, MailApiResource.AttachmentsUnknownError); } throw new Exception(error_text); }
private string UnreadMsgCountInfo(List <MessagesViewModel> vmList, MailBox MailBox) { int unread = vmList.Count(m => !m.IsRead); int total = vmList.Count(); if (MailBox == MailBox.Trash) { return(""); } string result = ""; if (total == 0) { result = "No messages in " + MailBox; } else if (unread == 0 && total == 1) { if (MailBox == MailBox.Inbox) { result = "1 read message"; } else { result = "You've sent 1 message and it's been read"; } } else if (unread == 1 && total == 1) { if (MailBox == MailBox.Inbox) { result = "1 unread message"; } else { result = "You've sent 1 message and it has not been read"; } } else if (unread == 0 && total > 0) { if (MailBox == MailBox.Inbox) { result = total + "read messages"; } else { result = "You've sent " + total + " messages and they've been read"; } } else if (unread == 1 && total > 1) { if (MailBox == MailBox.Inbox) { result = "1 unread message out of " + total; } else { result = "You've sent " + total + " messages and 1 has not been read"; } } else if (unread == total && total > 1) { if (MailBox == MailBox.Inbox) { result = total + " unread messages"; } else { result = "You've sent " + total + " messages and none has been read"; } } else { if (MailBox == MailBox.Inbox) { result = unread + " unread messages out of " + total; } else { result = "You've sent " + total + " messages and " + unread + " have not been read"; } } return(result); }
public void OnAuthSucceed(MailBox mailbox) { SetDelayExpires(mailbox); _mailBoxManager.SetAuthError(mailbox, false); }
public AvatarState(Address address, Address agentAddress, long blockIndex, AvatarSheets avatarSheets, GameConfigState gameConfigState, Address rankingMapAddress, string name = null) : base(address) { if (address == null) { throw new ArgumentNullException(nameof(address)); } this.name = name ?? string.Empty; characterId = GameConfig.DefaultAvatarCharacterId; level = 1; exp = 0; inventory = new Inventory(); worldInformation = new WorldInformation(blockIndex, avatarSheets.WorldSheet, GameConfig.IsEditor); updatedAt = blockIndex; this.agentAddress = agentAddress; questList = new QuestList( avatarSheets.QuestSheet, avatarSheets.QuestRewardSheet, avatarSheets.QuestItemRewardSheet, avatarSheets.EquipmentItemRecipeSheet, avatarSheets.EquipmentItemSubRecipeSheet ); mailBox = new MailBox(); this.blockIndex = blockIndex; actionPoint = gameConfigState.ActionPointMax; stageMap = new CollectionMap(); monsterMap = new CollectionMap(); itemMap = new CollectionMap(); const QuestEventType createEvent = QuestEventType.Create; const QuestEventType levelEvent = QuestEventType.Level; eventMap = new CollectionMap { new KeyValuePair <int, int>((int)createEvent, 1), new KeyValuePair <int, int>((int)levelEvent, level), }; combinationSlotAddresses = new List <Address>(CombinationSlotCapacity); for (var i = 0; i < CombinationSlotCapacity; i++) { var slotAddress = address.Derive( string.Format( CultureInfo.InvariantCulture, CombinationSlotState.DeriveFormat, i ) ); combinationSlotAddresses.Add(slotAddress); } combinationSlotAddresses = combinationSlotAddresses .OrderBy(element => element) .ToList(); RankingMapAddress = rankingMapAddress; UpdateGeneralQuest(new[] { createEvent, levelEvent }); UpdateCompletedQuest(); PostConstructor(); }
public void OnUpdateUidl(MailBox account, int message_id, string new_uidl) { _mailBoxManager.UpdateMessageUidl(account.TenantId, account.UserId, message_id, new_uidl); }
private MailClient CreateMailClient(MailBox mailbox, ILogger log, CancellationToken cancelToken) { MailClient client = null; var connectError = false; var stopClient = false; Stopwatch watch = null; if (_tasksConfig.CollectStatistics) { watch = new Stopwatch(); watch.Start(); } var manager = new MailBoxManager(log) { AuthErrorWarningTimeout = _tasksConfig.AuthErrorWarningTimeout, AuthErrorDisableTimeout = _tasksConfig.AuthErrorDisableMailboxTimeout }; try { client = new MailClient(mailbox, cancelToken, _tasksConfig.TcpTimeout, mailbox.IsTeamlab || _tasksConfig.SslCertificateErrorsPermit, _tasksConfig.ProtocolLogPath, log, true); log.Debug("MailClient.LoginImapPop(Tenant = {0}, MailboxId = {1} Address = '{2}')", mailbox.TenantId, mailbox.MailBoxId, mailbox.EMail); client.Authenticated += ClientOnAuthenticated; client.LoginImapPop(); } catch (System.TimeoutException exTimeout) { log.Warn( "[TIMEOUT] CreateTasks->client.LoginImapPop(Tenant = {0}, MailboxId = {1}, Address = '{2}') Exception: {3}", mailbox.TenantId, mailbox.MailBoxId, mailbox.EMail, exTimeout.ToString()); connectError = true; stopClient = true; } catch (OperationCanceledException) { log.Info( "[CANCEL] CreateTasks->client.LoginImapPop(Tenant = {0}, MailboxId = {1}, Address = '{2}')", mailbox.TenantId, mailbox.MailBoxId, mailbox.EMail); stopClient = true; } catch (AuthenticationException authEx) { log.Error( "CreateTasks->client.LoginImapPop(Tenant = {0}, MailboxId = {1}, Address = '{2}')\r\nException: {3}\r\n", mailbox.TenantId, mailbox.MailBoxId, mailbox.EMail, authEx.ToString()); connectError = true; stopClient = true; } catch (WebException webEx) { log.Error( "CreateTasks->client.LoginImapPop(Tenant = {0}, MailboxId = {1}, Address = '{2}')\r\nException: {3}\r\n", mailbox.TenantId, mailbox.MailBoxId, mailbox.EMail, webEx.ToString()); connectError = true; stopClient = true; } catch (Exception ex) { log.Error( "CreateTasks->client.LoginImapPop(Tenant = {0}, MailboxId = {1}, Address = '{2}')\r\nException: {3}\r\n", mailbox.TenantId, mailbox.MailBoxId, mailbox.EMail, ex is ImapProtocolException || ex is Pop3ProtocolException ? ex.Message : ex.ToString()); stopClient = true; } finally { if (connectError) { SetMailboxAuthError(manager, mailbox, log); } if (stopClient) { CloseMailClient(client, mailbox, log); } if (_tasksConfig.CollectStatistics && watch != null) { watch.Stop(); LogStat(CONNECT_MAILBOX, mailbox, watch.Elapsed, connectError); } } return(client); }
public MailBox Delete(MailBox obj) { throw new NotImplementedException(); }
public MailQueueItem GetItem() { try { while (true) { if (!_noTasks) { _log.Info("Getting new Item..."); } MailBox mbox = null; var locked_in_this_thread = false; lock (SyncObject) { if (!_isGetMailboxRunning) { _isGetMailboxRunning = true; locked_in_this_thread = true; } } try { if (locked_in_this_thread && _isGetMailboxRunning) { mbox = _manager.GetMailboxForProcessing(_tasksConfig); } } finally { if (locked_in_this_thread && _isGetMailboxRunning) { _isGetMailboxRunning = false; } } if (mbox == null) { if (!_noTasks) { _log.Info("Nothing to do."); } _noTasks = true; break; } var absence = false; var type = HttpRuntime.Cache.Get(mbox.TenantId.ToString(CultureInfo.InvariantCulture)); if (type == null) { _log.Info("Tenant {0} isn't in cache", mbox.TenantId); absence = true; try { type = _manager.GetTariffType(mbox.TenantId); } catch (Exception e) { _log.Error("Collector.GetItem() -> GetTariffType Exception: {0}", e.ToString()); type = MailBoxManager.TariffType.Active; } } else { _log.Info("Tenant {0} is in cache", mbox.TenantId); } _noTasks = false; _log.Info("MailboxId: {0} is processing. EMail: '{1}' User: '******' TenantId: {3} ", mbox.MailBoxId, mbox.EMail.Address, mbox.UserId, mbox.TenantId); switch ((MailBoxManager.TariffType)type) { case MailBoxManager.TariffType.LongDead: _log.Info("Tenant {0} is not paid. Disable mailboxes.", mbox.TenantId); _manager.DisableMailboxesForTenant(mbox.TenantId); break; case MailBoxManager.TariffType.Overdue: _log.Info("Tenant {0} is not paid. Stop processing mailboxes.", mbox.TenantId); _manager.SetNextLoginDelayedForTenant(mbox.TenantId, _settings.OverdueAccountDelay); break; default: var user_terminated = false; try { CoreContext.TenantManager.SetCurrentTenant(mbox.TenantId); var user = CoreContext.UserManager.GetUsers(new Guid(mbox.UserId)); if (user.Status == EmployeeStatus.Terminated) { user_terminated = true; } } catch (Exception ex) { _log.Error(ex, "Cannot get current user = '******'", mbox.UserId); } if (user_terminated) { _log.Info("User '{0}' was terminated. TenantId: {1}. Stop processing mailboxes.", mbox.UserId, mbox.TenantId); _manager.DisableMailboxesForUser(mbox.TenantId, mbox.UserId); return(null); } if (absence) { var mboxKey = mbox.TenantId.ToString(CultureInfo.InvariantCulture); HttpRuntime.Cache.Remove(mboxKey); HttpRuntime.Cache.Insert(mboxKey, type, null, DateTime.UtcNow.Add(_settings.TenantCachingPeriod), Cache.NoSlidingExpiration); } _log.Debug("CreateItemForAccount()..."); return(MailItemQueueFactory.CreateItemForAccount(mbox, _itemManger)); } } } catch (Exception e) { _log.Error("Collector.GetItem() Exception: {0}", e.ToString()); } return(null); }
public async static void FillingUserInfoAsync(MailBox mailBox, ViewModel viewModel) { if (mailBox == null) { return; } string domainName = mailBox.Domain; string name = mailBox.Name; string hostName = viewModel.MailServer; string userName = viewModel.UserNameForMailServer; string password = viewModel.PasswordBox?.Password; if (viewModel.PasswordBox != null) { await Task.Run(() => { XmlGetUserInfoReq xmlGetUserInfoReq = new XmlGetUserInfoReq(domainName, name); string xmlResponse = ApiClient.Request(hostName, userName, password, xmlGetUserInfoReq.ToString()); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xmlResponse); XmlNodeList xmlNodeList; xmlNodeList = xmlDocument.GetElementsByTagName("Password"); if (xmlNodeList.Count > 0) { mailBox.Password = xmlNodeList[0].InnerText; } else { mailBox.NoOk(); return; } xmlNodeList = xmlDocument.GetElementsByTagName("FirstName"); if (xmlNodeList.Count > 0) { mailBox.FirstName = xmlNodeList[0].InnerText; } xmlNodeList = xmlDocument.GetElementsByTagName("LastName"); if (xmlNodeList.Count > 0) { mailBox.LastName = xmlNodeList[0].InnerText; } xmlNodeList = xmlDocument.GetElementsByTagName("Frozen"); if (xmlNodeList.Count > 0) { mailBox.Frozen = xmlNodeList[0].InnerText; } xmlNodeList = xmlDocument.GetElementsByTagName("Disabled"); if (xmlNodeList.Count > 0) { mailBox.Disabled = xmlNodeList[0].InnerText; } xmlNodeList = xmlDocument.GetElementsByTagName("MailDir"); if (xmlNodeList.Count > 0) { mailBox.MailDir = xmlNodeList[0].InnerText; } }); } }
/// <summary> /// Initializes a new instance of the <see cref="T:MailClientEventArgs" /> class. /// </summary> /// <remarks> /// Creates a new <see cref="T:MailKit.AuthenticatedEventArgs" />. /// </remarks> /// <param name="message">The free-form text.</param> /// <param name="mailBox"></param> public MailClientEventArgs(string message, MailBox mailBox) { this.Message = message; this.Mailbox = mailBox; }
private async Task <List <MessagesViewModel> > GetListOfMessages(MailBox MailBox) { List <MessagesViewModel> vmList = new List <MessagesViewModel>(); string userID = User.Identity.GetUserId(); int maxSubjectLength = 80; int maxContentLength = 150; switch (MailBox) { case MailBox.Sent: ViewBag.Title = MailBox.Sent; ViewBag.MailBox = MailBox.Sent; using (ApplicationDbContext db = new ApplicationDbContext()) { List <Message> sentMessages = await db.Messages.Include("Receiver").Where(m => m.SenderID == userID && m.SenderStatus == MessageStatus.Available).OrderByDescending(m => m.SentDate).ToListAsync(); if (sentMessages.Count() > 0) { vmList.AddRange(sentMessages.Select(m => new MessagesViewModel() { MessageID = m.MessageID, CorrespondentID = m.ReceiverID, CorrespondentName = Utils.GetFullName(m.Receiver), SentDate = GetRelativeDate(m.SentDate), IsRead = (m.ReadDate != null), Status = m.SenderStatus, Mailbox = MailBox.Sent, Subject = ShortenText(m.Subject, maxSubjectLength), Content = ShortenText(m.Content, maxContentLength), }).ToList()); } } break; case MailBox.Trash: ViewBag.Title = MailBox.Trash; ViewBag.MailBox = MailBox.Trash; using (ApplicationDbContext db = new ApplicationDbContext()) { List <Message> deletedMessages = await db.Messages.Include("Sender").Include("Receiver").Where(m => (m.SenderID == userID && m.SenderStatus == MessageStatus.Trashed) || (m.ReceiverID == userID && m.ReceiverStatus == MessageStatus.Trashed) ).OrderByDescending(m => m.SentDate).ToListAsync(); if (deletedMessages.Count() > 0) { vmList.AddRange(deletedMessages.Select(m => new MessagesViewModel() { MessageID = m.MessageID, CorrespondentID = (m.SenderID == userID) ? m.ReceiverID : m.SenderID, CorrespondentName = (m.SenderID == userID) ? Utils.GetFullName(m.Receiver) : Utils.GetFullName(m.Sender), SentDate = GetRelativeDate(m.SentDate), IsRead = (m.ReadDate != null), Status = m.ReceiverStatus, Mailbox = MailBox.Trash, Subject = ShortenText(m.Subject, maxSubjectLength), Content = ShortenText(m.Content, maxContentLength), }).ToList()); } } break; case MailBox.Inbox: default: ViewBag.Title = MailBox.Inbox; ViewBag.MailBox = MailBox.Inbox; using (ApplicationDbContext db = new ApplicationDbContext()) { List <Message> receivedMessages = await db.Messages.Include("Sender").Where(m => m.ReceiverID == userID && m.ReceiverStatus == MessageStatus.Available).OrderByDescending(m => m.SentDate).ToListAsync(); if (receivedMessages.Count() > 0) { vmList.AddRange(receivedMessages.Select(m => new MessagesViewModel() { MessageID = m.MessageID, CorrespondentID = m.SenderID, CorrespondentName = Utils.GetFullName(m.Sender), SentDate = GetRelativeDate(m.SentDate), IsRead = (m.ReadDate != null), Status = m.ReceiverStatus, Mailbox = MailBox.Inbox, Subject = ShortenText(m.Subject, maxSubjectLength), Content = ShortenText(m.Content, maxContentLength), }).ToList()); } } break; } // Built a Session variable for the List of messages in this MailBox List <int> IdList = new List <int>(); foreach (MessagesViewModel m in vmList) { IdList.Add(m.MessageID); } Session["MessageList"] = IdList; return(vmList); }
private void DoOptionalOperations(MailMessage message, MimeMessage mimeMessage, MailBox mailbox, List <int> tagIds, ILogger log) { var manager = new MailBoxManager(log); log.Debug("DoOptionalOperations->SetMessageTags()"); SetMessageTags(manager, message, mailbox, tagIds, log); log.Debug("DoOptionalOperations->AddRelationshipEventForLinkedAccounts()"); manager.AddRelationshipEventForLinkedAccounts(mailbox, message, _tasksConfig.DefaultApiSchema, log); log.Debug("DoOptionalOperations->SaveEmailInData()"); manager.SaveEmailInData(mailbox, message, _tasksConfig.DefaultApiSchema, log); log.Debug("DoOptionalOperations->SendAutoreply()"); manager.SendAutoreply(mailbox, message, _tasksConfig.DefaultApiSchema, log); log.Debug("DoOptionalOperations->UploadIcsToCalendar()"); manager.UploadIcsToCalendar(mailbox, message.CalendarId, message.CalendarUid, message.CalendarEventIcs, message.CalendarEventCharset, message.CalendarEventMimeType, mailbox.EMail.Address, _tasksConfig.DefaultApiSchema, log); if (_tasksConfig.SaveOriginalMessage) { log.Debug("DoOptionalOperations->StoreMailEml()"); StoreMailEml(mailbox.TenantId, mailbox.UserId, message.StreamId, mimeMessage, log); } if (!_tasksConfig.EnableSignalr) { log.Debug("DoOptionalOperations->END"); return; } var now = DateTime.UtcNow; if (mailbox.LastSignalrNotify.HasValue && !((now - mailbox.LastSignalrNotify.Value).TotalSeconds > SIGNALR_WAIT_SECONDS)) { mailbox.LastSignalrNotifySkipped = true; return; } log.Debug("DoOptionalOperations->NotifySignalrIfNeed()"); NotifySignalrIfNeed(mailbox, log); mailbox.LastSignalrNotify = now; mailbox.LastSignalrNotifySkipped = false; log.Debug("DoOptionalOperations->END"); }
// Constructor public MailboxMessagesIterator(MailBox mailBox, MailBoxManager mailBoxManager) { _currentMailBox = mailBox; _mailBoxManager = mailBoxManager; _mailBoxManager.GetMailboxMessagesRange(_currentMailBox, out _minMessageId, out _maxMessageId); }
private bool TryLockMailbox(MailBox mailbox) { _log.Debug("TryLockMailbox(MailboxId={0} is {1})", mailbox.MailBoxId, mailbox.Active ? "active" : "inactive"); try { var contains = _tenantMemCache.Contains(mailbox.TenantId.ToString(CultureInfo.InvariantCulture)); if (!contains) { _log.Debug("Tenant {0} isn't in cache", mailbox.TenantId); try { var type = mailbox.GetTenantStatus(_tasksConfig.TenantOverdueDays, _tasksConfig.DefaultApiSchema, _log); switch (type) { case Defines.TariffType.LongDead: _log.Info("Tenant {0} is not paid. Disable mailboxes.", mailbox.TenantId); _manager.DisableMailboxesForTenant(mailbox.TenantId); RemoveFromQueue(mailbox.TenantId); return(false); case Defines.TariffType.Overdue: _log.Info("Tenant {0} is not paid. Stop processing mailboxes.", mailbox.TenantId); _manager.SetNextLoginDelayedForTenant(mailbox.TenantId, _tasksConfig.OverdueAccountDelay); RemoveFromQueue(mailbox.TenantId); return(false); default: _log.Info("Tenant {0} is paid.", mailbox.TenantId); if (mailbox.IsUserTerminated() || mailbox.IsUserRemoved()) { _log.Info("User '{0}' was terminated. Tenant = {1}. Disable mailboxes for user.", mailbox.UserId, mailbox.TenantId); _manager.DisableMailboxesForUser(mailbox.TenantId, mailbox.UserId); RemoveFromQueue(mailbox.TenantId, mailbox.UserId); return(false); } var expired = DateTime.UtcNow.Add(_tasksConfig.TenantCachingPeriod); var tenantData = new TenantData { Tenant = mailbox.TenantId, TariffType = type, Expired = expired }; AddTenantToCache(tenantData); break; } } catch (Exception e) { _log.Error("TryLockMailbox() -> GetTariffType Exception:\r\n{0}\r\n", e.ToString()); } } else { _log.Debug("Tenant {0} is in cache", mailbox.TenantId); } if (mailbox.IsTenantQuotaEnded(_tasksConfig.TenantMinQuotaBalance, _log)) { _log.Info("Tenant = {0} User = {1}. Quota is ended.", mailbox.TenantId, mailbox.UserId); if (!mailbox.QuotaError) { _manager.CreateQuotaErrorWarningAlert(mailbox.TenantId, mailbox.UserId); } _manager.SetNextLoginDelayedForUser(mailbox.TenantId, mailbox.UserId, _tasksConfig.QuotaEndedDelay); RemoveFromQueue(mailbox.TenantId, mailbox.UserId); return(false); } return(_manager.LockMailbox(mailbox.MailBoxId, true)); } catch (Exception ex) { _log.Error("TryLockMailbox(MailboxId={0} is {1}) Exception:\r\n{2}\r\n", mailbox.MailBoxId, mailbox.Active ? "active" : "inactive", ex.ToString()); return(false); } }