Example #1
0
 public StorageManager(int tenant, string user, MailBoxManager manager)
 {
     Tenant = tenant;
     User = user;
     Manager = manager;
     _logger = LoggerFactory.GetLogger(LoggerFactory.LoggerType.Log4Net, "ASC.Api");
 }
Example #2
0
        private const string EMPTY_HTML_BODY = "<div dir=\"ltr\"><br></div>"; // GMail style

        public MailSendQueue(MailBoxManager manager, ILogger log)
        {
            this.manager = manager;
            this.log = log;
            if (_signalrServiceClient != null) return;
            var enableSignalr = string.IsNullOrEmpty(ConfigurationManager.AppSettings["web.hub"]) ? "false" : "true";
            _signalrServiceClient = new SignalrServiceClient(enableSignalr);
        }
Example #3
0
        protected List <MailAccountData> GetAccounts()
        {
            var mailBoxManager = new ASC.Mail.Aggregator.MailBoxManager();

            return(mailBoxManager.
                   GetAccountInfo(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID.ToString()).
                   ToAddressData());
        }
 private void EditDocument(int attachment_id, HttpContext context)
 {
     var mail_box_manager = new MailBoxManager(0);
     var file = mail_box_manager.GetMessageAttachment(attachment_id, TenantId, Username);
     var temp_file_url = MailStoragePathCombiner.GetPreSignedUrl(file);
     var editor_url = FilesLinkUtility.GetFileWebEditorExternalUrl(temp_file_url, file.fileName);
     editor_url = new UriBuilder(CommonLinkUtility.GetFullAbsolutePath(editor_url)).ToString();
     context.Response.Redirect(editor_url, false);
 }
 private void ViewDocument(int attachment_id, HttpContext context)
 {
     var mail_box_manager = new MailBoxManager(ConfigurationManager.ConnectionStrings["mail"], 0);
     var file = mail_box_manager.GetMessageAttachment(attachment_id, TenantId, Username);
     var temp_file_url = file.GerPreSignedUrl();
     var viewer_url = CommonLinkUtility.GetFileWebViewerExternalUrl(temp_file_url, file.fileName);
     viewer_url = new UriBuilder(CommonLinkUtility.GetFullAbsolutePath(viewer_url)).ToString();
     context.Response.Redirect(viewer_url, false);
 }
        public MailGarbageEraser(ILogger log = null)
        {
            _log = log ?? new NullLogger();

            _log.Info("Service started");

            _mailBoxManager = new MailBoxManager();

            _garbageManager = new MailGarbageCleanDal(_mailBoxManager);
        }
 private void ViewDocument(int attachmentId, HttpContext context)
 {
     var mailBoxManager = new MailBoxManager();
     var file = mailBoxManager.GetMessageAttachment(attachmentId, TenantId, Username);
     var tempFileUrl = MailStoragePathCombiner.GetPreSignedUrl(file);
     // ToDo GetFileWebViewerExternalUrl last argument need to be reviewed
     var viewerUrl = FilesLinkUtility.GetFileWebViewerExternalUrl(tempFileUrl, file.fileName, "");
     viewerUrl = new UriBuilder(CommonLinkUtility.GetFullAbsolutePath(viewerUrl)).ToString();
     context.Response.Redirect(viewerUrl, false);
 }
        private void DownloadAllZipped(int message_id, HttpContext context)
        {
            var mail_box_manager = new MailBoxManager(ConfigurationManager.ConnectionStrings["mail"], 0);

            var attachments = mail_box_manager.GetMessageAttachments(TenantId, Username, message_id);

            if (attachments.Any())
            {
                using (var zip = new ZipFile())
                {
                    zip.CompressionLevel = CompressionLevel.Level3;
                    zip.AlternateEncodingUsage = ZipOption.AsNecessary;
                    zip.AlternateEncoding = Encoding.GetEncoding(Thread.CurrentThread.CurrentCulture.TextInfo.OEMCodePage);

                    foreach (var attachment in attachments)
                    {
                        using (var file = mail_box_manager.GetAttachmentStream(attachment))
                        {
                            var filename = file.FileName;

                            if (zip.ContainsEntry(filename))
                            {
                                var counter = 1;
                                var temp_name = filename;
                                while (zip.ContainsEntry(temp_name))
                                {
                                    temp_name = filename;
                                    var suffix = " (" + counter + ")";
                                    temp_name = 0 < temp_name.IndexOf('.')
                                                   ? temp_name.Insert(temp_name.LastIndexOf('.'), suffix)
                                                   : temp_name + suffix;

                                    counter++;
                                }
                                filename = temp_name;
                            }

                            zip.AddEntry(filename, file.FileStream.GetCorrectBuffer());
                        }
                    }

                    context.Response.AddHeader("Content-Disposition", ContentDispositionUtil.GetHeaderValue(ARCHIVE_NAME));

                    zip.Save(context.Response.OutputStream);

                }

            }
        }
        private void DownloadFile(int attachment_id, HttpContext context)
        {
            var mail_box_manager = new MailBoxManager(0);

            var auth = context.Request[FilesLinkUtility.AuthKey];

            var open_temp_stream = false;

            if (!string.IsNullOrEmpty(auth))
            {
                var stream = context.Request.QueryString["stream"];

                if (!string.IsNullOrEmpty(stream))
                {
                    int validate_timespan;
                    int.TryParse(WebConfigurationManager.AppSettings["files.stream-url-minute"], out validate_timespan);
                    if (validate_timespan <= 0) validate_timespan = 5;

                    var validate_result = EmailValidationKeyProvider.ValidateEmailKey(attachment_id + stream, auth, TimeSpan.FromMinutes(validate_timespan));
                    if (validate_result != EmailValidationKeyProvider.ValidationResult.Ok)
                    {
                        var exc = new HttpException((int)HttpStatusCode.Forbidden, "You don't have enough permission to perform the operation");
                        //Global.Logger.Error(string.Format("{0} {1}: {2}", CommonLinkUtility.AuthKey, validateResult, context.Request.Url), exc);
                        throw exc;
                    }

                    open_temp_stream = true;
                }
            }

            using (var file = open_temp_stream
                                  ? mail_box_manager.GetAttachmentStream(attachment_id, TenantId)
                                  : mail_box_manager.GetAttachmentStream(attachment_id, TenantId, Username))
            {
                context.Response.AddHeader("Content-Disposition", ContentDispositionUtil.GetHeaderValue(file.FileName));
                file.FileStream.StreamCopyTo(context.Response.OutputStream);
            }
        }
Example #10
0
 public MailSendQueue(MailBoxManager manager)
 {
     _manager = manager;
 }
Example #11
0
        static void Main(string[] args)
        {
            Console.WriteLine(".Begin");

            var parse_path = @"../../XmlData";

            try
            {
                var manger = new MailBoxManager(25);

                var list_of_config = new List<clientConfig>();

                if (args != null && args.Any())
                {
                    parse_path = args[0];
                }

                Console.WriteLine("\r\nParser path: '{0}'", parse_path);

                if (File.GetAttributes(parse_path) == FileAttributes.Directory)
                {
                    var parse_path_info = new DirectoryInfo(parse_path);

                    var files = parse_path_info.GetFiles();

                    Console.WriteLine("\r\n{0} file(s) found!", files.Count());
                    Console.WriteLine("");

                    var index = 0;
                    var count = files.Count();

                    files
                        .ToList()
                        .ForEach(f =>
                        {
                            if (f.Attributes == FileAttributes.Directory) return;
                            clientConfig obj;
                            if (!ParseXml(f.FullName, out obj)) return;
                            Console.SetCursorPosition(0, Console.CursorTop);
                            Console.Write("                                 ");
                            Console.SetCursorPosition(0, Console.CursorTop);
                            Console.Write("{0} from {1}", ++index, count);
                            list_of_config.Add(obj);
                        });
                    Console.WriteLine("");
                }
                else
                {
                    Console.WriteLine("\r\n1 file found!");

                    clientConfig obj;
                    if (ParseXml(parse_path, out obj))
                    {
                        list_of_config.Add(obj);
                    }
                }

                Console.WriteLine("\r\n{0} config(s) parsed!", list_of_config.Count);

                if (list_of_config.Count > 0)
                {
                    do
                    {
                        Console.Write("\r\nDo you want add configs to DB? [y, n]: ");
                        var info = Console.ReadKey();
                        if (info.Key == ConsoleKey.Y)
                        {
                            var index = 0;
                            var count = list_of_config.Count;
                            
                            Console.WriteLine("\r\n");

                            list_of_config.ForEach(c =>
                            {
                                Console.Write("{0} from {1}", ++index, count);

                                if (!manger.SetMailBoxSettings(c)) return;
                                if (index >= count) return;
                                Console.SetCursorPosition(0, Console.CursorTop);
                                Console.Write("                                 ");
                                Console.SetCursorPosition(0, Console.CursorTop);
                            });

                            Console.WriteLine("\r\n");
                            Console.WriteLine("{0} config(s) added to DB!", list_of_config.Count);
                            Console.WriteLine("");
                            break;
                        }
                        if (info.Key != ConsoleKey.N) continue;
                        Console.WriteLine("\r\n");
                        break;
                    } while (true);
                }

            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Such path not exists: '{0}'", parse_path);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine(".End");
            Console.ReadKey();
        }
        public List<MailAttachment> ChangeEmbededAttachmentLinksForStoring(int tenant, string username, int mail_id, MailBoxManager manager)
        {
            //Todo: This method can be separated in two
            var fck_storage = StorageManager.GetDataStoreForCkImages(tenant);
            var attachment_storage = StorageManager.GetDataStoreForAttachments(tenant);

            var current_mail_fckeditor_url = fck_storage.GetUri(StorageManager.CkeditorImagesDomain, "").ToString();
            var current_mail_attachment_folder_url = GetThisMailFolder(username);
            var current_user_storage_url = GetUserFolder(username);
            _logger.Info("ChangeEmbededAttachmentLinksForStoring() Fckeditor storage base url: {0}", current_mail_fckeditor_url);
            _logger.Info("ChangeEmbededAttachmentLinksForStoring() Current mail attachment folder storage base url: {0}", current_mail_attachment_folder_url);
            _logger.Info("ChangeEmbededAttachmentLinksForStoring() Current user folder storage base url: {0}", current_user_storage_url);

            var xpath_query = StorageManager.GetXpathQueryForAttachmentsToResaving(current_mail_fckeditor_url, current_mail_attachment_folder_url, current_user_storage_url);
            _logger.Info("ChangeEmbededAttachmentLinksForStoring() Xpath Query selector for embedded attachment links: {0}", xpath_query);
            var attachments_for_saving = new List<MailAttachment>();

            var doc = new HtmlDocument();
            doc.LoadHtml(HtmlBody);
            
            var link_nodes = doc.DocumentNode.SelectNodes(xpath_query);

            if (link_nodes != null)
            {
                foreach (var link_node in link_nodes)
                {
                    try
                    {
                        var link = link_node.Attributes["src"].Value;

                        _logger.Info("ChangeEmbededAttachmentLinksForStoring() Original selected file_link: {0}", link);

                        var is_fck_image = link.StartsWith(current_mail_fckeditor_url);
                        var prefix_length = is_fck_image
                                                ? current_mail_fckeditor_url.Length
                                                : link.IndexOf(current_user_storage_url, StringComparison.Ordinal) +
                                                  current_user_storage_url.Length + 1;
                        var file_link = HttpUtility.UrlDecode(link.Substring(prefix_length));

                        var file_name = Path.GetFileName(file_link);
                        var attach = CreateEmbbededAttachment(file_name, link, file_link, username, tenant);

                        var saved_attachment_id = manager.GetAttachmentId(mail_id, attach.contentId);
                        var attachment_was_saved = saved_attachment_id != 0;
                        var current_img_storage = is_fck_image ? fck_storage : attachment_storage;
                        var domain = is_fck_image ? StorageManager.CkeditorImagesDomain : username;

                        if (mail_id == 0 || !attachment_was_saved)
                        {
                            attach.data = StorageManager.LoadDataStoreItemData(domain, file_link, current_img_storage);
                            //TODO: Add quota if needed
                            manager.StoreAttachmentWithoutQuota(tenant, username, attach);
                            attachments_for_saving.Add(attach);
                        }

                        if (attachment_was_saved)
                        {
                            attach = manager.GetMessageAttachment(saved_attachment_id, tenant, username);
                            var path = MailStoragePathCombiner.GerStoredFilePath(attach);
                            current_img_storage = attachment_storage;
                            attach.storedFileUrl = current_img_storage.GetUri("", path).ToString();
                        }

                        _logger.Info("ChangeEmbededAttachmentLinksForStoring() Restored new file_link: {0}",
                                     attach.storedFileUrl);
                        link_node.SetAttributeValue("src", attach.storedFileUrl);

                    }
                    catch (Exception ex)
                    {
                        _logger.Error("ChangeEmbededAttachmentLinksForStoring() failed with exception: {0}", ex.ToString());
                    }
                }

                HtmlBody = doc.DocumentNode.OuterHtml;
            }

            return attachments_for_saving;
        }
        private const string EmptyHtmlBody = "<div dir=\"ltr\"><br></div>"; // GMail style

        public MailSendQueue(MailBoxManager manager, ILogger log, IEnumerable<MessageHandlerBase> message_handlers)
        {
            this.manager = manager;
            this.log = log;
            this.message_handlers = message_handlers;
        }
 public void Initialize(MailBoxManager mgr, string aggregator_ip)
 {
     _mgr = mgr;
     _aggregator_ip = aggregator_ip;
 }
Example #15
0
        public List<MailAttachment> ChangeEmbededAttachmentLinksForStoring(int tenant, string user, int mailId, MailBoxManager manager)
        {
            //Todo: This method can be separated in two
            var fckStorage = StorageManager.GetDataStoreForCkImages(tenant);
            var attachmentStorage = StorageManager.GetDataStoreForAttachments(tenant);

            var currentMailFckeditorUrl = fckStorage.GetUri(StorageManager.CKEDITOR_IMAGES_DOMAIN, "").ToString();
            var currentMailAttachmentFolderUrl = MailStoragePathCombiner.GetMessageDirectory(user, StreamId);
            var currentUserStorageUrl = MailStoragePathCombiner.GetUserMailsDirectory(user);
            _logger.Info("ChangeEmbededAttachmentLinksForStoring() Fckeditor storage base url: {0}", currentMailFckeditorUrl);
            _logger.Info("ChangeEmbededAttachmentLinksForStoring() Current mail attachment folder storage base url: {0}", currentMailAttachmentFolderUrl);
            _logger.Info("ChangeEmbededAttachmentLinksForStoring() Current user folder storage base url: {0}", currentUserStorageUrl);

            var xpathQuery = StorageManager.GetXpathQueryForAttachmentsToResaving(currentMailFckeditorUrl, currentMailAttachmentFolderUrl, currentUserStorageUrl);
            _logger.Info("ChangeEmbededAttachmentLinksForStoring() Xpath Query selector for embedded attachment links: {0}", xpathQuery);
            var attachmentsForSaving = new List<MailAttachment>();

            var doc = new HtmlDocument();
            doc.LoadHtml(HtmlBody);

            var linkNodes = doc.DocumentNode.SelectNodes(xpathQuery);

            if (linkNodes != null)
            {
                foreach (var linkNode in linkNodes)
                {
                    try
                    {
                        var link = linkNode.Attributes["src"].Value;

                        _logger.Info("ChangeEmbededAttachmentLinksForStoring() Original selected file_link: {0}", link);

                        var isFckImage = link.StartsWith(currentMailFckeditorUrl);
                        var prefixLength = isFckImage
                                                ? currentMailFckeditorUrl.Length
                                                : link.IndexOf(currentUserStorageUrl, StringComparison.Ordinal) +
                                                  currentUserStorageUrl.Length + 1;
                        var fileLink = HttpUtility.UrlDecode(link.Substring(prefixLength));

                        var fileName = Path.GetFileName(fileLink);
                        var attach = CreateEmbbededAttachment(fileName, link, fileLink, user, tenant, MailboxId);

                        var savedAttachmentId = manager.GetAttachmentId(mailId, attach.contentId);
                        var attachmentWasSaved = savedAttachmentId != 0;
                        var currentImgStorage = isFckImage ? fckStorage : attachmentStorage;
                        var domain = isFckImage ? StorageManager.CKEDITOR_IMAGES_DOMAIN : user;

                        if (mailId == 0 || !attachmentWasSaved)
                        {
                            attach.data = StorageManager.LoadDataStoreItemData(domain, fileLink, currentImgStorage);
                            manager.StoreAttachmentWithoutQuota(tenant, user, attach);
                            attachmentsForSaving.Add(attach);
                        }

                        if (attachmentWasSaved)
                        {
                            attach = manager.GetMessageAttachment(savedAttachmentId, tenant, user);
                            var path = MailStoragePathCombiner.GerStoredFilePath(attach);
                            currentImgStorage = attachmentStorage;
                            attach.storedFileUrl =
                                MailStoragePathCombiner.GetStoredUrl(currentImgStorage.GetUri(path));
                        }

                        _logger.Info("ChangeEmbededAttachmentLinksForStoring() Restored new file_link: {0}",
                                     attach.storedFileUrl);
                        linkNode.SetAttributeValue("src", attach.storedFileUrl);
                    }
                    catch(Exception ex)
                    {
                        _logger.Error("ChangeEmbededAttachmentLinksForStoring() failed with exception: {0}", ex.ToString());
                    }
                }

                HtmlBody = doc.DocumentNode.OuterHtml;
            }

            return attachmentsForSaving;
        }
Example #16
0
        public List<MailAttachment> ChangeEmbededAttachmentLinksForStoring(int tenant, string username, int mail_id, MailBoxManager manager)
        {
            //Todo: This method can be separated in two
            var fck_storage = GetDataStoreForFckImages(tenant);
            var attachment_storage = GetDataStoreForAttachments(tenant);
            
            var current_mail_fckeditor_url = fck_storage.GetUri(EMBEDDED_DOMAIN, "").ToString();
            var current_mail_attachment_folder_url = GetThisMailFolder(username);
            var current_user_storage_url = GetUserFolder(username);

            var xpath_query = GetXpathQueryForAttachmentsToResaving(current_mail_fckeditor_url, current_mail_attachment_folder_url, current_user_storage_url);
            var attachments_for_saving = new List<MailAttachment>();

            var doc = new HtmlDocument();
            doc.LoadHtml(HtmlBody);
            
            var link_nodes = doc.DocumentNode.SelectNodes(xpath_query);

            if (link_nodes != null)
            {
                foreach (var link_node in link_nodes)
                {
                    var link = link_node.Attributes["src"].Value;
                    var is_fck_image = link.StartsWith(current_mail_fckeditor_url);
                    var prefix_length = is_fck_image ? current_mail_fckeditor_url.Length 
                                                     : link.IndexOf(current_user_storage_url, StringComparison.Ordinal) + current_user_storage_url.Length + 1;
                    var file_link = HttpUtility.UrlDecode(link.Substring(prefix_length));

                    var file_name = Path.GetFileName(file_link);
                    var attach = CreateEmbbededAttachment(file_name, link, file_link, username, tenant);

                    var saved_attachment_id = manager.GetAttachmentId(mail_id, attach.contentId);
                    var attachment_was_saved = saved_attachment_id != 0;
                    var current_img_storage = is_fck_image ? fck_storage : attachment_storage;
                    var domain = is_fck_image ? EMBEDDED_DOMAIN : username;

                    if (mail_id == 0 || !attachment_was_saved)
                    {
                        LoadAttachmentData(attach, domain, file_link, current_img_storage);
                        //TODO: Add quota if needed
                        manager.StoreAttachmentWithoutQuota(tenant, username, attach);
                        attachments_for_saving.Add(attach);
                    }

                    if (attachment_was_saved)
                    {
                        attach = manager.GetMessageAttachment(saved_attachment_id, tenant, username);
                        var path = attach.GerStoredFilePath();
                        current_img_storage = attachment_storage;
                        attach.storedFileUrl = current_img_storage.GetUri("", path).ToString();
                    }

                    link_node.SetAttributeValue("src", attach.storedFileUrl);
                }

                HtmlBody = doc.DocumentNode.OuterHtml;
            }

            return attachments_for_saving;
        }
Example #17
0
        public void SendUnreadUser(int tenant, string userId)
        {
            try
            {
                int count = 0;
                var MailBoxManager =
                    new MailBoxManager(LoggerFactory.GetLogger(LoggerFactory.LoggerType.Log4Net, "SignalrService"));

                List<MailBoxManager.MailFolderInfo> mailFolderInfos =
                    MailBoxManager.GetFoldersList(tenant, userId, true);
                foreach (var mailFolderInfo in mailFolderInfos)
                {
                    if (mailFolderInfo.id == MailFolder.Ids.inbox)
                    {
                        count = mailFolderInfo.unread;
                        break;
                    }
                }
                CoreContext.TenantManager.SetCurrentTenant(tenant);
                var userInfo = CoreContext.UserManager.GetUsers(Guid.Parse(userId));
                if (userInfo.ID != Constants.LostUser.ID)
                {
                    // sendMailsCount
                    countersContext.Clients.Group(tenant + userInfo.UserName.ToLowerInvariant()).uf(count);
                }
            }
            catch (Exception e)
            {
                Chat.TraceMessage(Chat.TraceError, string.Format("Unknown Error. {0}, {1}, {2}", e.ToString(),
                    e.StackTrace, e.InnerException != null ? e.InnerException.Message : string.Empty));
            }
        }
Example #18
0
 protected List<MailAccountData> GetAccounts()
 {
     var mailBoxManager = new ASC.Mail.Aggregator.MailBoxManager();
     return mailBoxManager.
         GetAccountInfo(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID.ToString()).
         ToAddressData();
 }
Example #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor()) // Redirect to home page if user hasn't permissions or not authenticated.
            {
                Response.Redirect("/");
            }
            Accounts = GetAccounts();
            MailAccountData        defaultAccount;
            List <MailAccountData> commonAccounts;
            List <MailAccountData> serverAccounts;
            List <MailAccountData> aliases;
            List <MailAccountData> groups;

            Accounts.GetNeededAccounts(out defaultAccount, out commonAccounts, out serverAccounts, out aliases, out groups);
            DefaultAccount = defaultAccount;
            CommonAccounts = commonAccounts;
            ServerAccounts = serverAccounts;
            Aliases        = aliases;
            Groups         = groups;
            _manageFieldPopup.Options.IsPopup = true;
            _commonPopup.Options.IsPopup      = true;

            Page.Title = HeaderStringHelper.GetPageTitle(Resources.MailResource.MailTitle);

            ProductEntryPoint.ConfigurePortal();

            loaderHolder.Controls.Add(LoadControl(LoaderPage.Location));

            MailSidePanelContainer.Controls.Add(LoadControl(TagBox.Location));

            MailControlContainer.Controls.Add(LoadControl(MailBox.Location));

            var help_center = (HelpCenter)LoadControl(HelpCenter.Location);

            help_center.IsSideBar = true;
            sideHelpCenter.Controls.Add(help_center);

            SupportHolder.Controls.Add(LoadControl(Support.Location));
            VideoGuides.Controls.Add(LoadControl(VideoGuidesControl.Location));
            UserForumHolder.Controls.Add(LoadControl(UserForum.Location));
            InviteUserHolder.Controls.Add(LoadControl(InviteLink.Location));

            PeopleGroupLocalize.Text = CustomNamingPeople.Substitute <Resources.MailResource>("FilterByGroup");

            // If user doesn't have any mailboxes this will showed.
            var mail_box_manager = new ASC.Mail.Aggregator.MailBoxManager();

            if (!mail_box_manager.HasMailboxes(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID.ToString()))
            {
                BlankModalPH.Controls.Add(LoadControl(BlankModal.Location));
            }

            if (!IsCrmAvailable())
            {
                crmContactsContainer.Visible = false;
            }

            if (!IsPeopleAvailable())
            {
                tlContactsContainer.Visible = false;
            }

            Page.RegisterBodyScripts(LoadControl(VirtualPathUtility.ToAbsolute("~/addons/mail/masters/BodyScripts.ascx")));
            Page.RegisterStyleControl(LoadControl(VirtualPathUtility.ToAbsolute("~/addons/mail/masters/Styles.ascx")));
            Page.RegisterClientLocalizationScript(typeof(Masters.ClientScripts.ClientLocalizationResources));
            Page.RegisterClientLocalizationScript(typeof(Masters.ClientScripts.ClientTemplateResources));

            Master.DisabledHelpTour = true;

            Page.RegisterInlineScript(BuildErrorConstants());

            Page.RegisterInlineScript(BuildAlertTypes());
        }
Example #20
0
 private static MailBox GetMailBox(int mailboxId)
 {
     var manager = new MailBoxManager();
     return manager.GetMailBox(mailboxId);
 }
 public MailItemManager(MailBoxManager mailBoxManager)
 {
     if (mailBoxManager == null) throw new ArgumentNullException("mailBoxManager");
     this.mailBoxManager = mailBoxManager;
     _log = LogManager.GetLogger("MailItemManager");
 }
Example #22
0
        private static MailBox CreateAccountSimple(string email, string password)
        {
            var begin_date = DateTime.Now.Subtract(new TimeSpan(MailBox.DefaultMailLimitedTimeDelta));

            var mail_box_manager = new MailBoxManager(30);
            try
            {
                Logger.Info("Search mailbox settings:");
                var mbox = mail_box_manager.SearchMailboxSettings(email, password, "", 0);

                Logger.Info("Account: " + mbox.Account + "; Password: "******"Imap: " + mbox.Imap + "; Server: " + mbox.Server + "; Port: " + mbox.Port +
                            "; AuthenticationType: " + mbox.AuthenticationTypeIn + "; EncryptionType: " + mbox.IncomingEncryptionType);
                Logger.Info("SmtpServer: " + mbox.SmtpServer + "; SmtpPort: " + mbox.SmtpPort + "; AuthenticationType: " 
                    + mbox.AuthenticationTypeSmtp + "; OutcomingEncryptionType: " + mbox.OutcomingEncryptionType);

                mbox.BeginDate = begin_date; // Apply restrict for download

                MailServerHelper.Test(mbox);

                return mbox;
            }
            catch (ImapConnectionException ex_imap)
            {
                if (ex_imap is ImapConnectionTimeoutException)
                    Logger.Info("ImapConnectionTimeoutException: " + ex_imap.Message);
                else Logger.Info("ImapConnectionException: " + ex_imap.Message);
            }
            catch (Pop3ConnectionException ex_pop)
            {
                if (ex_pop is Pop3ConnectionTimeoutException)
                    Logger.Info("Pop3ConnectionTimeoutException: " + ex_pop.Message);
                else Logger.Info("Pop3ConnectionException: " + ex_pop.Message);
            }
            catch (SmtpConnectionException ex_smtp)
            {
                if (ex_smtp is SmtpConnectionTimeoutException)
                    Logger.Info("SmtpConnectionTimeoutException: " + ex_smtp.Message);
                else Logger.Info("SmtpConnectionException: " + ex_smtp.Message);
            }
            catch (Exception ex)
            {
                Logger.Info("Exception: " + ex.Message);
            }
            throw new Exception();
        }
Example #23
0
 public Service()
 {
     mailBoxManager = new MailBoxManager(ConfigurationManager.ConnectionStrings["mail"], 25);
     mailSendQueue = new MailSendQueue(mailBoxManager);
 }
Example #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor()) // Redirect to home page if user hasn't permissions or not authenticated.
            {
                Response.Redirect("/");
            }
            Accounts = GetAccounts();
            MailAccountData defaultAccount;
            List<MailAccountData> commonAccounts;
            List<MailAccountData> serverAccounts;
            List<MailAccountData> aliases;
            List<MailAccountData> groups;
            Accounts.GetNeededAccounts(out defaultAccount, out commonAccounts, out serverAccounts, out aliases, out groups);
            DefaultAccount = defaultAccount;
            CommonAccounts = commonAccounts;
            ServerAccounts = serverAccounts;
            Aliases = aliases;
            Groups = groups;
            _manageFieldPopup.Options.IsPopup = true;
            _commonPopup.Options.IsPopup = true;

            Page.Title = HeaderStringHelper.GetPageTitle(Resources.MailResource.MailTitle);

            ProductEntryPoint.ConfigurePortal();

            loaderHolder.Controls.Add(LoadControl(LoaderPage.Location));

            MailSidePanelContainer.Controls.Add(LoadControl(TagBox.Location));

            MailControlContainer.Controls.Add(LoadControl(MailBox.Location));

            var help_center = (HelpCenter)LoadControl(HelpCenter.Location);
            help_center.IsSideBar = true;
            sideHelpCenter.Controls.Add(help_center);

            SupportHolder.Controls.Add(LoadControl(Support.Location));
            VideoGuides.Controls.Add(LoadControl(VideoGuidesControl.Location));
            UserForumHolder.Controls.Add(LoadControl(UserForum.Location));
            InviteUserHolder.Controls.Add(LoadControl(InviteLink.Location));

            PeopleGroupLocalize.Text = CustomNamingPeople.Substitute<Resources.MailResource>("FilterByGroup");

            // If user doesn't have any mailboxes this will showed.
            var mail_box_manager = new ASC.Mail.Aggregator.MailBoxManager();
            if (!mail_box_manager.HasMailboxes(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID.ToString()))
                BlankModalPH.Controls.Add(LoadControl(BlankModal.Location));

            if (!IsCrmAvailable())
            {
                crmContactsContainer.Visible = false;
            }

            if (!IsPeopleAvailable())
            {
                tlContactsContainer.Visible = false;
            }

            Page.RegisterBodyScripts(LoadControl(VirtualPathUtility.ToAbsolute("~/addons/mail/masters/BodyScripts.ascx")));
            Page.RegisterStyleControl(LoadControl(VirtualPathUtility.ToAbsolute("~/addons/mail/masters/Styles.ascx")));
            Page.RegisterClientLocalizationScript(typeof(Masters.ClientScripts.ClientLocalizationResources));
            Page.RegisterClientLocalizationScript(typeof(Masters.ClientScripts.ClientTemplateResources));

            Master.DisabledHelpTour = true;

            Page.RegisterInlineScript(BuildErrorConstants());

            Page.RegisterInlineScript(BuildAlertTypes());
        }