Пример #1
0
        public static Channel FromXmlType(ChannelBaseType oio)
        {
            if (oio != null)
            {
                Channel dbChannel = new Channel();
                dbChannel.ChannelId = Guid.NewGuid();

                if (oio is WebServiceChannelType)
                {
                    WebServiceChannelType webServiceChannel = oio as WebServiceChannelType;
                    dbChannel.ChannelTypeId = (int)ChannelType.ChannelTypes.WebService;
                    dbChannel.Url           = webServiceChannel.WebServiceUrl;
                }
                else if (oio is FileShareChannelType)
                {
                    FileShareChannelType fileShareChannel = oio as FileShareChannelType;
                    dbChannel.ChannelTypeId = (int)ChannelType.ChannelTypes.FileShare;
                    dbChannel.Url           = fileShareChannel.Path;
                }
                else
                {
                    return(null);
                }
                return(dbChannel);
            }
            return(null);
        }
Пример #2
0
        public CprBroker.Schemas.Part.SubscriptionType ToOioSubscription(string appToken)
        {
            CprBroker.Schemas.Part.SubscriptionType ret = null;
            if (this.DataSubscription != null)
            {
                ChangeSubscriptionType dataSubscription = new ChangeSubscriptionType();
                ret = dataSubscription;
            }
            else // birthdate subscription
            {
                BirthdateSubscriptionType birthdateSubscription = new BirthdateSubscriptionType();
                birthdateSubscription.AgeYears  = this.BirthdateSubscription.AgeYears;
                birthdateSubscription.PriorDays = this.BirthdateSubscription.PriorDays;
                ret = birthdateSubscription;
            }
            ret.SubscriptionId   = this.SubscriptionId.ToString();
            ret.ApplicationToken = appToken;
            ret.Persons          = new SubscriptionPersonsType();
            if (this.IsForAllPersons)
            {
                ret.Persons.Item = true;
            }
            else if (this.Criteria == null)
            {
                ret.Persons.Item = new PersonUuidsType()
                {
                    UUID = this.SubscriptionPersons
                           .Select(sp => sp.PersonUuid.Value.ToString())
                           .ToArray()
                };
            }
            else
            {
                ret.Persons.Item = Utilities.Strings.Deserialize <SoegObjektType>(this.Criteria.ToString());
            }

            Channel channel = this.Channels.Single();

            switch ((ChannelType.ChannelTypes)channel.ChannelTypeId)
            {
            case ChannelType.ChannelTypes.WebService:
                CprBroker.Schemas.Part.WebServiceChannelType webServiceChannel = new WebServiceChannelType();
                webServiceChannel.WebServiceUrl = channel.Url;
                ret.NotificationChannel         = webServiceChannel;
                break;

            case ChannelType.ChannelTypes.FileShare:
                CprBroker.Schemas.Part.FileShareChannelType fileShareChannel = new FileShareChannelType();
                fileShareChannel.Path   = channel.Url;
                ret.NotificationChannel = fileShareChannel;
                break;
            }
            return(ret);
        }