예제 #1
0
 public static void DelMailBoxInstruct(string dName, string uName)
 {
     try
     {
         XMLayer xm = new XMLayer();
         xm = XMServer.CreateXMLayer();
         string raw       = string.Empty;
         string line      = string.Empty;
         string res_lines = string.Empty;
         xm.Login();
         raw = xm.GetMailProcTab(dName, uName);
         StringWriter sw = new StringWriter();
         using (StringReader sr = new StringReader(raw))
         {
             while ((line = sr.ReadLine()) != null)
             {
                 if (!line.Contains("mailbox"))
                 {
                     sw.WriteLine(line);
                 }
             }
         }
         xm.SetMailProcTab(dName, uName, sw.ToString());
         xm.Logout();
     }
     catch (Exception error)
     {
         Log.WriteException(error);
     }
 }
예제 #2
0
 public static void AdvancedSaveChanges(string domainName, string userName, string Advanced)
 {
     try
     {
         XMLayer xm = new XMLayer();
         xm = XMServer.CreateXMLayer();
         xm.Login();
         string data = XMUser.GetMailProcTab(domainName, userName)[0];
         data += Advanced.Trim();
         data += "\r\n.\r\n";
         xm.SetMailProcTab(domainName, userName, data);
         xm.Logout();
     }
     catch (Exception error)
     {
         Log.WriteException(error);
         throw;
     }
 }
예제 #3
0
 public static void SetMailBoxInstruct(string dName, string uName)
 {
     try
     {
         XMLayer xm = new XMLayer();
         xm = XMServer.CreateXMLayer();
         string raw = "";
         xm.Login();
         try
         {
             raw = xm.GetMailProcTab(dName, uName);
         }
         catch (XMailAdminProxy.XMailException)
         { }
         raw = "\"mailbox\"\r\n" + raw;
         xm.SetMailProcTab(dName, uName, raw);
         xm.Logout();
     }
     catch (Exception error)
     {
         Log.WriteException(error);
     }
 }
예제 #4
0
    public static void AddDeleteRedirections(string domainName, string userName, string command, string element)
    {
        try
        {
            string   data = "";
            string[] mailProcTabData;
            mailProcTabData = XMUser.GetMailProcTab(domainName, userName);

            string line;
            string head = "";

            string redirection  = "";
            string lredirection = "";

            bool noRedirection  = true;
            bool noLRedirection = true;

            string[]     id;
            int          lineIndex;
            StringReader reader = new StringReader(mailProcTabData[0]);
            switch (command)
            {
            case "AddToRedirection":
            case "AddToLRedirection":
                lineIndex = 0;
                while ((line = reader.ReadLine()) != null)
                {
                    lineIndex++;
                    id   = XMUser.extractMailProc(line);
                    line = line.Trim();
                    switch (id[0])
                    {
                    case "mailbox":
                        head = line + "\r\n";
                        break;

                    case "redirect":
                        noRedirection = false;
                        if (command == "AddToRedirection")
                        {
                            redirection = line + '\t' + '\"' + element + '\"' + "\r\n";
                        }
                        else
                        {
                            redirection = line + "\r\n";
                        }
                        break;

                    case "lredirect":
                        noLRedirection = false;
                        if (command == "AddToLRedirection")
                        {
                            lredirection = line + '\t' + '\"' + element + '\"' + "\r\n";
                        }
                        else
                        {
                            lredirection = line + "\r\n";
                        }
                        break;

                    default:
                        break;
                    }
                }

/*                    if (head == "")
 *                      head = '\"' + "mailbox" + '\"' + "\r\n";
 */
                if (noRedirection)
                {
                    if (command == "AddToRedirection")
                    {
                        redirection = "redirect" + '\t' + '\"' + element + '\"' + "\r\n";
                    }
                }
                if (noLRedirection)
                {
                    if (command == "AddToLRedirection")
                    {
                        lredirection = "lredirect" + '\t' + '\"' + element + '\"' + "\r\n";
                    }
                }
                break;

            case "DeleteRedirection":
            case "DeleteLRedirection":
                lineIndex = 0;
                while ((line = reader.ReadLine()) != null)
                {
                    lineIndex++;
                    id   = XMUser.extractMailProc(line);
                    line = line.Trim();
                    switch (id[0])
                    {
                    case "mailbox":
                        head = line + "\r\n";
                        break;

                    case "redirect":
                        if (command == "DeleteRedirection")
                        {
                            int    index  = line.IndexOf(element);
                            string before = line.Substring(0, index - 2);
                            string after  = line.Substring(index + 1 + element.Length);
                            redirection = before + after + "\r\n";
                            if (redirection.Length == 10)
                            {
                                redirection = "";
                            }
                        }
                        else
                        {
                            redirection = line + "\r\n";
                        }
                        break;

                    case "lredirect":
                        if (command == "DeleteLRedirection")
                        {
                            int    index  = line.IndexOf(element);
                            string before = line.Substring(0, index - 2);
                            string after  = line.Substring(index + 1 + element.Length);
                            lredirection = before + after + "\r\n";
                            if (lredirection.Length == 11)
                            {
                                lredirection = "";
                            }
                        }
                        else
                        {
                            lredirection = line + "\r\n";
                        }
                        break;

                    default:
                        break;
                    }
                }
                break;

            default:
                break;
            }
            data = head + redirection + lredirection + mailProcTabData[1];
            XMLayer xm = new XMLayer();
            xm = XMServer.CreateXMLayer();
            xm.Login();
            xm.SetMailProcTab(domainName, userName, data);
            xm.Logout();
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            throw;
        }
    }