Exemplo n.º 1
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;
     }
 }
Exemplo n.º 2
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;
        }
    }