}//END Method

    #region generate test case methods.

    // ==================================================================================
    /// <summary>
    /// This method geneates the app data test cases.
    /// </summary>
    // ----------------------------------------------------------------------------------
    private void generateTestCases ( )
    {
      this.LogMethod ( "generateTestCases" );
      //
      // Initialise the methods variables and objects.
      //
      EutAction action = new EutAction ( );

      //
      // Create test case for application object title.
      //
      action = new EutAction ( );
      action.Action = EutCommand.Test_Application_Title;
      action.setParameter ( EutCommandParameters.Value,
        this._ClientData.Title );

      this._TestCaseList.Add ( action );

      //
      // Create test case for page object title.
      //
      action = new EutAction ( );
      action.Action = EutCommand.Test_Page_Title;
      action.Description = EvStatics.enumValueToString ( action.Action );
      action.setParameter ( EutCommandParameters.Value,
        this._ClientData.Page.Title );

      this._TestCaseList.Add ( action );

      //
      // Create test case for page object status.
      //
      action = new EutAction ( );
      action.Action = EutCommand.Test_Page_Status;
      action.Description = EvStatics.enumValueToString ( action.Action );
      action.setParameter ( EutCommandParameters.Value,
        this._ClientData.Page.EditAccess.ToString ( ) );
      this._TestCaseList.Add ( action );

      //
      // Create test case for page group object title.
      //
      this.generateGroupTestCases ( );

    }//END method 
    }//END generateGroupTestCases method 

    // ==================================================================================
    /// <summary>
    /// This method creates page group test cases.
    /// </summary>
    // ----------------------------------------------------------------------------------
    private void generateGroupCommandTestCases ( Group group )
    {
      this.LogMethod ( "generateGroupCommandTestCases" );
      //
      // Initialise the methods variables and objects.
      //
      EutAction action = new EutAction ( );

      //
      // Create test case for page field title.
      //
      for ( int i = 0; i < group.CommandList.Count; i++ )
      {
        Command command = group.CommandList [ i ];

        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Command_Index;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          i .ToString() );

        string title = command.Title;
        title = title.Replace ( "\r", String.Empty );
        title = title.Replace ( "\n", String.Empty );

        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Command_Title;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          title );

        this._TestCaseList.Add ( action );

        //
        // Create test case for field status.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Command_Type;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          command.Type.ToString ( ) );

        this._TestCaseList.Add ( action );

        //
        // Create test case for field layout.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Command_Application;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          command.ApplicationId );

        //
        // Create test case for field data type.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Command_Object;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          command.Object );

        this._TestCaseList.Add ( action );

        //
        // Create test case for field is mandatory setting
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Command_Method;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          command.Method.ToString ( ) );

        this._TestCaseList.Add ( action );

        //
        // Create test case for group parameters
        //
        foreach ( Parameter prm in command.Parameters )
        {
          action = new EutAction ( );
          action.Action = EutCommand.Test_Group_Command_Parameter_Value;
          action.Description = EvStatics.enumValueToString ( action.Action );
          action.setParameter ( EutCommandParameters.Parameter_Name,
           prm.Name );
          action.setParameter ( EutCommandParameters.Value,
            prm.Value );

          this._TestCaseList.Add ( action );

        }//END parameter interation loop.

      }//END iteration loop

    }//END generateGroupTestCases method 
    }//END generateGroupTestCases method 

    // ==================================================================================
    /// <summary>
    /// This method creates page group test cases.
    /// </summary>
    // ----------------------------------------------------------------------------------
    private void generateGroupFieldsTestCases ( Group group )
    {
      this.LogMethod ( "generateFieldsTestCases" );
      //
      // Initialise the methods variables and objects.
      //
      EutAction action = new EutAction ( );

      //
      // Create test case for page field title.
      //
      foreach ( Field field in group.FieldList )
      {
        action = new EutAction ( );
        action.Action = EutCommand.Test_Field_Title;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          field.Title );

        this._TestCaseList.Add ( action );

        //
        // Create test case for field status.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Edit_Status;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          field.EditAccess.ToString ( ) );

        this._TestCaseList.Add ( action );

        //
        // Create test case for field layout.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Layout_Setting;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          field.Layout.ToString ( ) );

        //
        // Create test case for field data type.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Field_Data_Type;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          field.Type.ToString ( ) );

        this._TestCaseList.Add ( action );

        //
        // Create test case for field is mandatory setting
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Field_Mandatory;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          field.Mandatory.ToString ( ) );

        this._TestCaseList.Add ( action );

        //
        // Create test case for field identifier
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Field_Identifier;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          field.FieldId.ToString ( ) );

        this._TestCaseList.Add ( action );

        //
        // Create test case for group parameters
        //
        foreach ( Parameter prm in field.Parameters )
        {
          action = new EutAction ( );
          action.Action = EutCommand.Test_Field_Parameter_Value;
          action.Description = EvStatics.enumValueToString ( action.Action );
          action.setParameter ( EutCommandParameters.Parameter_Name,
           prm.Name );
          action.setParameter ( EutCommandParameters.Value,
            prm.Value );

          this._TestCaseList.Add ( action );
        }//END parameter interation loop.

      }//END iteration loop

    }//END generateGroupTestCases method 
    }//END generateGroupTestCases method 

    // ==================================================================================
    /// <summary>
    /// This method creates page group test cases.
    /// </summary>
    // ----------------------------------------------------------------------------------
    private void generateGroupTestCases ( )
    {
      this.LogMethod ( "generateGroupTestCases" );
      //
      // Initialise the methods variables and objects.
      //
      EutAction action = new EutAction ( );

      //
      // Create test case for page group object title.
      //
      foreach ( Group group in this._ClientData.Page.GroupList )
      {
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Title;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          group.Title );

        this._TestCaseList.Add ( action );

        //
        // Create test case for group object status.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Edit_Status;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          group.EditAccess.ToString ( ) );

        this._TestCaseList.Add ( action );

        //
        // Create test case for group object layout.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Layout_Setting;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          group.Layout.ToString ( ) );

        //
        // Create test case for group object type.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Type_Setting;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          group.GroupType.ToString ( ) );

        this._TestCaseList.Add ( action );

        //
        // Create test case for group object type.
        //
        action = new EutAction ( );
        action.Action = EutCommand.Test_Group_Command_Layout_Setting;
        action.Description = EvStatics.enumValueToString ( action.Action );
        action.setParameter ( EutCommandParameters.Value,
          group.CmdLayout.ToString ( ) );

        this._TestCaseList.Add ( action );

        //
        // Create test case for group parameters
        //
        foreach ( Parameter prm in group.Parameters )
        {
          action = new EutAction ( );
          action.Action = EutCommand.Test_Group_Parameter_Value;
          action.Description = EvStatics.enumValueToString ( action.Action );
          action.setParameter ( EutCommandParameters.Parameter_Name,
           prm.Name );
          action.setParameter ( EutCommandParameters.Value,
            prm.Value );

          this._TestCaseList.Add ( action );
        }//END parameter interation loop.

        //
        // Generat the group fields test cases.
        //
        this.generateGroupFieldsTestCases ( group );

        this.generateGroupCommandTestCases ( group );

      }//END iteration loop

    }//END generateGroupTestCases method 
Пример #5
0
    }//END sendEmail method

    //  ==================================================================================
    /// <summary>
    ///
    ///  This method sends an email to the recipants in the email address list.
    ///
    /// </summary>
    /// <param name="Subject">The email subject string</param>
    /// <param name="HtmlBody">The email html body</param>
    /// <param name="SenderEmailAddress">The sender's email address</param>
    /// <param name="RecipantEmailAddresses">Delimited string of recipant email addresses.</param>
    /// <param name="AttachmentDirectoryPath">Directory path to the attachment if it exists.</param>
    /// <returns>EmailStatus value</returns>
    //  ---------------------------------------------------------------------------------
    public EmailStatus sendEmail(
        String Subject,
        String HtmlBody,
        String SenderEmailAddress,
        String RecipantEmailAddresses,
        String AttachmentDirectoryPath)
    {
        this.LogMethod("sendEmail method. ");
        this.LogDebug("Subject: " + Subject);
        // this.LogDebugValue(  "HtmlBody: " + HtmlBody );
        this.LogDebug("SenderEmailAddress: " + SenderEmailAddress);
        this.LogDebug("RecipantEmailAddresses: " + RecipantEmailAddresses);
        this.LogDebug("AttachmentDirectoryPath: " + AttachmentDirectoryPath);
        try
        {
            //
            // Validate that the are the settings for the SMTP server.
            //
            if (this._SmtpServer == String.Empty)
            {
                this.LogDebug(EvStatics.enumValueToString(EmailStatus.No_SMTP_Url));
                return(EmailStatus.No_SMTP_Url);
            }

            //
            // Validate that the are the settings for the SMTP server.
            //
            if (RecipantEmailAddresses == String.Empty)
            {
                this.LogDebug(EvStatics.enumValueToString(EmailStatus.No_Reciever_Addresses));
                return(EmailStatus.No_Reciever_Addresses);
            }

            //
            // If the sender's email address is empty put in a dummy address.
            //
            if (SenderEmailAddress == String.Empty)
            {
                SenderEmailAddress = "*****@*****.**";
            }

            //
            // Get the list of email addresses.
            //
            MailAddress           fromAddress         = new MailAddress(this._SmtpUserId);
            MailAddressCollection recipantAddressList = new MailAddressCollection( );
            MailAddress           replyToAddress      = new MailAddress(SenderEmailAddress);

            //
            // Generate an array of email addresses.
            //
            String[] arrRecipantEmailAddresses = RecipantEmailAddresses.Split(';');

            //
            // Create the to address list.
            //
            foreach (String recipantEmailAddress in arrRecipantEmailAddresses)
            {
                String stRecipantEmailAddress = recipantEmailAddress.Replace("(", "<");
                stRecipantEmailAddress = stRecipantEmailAddress.Replace(")", ">");

                if (stRecipantEmailAddress.Contains(">") == true)
                {
                    stRecipantEmailAddress = stRecipantEmailAddress.Replace(">", String.Empty);
                    int    index             = stRecipantEmailAddress.IndexOf('<');
                    string recipantntName    = stRecipantEmailAddress.Substring(0, index).Trim( );
                    string recipantntAddress = stRecipantEmailAddress.Substring(index + 1).Trim( );

                    // this.LogDebugValue(  "name: " + recipantntName + ", address: " + recipantntAddress );

                    MailAddress toAddress = new MailAddress(recipantntAddress, recipantntName);
                    recipantAddressList.Add(toAddress);
                }
                else
                {
                    if (recipantEmailAddress.Length > 0)
                    {
                        // this.LogDebugValue(  "name: " + recipantEmailAddress + ", address: " + recipantEmailAddress );

                        MailAddress toAddress = new MailAddress(recipantEmailAddress, recipantEmailAddress);
                        recipantAddressList.Add(toAddress);
                    }
                }
            }//END interation loop

            this.LogDebug("toAddresses: " + recipantAddressList.Count);

            if (recipantAddressList.Count == 0)
            {
                this.LogDebug("No Addressee list.");
                return(EmailStatus.No_Reciever_Addresses);
            }

            this.LogDebug("Creating Email message.");

            //
            // Initialise the email message content
            //
            MailMessage message = new MailMessage(fromAddress, recipantAddressList[0]);
            message.ReplyToList.Add(replyToAddress);
            message.Subject = Subject;

            message.IsBodyHtml = true;
            message.Body       = HtmlBody;

            //
            // Add the to recipant email address list.
            //
            for (int i = 1; i < recipantAddressList.Count; i++)
            {
                message.To.Add(recipantAddressList[i]);
            }//END interation loop
            this.LogDebug("message.To: " + message.To.Count);

            //
            // Get the report and save it in a temporary file.
            //
            if (AttachmentDirectoryPath != String.Empty)
            {
                //
                // Create  the file attachment for this e-mail message.
                //
                Attachment attachment = new Attachment(AttachmentDirectoryPath);

                // Add the file attachment to this e-mail message.
                message.Attachments.Add(attachment);
                this.LogDebug("message.Attachments: " + message.Attachments.Count);
            }

            //
            // Initialise the Smtp Email client
            //
            SmtpClient smtpClient = new SmtpClient(this._SmtpServer, this._SmtpServerPort);
            smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtpClient.EnableSsl      = _EnableSsl;
            this.LogDebug("client.Host: " + smtpClient.Host);
            this.LogDebug("client.Port: " + smtpClient.Port);
            this.LogDebug("client.DeliveryMethod: " + smtpClient.DeliveryMethod);
            this.LogDebug("client.EnableSsl: " + smtpClient.EnableSsl);

            //
            // Initialise the email server credentials if it is needed.
            //
            if (this._SmtpUserId != String.Empty)
            {
                this.LogDebug("SmtpUserId: " + this._SmtpUserId);
                this.LogDebug("SmtpPassword: "******"Email Sent.");

            return(EmailStatus.Email_Sent);
        }
        catch (Exception Ex)
        {
            this.LogDebug("Event content: ");
            this.LogDebug(EvStatics.getException(Ex));

            return(EmailStatus.Email_Send_Request_Failed);
        }
    }//END sendEmail method