コード例 #1
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (value != null)
                {
                    string key = null;
                    switch ((string)value)
                    {
                    case "start":
                        key = "CallStart";
                        break;

                    case "end":
                        key = "CallEnd";
                        break;

                    case "noack":
                        key = "NoAck";
                        break;
                    }
                    if (key != null)
                    {
                        return(CulturesHelper.GetTextValue(key));
                    }
                }
                return("");
            }
            catch (Exception)
            {
                return(Binding.DoNothing);
            }
        }
コード例 #2
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     Messenger.Default.Register <ReceivedIncomingCallEvent>(this, (msg) =>
     {
         VideoWindow.Image = System.Drawing.Image.FromFile(@"Images\video_window_recevied_incoming_call.bmp");
         if (this._parentForm != null)
         {
             this._parentForm.BringToFront();
         }
     });
     Messenger.Default.Register <AcceptedIncomingCallEvent>(this, (msg) =>
     {
         VideoWindow.Image = System.Drawing.Image.FromFile(@"Images\video_window_on_phone_call.bmp");
     });
     Messenger.Default.Register <ReceivedHangUpEvent>(this, async(msg) =>
     {
         VideoWindow.Image = System.Drawing.Image.FromFile(@"Images\video_window_hang_up.bmp");
         await Task.Delay(1000);
         VideoWindow.Image = System.Drawing.Image.FromFile(@"Images\video_window_default_background.bmp");
     });
     Messenger.Default.Register <ReceivedOutgoingCallTimeoutEvent>(this, (msg) =>
     {
         MessageBox.Show(CulturesHelper.GetTextValue("OutgoingCallTimeout"));
     });
     Messenger.Default.Register <CallingEvent>(this, (msg) =>
     {
         VideoWindow.Image = System.Drawing.Image.FromFile(@"Images\video_window_calling.bmp");
     });
 }
コード例 #3
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (value != null)
                {
                    string key = null;
                    switch ((string)value)
                    {
                    case "remote":
                        key = "Remote";
                        break;

                    case "card":
                        key = "ICCard";
                        break;
                    }
                    if (key != null)
                    {
                        return(CulturesHelper.GetTextValue(key));
                    }
                }
                return("");
            }
            catch (Exception)
            {
                return(Binding.DoNothing);
            }
        }
コード例 #4
0
        private async Task SyncSipAccounts(
            CancellationToken cancelToken = new CancellationToken())
        {
            bool   result        = false;
            string sipServerIP   = Config.Instance.SIPServerIP;
            int    sipServerPort = Config.Instance.SIPServerPort;

            if (string.IsNullOrWhiteSpace(sipServerIP) || sipServerPort == 0)
            {
                throw new Exception(CulturesHelper.GetTextValue("PleaseSetTheIPAndPortNumberOfSIPServerFirst"));
            }

            // http://172.29.1.21:5050/AddSipAccount?sip_account=account1&sip_pwd=BqVXrqD0YS&apply=1
            // ring group
            // account1-account2-account3
            // http://172.29.1.21:5050/AddRingGroup?group_num=0000000000&group_list=account1-account2-account3
            //var unsyncedAccounts = this.SipAccounts.Cast<sipaccount>();
            var groups = this.SipAccounts.Groups.ToList();

            foreach (var group in groups)
            {
                result = false;
                string        roomAddress  = (string)((CollectionViewGroup)group).Name;
                List <string> accountNames = new List <string>();
                var           accounts     = (from a in this._dataModel.Data
                                              where a.C_room == roomAddress
                                              select a).ToList();

                foreach (var account in accounts)
                {
                    accountNames.Add(account.C_user);
                    if (account.C_sync == null || account.C_sync == 0)
                    {
                        result = await HttpClient.AddSipAccountAsync(sipServerIP, sipServerPort, account.C_user, account.C_password, cancelToken).ConfigureAwait(false);

                        if (result == false)
                        {
                            break;
                        }
                    }
                }

                if (!result || false == (result = await HttpClient.AddRingGroupAsync(sipServerIP, sipServerPort,
                                                                                     roomAddress.Replace("-", ""),
                                                                                     string.Join("-", accountNames),
                                                                                     cancelToken).ConfigureAwait(false)))
                {
                    continue;
                }

                foreach (var account in accounts)
                {
                    if (account.C_sync == null || account.C_sync == 0)
                    {
                        account.C_sync = 1;
                        await this._dataModel.UpdateAsync(account).ConfigureAwait(false);
                    }
                }
            }
        }
コード例 #5
0
 private void InitSeparatorTexts()
 {
     SeparatorTexts[0] = CulturesHelper.GetTextValue("DeviceAddressUnit1");
     SeparatorTexts[1] = CulturesHelper.GetTextValue("DeviceAddressUnit2");
     SeparatorTexts[2] = CulturesHelper.GetTextValue("DeviceAddressUnit3");
     SeparatorTexts[3] = CulturesHelper.GetTextValue("DeviceAddressUnit4");
     SeparatorTexts[4] = CulturesHelper.GetTextValue("DeviceAddressUnit5");
     SeparatorTexts[5] = CulturesHelper.GetTextValue("DeviceAddressUnit6");
 }
コード例 #6
0
 private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (sender is ComboBox comboBox)
     {
         if (comboBox.SelectedItem is CultureInfo cultureInfo)
         {
             CulturesHelper.ChangeCulture(cultureInfo);
         }
     }
 }
コード例 #7
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (value != null)
                {
                    string key = null;
                    switch ((string)value)
                    {
                    case "emergency":
                        key = "EmergencyDetector";
                        break;

                    case "infrared":
                        key = "InfraredDetector";
                        break;

                    case "door":
                        key = "DoorDetector";
                        break;

                    case "window":
                        key = "WindowDetector";
                        break;

                    case "smoke":
                        key = "SmokeDetector";
                        break;

                    case "gas":
                        key = "GasDetector";
                        break;

                    case "area":
                        key = "AreaDetector";
                        break;

                    case "rob":
                        key = "RobDetector";
                        break;
                    }
                    if (key != null)
                    {
                        return(CulturesHelper.GetTextValue(key));;
                    }
                }
                return("");
            }
            catch (Exception)
            {
                return(Binding.DoNothing);
            }
        }
コード例 #8
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                ProcessState state = value != null ? (ProcessState)value : ProcessState.Unprocessed;

                string key = state.ToString();
                return(CulturesHelper.GetTextValue(key));;
            }
            catch (Exception)
            {
                return(Binding.DoNothing);
            }
        }
コード例 #9
0
 public virtual object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     try
     {
         string key = _nullKey;
         if (value != null)
         {
             T enumValue = (T)value;
             key = enumValue.ToString();
         }
         return(CulturesHelper.GetTextValue(key));
     }
     catch (Exception)
     {
         return(Binding.DoNothing);
     }
 }
コード例 #10
0
	private void Launch(object state)
	{
		LaunchTimer.Dispose();
		base.Dispatcher.BeginInvoke((Action)delegate
		{
			try
			{
				CulturesHelper.CurrentCulture = Hamastar.DefaultConfig.Config.Language.ToCultureInfo();
				CulturesHelper.ChangedCulterHandler = (EventHandler)Delegate.Combine(CulturesHelper.ChangedCulterHandler, new EventHandler(ChangedCulterHandler));
				CulturesHelper culturesHelper = new CulturesHelper();
			}
			catch (Exception ex)
			{
				Utilities.AppLog.Error("Load culturesHelper occour error:" + ex.StackTrace);
			}
		});
	}
コード例 #11
0
 object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     try
     {
         if (value != null)
         {
             int?   syncStatus = (int?)value;
             string key        = (syncStatus == null || syncStatus == 0)
                        ? "Unsynced"
                        : "Synced";
             return(CulturesHelper.GetTextValue(key));
         }
         return("");
     }
     catch (Exception)
     {
         return(Binding.DoNothing);
     }
 }
コード例 #12
0
        public void Configure(IApplicationBuilder app)
        {
            if (WebHostEnvironment.IsDevelopment())
            {
                app.UseCors("EnableCORS");
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
                app.UseHttpsRedirection();
            }

            var supportedCultures = CulturesHelper.GetSupportedCulturesInfo();

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture =
                    new RequestCulture(Cultures.RU.GetEnumDescription()),
                SupportedCultures   = supportedCultures,
                SupportedUICultures = supportedCultures
            });

            app.UseCustomExceptionHandler();
            app.UseHealthChecks("/health");

            const string specificationRoute = "/api/specification.json";

            app.UseOpenApi(settings => settings.Path = specificationRoute);
            app.UseSwaggerUi3(settings =>
            {
                settings.Path         = "/api";
                settings.DocumentPath = specificationRoute;
            });

            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        }
コード例 #13
0
        private void CallDevice(Device device)
        {
            if (device == null)
            {
                this._dialogService.ShowMessageBox(CulturesHelper.GetTextValue("TheDeviceDoesNotExist"));
                return;
            }

            lock (m_SyncRoot)
            {
                this.ClientDevice = device;
                this.CallState    = CallState.Calling;
            }
            _RingTimeoutAction.Start(RingTimeout);
            //StartRingTimeoutTimer(RingTimeout);
            Application.Current.Dispatcher.Invoke(() => Messenger.Default.Send(new CallingEvent()));
            NativeMethods.Dll_DataOut((int)VideoTalkOperation.emMEET_REQUEST,
                                      new StringBuilder(device.ip),
                                      new StringBuilder(device.roomid.Replace("-", "")));
        }
コード例 #14
0
 object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     try
     {
         string key = value as string;
         if (key != null)
         {
             string result = CulturesHelper.GetTextValue(key);
             if (string.IsNullOrEmpty(result))
             {
                 return(key);
             }
             return(result);
         }
         return("");
     }
     catch (Exception)
     {
         return(Binding.DoNothing);
     }
 }
コード例 #15
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (value != null)
                {
                    string key = null;
                    switch ((string)value)
                    {
                    case "enable":
                        key = "Arming";
                        break;

                    case "disable":
                        key = "Disarmed";
                        break;

                    case "trig":
                        key = "EventTrigger";
                        break;

                    case "unalarm":
                        key = "EventLifted";
                        break;
                    }
                    if (key != null)
                    {
                        return(CulturesHelper.GetTextValue(key));
                    }
                }
                return("");
            }
            catch (Exception)
            {
                return(Binding.DoNothing);
            }
        }
コード例 #16
0
        object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                string input  = value as string;
                string output = "";
                if (string.IsNullOrWhiteSpace(input))
                {
                    string key = parameter as string;
                    if (!string.IsNullOrWhiteSpace(key))
                    {
                        output = CulturesHelper.GetTextValue(key);
                    }
                    return(output);
                }

                InitSeparatorTexts();

                input = input.Trim().Replace("-", "");
                const int MAX_LENGTH = 12;
                int       length     = Math.Min(MAX_LENGTH, input.Length);
                for (int i = 0; i < length;)
                {
                    string token = input.Substring(i, Math.Min(2, length - i));
                    output += (token.Length == 2)
                           ? token + SeparatorTexts[i / 2]
                           : token;
                    i += token.Length;
                }

                return(output);
            }
            catch (Exception)
            {
                return(Binding.DoNothing);
            }
        }