Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Int64 forFaxServerId = 0;


            if (MercuryApplication == null)
            {
                return;
            }

            if ((!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.FaxServerReview))

                && (!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.FaxServerManage)))
            {
                Response.Redirect("/PermissionDenied.aspx", true); return;
            }


            if (!Page.IsPostBack)
            {
                #region Initial Page Load

                if (Request.QueryString["FaxServerId"] != null)
                {
                    forFaxServerId = Int64.Parse(Request.QueryString["FaxServerId"]);
                }

                if (forFaxServerId != 0)
                {
                    faxServer = MercuryApplication.FaxServerGet(forFaxServerId, false);

                    if (faxServer == null)
                    {
                        faxServer = new Mercury.Client.Faxing.FaxServer(MercuryApplication);
                    }
                }

                else
                {
                    faxServer = new Mercury.Client.Faxing.FaxServer(MercuryApplication);
                }

                InitializeAll();

                Session[SessionCachePrefix + "FaxServer"] = faxServer;

                Session[SessionCachePrefix + "FaxServerUnmodified"] = faxServer.Copy();

                #endregion
            } // Initial Page Load

            else   // Postback

            {
                faxServer = (Mercury.Client.Faxing.FaxServer)Session[SessionCachePrefix + "FaxServer"];
            }

            ApplySecurity();

            if (!String.IsNullOrEmpty(faxServer.Name))
            {
                Page.Title = "Fax Server - " + faxServer.Name;
            }
            else
            {
                Page.Title = "Fax Server";
            }

            return;
        }
Exemplo n.º 2
0
        protected Boolean ApplyChanges()
        {
            Boolean isModified = false;

            Boolean success = false;


            Mercury.Client.Faxing.FaxServer faxServerUnmodified = (Mercury.Client.Faxing.FaxServer)Session[SessionCachePrefix + "FaxServerUnmodified"];

            if (faxServerUnmodified.Id == 0)
            {
                isModified = true;
            }


            faxServer.Name = FaxServerName.Text.Trim();

            faxServer.Description = FaxServerDescription.Text.Trim();

            faxServer.Enabled = FaxServerEnabled.Checked;

            faxServer.Visible = FaxServerVisible.Checked;


            faxServer.AssemblyPath = FaxServerAssemblyPath.Text;

            faxServer.AssemblyName = FaxServerAssemblyName.Text;

            faxServer.AssemblyClassName = FaxServerAssemblyClassName.Text;


            faxServer.FaxServerConfiguration.FaxUrl = FaxServerConfigurationFaxUrl.Text;

            faxServer.FaxServerConfiguration.FaxQueueName = FaxServerConfigurationFaxQueueName.Text;

            faxServer.FaxServerConfiguration.SenderEmailAddress = FaxServerConfigurationSenderEmail.Text;


            faxServer.FaxServerConfiguration.MonitorInterval = Convert.ToInt32(FaxServerConfigurationMonitorInterval.Value);

            faxServer.FaxServerConfiguration.MonitorTimeout = Convert.ToInt32(FaxServerConfigurationMonitorTimeout.Value);



            faxServer.WebServiceHostConfiguration.Server = FaxServerConfigurationServerName.Text;

            faxServer.WebServiceHostConfiguration.BindingConfiguration.Protocol = FaxServerConfigurationBindingProtocol.Text;

            faxServer.WebServiceHostConfiguration.Port = Convert.ToInt32(FaxServerConfigurationPort.Value);

            faxServer.WebServiceHostConfiguration.ServicePath = FaxServerConfigurationServicePath.Text;

            faxServer.WebServiceHostConfiguration.ServiceName = FaxServerConfigurationServiceName.Text;


            faxServer.WebServiceHostConfiguration.BindingConfiguration.BindingType = (Mercury.Server.Application.WebServiceBindingType)

                                                                                     Convert.ToInt32(FaxServerConfigurationBindingTypeSelection.SelectedValue);

            faxServer.WebServiceHostConfiguration.BindingConfiguration.TimeoutReceive = new TimeSpan(0, Convert.ToInt32(FaxServerConfigurationBindingTimeout.Value), 0);

            faxServer.WebServiceHostConfiguration.BindingConfiguration.SecurityMode = (System.ServiceModel.BasicHttpSecurityMode)

                                                                                      Convert.ToInt32(FaxServerConfigurationBindingSecurityMode.SelectedValue);

            faxServer.WebServiceHostConfiguration.BindingConfiguration.TransportCredentialType = (System.ServiceModel.HttpClientCredentialType)

                                                                                                 Convert.ToInt32(FaxServerConfigurationBindingTransportCredential.SelectedValue);

            faxServer.WebServiceHostConfiguration.BindingConfiguration.MessageCredentialType = (System.ServiceModel.MessageCredentialType)

                                                                                               Convert.ToInt32(FaxServerConfigurationBindingMessageCredential.SelectedValue);


            faxServer.WebServiceHostConfiguration.ClientCredentials.Domain = FaxServerConfigurationClientCredentialsDomain.Text;

            faxServer.WebServiceHostConfiguration.ClientCredentials.UserName = FaxServerConfigurationClientCredentialsUserName.Text;

            faxServer.WebServiceHostConfiguration.ClientCredentials.Password = FaxServerConfigurationClientCredentialsPassword.Text;

            faxServer.WebServiceHostConfiguration.ClientCredentials.WindowsImpersonationLevel = (System.Security.Principal.TokenImpersonationLevel)

                                                                                                Convert.ToInt32(FaxServerConfigurationClientCredentialsImpersonation.SelectedValue);


            if (!isModified)
            {
                isModified = !faxServer.IsEqual(faxServerUnmodified);
            }

            if (isModified)
            {
                success = MercuryApplication.FaxServerSave(faxServer);

                if (success)
                {
                    faxServer = MercuryApplication.FaxServerGet(faxServer.Id, false);

                    Session[SessionCachePrefix + "FaxServer"] = faxServer;

                    Session[SessionCachePrefix + "FaxServerUnmodified"] = faxServer.Copy();

                    SaveResponseLabel.Text = "Save Successful";

                    InitializeAll();
                }

                else
                {
                    SaveResponseLabel.Text = "Unable to Save.";

                    if (MercuryApplication.LastException != null)
                    {
                        SaveResponseLabel.Text = SaveResponseLabel.Text + " [" + MercuryApplication.LastException.Message + "]";
                    }

                    success = false;
                }
            }

            else
            {
                SaveResponseLabel.Text = "No Changes Detected."; success = true;
            }

            return(success);
        }