Esempio n. 1
0
        public override int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra)
        {
            int status = 0;
            ProcessAgentInfo paiOld = GetProcessAgentInfo(originalGuid);

            if (paiOld != null)
            {

                try
                {
                    status = UpdateProcessAgent(paiOld.agentId, agent.agentGuid, agent.agentName, agent.type,
                        agent.domainGuid, agent.codeBaseUrl, agent.webServiceUrl);
                }
                catch (Exception ex)
                {
                    throw new Exception("ISB: ", ex);
                }

                if (agent.codeBaseUrl.CompareTo(paiOld.codeBaseUrl) != 0)
                {
                    status += ModifyAdminUrls(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl);
                    status += ModifyResourceInfoURL(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl);
                    if (paiOld.agentType == ProcessAgentType.AgentType.LAB_SERVER)
                    {
                        status += ModifyClientScripts(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl);
                    }
                }
                if (agent.agentName.CompareTo(paiOld.agentName) != 0)
                {
                    // need to update Qualifier Names
                    AuthorizationAPI.ModifyQualifierName(Qualifier.ToTypeID(agent.type), paiOld.agentId, agent.agentName);
                    int[] resourceMapIds = GetResourceMappingIdsByValue(ResourceMappingTypes.PROCESS_AGENT, paiOld.agentId);
                    foreach (int id in resourceMapIds)
                    {
                        ResourceMapping map = ResourceMapManager.GetMap(id);
                        AuthorizationAPI.ModifyQualifierName(Qualifier.resourceMappingQualifierTypeID, id, ResourceMappingToString(map));
                    }
                }
                //Notify all ProcessAgents about the change
                ProcessAgentInfo[] domainServices = GetProcessAgentInfos();
                ProcessAgentProxy proxy = null;
                foreach (ProcessAgentInfo pi in domainServices)
                {
                    // Do not send if retired this service or the service being modified since this is
                    if (!pi.retired && (pi.agentType != ProcessAgentType.AgentType.BATCH_LAB_SERVER)
                        && (pi.agentGuid.CompareTo(ProcessAgentDB.ServiceGuid) != 0)
                        && (pi.agentGuid.CompareTo(agent.agentGuid) != 0))
                    {
                        proxy = new ProcessAgentProxy();
                        proxy.AgentAuthHeaderValue = new AgentAuthHeader();
                        proxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                        proxy.AgentAuthHeaderValue.coupon = pi.identOut;
                        proxy.Url = pi.webServiceUrl;
                        try
                        {
                            status += proxy.ModifyProcessAgent(originalGuid, agent, extra);
                        }
                        catch (Exception ex)
                        {
                            Exception ex2 = new Exception("ModifyProcessAgent: " + pi.webServiceUrl, ex);
                            throw ex2;
                        }
                    }
                }
            }

            return status;
        }
Esempio n. 2
0
        protected void modifyService(object sender, System.EventArgs e)
        {
            bool error = false;
            StringBuilder message = new StringBuilder();
            try
            {
                if (ProcessAgentDB.ServiceAgent != null)
                {
                    string originalGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                    if (!(txtServiceName.Text != null && txtServiceName.Text.Trim().Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter a Service Name<br/>");
                    }

                    if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Trim().Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter the base URL for the Web Site<br/>");
                    }
                    if (!(txtWebServiceUrl.Text != null && txtWebServiceUrl.Text.Trim().Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter full URL of the Web Service page<br/>");
                    }
                    if (error)
                    {
                        lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                        lblResponse.Visible = true;
                        return;
                    }
                    if ((txtServiceName.Text.Trim().CompareTo(bakServiceName.Value) == 0)
                        && (txtCodebaseUrl.Text.Trim().CompareTo(bakCodebase.Value) == 0)
                        && (txtWebServiceUrl.Text.Trim().CompareTo(bakServiceUrl.Value) == 0))
                    {
                        lblResponse.Text = Utilities.FormatWarningMessage("No user editable fields have been changed, modify aborted!");
                        lblResponse.Visible = true;
                        return;
                    }
                    if (ProcessAgentDB.ServiceAgent.domainGuid != null)
                    {
                        ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(originalGuid);
                        ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid);
                        if ((sb != null) && !sb.retired)
                        {
                            ProcessAgentProxy psProxy = new ProcessAgentProxy();
                            AgentAuthHeader header = new AgentAuthHeader();
                            header.agentGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                            header.coupon = sb.identOut;
                            psProxy.AgentAuthHeaderValue = header;
                            psProxy.Url = sb.webServiceUrl;
                            ProcessAgent pa = new ProcessAgent();
                            pa.agentGuid = txtServiceGUID.Text.Trim();
                            pa.agentName = txtServiceName.Text.Trim();
                            pa.domainGuid = ProcessAgentDB.ServiceAgent.domainGuid;
                            pa.codeBaseUrl = txtCodebaseUrl.Text.Trim();
                            pa.webServiceUrl = txtWebServiceUrl.Text.Trim();
                            pa.type = agentType;
                            //dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType,
                            //    pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);
                            //message.Append("Local information has been saved. ");
                            int returnValue = psProxy.ModifyProcessAgent(originalGuid, pa, null);
                            message.Append("The changes have been sent to the ServiceBroker");
                            if (returnValue > 0)
                            {
                                dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType,
                                pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);
                                bakServiceName.Value = pa.agentName;
                                bakCodebase.Value = pa.codeBaseUrl;
                                bakServiceUrl.Value = pa.webServiceUrl;
                                message.Append(".<br />Local information has been saved. ");
                                lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString());
                                lblResponse.Visible = true;

                            }
                            else
                            {
                                message.Append(", but did not process correctly!");
                                message.Append("<br />Local information has not been saved. ");
                                lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                                lblResponse.Visible = true;
                            }
                        }
                    }
                    else
                    {
                        dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, agentType,
                                null, txtCodebaseUrl.Text, txtWebServiceUrl.Text);
                    }
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Error in  selfRegistration.modify()",ex);
                Utilities.WriteLog(Utilities.DumpException(ex2));
                throw ex2;
            }
        }
Esempio n. 3
0
        protected void btnModify_Click(object sender, System.EventArgs e)
        {
            bool error = false;
            StringBuilder message = new StringBuilder();
            try
            {
                if (ProcessAgentDB.ServiceAgent != null)
                {
                    string originalGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                    if (!(txtServiceName.Text != null && txtServiceName.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter a Service Name<br/>");
                    }
                    try
                    {
                        if (!checkGuid())
                        {
                            error = true;
                            message.Append("There is an unspecified error with the GUID string.<br/>");
                        }
                    }
                    catch (Exception ex)
                    {
                        error = true;
                        message.Append("GUID Error: ");
                        message.Append(ex.Message);
                        message.Append("<br/>");
                    }

                    if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter the base URL for the Web Site<br/>");
                    }
                    if (!(txtServiceUrl.Text != null && txtServiceUrl.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter full URL of the Web Service page<br/>");
                    }
                    if (error)
                    {
                        lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                        lblResponse.Visible = true;
                        return;
                    }
                    if (ProcessAgentDB.ServiceAgent.domainGuid != null)
                    {
                        ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(originalGuid);
                        ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid);
                        if ((sb != null) && !sb.retired)
                        {
                            ProcessAgentProxy psProxy = new ProcessAgentProxy();
                            AgentAuthHeader header = new AgentAuthHeader();
                            header.agentGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                            header.coupon = sb.identOut;
                            psProxy.AgentAuthHeaderValue = header;
                            psProxy.Url = sb.webServiceUrl;
                            ProcessAgent pa = new ProcessAgent();
                            pa.agentGuid = txtServiceGuid.Text;
                            pa.agentName = txtServiceName.Text;
                            pa.domainGuid = ProcessAgentDB.ServiceAgent.domainGuid;
                            pa.codeBaseUrl = txtCodebaseUrl.Text;
                            pa.webServiceUrl = txtServiceUrl.Text;
                            pa.type = AgentType;
                            //dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType,
                            //    pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);
                            //message.Append("Local information has been saved. ");
                            int returnValue = psProxy.ModifyProcessAgent(originalGuid, pa, null);
                            message.Append("The changes have been sent to the ServiceBroker");
                            if (returnValue > 0)
                            {
                                dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, AgentType,
                                pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);

                                message.Append(".<br />Local information has been saved. ");
                                lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString());
                                lblResponse.Visible = true;

                            }
                            else
                            {
                                message.Append(", but did not process correctly!");
                                message.Append("<br />Local information has not been saved. ");
                                lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                                lblResponse.Visible = true;
                            }
                        }
                    }
                    else
                    {
                        dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, AgentType,
                                null, txtCodebaseUrl.Text, txtServiceUrl.Text);
                        dbTicketing.SaveSystemSupport(ProcessAgentDB.ServiceAgent.agentGuid, txtContactInfo.Text, txtBugEmail.Text,
                           txtInfoUrl.Text, txtDescription.Text, txtLocation.Text);
                    }
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Error in  selfRegistration.modify()", ex);
                Utilities.WriteLog(Utilities.DumpException(ex2));
                throw ex2;
            }
        }
Esempio n. 4
0
        protected void btnModify_Click(object sender, System.EventArgs e)
        {
            bool error = false;
            StringBuilder message = new StringBuilder();
            try
            {
                if (ProcessAgentDB.ServiceAgent != null)
                {
                    string originalGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                    if (!(txtServiceName.Text != null && txtServiceName.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter a Service Name<br/>");
                    }
                    try
                    {
                        if (!checkGuid())
                        {
                            error = true;
                            message.Append("There is an unspecified error with the GUID string.<br/>");
                        }
                    }
                    catch (Exception ex)
                    {
                        error = true;
                        message.Append("GUID Error: ");
                        message.Append(ex.Message);
                        message.Append("<br/>");
                    }
                    if (!(txtOutPasskey.Text != null && txtOutPasskey.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter a default passkey<br/>");
                    }
                    if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter the base URL for the Web Site<br/>");
                    }
                    else if (txtCodebaseUrl.Text.Contains("localhost"))
                    {
                        error = true;
                        message.Append(" You must not use localhost in a codebase URL, if you must test on the local machine please use '127.0.0.1'.<br/>");
                    }
                    if (!(txtServiceUrl.Text != null && txtServiceUrl.Text.Length > 0))
                    {
                        error = true;
                        message.Append(" You must enter the web Ssrvice URL for the Web Site<br/>");
                    }
                    else if (txtServiceUrl.Text.Contains("localhost"))
                    {
                        error = true;
                        message.Append(" You must not use localhost in a web service URL, if you must test only on the local machine please use '127.0.0.1'.<br/>");
                    }
                    else
                    { // Test for valid webService URL
                        ProcessAgentProxy paProxy = new ProcessAgentProxy();
                        paProxy.Url = txtServiceUrl.Text.Trim();
                        try
                        {
                            DateTime serTime = paProxy.GetServiceTime();
                        }
                        catch
                        {
                                error = true;
                                message.Append(" There is an error with the web service URL: " + txtServiceUrl.Text.Trim() + " Please check that it is valid and the web service is configured correctly.<br/>");
                        }
                    }
                    if (error)
                    {
                        lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                        lblResponse.Visible = true;
                        return;
                    }
                    if (ProcessAgentDB.ServiceAgent.domainGuid != null)
                    {
                        ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(originalGuid);
                        ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid);
                        if ((sb != null) && !sb.retired)
                        {
                            ProcessAgentProxy psProxy = new ProcessAgentProxy();
                            AgentAuthHeader header = new AgentAuthHeader();
                            header.agentGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                            header.coupon = sb.identOut;
                            psProxy.AgentAuthHeaderValue = header;
                            psProxy.Url = sb.webServiceUrl;
                            ProcessAgent pa = new ProcessAgent();
                            pa.agentGuid = txtServiceGuid.Text;
                            pa.agentName = txtServiceName.Text;
                            pa.domainGuid = ProcessAgentDB.ServiceAgent.domainGuid;
                            pa.codeBaseUrl = txtCodebaseUrl.Text;
                            pa.webServiceUrl = txtServiceUrl.Text;
                            pa.type = AgentType;
                            //dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType,
                            //    pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);
                            //message.Append("Local information has been saved. ");
                            int returnValue = psProxy.ModifyProcessAgent(originalGuid, pa, null);
                            message.Append("The changes have been sent to the ServiceBroker");
                            if (returnValue > 0)
                            {
                                dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, AgentType,
                                pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl);

                                message.Append(".<br />Local information has been saved. ");
                                lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString());
                                lblResponse.Visible = true;

                            }
                            else
                            {
                                message.Append(", but did not process correctly!");
                                message.Append("<br />Local information has not been saved. ");
                                lblResponse.Text = Utilities.FormatErrorMessage(message.ToString());
                                lblResponse.Visible = true;
                            }
                        }
                    }
                    else
                    {
                        string tmpGuid = null;
                        if (AgentType == ProcessAgentType.SERVICE_BROKER)
                        {
                            tmpGuid = ProcessAgentDB.ServiceAgent.agentGuid;
                            AuthorityUpdateSelf(txtServiceName.Text,ProcessAgentDB.ServiceAgent.agentGuid,
                                 txtCodebaseUrl.Text.Trim(), txtDescription.Text, txtContactInfo.Text,
                                 txtBugEmail.Text, txtLocation.Text);
                        }
                        dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, AgentType,
                                tmpGuid, txtCodebaseUrl.Text.Trim(), txtServiceUrl.Text.Trim());
                        dbTicketing.SaveSystemSupport(ProcessAgentDB.ServiceAgent.agentGuid, txtContactInfo.Text, txtBugEmail.Text,
                           txtInfoUrl.Text, txtDescription.Text, txtLocation.Text);
                    }
                    ProcessAgentDB.RefreshServiceAgent();
                //    if (txtOutPasskey.Text.CompareTo(ConfigurationManager.AppSettings["defaultPasskey"]) != 0)
                //    {
                //        ConfigurationManager.AppSettings.Set("defaultPasskey", txtOutPasskey.Text);
                //    }
                }
            }
            catch (Exception ex)
            {
                Exception ex2 = new Exception("Error in  selfRegistration.modify()", ex);
               Logger.WriteLine(Utilities.DumpException(ex2));
                throw ex2;
            }
        }