Beispiel #1
0
        public void Alter()
        {
            MessageType msgType = null;

            if (this.ServiceBroker.MessageTypes.Contains(this.FullName))
            {
                // Create message types
                msgType = this.ServiceBroker.MessageTypes[this.FullName];

                msgType.MessageTypeValidation = this.MessageTypeValidation;

                if (msgType.MessageTypeValidation == MessageTypeValidation.XmlSchemaCollection)
                {
                    if (!String.IsNullOrEmpty(this.ValidationXmlSchemaCollection) ||
                        !String.IsNullOrEmpty(this.ValidationXmlSchemaCollectionSchema))
                    {
                        //Must drop and re-create
                        this.Drop();

                        //Re-create the contract
                        this.Create();
                    }
                }
                else
                {
                    msgType.Alter();
                }
            }
        }
Beispiel #2
0
        internal static void DeploySsbObj(object obj, string svrName, string dbName, SsbEnum ssbType, bool isEdit)
        {
            Server               svr  = CreateServer(svrName, null, null);
            Database             db   = svr.Databases[dbName];
            ServiceBroker        sb   = db.ServiceBroker;
            MessageType          mt   = null;
            ServiceContract      sc   = null;
            ServiceQueue         q    = null;
            BrokerService        serv = null;
            ServiceRoute         rt   = null;
            RemoteServiceBinding bind = null;

            try {
                switch (ssbType)
                {
                case SsbEnum.MessageType:
                    MessageType mtNew = new MessageType();
                    mtNew.Parent = sb;
                    mt           = (MessageType)obj;
                    mtNew.Name   = mt.Name;
                    mtNew.MessageTypeValidation = mt.MessageTypeValidation;
                    if (mt.MessageTypeValidation == MessageTypeValidation.XmlSchemaCollection)
                    {
                        mtNew.ValidationXmlSchemaCollection = mt.ValidationXmlSchemaCollection;
                    }

                    if (isEdit)
                    {
                        mtNew.Alter();
                    }
                    else
                    {
                        mtNew.Create();
                    }

                    break;

                case SsbEnum.Contract:
                    ServiceContract scNew = new ServiceContract();
                    sc           = (ServiceContract)obj;
                    scNew.Parent = sb;
                    scNew.Name   = sc.Name;
                    foreach (MessageTypeMapping mtm in sc.MessageTypeMappings)
                    {
                        if (!sb.MessageTypes.Contains(mtm.Name))
                        {
                            ServiceBroker sbParent = sc.Parent;
                            MessageType   mtp      = sbParent.MessageTypes[mtm.Name];
                            DeploySsbObj(mtp, svrName, dbName, SsbEnum.MessageType, false);
                        }

                        MessageTypeMapping mtmNew = new MessageTypeMapping();
                        mtmNew.Name          = mtm.Name;
                        mtmNew.Parent        = scNew;
                        mtmNew.MessageSource = mtm.MessageSource;
                        scNew.MessageTypeMappings.Add(mtmNew);
                    }

                    if (isEdit)
                    {
                        scNew.Alter();
                    }
                    else
                    {
                        scNew.Create();
                    }

                    break;

                case SsbEnum.Queu:
                    q        = (ServiceQueue)obj;
                    q.Parent = sb;

                    if (isEdit)
                    {
                        q.Alter();
                    }
                    else
                    {
                        q.Create();
                    }

                    break;

                case SsbEnum.Service:
                    serv        = (BrokerService)obj;
                    serv.Parent = sb;

                    if (isEdit)
                    {
                        serv.Alter();
                    }
                    else
                    {
                        serv.Create();
                    }

                    break;

                case SsbEnum.Route:
                    rt        = (ServiceRoute)obj;
                    rt.Parent = sb;

                    if (isEdit)
                    {
                        rt.Alter();
                    }
                    else
                    {
                        rt.Create();
                    }

                    break;

                case SsbEnum.RemoteBinding:
                    bind        = (RemoteServiceBinding)obj;
                    bind.Parent = sb;

                    if (isEdit)
                    {
                        bind.Alter();
                    }
                    else
                    {
                        bind.Create();
                    }

                    break;
                }
            }
            catch (FailedOperationException e) {
                string err = string.Format("{0}", e.InnerException);
                //throw;
            }
            catch (Exception ex) {
                string errx = string.Format("{0}", ex.InnerException);
            }

            finally {
                svr.ConnectionContext.Disconnect();
            }
        }
Beispiel #3
0
        internal static void DeploySsbObj(object obj, string svrName, string dbName, SsbEnum ssbType, bool isEdit)
        {
            Server svr = CreateServer(svrName, null, null);
              Database db = svr.Databases[dbName];
              ServiceBroker sb = db.ServiceBroker;
              MessageType mt = null;
              ServiceContract sc = null;
              ServiceQueue q = null;
              BrokerService serv = null;
              ServiceRoute rt = null;
              RemoteServiceBinding bind = null;

              try {
            switch (ssbType) {
              case SsbEnum.MessageType:
            MessageType mtNew = new MessageType();
            mtNew.Parent = sb;
            mt = (MessageType)obj;
            mtNew.Name = mt.Name;
            mtNew.MessageTypeValidation = mt.MessageTypeValidation;
            if (mt.MessageTypeValidation == MessageTypeValidation.XmlSchemaCollection)
              mtNew.ValidationXmlSchemaCollection = mt.ValidationXmlSchemaCollection;

            if (isEdit)
              mtNew.Alter();
            else
              mtNew.Create();

            break;

              case SsbEnum.Contract:
            ServiceContract scNew = new ServiceContract();
            sc = (ServiceContract)obj;
            scNew.Parent = sb;
            scNew.Name = sc.Name;
            foreach (MessageTypeMapping mtm in sc.MessageTypeMappings) {
              if (!sb.MessageTypes.Contains(mtm.Name)) {
                ServiceBroker sbParent = sc.Parent;
                MessageType mtp = sbParent.MessageTypes[mtm.Name];
                DeploySsbObj(mtp, svrName, dbName, SsbEnum.MessageType, false);
              }

              MessageTypeMapping mtmNew = new MessageTypeMapping();
              mtmNew.Name = mtm.Name;
              mtmNew.Parent = scNew;
              mtmNew.MessageSource = mtm.MessageSource;
              scNew.MessageTypeMappings.Add(mtmNew);

            }

            if (isEdit)
              scNew.Alter();
            else
              scNew.Create();

            break;

              case SsbEnum.Queu:
            q = (ServiceQueue)obj;
            q.Parent = sb;

            if (isEdit)
              q.Alter();
            else
              q.Create();

            break;

              case SsbEnum.Service:
            serv = (BrokerService)obj;
            serv.Parent = sb;

            if (isEdit)
              serv.Alter();
            else
              serv.Create();

            break;

              case SsbEnum.Route:
            rt = (ServiceRoute)obj;
            rt.Parent = sb;

            if (isEdit)
              rt.Alter();
            else
              rt.Create();

            break;

              case SsbEnum.RemoteBinding:
            bind = (RemoteServiceBinding)obj;
            bind.Parent = sb;

            if (isEdit)
              bind.Alter();
            else
              bind.Create();

            break;

            }
              }
              catch (FailedOperationException e) {
            string err = string.Format("{0}", e.InnerException);
            //throw;
              }
              catch (Exception ex) {
            string errx = string.Format("{0}", ex.InnerException);

              }

              finally {
            svr.ConnectionContext.Disconnect();
              }
        }