public void SetSubscriptionMethod(SubscriptionMethod m)
 {
     service.SetSubscriptionMethod(m);
     notifyMethod.Publish(m, CacheNotifyAction.Any);
 }
Пример #2
0
 public void ClearCache(int tenantId)
 {
     notify.Publish(new TariffCacheItem {
         TenantId = tenantId
     }, CacheNotifyAction.Remove);
 }
 public void SaveSubscription(SubscriptionRecord s)
 {
     service.SaveSubscription(s);
     notifyRecord.Publish(s, CacheNotifyAction.InsertOrUpdate);
 }
Пример #4
0
        public static void UpdateDataFromInternalDatabase(string hostname, MailServerInfo mailServer)
        {
            DemandPermission();

            using var dbManager   = GetDb();
            using var transaction = dbManager.BeginTransaction();
            var insertQuery = new SqlInsert("mail_mailbox_provider")
                              .InColumnValue("id", 0)
                              .InColumnValue("name", hostname)
                              .Identity(0, 0, true);

            var providerId = dbManager.ExecuteScalar <int>(insertQuery);

            insertQuery = new SqlInsert("mail_mailbox_server")
                          .InColumnValue("id", 0)
                          .InColumnValue("id_provider", providerId)
                          .InColumnValue("type", "smtp")
                          .InColumnValue("hostname", hostname)
                          .InColumnValue("port", 587)
                          .InColumnValue("socket_type", "STARTTLS")
                          .InColumnValue("username", "%EMAILADDRESS%")
                          .InColumnValue("authentication", "")
                          .InColumnValue("is_user_data", false)
                          .Identity(0, 0, true);

            var smtpServerId = dbManager.ExecuteScalar <int>(insertQuery);

            insertQuery = new SqlInsert("mail_mailbox_server")
                          .InColumnValue("id", 0)
                          .InColumnValue("id_provider", providerId)
                          .InColumnValue("type", "imap")
                          .InColumnValue("hostname", hostname)
                          .InColumnValue("port", 143)
                          .InColumnValue("socket_type", "STARTTLS")
                          .InColumnValue("username", "%EMAILADDRESS%")
                          .InColumnValue("authentication", "")
                          .InColumnValue("is_user_data", false)
                          .Identity(0, 0, true);

            var imapServerId = dbManager.ExecuteScalar <int>(insertQuery);


            var selectQuery = new SqlQuery("mail_server_server")
                              .Select("id, smtp_settings_id, imap_settings_id")
                              .SetMaxResults(1);

            var mailServerData = dbManager
                                 .ExecuteList(selectQuery)
                                 .Select(r => new[] { Convert.ToInt32(r[0]), Convert.ToInt32(r[1]), Convert.ToInt32(r[2]) })
                                 .FirstOrDefault();

            var connectionString = Newtonsoft.Json.JsonConvert.SerializeObject(mailServer);

            insertQuery = new SqlInsert("mail_server_server")
                          .InColumnValue("id", 0)
                          .InColumnValue("mx_record", hostname)
                          .InColumnValue("connection_string", connectionString)
                          .InColumnValue("server_type", 2)
                          .InColumnValue("smtp_settings_id", smtpServerId)
                          .InColumnValue("imap_settings_id", imapServerId);

            dbManager.ExecuteNonQuery(insertQuery);

            if (mailServerData != null)
            {
                var deleteQuery = new SqlDelete("mail_server_server")
                                  .Where(Exp.Eq("id", mailServerData[0]));

                dbManager.ExecuteNonQuery(deleteQuery);

                selectQuery = new SqlQuery("mail_mailbox_server")
                              .Select("id_provider")
                              .Where(Exp.Eq("id", mailServerData[1]))
                              .SetMaxResults(1);

                providerId = dbManager
                             .ExecuteList(selectQuery)
                             .Select(r => Convert.ToInt32(r[0]))
                             .FirstOrDefault();

                deleteQuery = new SqlDelete("mail_mailbox_provider")
                              .Where(Exp.Eq("id", providerId));

                dbManager.ExecuteNonQuery(deleteQuery);

                deleteQuery = new SqlDelete("mail_mailbox_server")
                              .Where(Exp.In("id", new[] { mailServerData[1], mailServerData[2] }));

                dbManager.ExecuteNonQuery(deleteQuery);

                selectQuery = new SqlQuery("mail_mailbox")
                              .Select("id")
                              .Where(Exp.Eq("id_smtp_server", mailServerData[1]))
                              .Where(Exp.Eq("id_in_server", mailServerData[2]));

                var mailboxId = dbManager
                                .ExecuteList(selectQuery)
                                .Select(r => Convert.ToInt32(r[0]))
                                .ToArray();

                var updateQuery = new SqlUpdate("mail_mailbox")
                                  .Set("id_smtp_server", smtpServerId)
                                  .Set("id_in_server", imapServerId)
                                  .Where(Exp.In("id", mailboxId));

                dbManager.ExecuteNonQuery(updateQuery);
            }

            transaction.Commit();

            CacheNotify.Publish(new MailServiceHelperCache()
            {
                Key = CacheKey
            }, CacheNotifyAction.Remove);
        }
Пример #5
0
 public void SetTask(DistributedTask task)
 {
     notifyCache.Publish(task.DistributedTaskCache, CacheNotifyAction.InsertOrUpdate);
 }
Пример #6
0
 public void SendNotifyMessage(NotifyMessage m)
 {
     СacheNotify.Publish(m, CacheNotifyAction.InsertOrUpdate);
 }
Пример #7
0
 public void InvokeSendMethod(NotifyInvoke notifyInvoke)
 {
     NotifyInvoke.Publish(notifyInvoke, CacheNotifyAction.InsertOrUpdate);
 }
Пример #8
0
 private static void RemoveFromCache(int contactID)
 {
     cachyNotify.Publish(CreateCacheItem(contactID, "", Size.Empty), CacheNotifyAction.Remove);
 }
Пример #9
0
 internal void Terminate()
 {
     cacheNotify.Publish(GetNotifyKey(), CacheNotifyAction.Remove);
 }
Пример #10
0
 public void RemoveFromCache(string obj)
 {
     notify.Publish(new LinkerCacheItem {
         Obj = obj
     }, CacheNotifyAction.Remove);
 }
Пример #11
0
 public void Clear(string username)
 {
     cacheNotify.Publish(new AccountCacheItem {
         Key = username
     }, CacheNotifyAction.Remove);
 }
Пример #12
0
 public static void ClearCache()
 {
     Notify.Publish(new AscCacheItem(), CacheNotifyAction.Any);
 }
Пример #13
0
 public void Invalidate()
 {
     Notify.Publish(new SharePointProviderCacheItem {
     }, CacheNotifyAction.Remove);
 }
 public AzRecord SaveAce(int tenant, AzRecord r)
 {
     r = service.SaveAce(tenant, r);
     cacheNotify.Publish(r, CacheNotifyAction.InsertOrUpdate);
     return(r);
 }