예제 #1
0
        public AmqpCloudEventMessage(CloudEvent cloudEvent, ContentMode contentMode, ICloudEventFormatter formatter)
        {
            ApplicationProperties = new ApplicationProperties();
            MapHeaders(cloudEvent);

            if (contentMode == ContentMode.Structured)
            {
                BodySection = new Data
                {
                    Binary = formatter.EncodeStructuredEvent(cloudEvent, out var contentType)
                };
                Properties = new Properties {
                    ContentType = contentType.MediaType
                };
                ApplicationProperties = new ApplicationProperties();
                MapHeaders(cloudEvent);
                return;
            }
            else
            {
                BodySection = SerializeData(cloudEvent.Data);
                Properties  = new Properties {
                    ContentType = cloudEvent.DataContentType
                };
            }
        }
        public static void Configure()
        {
            GlobalContext.Properties["applicationName"] = ApplicationProperties.GetApplicationName();
            GlobalContext.Properties["applicationKey"]  = ApplicationProperties.GetApplicationKey();

            //XmlConfigurator.Configure();
        }
예제 #3
0
        private static ApplicationProperties MapHeaders(CloudEvent cloudEvent)
        {
            var applicationProperties = new ApplicationProperties();
            var properties            = applicationProperties.Map;

            properties.Add(SpecVersionAmqpHeader, cloudEvent.SpecVersion.VersionId);

            foreach (var pair in cloudEvent.GetPopulatedAttributes())
            {
                var attribute = pair.Key;

                // The content type is specified elsewhere.
                if (attribute == cloudEvent.SpecVersion.DataContentTypeAttribute)
                {
                    continue;
                }

                string propKey = AmqpHeaderPrefix + attribute.Name;

                // TODO: Check that AMQP can handle byte[], bool and int values
                object propValue = pair.Value switch
                {
                    Uri uri => uri.ToString(),
                    // AMQPNetLite doesn't support DateTimeOffset values, so convert to UTC.
                    // That means we can't roundtrip events with non-UTC timestamps, but that's not awful.
                    DateTimeOffset dto => dto.UtcDateTime,
                       _ => pair.Value
                };
                properties.Add(propKey, propValue);
            }
            return(applicationProperties);
        }
    }
예제 #4
0
 public JsonSerializedMessage(T messageContent) : base(JsonSerializer.SerializeToUtf8Bytes(messageContent))
 {
     ContentType = "application/json";
     MessageId   = Guid.NewGuid().ToString();
     SessionId   = Guid.NewGuid().ToString();
     Subject     = typeof(T).Name.Replace(nameof(EventMessage), string.Empty);
     ApplicationProperties.Add("messageName", typeof(T).Name);
 }
예제 #5
0
 protected BaseDomain(
     ApplicationProperties applicationProperties, IFileCacheHelper fileCacheHelper,
     IBaseService <TModel> service, WarmupTypes warmupType = WarmupTypes.Sql) :
     base(applicationProperties, fileCacheHelper, warmupType, false)
 {
     _service = service;
     ConstructData();
 }
예제 #6
0
        public void NumberOfUpdateMethodEqualsVersionInSettingsHelper()
        {
            var data     = Data.CreateDataStorage();
            var upgrader = new SettingsUpgrader(data);

            var settingsVersion = new ApplicationProperties().SettingsVersion;

            Assert.AreEqual(settingsVersion, upgrader.NumberOfUpgradeMethods());
        }
예제 #7
0
        public MeetingLabelItemDataCreatePageViewModel(INavigationService navigationService) : base(navigationService)
        {
            _restService     = new RestService();
            _operateDateTime = new OperateDateTime();

            _createMeetingLabelItemValidation = new CreateMeetingLabelItemValidation();
            _tokenCheckValidation             = new TokenCheckValidation(_restService);
            _applicationProperties            = new ApplicationProperties();
            _meetingLabelItemDatas            = new ObservableCollection <MeetingLabelItemData>();
            _createMeetingLabelItemParam      = new CreateMeetingLabelItemParam();

            _additionalMeetingLabelItemDatas = new List <MeetingLabelItemData>();

            //会議の各ラベルに項目(Item)を追加するコマンド
            CreateMeetingLabelItemCommand = new DelegateCommand(async() =>
            {
                //項目入力値のバリデーション
                CreateMeetingLabelItemParam = _createMeetingLabelItemValidation.InputValidate(InputLabelItemName);
                if (CreateMeetingLabelItemParam.HasError == true)
                {
                    return;
                }



                //uid取得の際のtoken情報照合
                TokenCheckParam = await _tokenCheckValidation.Validate(_applicationProperties.GetFromProperties <TokenData>("token"));

                var inputUid = 0;

                if (TokenCheckParam.HasError == true)
                {
                    return;
                }
                else
                {
                    //token情報照合に成功したらuid取得
                    GetUserParam = await _restService.GetUserDataAsync(UserConstants.OpenUserEndPoint, _applicationProperties.GetFromProperties <string>("userId"));

                    if (GetUserParam.HasError == true)
                    {
                        return;
                    }
                    else
                    {
                        //userDataの取得に成功したらuidを代入
                        var userData = GetUserParam.User;
                        inputUid     = userData.Id;
                    }
                }
                var meetingLabelItemData = new MeetingLabelItemData(TargetMeetingLabel.Id, inputUid, InputLabelItemName);
                MeetingLabelItemDatas.Add(meetingLabelItemData);
                AdditionalMeetingLabelItemDatas.Add(meetingLabelItemData);

                InputLabelItemName = "";
            });
        }
예제 #8
0
파일: Runtime.cs 프로젝트: d8q8/NanUI
        internal Runtime(RuntimeOptions options) : this()
        {
            _options = options;

            if (ApplicationProperties.ContainsKey("UseDebuggingMode"))
            {
                IsDebuggingMode = true;
            }
        }
예제 #9
0
        private static void Main(string[] args)
        {
            Trace.TraceLevel    = TraceLevel.Frame;
            Trace.TraceListener = (f, a) =>
                                  System.Diagnostics.Trace.WriteLine(DateTime.Now.ToString("[hh:ss.fff]") + " " + string.Format(f, a));

            // Ignore root certificate store and accept all SSL certificates.
            Connection.DisableServerCertValidation = true;

            var amqpConnection = new Connection(
                new Address("amqps://*****:*****@bus001.servicebus.windows.net"))
            {
                Closed = (sender, error) => { Console.WriteLine("Connection closed"); }
            };

            var amqpSession = new Session(amqpConnection)
            {
                Closed = (sender, error) => { Console.WriteLine("Session closed"); }
            };

            var amqpSender = new SenderLink(amqpSession,
                                            "send-link/" + TopicName, // unique name for all links from this client
                                            TopicName)                // Service Bus topic name
            {
                Closed = (sender, error) => { Console.WriteLine("SenderLink closed"); }
            };

            for (var i = 1; i < 6; i++)
            {
                var properties = new Properties
                {
                    Subject   = "Message #" + i,
                    MessageId = Guid.NewGuid().ToString()
                };

                var appProperties = new ApplicationProperties();
                appProperties["MyProperty"] = "Hello World!";

                var message = new Message
                {
                    Properties            = properties,
                    ApplicationProperties = appProperties
                };

                amqpSender.Send(message, (msg, outcome, state) =>
                {
                    Console.WriteLine("Message sent");
                }, null);
            }

            Console.WriteLine("Press ENTER to quit");
            Console.ReadLine();

            amqpSender.Close();
            amqpSession.Close();
            amqpConnection.Close();
        }
        public override async void OnNavigatingTo(INavigationParameters parameters)
        {
            base.OnNavigatingTo(parameters);

            LoadingData = true;

            _restService           = new RestService();
            _applicationProperties = new ApplicationProperties();

            //participantsDBにuidが存在するかどうか読み込み
            GetUserParam = await _restService.GetUserDataAsync(UserConstants.OpenUserEndPoint, _applicationProperties.GetFromProperties <string>("userId"));

            var uid = GetUserParam.User.Id;
            var mid = (int)parameters["mid"];

            CheckParticipantParam = await _restService.CheckParticipantDataAsync(MeetingConstants.OPENMeetingParticipantEndPoint, uid, mid);

            if (CheckParticipantParam.HasError == true)
            {
                return;
            }

            //対象の会議データ取得

            TargetMeetingId = (int)parameters["mid"];
            GetMeetingParam = await _restService.GetMeetingDataAsync(MeetingConstants.OpenMeetingEndPoint, TargetMeetingId);

            TargetMeetingData = GetMeetingParam.MeetingData;

            //会議が終了状態でないかどうか判定
            if (GetMeetingParam.MeetingData.IsVisible == false)
            {
                var p = new NavigationParameters
                {
                    { "ErrorPageType", ErrorPageType.FinishedMeeting }
                };
                //終了している会議なのでエラー画面に飛ばす
                await _navigationService.NavigateAsync("/NavigationPage/ErrorTemplatePage", p);
            }

            //会議管理者かどうか取得
            if (TargetMeetingData.Owner == GetUserParam.User.Id)
            {
                IsOwner = true;
            }
            else
            {
                IsGeneral = true;
            }

            LoadingData = false;

            Reload();

            //Participants全件取得
            Participants = await GetParticipants();
        }
예제 #11
0
        void DeepCopy(AmqpMessage source)
        {
            if (source.header != null)
            {
                this.header               = new Header();
                this.header.Durable       = source.header.Durable;
                this.header.Priority      = source.header.Priority;
                this.header.Ttl           = source.header.Ttl;
                this.header.FirstAcquirer = source.header.FirstAcquirer;
                this.header.DeliveryCount = source.header.DeliveryCount;
            }

            if (source.deliveryAnnotations != null)
            {
                this.deliveryAnnotations = new DeliveryAnnotations();
                this.deliveryAnnotations.Map.Merge(source.deliveryAnnotations.Map);
            }

            if (source.messageAnnotations != null)
            {
                this.messageAnnotations = new MessageAnnotations();
                this.messageAnnotations.Map.Merge(source.messageAnnotations.Map);
            }

            if (source.applicationProperties != null)
            {
                this.applicationProperties = new ApplicationProperties();
                this.applicationProperties.Map.Merge(source.applicationProperties.Map);
            }

            if (source.properties != null)
            {
                this.properties                    = new Properties();
                this.properties.MessageId          = source.properties.MessageId;
                this.properties.UserId             = source.properties.UserId;
                this.properties.To                 = source.properties.To;
                this.properties.Subject            = source.properties.Subject;
                this.properties.ReplyTo            = source.properties.ReplyTo;
                this.properties.CorrelationId      = source.properties.CorrelationId;
                this.properties.ContentType        = source.properties.ContentType;
                this.properties.ContentEncoding    = source.properties.ContentEncoding;
                this.properties.AbsoluteExpiryTime = source.properties.AbsoluteExpiryTime;
                this.properties.CreationTime       = source.properties.CreationTime;
                this.properties.GroupId            = source.properties.GroupId;
                this.properties.GroupSequence      = source.properties.GroupSequence;
                this.properties.ReplyToGroupId     = source.properties.ReplyToGroupId;
            }

            if (source.footer != null)
            {
                this.footer = new Footer();
                this.footer.Map.Merge(source.footer.Map);
            }

            this.sectionFlags |= (source.sectionFlags & SectionFlag.NonBody);
        }
예제 #12
0
 void ShadowCopy(AmqpMessage source)
 {
     this.header = source.header;
     this.deliveryAnnotations   = source.deliveryAnnotations;
     this.messageAnnotations    = source.messageAnnotations;
     this.properties            = source.properties;
     this.applicationProperties = source.applicationProperties;
     this.footer        = source.footer;
     this.sectionFlags |= (source.sectionFlags & SectionFlag.NonBody);
 }
        private void GenerateServiceFromApplicationPropertiesFile()
        {
            ApplicationProperties myApplicationProperties = ApplicationProperties.Read();

            this.mySmartobject = new SmartObject(
                myApplicationProperties.Uuid,
                myApplicationProperties.Name,
                myApplicationProperties.Description,
                myApplicationProperties.Token);
        }
예제 #14
0
        public void ApplicationProperties_GetFromProperties_Success()
        {
            MockForms.Init();
            Application.Current = new CustomApplication();
            Application.Current.Properties.Add("testSuccessKey", "testValue");

            var applicationProperties = new ApplicationProperties();

            Assert.IsTrue("testValue".Equals(applicationProperties.GetFromProperties <string>("testSuccessKey")));
        }
        public static AMQPSection getSection(IByteBuffer buf)
        {
            TLVAmqp value = TLVFactory.getTlv(buf);

            AMQPSection section = null;

            Byte         byteCode = value.Constructor.getDescriptorCode().Value;
            SectionCodes code     = (SectionCodes)byteCode;

            switch (code)
            {
            case SectionCodes.APPLICATION_PROPERTIES:
                section = new ApplicationProperties();
                break;

            case SectionCodes.DATA:
                section = new AMQPData();
                break;

            case SectionCodes.DELIVERY_ANNOTATIONS:
                section = new DeliveryAnnotations();
                break;

            case SectionCodes.FOOTER:
                section = new AMQPFooter();
                break;

            case SectionCodes.HEADER:
                section = new MessageHeader();
                break;

            case SectionCodes.MESSAGE_ANNOTATIONS:
                section = new MessageAnnotations();
                break;

            case SectionCodes.PROPERTIES:
                section = new AMQPProperties();
                break;

            case SectionCodes.SEQUENCE:
                section = new AMQPSequence();
                break;

            case SectionCodes.VALUE:
                section = new AMQPValue();
                break;

            default:
                throw new MalformedMessageException("Received header with unrecognized message section code");
            }

            section.fill(value);

            return(section);
        }
예제 #16
0
        public void ApplicationProperties_GetFromProperties_Failure()
        {
            MockForms.Init();
            Application.Current = new CustomApplication();
            Application.Current.Properties.Add("testKey", "testValue");

            var applicationProperties = new ApplicationProperties();

            Assert.IsNull(applicationProperties.GetFromProperties <string>(string.Empty));
            Assert.IsNull(applicationProperties.GetFromProperties <string>("notExistKey"));
        }
            public void ReadApplicationPropertiesFile()
            {
                var applicationProperties = ApplicationProperties.Read();

                Assert.Equal("ws://localhost:8085", applicationProperties.Url);
                Assert.Equal("SmartObject", applicationProperties.ServiceType);
                Assert.Equal("057f5eb2-cc23-4e8a-99e1-abb8f63ca3a4", applicationProperties.Uuid);
                Assert.Equal("C# Sample Client", applicationProperties.Name);
                Assert.Equal("Description of C# Sample Client", applicationProperties.Description);
                Assert.Equal("ecd4c916-e98c-40db-ba1c-b39050183540", applicationProperties.Token);
            }
예제 #18
0
        public void Settings_ImplementPropertyChanged()
        {
            var wasRaised = false;
            var settings  = new ApplicationProperties();

            settings.PropertyChanged += (sender, args) => wasRaised = true;

            settings.NextUpdate = DateTime.Today;

            Assert.IsTrue(wasRaised);
        }
예제 #19
0
        protected BaseDomainServiceless(ApplicationProperties applicationProperties, IFileCacheHelper fileCacheHelper, WarmupTypes warmupType = WarmupTypes.Sql, bool constructData = false)
        {
            _warmupType            = warmupType;
            _fileCacheHelper       = fileCacheHelper;
            _applicationProperties = applicationProperties;

            if (constructData)
            {
                ConstructData();
            }
        }
예제 #20
0
 public void receive(int lCMReceiveRate, ApplicationProperties props, RTMATransmitter rtmaTransmitter)
 {
     try
     {
         lCM.SubscribeAll(new SimpleSubscriber(props, rtmaTransmitter));
     }
     catch (Exception e)
     {
         Console.Error.WriteLine("Ex: " + e);
         Environment.Exit(1);
     }
 }
예제 #21
0
        public void ApplicationProperties_ClearPropertie_Success()
        {
            MockForms.Init();
            Application.Current = new CustomApplication();
            Application.Current.Properties.Add("testClearKey", "testClearValue");

            var applicationProperties = new ApplicationProperties();

            applicationProperties.ClearPropertie("testClearKey");

            Assert.IsNull(applicationProperties.GetFromProperties <string>("testClearKey"));
        }
 public ApplicationSettingsWindow(ApplicationSettings applicationSettings,
                                  ApplicationProperties applicationProperties, IEnumerable <ConversionProfile> conversionProfiles)
     : this()
 {
     GeneralTabUserControl.ViewModel.ApplicationSettings   = applicationSettings;
     GeneralTabUserControl.ViewModel.ApplicationProperties = applicationProperties;
     GeneralTabUserControl.PreviewLanguageAction           = PreviewLanguageAction;
     TitleTabUserControl.ViewModel.ApplyTitleReplacements(applicationSettings.TitleReplacement);
     DebugTabUserControl.ViewModel.ApplicationSettings = applicationSettings;
     DebugTabUserControl.UpdateSettings = UpdateSettingsAction;
     PrinterTabUserControl.ViewModel.ConversionProfiles  = conversionProfiles;
     PrinterTabUserControl.ViewModel.ApplicationSettings = applicationSettings;
 }
예제 #23
0
 /// <summary>
 /// Creates a new message from the specified received message by copying the properties.
 /// </summary>
 /// <param name="receivedMessage">The received message to copy the data from.</param>
 public ServiceBusMessage(ServiceBusReceivedMessage receivedMessage)
 {
     Argument.AssertNotNull(receivedMessage, nameof(receivedMessage));
     AmqpMessage = new AmqpAnnotatedMessage(receivedMessage.AmqpMessage);
     AmqpMessage.Header.DeliveryCount = null;
     AmqpMessage.MessageAnnotations.Remove(AmqpMessageConstants.LockedUntilName);
     AmqpMessage.MessageAnnotations.Remove(AmqpMessageConstants.SequenceNumberName);
     AmqpMessage.MessageAnnotations.Remove(AmqpMessageConstants.DeadLetterSourceName);
     AmqpMessage.MessageAnnotations.Remove(AmqpMessageConstants.EnqueueSequenceNumberName);
     AmqpMessage.MessageAnnotations.Remove(AmqpMessageConstants.EnqueuedTimeUtcName);
     ApplicationProperties.Remove(AmqpMessageConstants.DeadLetterReasonHeader);
     ApplicationProperties.Remove(AmqpMessageConstants.DeadLetterErrorDescriptionHeader);
 }
예제 #24
0
        //...

        public Themes(BaseApplication application) : base()
        {
            Get.New <Themes>(this);
            DefaultResources.Add(new AssemblyResource(AssemblyData.Name));

            application.Resources.MergedDictionaries.Add(this);
            application.Resources.MergedDictionaries.Add(New(AssemblyData.Name, $"Styles/Generic.xaml"));

            FolderPath = $@"{ApplicationProperties.GetFolderPath(DataFolders.Documents)}\Themes";
            if (!Folder.Long.Exists(FolderPath))
            {
                System.IO.Directory.CreateDirectory(FolderPath);
            }

            Custom.Refresh(FolderPath);
        }
예제 #25
0
 protected void InitApplicationProperties()
 {
     if (this.applicationProperties == null && this.message.ApplicationProperties == null)
     {
         this.applicationProperties         = new ApplicationProperties();
         this.message.ApplicationProperties = this.applicationProperties;
     }
     else if (this.applicationProperties == null && this.message.ApplicationProperties != null)
     {
         this.applicationProperties = this.message.ApplicationProperties;
     }
     else if (this.applicationProperties != null && this.message.ApplicationProperties == null)
     {
         this.message.ApplicationProperties = this.applicationProperties;
     }
 }
예제 #26
0
        public LoginPageViewModel(INavigationService navigationService) : base(navigationService)
        {
            _navigationService = navigationService;

            _restService           = new RestService();
            _applicationProperties = new ApplicationProperties();

            LoginParam = new LoginParam();


            //新規登録ページへ遷移
            NavigationSignUpPageCommand = new DelegateCommand(() =>
            {
                _navigationService.NavigateAsync("SignUpPage");
            });

            //ログインボタンの動作
            LoginCommand = new DelegateCommand(async() =>
            {
                //ローディング情報の表示
                LoadingLogin = true;

                //ログインAPIのコール
                LoginParam = await _restService.LoginUserDataAsync(UserConstants.OpenUserLoginEndPoint, LoginUserId, LoginPassword);

                //ログイン処理にエラーが無く追加が実行されていれば
                if (LoginParam.HasError == false)
                {
                    //token情報を保持する
                    var tokenData = LoginParam.TokenData;
                    _applicationProperties.SaveToProperties <TokenData>("token", tokenData);
                    //ローカルにuserId情報を保持する
                    _applicationProperties.SaveToProperties <string>("userId", LoginUserId);

                    //ローディング情報を非表示にする
                    LoadingLogin = false;

                    //会議情報トップページに遷移する
                    await _navigationService.NavigateAsync("/NavigationPage/MeetingDataTopPage");
                }
                else
                {
                    //ローディング情報を非表示にする
                    LoadingLogin = false;
                }
            });
        }
예제 #27
0
        public ErrorTemplatePageViewModel(INavigationService navigationService) : base(navigationService)
        {
            _navigationService     = navigationService;
            _applicationProperties = new ApplicationProperties();


            NavigateLoginPageCommand = new DelegateCommand(() =>

            {
                //ログイン済情報の削除
                _applicationProperties.ClearPropertie("userId");
                _applicationProperties.ClearPropertie("token");

                //ログインページに遷移させる
                _navigationService.NavigateAsync("/NavigationPage/LoginPage");
            });
        }
예제 #28
0
        /// <summary>
        /// Initialize with NextUpdate and UpdateInterval from Settings
        /// </summary>
        /// <param name="appSettings">Current ApplicationSettings</param>
        /// <param name="appProperties">Current ApplicationProperties</param>
        /// <param name="gpoSettings">Current GpoSettings</param>
        public void Initialize(ApplicationSettings appSettings, ApplicationProperties appProperties, GpoSettings gpoSettings)
        {
            NextUpdate = appProperties.NextUpdate;

            if (EditionFactory.Instance.Edition.HideAndDisableUpdates)
            {
                _updateInterval = UpdateInterval.Never;
            }
            else if ((gpoSettings == null) || (gpoSettings.UpdateInterval == null))
            {
                _updateInterval = appSettings.UpdateInterval;
            }
            else
            {
                _updateInterval = SettingsHelper.GetUpdateInterval(gpoSettings.UpdateInterval);
            }

            _logger.Debug("UpdateManager initialised");
        }
예제 #29
0
        /// <summary>
        /// Serializes the object to JSON.
        /// </summary>
        /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param>
        /// <param name="obj">The object to serialize to JSON.</param>
        internal static void Serialize(JsonWriter writer, ApplicationProperties obj)
        {
            // Required properties are always serialized, optional properties are serialized when not null.
            writer.WriteStartObject();
            writer.WriteProperty(obj.Status, "status", ResourceStatusConverter.Serialize);
            writer.WriteProperty(obj.HealthState, "healthState", HealthStateConverter.Serialize);
            if (obj.Description != null)
            {
                writer.WriteProperty(obj.Description, "description", JsonWriterExtensions.WriteStringValue);
            }

            if (obj.Services != null)
            {
                writer.WriteEnumerableProperty(obj.Services, "services", ServiceResourceDescriptionConverter.Serialize);
            }

            if (obj.Diagnostics != null)
            {
                writer.WriteProperty(obj.Diagnostics, "diagnostics", DiagnosticsDescriptionConverter.Serialize);
            }

            if (obj.DebugParams != null)
            {
                writer.WriteProperty(obj.DebugParams, "debugParams", JsonWriterExtensions.WriteStringValue);
            }

            if (obj.ServiceNames != null)
            {
                writer.WriteEnumerableProperty(obj.ServiceNames, "serviceNames", (w, v) => writer.WriteStringValue(v));
            }

            if (obj.StatusDetails != null)
            {
                writer.WriteProperty(obj.StatusDetails, "statusDetails", JsonWriterExtensions.WriteStringValue);
            }

            if (obj.UnhealthyEvaluation != null)
            {
                writer.WriteProperty(obj.UnhealthyEvaluation, "unhealthyEvaluation", JsonWriterExtensions.WriteStringValue);
            }

            writer.WriteEndObject();
        }
 public StompSocketProvider(StompMessageSerializer serializer, ApplicationProperties properties)
 {
     _serializer = serializer;
     _properties = properties;
     InitializeWebSocket();
 }