/// <summary> /// Deletes specified action from user message rule. /// </summary> /// <param name="action">Action to remove.</param> public void Remove(UserMessageRuleActionBase action) { /* DeleteUserMessageRuleAction <virtualServerID> "<ruleID>" "<actionID>" * Responses: +OK * -ERR <errorText> */ string id = Guid.NewGuid().ToString(); // Call TCP DeleteUserMessageRuleAction m_pRule.Owner.VirtualServer.Server.TcpClient.TcpStream.WriteLine("DeleteUserMessageRuleAction " + m_pRule.Owner.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(m_pRule.Owner.Owner.UserID) + " " + TextUtils.QuoteString(m_pRule.ID) + " " + TextUtils.QuoteString(action.ID) ); string response = m_pRule.Owner.VirtualServer.Server.ReadLine(); if (!response.ToUpper().StartsWith("+OK")) { throw new Exception(response); } m_pActions.Remove(action); }
/// <summary> /// Adds specified action to user message rule. /// </summary> /// <param name="action">Action to add.</param> private void Add(UserMessageRuleActionBase action) { Add(action.ID,action.Description,action.ActionType,action.Serialize(),false); }
/// <summary> /// Deletes specified action from user message rule. /// </summary> /// <param name="action">Action to remove.</param> public void Remove(UserMessageRuleActionBase action) { /* DeleteUserMessageRuleAction <virtualServerID> "<ruleID>" "<actionID>" Responses: +OK -ERR <errorText> */ string id = Guid.NewGuid().ToString(); // Call TCP DeleteUserMessageRuleAction m_pRule.Owner.VirtualServer.Server.Socket.WriteLine("DeleteUserMessageRuleAction " + m_pRule.Owner.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(m_pRule.Owner.Owner.UserID) + " " + TextUtils.QuoteString(m_pRule.ID) + " " + TextUtils.QuoteString(action.ID) ); string response = m_pRule.Owner.VirtualServer.Server.Socket.ReadLine(); if(!response.ToUpper().StartsWith("+OK")){ throw new Exception(response); } m_pActions.Remove(action); }
/// <summary> /// Adds specified action to user message rule. /// </summary> /// <param name="action">Action to add.</param> private void Add(UserMessageRuleActionBase action) { Add(action.ID, action.Description, action.ActionType, action.Serialize(), false); }
private void m_Ok_Click(object sender, EventArgs e) { #region AutoResponse if(m_pAction.SelectedItem.ToString() == "Auto Response"){ //--- Validate values ------------------------------------------------// if(m_pAutoResponse_FullMEssage.Text == ""){ MessageBox.Show(this,"Full Message: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_AutoResponse( m_pDescription.Text, m_pAutoResponse_From.Text, System.Text.Encoding.Default.GetBytes(m_pAutoResponse_FullMEssage.Text) ); } else{ UserMessageRuleAction_AutoResponse a = (UserMessageRuleAction_AutoResponse)m_pActionData; a.Description = m_pDescription.Text; a.From = m_pAutoResponse_From.Text; a.Message = System.Text.Encoding.Default.GetBytes(m_pAutoResponse_FullMEssage.Text); a.Commit(); } } #endregion #region DeleteMessage else if(m_pAction.SelectedItem.ToString() == "Delete Message"){ if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_DeleteMessage(m_pDescription.Text); } else{ UserMessageRuleAction_DeleteMessage a = (UserMessageRuleAction_DeleteMessage)m_pActionData; a.Description = m_pDescription.Text; a.Commit(); } } #endregion #region ExecuteProgram else if(m_pAction.SelectedItem.ToString() == "Execute Program"){ //--- Validate values ------------------------------------------------// if(m_pExecuteProgram_ProgramToExecute.Text == ""){ MessageBox.Show(this,"Program to Execute: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_ExecuteProgram( m_pDescription.Text, m_pExecuteProgram_ProgramToExecute.Text, m_pExecuteProgram_ProgramArguments.Text ); } else{ UserMessageRuleAction_ExecuteProgram a = (UserMessageRuleAction_ExecuteProgram)m_pActionData; a.Description = m_pDescription.Text; a.Program = m_pExecuteProgram_ProgramToExecute.Text; a.ProgramArguments = m_pExecuteProgram_ProgramArguments.Text; a.Commit(); } } #endregion #region ForwardToEmail else if(m_pAction.SelectedItem.ToString() == "Forward To Email"){ //--- Validate values ------------------------------------------------// if(m_pForwardToEmail_Email.Text == ""){ MessageBox.Show(this,"Forward to Email: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_ForwardToEmail( m_pDescription.Text, m_pForwardToEmail_Email.Text ); } else{ UserMessageRuleAction_ForwardToEmail a = (UserMessageRuleAction_ForwardToEmail)m_pActionData; a.Description = m_pDescription.Text; a.EmailAddress = m_pForwardToEmail_Email.Text; a.Commit(); } } #endregion #region ForwartToHost else if(m_pAction.SelectedItem.ToString() == "Forward To Host"){ //--- Validate values ------------------------------------------------// if(m_pForwardToHost_Host.Text == ""){ MessageBox.Show(this,"Forward to Host: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_ForwardToHost( m_pDescription.Text, m_pForwardToHost_Host.Text, (int)m_pForwardToHost_HostPort.Value ); } else{ UserMessageRuleAction_ForwardToHost a = (UserMessageRuleAction_ForwardToHost)m_pActionData; a.Description = m_pDescription.Text; a.Host = m_pForwardToHost_Host.Text; a.Port = (int)m_pForwardToHost_HostPort.Value; a.Commit(); } } #endregion #region StoreToDiskFolder else if(m_pAction.SelectedItem.ToString() == "Store To Disk Folder"){ //--- Validate values ------------------------------------------------// if(m_pStoreToDiskFolder_Folder.Text == ""){ MessageBox.Show(this,"Store to Disk Folder: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_StoreToDisk( m_pDescription.Text, m_pStoreToDiskFolder_Folder.Text ); } else{ UserMessageRuleAction_StoreToDiskFolder a = (UserMessageRuleAction_StoreToDiskFolder)m_pActionData; a.Description = m_pDescription.Text; a.Folder = m_pStoreToDiskFolder_Folder.Text; a.Commit(); } } #endregion #region MoveToIMAPFolder else if(m_pAction.SelectedItem.ToString() == "Move To IMAP Folder"){ //--- Validate values ------------------------------------------------// if(m_pMoveToIMAPFolder_Folder.Text == ""){ MessageBox.Show(this,"Move to IMAP Folder: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_MoveToImapFolder( m_pDescription.Text, m_pMoveToIMAPFolder_Folder.Text ); } else{ UserMessageRuleAction_MoveToImapFolder a = (UserMessageRuleAction_MoveToImapFolder)m_pActionData; a.Description = m_pDescription.Text; a.Folder = m_pMoveToIMAPFolder_Folder.Text; a.Commit(); } } #endregion #region AddHeaderField else if(m_pAction.SelectedItem.ToString() == "Add Header Field"){ //--- Validate values ------------------------------------------------// if(m_pAddHeaderField_FieldName.Text == ""){ MessageBox.Show(this,"Header Field Name: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_AddHeaderField( m_pDescription.Text, m_pAddHeaderField_FieldName.Text, m_pAddHeaderField_FieldValue.Text ); } else{ UserMessageRuleAction_AddHeaderField a = (UserMessageRuleAction_AddHeaderField)m_pActionData; a.Description = m_pDescription.Text; a.HeaderFieldName = m_pAddHeaderField_FieldName.Text; a.HeaderFieldValue = m_pAddHeaderField_FieldValue.Text; a.Commit(); } } #endregion #region RemoveHeaderField else if(m_pAction.SelectedItem.ToString() == "Remove Header Field"){ //--- Validate values ------------------------------------------------// if(m_pRemoveHeaderField_FieldName.Text == ""){ MessageBox.Show(this,"Header Field Name: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_RemoveHeaderField( m_pDescription.Text, m_pAddHeaderField_FieldName.Text ); } else{ UserMessageRuleAction_RemoveHeaderField a = (UserMessageRuleAction_RemoveHeaderField)m_pActionData; a.Description = m_pDescription.Text; a.HeaderFieldName = m_pAddHeaderField_FieldName.Text; a.Commit(); } } #endregion #region StoreToFTPFolder else if(m_pAction.SelectedItem.ToString() == "Store To FTP Folder"){ //--- Validate values ------------------------------------------------// if(m_pStoreToFTPFolder_Server.Text == ""){ MessageBox.Show(this,"FTP Server: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_StoreToFtp( m_pDescription.Text, m_pStoreToFTPFolder_Server.Text, (int)m_pStoreToFTPFolder_Port.Value, m_pStoreToFTPFolder_User.Text, m_pStoreToFTPFolder_Password.Text, m_pStoreToFTPFolder_Folder.Text ); } else{ UserMessageRuleAction_StoreToFtp a = (UserMessageRuleAction_StoreToFtp)m_pActionData; a.Description = m_pDescription.Text; a.Server = m_pStoreToFTPFolder_Server.Text; a.Port = (int)m_pStoreToFTPFolder_Port.Value; a.UserName = m_pStoreToFTPFolder_User.Text; a.Password = m_pStoreToFTPFolder_Password.Text; a.Folder = m_pStoreToFTPFolder_Folder.Text; a.Commit(); } } #endregion #region PostToNNTPNewsgroup else if(m_pAction.SelectedItem.ToString() == "Post To NNTP Newsgroup"){ //--- Validate values ------------------------------------------------// if(m_pPostToNNTPNewsgroup_Server.Text == ""){ MessageBox.Show(this,"NNTP Server: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } if(m_pPostToNNTPNewsgroup_Newsgroup.Text == ""){ MessageBox.Show(this,"Newsgroup: value can't empty !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } //--------------------------------------------------------------------// if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_PostToNntp( m_pDescription.Text, m_pPostToNNTPNewsgroup_Server.Text, (int)m_pPostToNNTPNewsgroup_Port.Value, m_pPostToNNTPNewsgroup_Newsgroup.Text ); } else{ UserMessageRuleAction_PostToNntpNewsgroup a = (UserMessageRuleAction_PostToNntpNewsgroup)m_pActionData; a.Description = m_pDescription.Text; a.Server = m_pPostToNNTPNewsgroup_Server.Text; a.Port = (int)m_pPostToNNTPNewsgroup_Port.Value; a.Newsgroup = m_pPostToNNTPNewsgroup_Newsgroup.Text; a.Commit(); } } #endregion #region PostToHTTP else if(m_pAction.SelectedItem.ToString() == "Post To HTTP"){ if(m_pActionData == null){ m_pActionData = m_pRule.Actions.Add_PostToHttp( m_pDescription.Text, m_pPostToHTTP_URL.Text ); } else{ UserMessageRuleAction_PostToHttp a = (UserMessageRuleAction_PostToHttp)m_pActionData; a.Description = m_pDescription.Text; a.Url = m_pPostToHTTP_URL.Text; a.Commit(); } } #endregion this.DialogResult = DialogResult.OK; }
/// <summary> /// Edit constructor. /// </summary> /// <param name="rule">Owner rule.</param> /// <param name="action">User messgae rule action action.</param> public wfrm_UserMessageRule_Action(UserMessageRule rule,UserMessageRuleActionBase action) { m_pRule = rule; m_pActionData = action; InitUI(); m_pDescription.Text = action.Description; m_pAction.Enabled = false; //--- Pase action data -------------------------------------------------// #region AutoResponse if(action.ActionType == UserMessageRuleAction_enum.AutoResponse){ UserMessageRuleAction_AutoResponse a = (UserMessageRuleAction_AutoResponse)action; m_pAutoResponse_From.Text = a.From; m_pAutoResponse_FullMEssage.Text = System.Text.Encoding.Default.GetString(a.Message); m_pAction.SelectedIndex = 0; } #endregion #region DeleteMessage else if(action.ActionType == UserMessageRuleAction_enum.DeleteMessage){ UserMessageRuleAction_DeleteMessage a = (UserMessageRuleAction_DeleteMessage)action; m_pAction.SelectedIndex = 1; } #endregion #region ExecuteProgram else if(action.ActionType == UserMessageRuleAction_enum.ExecuteProgram){ UserMessageRuleAction_ExecuteProgram a = (UserMessageRuleAction_ExecuteProgram)action; m_pExecuteProgram_ProgramToExecute.Text = a.Program; m_pExecuteProgram_ProgramArguments.Text = a.ProgramArguments; m_pAction.SelectedIndex = 2; } #endregion #region ForwardToEmail else if(action.ActionType == UserMessageRuleAction_enum.ForwardToEmail){ UserMessageRuleAction_ForwardToEmail a = (UserMessageRuleAction_ForwardToEmail)action; m_pForwardToEmail_Email.Text = a.EmailAddress; m_pAction.SelectedIndex = 3; } #endregion #region ForwardToHost else if(action.ActionType == UserMessageRuleAction_enum.ForwardToHost){ UserMessageRuleAction_ForwardToHost a = (UserMessageRuleAction_ForwardToHost)action; m_pForwardToHost_Host.Text = a.Host; m_pForwardToHost_HostPort.Value = a.Port; m_pAction.SelectedIndex = 4; } #endregion #region StoreToDiskFolder else if(action.ActionType == UserMessageRuleAction_enum.StoreToDiskFolder){ UserMessageRuleAction_StoreToDiskFolder a = (UserMessageRuleAction_StoreToDiskFolder)action; m_pStoreToDiskFolder_Folder.Text = a.Folder; m_pAction.SelectedIndex = 5; } #endregion #region StoreToIMAPFolder else if(action.ActionType == UserMessageRuleAction_enum.MoveToIMAPFolder){ UserMessageRuleAction_MoveToImapFolder a = (UserMessageRuleAction_MoveToImapFolder)action; m_pMoveToIMAPFolder_Folder.Text = a.Folder; m_pAction.SelectedIndex = 6; } #endregion #region AddHeaderField else if(action.ActionType == UserMessageRuleAction_enum.AddHeaderField){ UserMessageRuleAction_AddHeaderField a = (UserMessageRuleAction_AddHeaderField)action; m_pAddHeaderField_FieldName.Text = a.HeaderFieldName; m_pAddHeaderField_FieldValue.Text = a.HeaderFieldValue; m_pAction.SelectedIndex = 7; } #endregion #region RemoveHeaderField else if(action.ActionType == UserMessageRuleAction_enum.RemoveHeaderField){ UserMessageRuleAction_RemoveHeaderField a = (UserMessageRuleAction_RemoveHeaderField)action; m_pRemoveHeaderField_FieldName.Text = a.HeaderFieldName; m_pAction.SelectedIndex = 8; } #endregion #region StoreToFTPFolder else if(action.ActionType == UserMessageRuleAction_enum.StoreToFTPFolder){ UserMessageRuleAction_StoreToFtp a = (UserMessageRuleAction_StoreToFtp)action; m_pStoreToFTPFolder_Server.Text = a.Server; m_pStoreToFTPFolder_Port.Value = a.Port; m_pStoreToFTPFolder_User.Text = a.UserName; m_pStoreToFTPFolder_Password.Text = a.Password; m_pStoreToFTPFolder_Folder.Text = a.Folder; m_pAction.SelectedIndex = 10; } #endregion #region PostToNNTPNewsGroup else if(action.ActionType == UserMessageRuleAction_enum.PostToNNTPNewsGroup){ UserMessageRuleAction_PostToNntpNewsgroup a = (UserMessageRuleAction_PostToNntpNewsgroup)action; m_pPostToNNTPNewsgroup_Server.Text = a.Server; m_pPostToNNTPNewsgroup_Port.Value = a.Port; // table.Add("User",""); // table.Add("Password",""); m_pPostToNNTPNewsgroup_Newsgroup.Text = a.Newsgroup; m_pAction.SelectedIndex = 11; } #endregion #region PostToHTTP else if(action.ActionType == UserMessageRuleAction_enum.PostToHTTP){ UserMessageRuleAction_PostToHttp a = (UserMessageRuleAction_PostToHttp)action; m_pPostToHTTP_URL.Text = a.Url; // table.GetValue("FileName"); m_pAction.SelectedIndex = 12; } #endregion //---------------------------------------------------------------------// }