Esempio n. 1
0
        private void OnAddSubmit <T>(T newobj, Label errorlabel, Action[] callback)
            where T : class
        {
            try
            {
                var wcfconfigdatacontext = new WcfConfigDataContext();

                wcfconfigdatacontext.GetTable <T>().InsertOnSubmit(newobj);

                wcfconfigdatacontext.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
                wcfconfigdatacontext.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
                errorlabel.Text = "添加成功";
            }
            catch (Exception ex)
            {
                errorlabel.Text = ex.Message;
            }
            finally
            {
                foreach (Action act in callback)
                {
                    act();
                }
            }
        }
Esempio n. 2
0
        private void OnDeleteSubmit <T>(WcfConfigDataContext wcfconfigdatacontext, T entity, Label errorlabel, Action[] callback)
            where T : class
        {
            try
            {
                var query =
                    (from e in wcfconfigdatacontext.GetTable <T>()
                     where e == entity
                     select e);

                wcfconfigdatacontext.GetTable <T>().DeleteOnSubmit(entity);

                wcfconfigdatacontext.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);

                wcfconfigdatacontext.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
            }
            catch (Exception ex)
            {
                errorlabel.Text = ex.Message;
            }
            finally
            {
                foreach (Action act in callback)
                {
                    act();
                }
            }
        }
Esempio n. 3
0
        protected void BtnAddService_Click(object sender, EventArgs e)
        {
            var servicetype     = this.TBServiceType.Text.Trim();
            var behaviorxml     = this.TBServiceBehaviorXml.Text.Trim();
            var serviceconfig   = this.TBServiceConfig.Text.Trim();
            var servermachineIP = this.TBServerMachineIP.Text.Trim();

            var context = new WcfConfigDataContext();

            var query =
                (from service in context.Services
                 where service.ServiceType == servicetype
                 select service);

            if (query.Count() < 1)
            {
                this.OnAddSubmit <Service>(
                    new Service()
                {
                    ServerFarmName     = this.DDLServerFarm.SelectedValue,
                    ServiceType        = servicetype,
                    ServiceBehaviorXml = string.IsNullOrEmpty(behaviorxml) ? null : XElement.Parse(behaviorxml),
                    ServiceConfig      = string.IsNullOrEmpty(serviceconfig) ? null : XElement.Parse(serviceconfig),
                    ServerMachineIP    = servermachineIP
                },
                    this.LabelServiceErrorMessage,
                    new Action[] {
                    this.InitService
                }
                    );
            }
            else
            {
                var obj = query.First <Service>();
                obj.ServerFarmName     = this.DDLServerFarm.SelectedValue;
                obj.ServiceType        = servicetype;
                obj.ServiceBehaviorXml =
                    string.IsNullOrEmpty(behaviorxml) ?
                    null : XElement.Parse(behaviorxml);
                obj.ServiceConfig =
                    string.IsNullOrEmpty(serviceconfig) ?
                    null : XElement.Parse(serviceconfig);
                obj.ServerMachineIP = servermachineIP;
                context.SubmitChanges();
                this.LabelServiceErrorMessage.Text = "修改成功";
                this.InitService();
            }
            this.LabelServiceErrorMessage.Focus();
        }
Esempio n. 4
0
        protected void BtnAddBinding_Click(object sender, EventArgs e)
        {
            var bindingname     = this.TBBindingName.Text.Trim();
            var bindingtype     = this.DDLBindingType.SelectedValue;
            var bindingpriority = int.Parse(this.DDLBindingPriority.SelectedValue);
            var bindingxml      = this.TBBindingXml.Text.Trim();
            var bindingprotocol = this.DDLBindingProtocol.SelectedValue;

            var context = new WcfConfigDataContext();

            var query =
                (from binding in context.Bindings
                 where binding.BindingName == bindingname
                 select binding);

            if (query.Count() < 1)
            {
                this.OnAddSubmit <Binding>(
                    new Binding()
                {
                    BindingName     = bindingname,
                    BindingType     = bindingtype,
                    BindingPriority = bindingpriority,
                    BindingXml      = string.IsNullOrEmpty(bindingxml) ? null : XElement.Parse(bindingxml),
                    BindingProtocol = bindingprotocol
                },
                    this.LabelBindingErrorMessage,
                    new Action[] {
                    this.InitBinding
                }
                    );
            }
            else
            {
                var obj = query.First <Binding>();
                obj.BindingName     = bindingname;
                obj.BindingType     = bindingtype;
                obj.BindingPriority = bindingpriority;
                obj.BindingXml      = string.IsNullOrEmpty(bindingxml) ? null : XElement.Parse(bindingxml);
                obj.BindingProtocol = bindingprotocol;
                context.SubmitChanges();
                this.LabelBindingErrorMessage.Text = "修改成功";
                this.InitBinding();
            }

            this.LabelBindingErrorMessage.Focus();
            //this.PublisherToRedisMessageChannel(REDISMESSAGESERVERCHANNEL, bindingname);
        }
Esempio n. 5
0
        protected void BtnAddClientEndPoint_Click(object sender, EventArgs e)
        {
            var servicecontracttype       = this.TBServiceContractType.Text.Trim();
            var clientendpointbehaviorxml = this.TBClientEndpointBehaviorXml.Text.Trim();

            var context = new WcfConfigDataContext();

            var query =
                (from clientendpoint in context.ClientEndpoints
                 where clientendpoint.ServiceContractType == servicecontracttype
                 select clientendpoint);

            if (query.Count() < 1)
            {
                this.OnAddSubmit <ClientEndpoint>(
                    new ClientEndpoint()
                {
                    ServiceContractType       = servicecontracttype,
                    ClientMachineIP           = "*",
                    ClientEndpointBehaviorXml =
                        string.IsNullOrEmpty(clientendpointbehaviorxml) ?
                        null : XElement.Parse(clientendpointbehaviorxml)
                },
                    this.LabelClientEndPointErrorMessage,
                    new Action[] {
                    this.InitClientEndPoint
                }
                    );
            }
            else
            {
                var obj = query.First <ClientEndpoint>();
                obj.ServiceContractType       = servicecontracttype;
                obj.ClientMachineIP           = "*";
                obj.ClientEndpointBehaviorXml =
                    string.IsNullOrEmpty(clientendpointbehaviorxml) ?
                    null : XElement.Parse(clientendpointbehaviorxml);
                context.SubmitChanges();
                this.LabelClientEndPointErrorMessage.Text = "修改成功";
                this.InitClientEndPoint();
            }

            this.LabelClientEndPointErrorMessage.Focus();
            //this.PublisherToRedisMessageChannel(REDISMESSAGECLIENTCHANNEL, servicecontracttype);
        }
Esempio n. 6
0
        protected void BtnAddServerFarm_Click(object sender, EventArgs e)
        {
            var name    = TBServerFarmName.Text.Trim();
            var address = TBServerFarmAddress.Text.Trim();

            var context = new WcfConfigDataContext();
            var query   =
                (from serverfarm in context.ServerFarms
                 where serverfarm.ServerFarmName == name
                 select serverfarm);

            if (query.Count() < 1) // create
            {
                this.OnAddSubmit <ServerFarm>(
                    new ServerFarm()
                {
                    ServerFarmName    = name,
                    ServerFarmAddress = address
                },
                    this.LabelServerFarmErrorMessage,
                    new Action[] {
                    this.InitServerFarms,
                    this.InitService
                }
                    );
            }
            else
            {
                var obj = query.First <ServerFarm>();
                obj.ServerFarmName    = name;
                obj.ServerFarmAddress = address;
                context.SubmitChanges();
                this.LabelServerFarmErrorMessage.Text = "修改成功";
                this.InitServerFarms();
                this.InitService();
            }

            this.LabelServerFarmErrorMessage.Focus();
        }
Esempio n. 7
0
        protected void BtnAddServiceEndPoint_Click(object sender, EventArgs e)
        {
            var servicecontracttype        = this.TBSEPServiceContractType.Text.Trim();
            var serviceContractversion     = this.TBSEPServiceContractVersion.Text.Trim();
            var servicetype                = this.TBSEPServiceType.Text.Trim();
            var serviceendpointbehaviorxml = this.TBSEPServiceEndPointBehaviorXml.Text.Trim();
            var serviceendpointbindingname = this.DDLSEPServiceEndPointBindingName.SelectedValue;
            var serviceendpointport        = int.Parse(this.TBSEPServiceEndPointPort.Text.Trim());
            var serviceendpointname        = this.TBSEPServiceEndPointName.Text.Trim();

            var context = new WcfConfigDataContext();

            var query =
                (from serviceendpoint in context.ServiceEndpoints
                 where serviceendpoint.ServiceContractType == servicecontracttype &&
                 serviceendpoint.ServiceContractVersion == serviceContractversion
                 select serviceendpoint);

            if (query.Count() < 1)
            {
                this.OnAddSubmit <ServiceEndpoint>(
                    new ServiceEndpoint()
                {
                    ServiceContractType        = servicecontracttype,
                    ServiceContractVersion     = serviceContractversion,
                    ServiceType                = servicetype,
                    ServiceEndpointBehaviorXml =
                        string.IsNullOrEmpty(serviceendpointbehaviorxml) ?
                        null : XElement.Parse(serviceendpointbehaviorxml),
                    ServiceEndpointBindingName = serviceendpointbindingname,
                    ServiceEndpointName        = serviceendpointname,
                    ServerMachineIP            = "*",
                    ServiceEndpointPort        = serviceendpointport
                },
                    this.LabelSEPServiceEndPointErrorMessage,
                    new Action[] {
                    this.InitServiceEndPoint
                }
                    );
            }
            else
            {
                var obj = query.First <ServiceEndpoint>();
                obj.ServiceContractType        = servicecontracttype;
                obj.ServiceContractVersion     = serviceContractversion;
                obj.ServiceType                = servicetype;
                obj.ServiceEndpointBehaviorXml =
                    string.IsNullOrEmpty(serviceendpointbehaviorxml) ?
                    null : XElement.Parse(serviceendpointbehaviorxml);
                obj.ServiceEndpointBindingName = serviceendpointbindingname;
                obj.ServiceEndpointName        = serviceendpointname;
                obj.ServiceEndpointPort        = serviceendpointport;
                obj.ServerMachineIP            = "*";

                context.SubmitChanges();
                this.LabelSEPServiceEndPointErrorMessage.Text = "修改成功";
                this.InitServiceEndPoint();
            }

            this.LabelSEPServiceEndPointErrorMessage.Focus();
        }