Ejemplo n.º 1
0
        /// <summary>
        /// Gets the POP3 box list.
        /// </summary>
        /// <returns></returns>
        public Pop3Box[] GetPop3BoxList()
        {
            ArrayList list = new ArrayList();

            using (IDataReader reader = DBPop3Box.GetList())
            {
                Pop3Box box   = null;
                int     boxId = -1;
                while (reader.Read())
                {
                    if (boxId != (int)reader["Pop3BoxId"])
                    {
                        if (box != null)
                        {
                            box.Handlers.ResetModified();
                        }

                        box = new Pop3Box(reader);
                        list.Add(box);
                    }
                    if (reader["HandlerName"] != DBNull.Value)
                    {
                        box.AddHandler(_config.Handlers[(string)reader["HandlerName"]]);
                    }
                }
            }
            return((Pop3Box[])list.ToArray(typeof(Pop3Box)));
        }
Ejemplo n.º 2
0
 public int GetPop3BoxPropertyValue(Pop3Box box, string name)
 {
     if (box.Parameters[name] != null)
         return int.Parse(box.Parameters[name]);
     else
         return 0;
 }
Ejemplo n.º 3
0
 public string GetPop3BoxHandlerName(Pop3Box box)
 {
     if (box.Handlers.Count > 0)
         return box.Handlers[0].Name;
     else
         return "none";
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the POP3 box.
        /// </summary>
        /// <param name="box">The box.</param>
        /// <returns></returns>
        public Pop3Box UpdatePop3Box(Pop3Box box)
        {
            if (box.IsBoxModified())
            {
                using (DbTransaction tra = DbTransaction.Begin())
                {
                    int BoxId = box.Id;

                    if (box.Modified)
                    {
                        if (BoxId == -1)
                        {
                            using (IDataReader reader = DBPop3Box.Create(box.Name, box.Server,
                                                                         box.Port, box.Login, box.Password, box.IsActive,
                                                                         box.Interval, box.LastRequest, box.LastSuccessfulRequest,
                                                                         box.LastErrorText, box.AutoKillForRead))
                            {
                                if (reader.Read())
                                {
                                    BoxId = (int)reader["Pop3BoxId"];
                                }
                            }
                        }
                        else
                        {
                            DBPop3Box.Update(BoxId, box.Name, box.Server,
                                             box.Port, box.Login, box.Password, box.IsActive,
                                             box.Interval, box.LastRequest, box.LastSuccessfulRequest,
                                             box.LastErrorText, box.AutoKillForRead);
                        }

                        box.ResetModified();
                    }

                    if (box.Handlers.IsModified)
                    {
                        DBPop3Box.DeleteHandlers(BoxId);

                        foreach (Pop3MessageHandlerInfo info in box.Handlers)
                        {
                            DBPop3Box.CreateHandler(BoxId, info.Name);
                        }
                        box.Handlers.ResetModified();
                    }
                    if (box.Parameters.IsModified)
                    {
                        DBPop3Box.DeleteParameters(BoxId);

                        foreach (string name in box.Parameters.Keys)
                        {
                            DBPop3Box.AddParameter(BoxId, name, box.Parameters[name]);
                        }
                    }

                    tra.Commit();
                }
            }
            return(box);
        }
Ejemplo n.º 5
0
 void IPersistPop3MessageHandlerStorage.Save(Pop3Box box)
 {
     box.Parameters["AutoApproveForKnown"] = cbAutoApprove.Checked?"1":"0";//cbAutoApprove.Checked?"1":"0";
     box.Parameters["OnlyExternalSenders"] = cbUseExternal.Checked?"1":"0";
     box.Parameters["AutoKillForUnknown"] = cbAutoDelete.Checked?"1":"0";
     box.Parameters["SaveMessageBodyAsEml"] = cbSaveMessageBodyAsEml.Checked?"1":"0";
     box.Parameters["SaveMessageBodyAsMsg"] = cbSaveMessageBodyAsMsg.Checked?"1":"0";
     box.Parameters["SaveMessageBodyAsMht"] = cbSaveMessageBodyAsMht.Checked?"1":"0";
 }
Ejemplo n.º 6
0
 public int GetPop3BoxType(Pop3Box box)
 {
     if (box.Handlers.Contains("File.Pop3MessageHandler"))
         return 1;
     else if (box.Handlers.Contains("IssueRequest.Pop3MessageHandler"))
         return 0;
     else
         return -1;
 }
Ejemplo n.º 7
0
 void IPersistPop3MessageHandlerStorage.Load(Pop3Box box)
 {
     cbAutoApprove.Checked=box.Parameters["AutoApproveForKnown"]=="1";
     cbUseExternal.Checked=box.Parameters["OnlyExternalSenders"]=="1";
     cbAutoDelete.Checked=box.Parameters["AutoKillForUnknown"]=="1";
     cbSaveMessageBodyAsEml.Checked=box.Parameters["SaveMessageBodyAsEml"]=="1";
     cbSaveMessageBodyAsMsg.Checked=box.Parameters["SaveMessageBodyAsMsg"]=="1";
     if(box.Parameters["SaveMessageBodyAsMht"] != null)
         cbSaveMessageBodyAsMht.Checked=box.Parameters["SaveMessageBodyAsMht"]=="1";
     else cbSaveMessageBodyAsMht.Checked = true;
 }
Ejemplo n.º 8
0
        public Pop3Parameters(Pop3Box pop3Box)
        {
            _ownerPop3Box = pop3Box;

            using (IDataReader reader = DBPop3Box.GetParameterList(pop3Box.Id))
            {
                while (reader.Read())
                {
                    string name  = (string)reader["Name"];
                    string value = (reader["Value"] == DBNull.Value) ? string.Empty : (string)reader["Value"];

                    Add(name, value);
                }
            }

            _modified = false;
        }
Ejemplo n.º 9
0
        public Pop3Parameters(Pop3Box pop3Box)
        {
            _ownerPop3Box = pop3Box;

            using (IDataReader reader = DBPop3Box.GetParameterList(pop3Box.Id))
            {
                while (reader.Read())
                {
                    string name = (string)reader["Name"];
                    string value = (reader["Value"]==DBNull.Value) ? string.Empty : (string)reader["Value"];

                    Add(name, value);
                }
            }

            _modified = false;
        }
Ejemplo n.º 10
0
        protected virtual FileSettings GetSettings(Pop3Box box)
        {
            FileSettings settings = new FileSettings();

            if (box.Parameters.Contains("ContainerKey"))
            {
                settings.ContainerKey = box.Parameters["ContainerKey"];
            }
            if (box.Parameters.Contains("FolderId"))
            {
                settings.FolderId = int.Parse(box.Parameters["FolderId"]);
            }
            if (box.Parameters.Contains("FolderPattern"))
            {
                settings.FolderPattern = box.Parameters["FolderPattern"].Trim();
            }
            if (box.Parameters.Contains("OnlyExternalSenders"))
            {
                settings.OnlyExternalSenders = str2bool(box.Parameters["OnlyExternalSenders"]);
            }
            if (box.Parameters.Contains("AutoKillForUnknown"))
            {
                settings.AutoKillForUnknown = str2bool(box.Parameters["AutoKillForUnknown"]);
            }
            if (box.Parameters.Contains("SaveMessageBodyAsEml"))
            {
                settings.SaveMessageBodyAsEml = str2bool(box.Parameters["SaveMessageBodyAsEml"]);
            }
            if (box.Parameters.Contains("SaveMessageBodyAsMht"))
            {
                settings.SaveMessageBodyAsMht = str2bool(box.Parameters["SaveMessageBodyAsMht"]);
            }
            if (box.Parameters.Contains("SaveMessageBodyAsMsg"))
            {
                settings.SaveMessageBodyAsMsg = str2bool(box.Parameters["SaveMessageBodyAsMsg"]);
            }
            return(settings);
        }
Ejemplo n.º 11
0
        protected override void OnProcessPop3Message(Pop3Box box, Mediachase.Net.Mail.Pop3Message message)
        {
            try
            {
                // Step 0. Get settings
                FileSettings settings = GetSettings(box);

                // Step 0.5 Create storage
                string containerKey = "Workspace";
                if (settings.ContainerKey != String.Empty)
                {
                    containerKey = settings.ContainerKey;
                }
                BaseIbnContainer baseContainer = BaseIbnContainer.Create("FileLibrary", containerKey);
                FileStorage      storage       = (FileStorage)baseContainer.LoadControl("FileStorage");

                // Step 1. Get Email sender info
                MailAddress from = message.Sender;
                if (from == null)
                {
                    from = message.From;
                }

                // Step 2. Get Ibn User
                int userId = GetUserIdByEmail(from.Address, settings.OnlyExternalSenders);

                if (userId != -1)
                {
                }
                else
                {
                    if (settings.AutoKillForUnknown)
                    {
                        return;
                    }
                }

                // Step 3. Find Folder
                int FolderId = settings.FolderId;
                if (settings.FolderPattern != String.Empty)
                {
                    String FolderName = ValidatePatternPath(ParseFolderPattern(settings.FolderPattern, message, userId));

                    Mediachase.IBN.Business.ControlSystem.DirectoryInfo dirInfo = storage.GetDirectory(FolderId, FolderName, true);
                    if (dirInfo != null)
                    {
                        FolderId = dirInfo.Id;
                    }
                    else
                    {
                        FolderId = -1;
                    }
                }

                // Step 3. Create Files
                AddAttachments(storage, FolderId, message, userId);

                // Step 4. Create EML File
                if (settings.SaveMessageBodyAsEml)
                {
                    UploadEmlFile(storage, FolderId, userId, message);
                }
                // Step 5. Create MHT File
                if (settings.SaveMessageBodyAsMht)
                {
                    UploadMhtFile(storage, FolderId, userId, message);
                }
                // Step 5. Create MSG File
                if (settings.SaveMessageBodyAsMsg)
                {
                    UploadMsgFile(storage, FolderId, userId, message);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex);
                throw;
            }
        }
Ejemplo n.º 12
0
 public void ProcessPop3Message(Pop3Box box, Mediachase.Net.Mail.Pop3Message message)
 {
     OnProcessPop3Message(box, message);
 }
Ejemplo n.º 13
0
 protected virtual void OnProcessPop3Message(Pop3Box box, Mediachase.Net.Mail.Pop3Message message)
 {
 }
Ejemplo n.º 14
0
        protected override void OnProcessPop3Message(Pop3Box box, Mediachase.Net.Mail.Pop3Message message)
        {
            try
            {
                // Step 0. Get settings
                FileSettings settings = GetSettings(box);

                // Step 0.5 Create storage
                string containerKey = "Workspace";
                if (settings.ContainerKey != String.Empty)
                {
                    containerKey = settings.ContainerKey;
                }
                BaseIbnContainer baseContainer = BaseIbnContainer.Create("FileLibrary", containerKey);
                FileStorage storage = (FileStorage)baseContainer.LoadControl("FileStorage");

                // Step 1. Get Email sender info
                MailAddress from = message.Sender;
                if(from == null)
                    from = message.From;

                // Step 2. Get Ibn User
                int userId = GetUserIdByEmail(from.Address, settings.OnlyExternalSenders);

                if (userId != -1)
                {
                }
                else
                {
                    if(settings.AutoKillForUnknown)
                        return;
                }

                // Step 3. Find Folder
                int FolderId = settings.FolderId;
                if (settings.FolderPattern != String.Empty)
                {
                    String FolderName = ValidatePatternPath(ParseFolderPattern(settings.FolderPattern, message, userId));

                    Mediachase.IBN.Business.ControlSystem.DirectoryInfo dirInfo = storage.GetDirectory(FolderId, FolderName, true);
                    if (dirInfo != null)
                    {
                        FolderId = dirInfo.Id;
                    }
                    else FolderId = -1;
                }

                // Step 3. Create Files
                AddAttachments(storage, FolderId, message, userId);

                // Step 4. Create EML File
                if (settings.SaveMessageBodyAsEml)
                {
                    UploadEmlFile(storage, FolderId, userId, message);
                }
                // Step 5. Create MHT File
                if (settings.SaveMessageBodyAsMht)
                {
                    UploadMhtFile(storage, FolderId, userId, message);
                }
                // Step 5. Create MSG File
                if (settings.SaveMessageBodyAsMsg)
                {
                    UploadMsgFile(storage, FolderId, userId, message);
                }
            }
            catch(Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex);
                throw;
            }
        }
Ejemplo n.º 15
0
 public void ProcessPop3Message(Pop3Box box, Mediachase.Net.Mail.Pop3Message message)
 {
     OnProcessPop3Message(box, message);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Updates the POP3 box.
        /// </summary>
        /// <param name="box">The box.</param>
        /// <returns></returns>
        public Pop3Box UpdatePop3Box(Pop3Box box)
        {
            if (box.IsBoxModified())
            {
                using (DbTransaction tra = DbTransaction.Begin())
                {
                    int BoxId = box.Id;

                    if (box.Modified)
                    {
                        if (BoxId == -1)
                        {
                            using (IDataReader reader = DBPop3Box.Create(box.Name, box.Server,
                                        box.Port, box.Login, box.Password, box.IsActive,
                                        box.Interval, box.LastRequest, box.LastSuccessfulRequest,
                                        box.LastErrorText, box.AutoKillForRead))
                            {
                                if (reader.Read())
                                {
                                    BoxId = (int)reader["Pop3BoxId"];
                                }
                            }
                        }
                        else
                        {
                            DBPop3Box.Update(BoxId, box.Name, box.Server,
                                box.Port, box.Login, box.Password, box.IsActive,
                                box.Interval, box.LastRequest, box.LastSuccessfulRequest,
                                box.LastErrorText, box.AutoKillForRead);
                        }

                        box.ResetModified();
                    }

                    if (box.Handlers.IsModified)
                    {
                        DBPop3Box.DeleteHandlers(BoxId);

                        foreach(Pop3MessageHandlerInfo info in box.Handlers)
                        {
                            DBPop3Box.CreateHandler(BoxId, info.Name);
                        }
                        box.Handlers.ResetModified();
                    }
                    if (box.Parameters.IsModified)
                    {
                        DBPop3Box.DeleteParameters(BoxId);

                        foreach(string name in box.Parameters.Keys)
                        {
                            DBPop3Box.AddParameter(BoxId, name, box.Parameters[name]);
                        }
                    }

                    tra.Commit();
                }
            }
            return box;
        }
Ejemplo n.º 17
0
 protected virtual void OnProcessPop3Message(Pop3Box box, Mediachase.Net.Mail.Pop3Message message)
 {
 }
Ejemplo n.º 18
0
        void IPersistPop3MessageHandlerStorage.Load(Pop3Box box)
        {
            cbSaveMessageBodyAsEml.Checked=box.Parameters["SaveMessageBodyAsEml"]=="1";
            cbSaveMessageBodyAsMsg.Checked=box.Parameters["SaveMessageBodyAsMsg"]=="1";
            cbSaveMessageBodyAsMht.Checked=box.Parameters["SaveMessageBodyAsMht"]=="1";
            cbUseExternal.Checked=box.Parameters["OnlyExternalSenders"]=="1";
            cbAutoDelete.Checked=box.Parameters["AutoKillForUnknown"]=="1";

            //txtFolderId.Value = "";
            int iFolderId = -1;
            if(box.Parameters["FolderId"] != null)
            {
                try{iFolderId = int.Parse(box.Parameters["FolderId"]);}
                catch{}
                /*
                if(iFolderId != -1)
                    txtFolderId.Value = iFolderId.ToString();
                */
            }

            dtv.FolderId=iFolderId;

            /*
            txtContainerKey.Value = "";
            txtFolder.Text = "";
            */
            string ContainerKey = "";
            if(box.Parameters["ContainerKey"] != null)
            {
                ContainerKey = box.Parameters["ContainerKey"];
                /*
                txtContainerKey.Value = ContainerKey;

                bic = BaseIbnContainer.Create("FileLibrary", ContainerKey);
                fs = (FileStorage)bic.LoadControl("FileStorage");

                string name = "unknown";
                if(iFolderId==fs.Root.Id)
                {
                    if(ContainerKey.LastIndexOf("_") > 0)
                    {
                        int ProjectId = -1;
                        try
                        {
                            ProjectId = int.Parse(ContainerKey.Substring(ContainerKey.LastIndexOf("_")+1));
                        }
                        catch{}
                        if(ProjectId != -1)
                        {
                            using(IDataReader reader = Project.GetProject(ProjectId))
                            {
                                reader.Read();
                                if(reader["Title"] != null)
                                    name = reader["Title"].ToString();
                            }
                        }
                    }
                    else
                        name = LocRM.GetString("tRoot");
                }
                else
                    name = fs.GetDirectory(iFolderId).Name;

                System.IO.StringWriter writer = new System.IO.StringWriter();
                Server.HtmlDecode(name, writer);
                string decoded = writer.ToString();
                txtFolder.Text = decoded;
                */
            }

            dtv.ContainerKey=ContainerKey;

            if(box.Parameters["FolderPattern"] != null)
                txtFolderPattern.Text = box.Parameters["FolderPattern"];
            else txtFolderPattern.Text = "";
        }
Ejemplo n.º 19
0
        void IPersistPop3MessageHandlerStorage.Save(Pop3Box box)
        {
            box.Parameters["SaveMessageBodyAsEml"] = cbSaveMessageBodyAsEml.Checked?"1":"0";
            box.Parameters["SaveMessageBodyAsMsg"] = cbSaveMessageBodyAsMsg.Checked?"1":"0";
            box.Parameters["SaveMessageBodyAsMht"] = cbSaveMessageBodyAsMht.Checked?"1":"0";
            box.Parameters["OnlyExternalSenders"] = cbUseExternal.Checked?"1":"0";
            box.Parameters["AutoKillForUnknown"] = cbAutoDelete.Checked?"1":"0";

            string ContainerKey = "";
            int iFolderId = -1;
            /*
            ContainerKey = txtContainerKey.Value;
            try
            {
                iFolderId = int.Parse(txtFolderId.Value);
            }
            catch{}
            */

            iFolderId = dtv.FolderId;
            ContainerKey = dtv.ContainerKey;

            if(iFolderId != -1)
                box.Parameters["FolderId"] = iFolderId.ToString();
            if(ContainerKey != "")
                box.Parameters["ContainerKey"] = ContainerKey;

            box.Parameters["FolderPattern"] = txtFolderPattern.Text;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Gets the POP3 box list.
        /// </summary>
        /// <returns></returns>
        public Pop3Box[] GetPop3BoxList()
        {
            ArrayList list = new ArrayList();

            using (IDataReader reader = DBPop3Box.GetList())
            {
                Pop3Box box = null;
                int     boxId = -1;
                while (reader.Read())
                {
                    if (boxId!=(int)reader["Pop3BoxId"])
                    {
                        if(box!=null)
                            box.Handlers.ResetModified();

                        box = new Pop3Box(reader);
                        list.Add(box);
                    }
                    if (reader["HandlerName"]!=DBNull.Value)
                    {
                        box.AddHandler(_config.Handlers[(string)reader["HandlerName"]]);
                    }
                }
            }
            return (Pop3Box[])list.ToArray(typeof(Pop3Box));
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Removes the POP3 box.
 /// </summary>
 /// <param name="box">The box.</param>
 public void RemovePop3Box(Pop3Box box)
 {
     RemovePop3Box(box.Id);
 }
Ejemplo n.º 22
0
        protected virtual FileSettings GetSettings(Pop3Box box)
        {
            FileSettings settings = new FileSettings();

            if (box.Parameters.Contains("ContainerKey")) {
                settings.ContainerKey = box.Parameters["ContainerKey"];
            }
            if (box.Parameters.Contains("FolderId"))
            {
                settings.FolderId = int.Parse(box.Parameters["FolderId"]);
            }
            if (box.Parameters.Contains("FolderPattern"))
            {
                settings.FolderPattern = box.Parameters["FolderPattern"].Trim();
            }
            if (box.Parameters.Contains("OnlyExternalSenders"))
            {
                settings.OnlyExternalSenders = str2bool(box.Parameters["OnlyExternalSenders"]);
            }
            if (box.Parameters.Contains("AutoKillForUnknown"))
            {
                settings.AutoKillForUnknown = str2bool(box.Parameters["AutoKillForUnknown"]);
            }
            if (box.Parameters.Contains("SaveMessageBodyAsEml"))
            {
                settings.SaveMessageBodyAsEml = str2bool(box.Parameters["SaveMessageBodyAsEml"]);
            }
            if (box.Parameters.Contains("SaveMessageBodyAsMht"))
            {
                settings.SaveMessageBodyAsMht = str2bool(box.Parameters["SaveMessageBodyAsMht"]);
            }
            if (box.Parameters.Contains("SaveMessageBodyAsMsg"))
            {
                settings.SaveMessageBodyAsMsg = str2bool(box.Parameters["SaveMessageBodyAsMsg"]);
            }
            return settings;
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Requests the specified boxes.
        /// </summary>
        /// <param name="boxes">The boxes.</param>
        private void Request(Pop3Box[] boxes)
        {
            DateTime current = DateTime.Now;
            foreach(Pop3Box box in boxes)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("Request mails from: {0}. IsActive = {1}. LastRequest = {2}. Interval = {3}", box.Name, box.IsActive, box.LastRequest, box.Interval));

                // OZ [2009-05-05]: Skip Read Maindler if handler not set
                if (box.Handlers.Count >0 &&
                    box.IsActive &&
                    current >= box.LastRequest.AddMinutes(box.Interval))
                {
                    box.Request();
                }
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Removes the POP3 box.
 /// </summary>
 /// <param name="box">The box.</param>
 public void RemovePop3Box(Pop3Box box)
 {
     RemovePop3Box(box.Id);
 }