Ejemplo n.º 1
0
    /// <summary>
    /// Actually calls into Compare Service to perform comparison. Currently it used a hardcoded
    /// binding wsHttpBinding. After the call has returned successfully, it calls the results
    /// routine to display the results.
    /// </summary>
    /// <param name="sOriginalFile"></param>
    /// <param name="sModifiedFile"></param>
    /// <param name="sVirtualPath"></param>
    private void DoCompare(string sOriginalFile, string sModifiedFile, string sVirtualPath)
    {
        ResponseOptions responseOptions = ResponseOptions.Rtf;

        string password = (string)Session["Passw"];

        password = CodePassword(password);

        // Hardcoded wsHttpBinding. Host info is picked from config file
        ComparerClient cp = new ComparerClient("CompareWebServiceWCF");

        cp.ClientCredentials.Windows.ClientCredential.UserName = UserNameTextBox.Text;
        cp.ClientCredentials.Windows.ClientCredential.Password = password;
        cp.ClientCredentials.Windows.ClientCredential.Domain   = RealmTextBox.Text;

        // Authenticate first.
        if (cp.Authenticate(RealmTextBox.Text, UserNameTextBox.Text, password))
        {
            byte[] original      = File.ReadAllBytes(sOriginalFile);
            byte[] modified      = File.ReadAllBytes(sModifiedFile);
            string sRenderingSet = RenderingSetDropDownList.SelectedValue;
            string sOptionSet    = File.ReadAllText(Request.MapPath(Path.Combine(sRenderSetPath, sRenderingSet)));

            ExecuteParams executeParams = new ExecuteParams()
            {
                CompareOptions       = sOptionSet,
                ResponseOption       = responseOptions,
                Original             = original,
                Modified             = modified,
                OriginalDocumentInfo = new DocumentInfo()
                {
                    DocumentDescription = Path.GetFileName(sOriginalFile), DocumentSource = Path.GetFileName(sOriginalFile)
                },
                ModifiedDocumentInfo = new DocumentInfo()
                {
                    DocumentDescription = Path.GetFileName(sModifiedFile), DocumentSource = Path.GetFileName(sModifiedFile)
                },
            };
            // Peform comparison
            CompareResults results = cp.ExecuteEx(executeParams);

            // Prepare and Display results.
            HandleResults(results, responseOptions, sOriginalFile, sModifiedFile, sRenderingSet, sVirtualPath);
        }
        else
        {
            ShowMessage("Authentication failed.");
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Authenticated the user on Compare Service and stores the password for later use.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AuthenticateButton_Click(object sender, EventArgs e)
    {
        try
        {
            ShowMessage("");
            ComparerClient cp = new ComparerClient("CompareWebServiceWCF");

            cp.ClientCredentials.Windows.ClientCredential.UserName = UserNameTextBox.Text;
            cp.ClientCredentials.Windows.ClientCredential.Password = PasswordTextBox.Text;
            cp.ClientCredentials.Windows.ClientCredential.Domain   = RealmTextBox.Text;

            if (cp.Authenticate(RealmTextBox.Text, UserNameTextBox.Text, PasswordTextBox.Text))
            {
                string sServiceVersion    = cp.GetVersion();
                string sCompositorVersion = cp.GetCompositorVersion();

                string sVersionString = "Compare Service Version: " + sServiceVersion + " ";
                sVersionString += "Compositor Version: " + sCompositorVersion;

                WCSVersionLabel.Text = sVersionString;

                Session["sVersionString"] = sVersionString;
                Session["Authenticated"]  = true;
                Session["Passw"]          = CodePassword(PasswordTextBox.Text);

                SetupPageUI();
            }
            else
            {
                WCSVersionLabel.Text = "Authentication failed.";
                ShowMessage("Authentication failed.");
            }
        }
        catch (TimeoutException ex)
        {
            ShowMessage("The connection to Compare Service has timed out. The service may be down or unavailable for some other reason. \nDetailed description: " + ex.Message);
        }
        catch (Exception ex)
        {
            ShowMessage("Error: " + ex.Message);
        }
    }