Example #1
0
        private void AddDevice(IDevice device, Gtk.TreeIter iter)
        {
            // choose the deviceInformation to create
            IDeviceInformation deviceInformation = null;

            if (device is IWiimote)
            {
                _ListStore.SetValue(iter, 0, "Wiimote");
                deviceInformation = new WiimoteInformation(this, (IWiimote)device);
            }
            else if (device is IBalanceBoard)
            {
                _ListStore.SetValue(iter, 0, "Balanceboard");
                deviceInformation = new BalanceBoardInformation((IBalanceBoard)device);
            }

            // add a seperator to the form to separate from other deviceInformations
            deviceInformation.Separator = new VSeparator();
            _HBox.PackStart(deviceInformation.Separator);
            deviceInformation.Separator.Show();

            // add the deviceInformation to the form
            _HBox.PackStart(deviceInformation.Widget, false, false, 0);
            deviceInformation.Widget.Show();
            _DeviceInformations.Add(deviceInformation);
            _DeviceNodes[deviceInformation] = iter;

            // register for the event so the deviceInformation can be removed upon disconnection
            device.Disconnected += new EventHandler(DeviceDisconnected);
        }
Example #2
0
 public void Remove(ISection section, Action <OnCompleteEventArgs> onComplete)
 {
     if (!IsOpened)
     {
         _uiNotifier.Notify(() => onComplete(new OnCompleteEventArgs(OnCompleteEventArgs.CompleteResult.Error, "Сперва необходимо открыть репозиторий!")));
     }
     else
     {
         _backWorker.AddWork(
             () => {
             try {
                 var devInfosToRemove = _deviceInformationStorage.DeviceInformations.Where(di => di.Id.ToString() == section.DeviceInformationId.ToString()).ToList();
                 foreach (var devInfo in devInfosToRemove)
                 {
                     IDeviceInformation info = devInfo;                                     // for closure
                     var idsToRemove         = _psnDataInformtationStorage.PsnDataInformations.Where(pdi => pdi.DeviceInformationId == info.Id).Select(pdi => pdi.Id).ToList();
                     foreach (var idToRemove in idsToRemove)
                     {
                         _psnDataStorage.Remove(idToRemove);
                         _psnDataInformtationStorage.Remove(idToRemove);
                         _psnDataCustomConfigurationsStorage.Remove(idToRemove);
                     }
                     // TODO: remove RPD logs
                     _deviceInformationStorage.Remove(devInfo.Id);
                 }
                 UpdateLocomotivesIfDeletedUnsafe();
                 _uiNotifier.Notify(() => onComplete(new OnCompleteEventArgs(OnCompleteEventArgs.CompleteResult.Ok, "Секция удалена из репозитория")));
             }
             catch (Exception ex) {
                 _uiNotifier.Notify(() => onComplete(new OnCompleteEventArgs(OnCompleteEventArgs.CompleteResult.Error, ex.ToString())));
             }
         });
     }
 }
        /// <summary>
        /// Creates a new instance of the <see cref="RegisterIdentityModel"/> class.
        /// <param name="tagProfile">The tag profile to work with.</param>
        /// <param name="uiDispatcher">The UI dispatcher for alerts.</param>
        /// <param name="neuronService">The Neuron service for XMPP communication.</param>
        /// <param name="navigationService">The navigation service to use for app navigation</param>
        /// <param name="settingsService">The settings service for persisting UI state.</param>
        /// <param name="networkService">The network service for network access.</param>
        /// <param name="logService">The log service.</param>
        /// <param name="imageCacheService">The image cache to use.</param>
        /// </summary>
        public RegisterIdentityViewModel(
            ITagProfile tagProfile,
            IUiDispatcher uiDispatcher,
            INeuronService neuronService,
            INavigationService navigationService,
            ISettingsService settingsService,
            INetworkService networkService,
            ILogService logService,
            IImageCacheService imageCacheService)
            : base(RegistrationStep.RegisterIdentity, tagProfile, uiDispatcher, neuronService, navigationService, settingsService, logService)
        {
            this.networkService = networkService;
            IDeviceInformation deviceInfo = DependencyService.Get <IDeviceInformation>();

            this.DeviceId  = deviceInfo?.GetDeviceId();
            this.Countries = new ObservableCollection <string>();
            foreach (string country in ISO_3166_1.Countries)
            {
                this.Countries.Add(country);
            }
            this.SelectedCountry    = null;
            this.RegisterCommand    = new Command(async _ => await Register(), _ => CanRegister());
            this.TakePhotoCommand   = new Command(async _ => await TakePhoto(), _ => !IsBusy);
            this.PickPhotoCommand   = new Command(async _ => await PickPhoto(), _ => !IsBusy);
            this.RemovePhotoCommand = new Command(_ => RemovePhoto(true));
            this.Title = AppResources.PersonalLegalInformation;
            this.PersonalNumberPlaceholder = AppResources.PersonalNumber;
            this.localPhotoFileName        = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ProfilePhotoFileName);
            imageCacheService = imageCacheService ?? DependencyService.Resolve <IImageCacheService>();
            this.photosLoader = new PhotosLoader(logService, networkService, neuronService, uiDispatcher, imageCacheService);
        }
 public SynchroMiddleWare(
     IPullSynchro pullSynchro,
     IServerPushSynchro serverPushSynchro,
     IDeviceInformation deviceInformation,
     IDateTimeService dateTimeService)
 {
     this.pullSynchro       = pullSynchro;
     this.serverPushSynchro = serverPushSynchro;
     this.deviceInformation = deviceInformation;
     this.dateTimeService   = dateTimeService;
 }
        private string CreateReportFile(Exception ex, bool isApiError, IDeviceInformation device, string title, string message)
        {
            // Create the custom report
            var          guid   = Guid.NewGuid();
            const string space  = "\r\n";
            var          baseEx = ex.GetBaseException();
            // Feel free to add any (key: value)
            // Metadata that you need
            // also remove colons on value to avoid break the report
            var report =
                "Format: Xamarin" + space +
                "Package: " + string.Format("com.{0}.casino", device.GetApplicationName().ToLower()) + space +
                "Version: " + device.GetApplicationVersionNumber() + space +
                "IsApiError: " + isApiError + space +
                //"User: "******"Title: " + title.Replace(":", "=") + space +
                "Message: " + "Feedback Handled Exception - " + message.Replace(":", "=") + space +
                "CrashReporter Key: " + guid +
                space + space +
                baseEx.Message.Replace(":", "=") + space +
                baseEx.StackTrace;

            return(report);
        }
Example #6
0
        private void InitialTreeBuildUnsafe(Action <double> progressChangeAction)
        {
            // Этот метод, в отличие от UpdateLocomotivesUnsafe() не оперирует хэшами,
            // что позволяет выиграть производительность в медленных хранилищах (например, NAND)

            var devInfos     = _deviceInformationStorage.DeviceInformations.ToList();
            var psnDatas     = _psnDataStorage.PsnDatas.ToList();
            var psnDataInfos = _psnDataInformtationStorage.PsnDataInformations.ToList();

            var signal = new AutoResetEvent(false);
            //Exception exc = null;
            //_uiNotifier.Notify(
            //() => {
            //try {
            int totalDevInfosCount    = devInfos.Count;
            int currentDevInfoZbIndex = 0;

            foreach (var devInfo in devInfos)
            {
                var loc = new Locomotive(devInfo.Name, _backWorker, _deviceInformationStorage);

                _uiNotifier.NotifyAndWait(() => _locomotives.Add(loc));


                var section = new Section(new UidStringToLower(devInfo.Id.IdentyString), devInfo.Description, _backWorker, _deviceInformationStorage);

                _uiNotifier.NotifyAndWait(() => loc.Sections.Add(section));


                IDeviceInformation info = devInfo;

                var psnDatasInfosForDev       = psnDataInfos.Where(pdi => pdi.DeviceInformationId.ToString() == info.Id.ToString()).ToList();
                var totalPsnDatasCount        = psnDatasInfosForDev.Count;
                int currentPsnDataInfoZbIndex = 0;
                foreach (var psnDataInfo in psnDatasInfosForDev)
                {
                    try {
                        var psnData         = psnDatas.First(pl => pl.Id.IdentyString == psnDataInfo.Id.IdentyString);
                        var psnCustomConfig = _psnDataCustomConfigurationsStorage.Configurations.First(pc => pc.Id.IdentyString == psnDataInfo.Id.IdentyString);

                        var psnConfig = _psnConfigurationsStorage.StoredItems.First(pc => pc.Id.IdentyString.ToLower() == psnCustomConfig.PsnConfigurationId.IdentyString.ToLower());

                        var builder           = new PsnProtocolConfigBuilderFromLowLevel(psnConfig);
                        var psnProtocolConfig = builder.Build();

                        IPsnDataInformation dataInfo = psnDataInfo;
                        var psnLog = new PsnLogRelay(
                            psnDataInfo
                            , psnData
                            , psnProtocolConfig
                            , psnConfig
                            , psnCustomConfig
                            , _uiNotifier
                            , _backWorker
                            , _psnConfigurationsStorage
                            , _psnDataCustomConfigurationsStorage
                            , _kvStorageHolder);

                        _uiNotifier.NotifyAndWait(() => section.Psns.Add(psnLog));
                    }
                    catch (Exception ex) {
                        // TODO: catch exception and deliver it to user as warning message
                        Console.WriteLine(ex);
                    }
                    currentPsnDataInfoZbIndex++;
                    progressChangeAction((currentDevInfoZbIndex * 100.0 + currentPsnDataInfoZbIndex * 100.0 / totalPsnDatasCount) / totalDevInfosCount);
                }
                currentDevInfoZbIndex++;
                progressChangeAction(currentDevInfoZbIndex * 100.0 / totalDevInfosCount);
            }
        }
Example #7
0
        private void UpdateLocomotivesIfAddedUnsafe()
        {
            var devInfos           = _deviceInformationStorage.DeviceInformations.ToList();
            var psnDatas           = _psnDataStorage.PsnDatas.ToList();
            var psnDataInfos       = _psnDataInformtationStorage.PsnDataInformations.ToList();
            var psnDataCustomInfos = _psnDataCustomConfigurationsStorage.Configurations.ToList();

            // TODO: нужно работать максимально в фоне: в потоке UI только операции изменения ObservableCollection коллекций

            // 1. Check for newly things:
            foreach (var devInfo in devInfos)
            {
                var loc = _locomotives.FirstOrDefault(l => l.Name == devInfo.Name);
                if (loc == null)
                {
                    loc = new Locomotive(devInfo.Name, _backWorker, _deviceInformationStorage);

                    _uiNotifier.NotifyAndWait(() => _locomotives.Add(loc));
                }
                // at that point loc exist

                var section = loc.Sections.FirstOrDefault(s => s.Name == devInfo.Description);
                if (section == null)
                {
                    section = new Section(new UidStringToLower(devInfo.Id.IdentyString), devInfo.Description, _backWorker, _deviceInformationStorage);
                    _uiNotifier.NotifyAndWait(() => loc.Sections.Add(section));
                }
                // at that point section already exist


                IDeviceInformation currentDeviceInformation = devInfo;

                var possiblePsnDataToAdd = psnDataInfos.Where(pdi => pdi.DeviceInformationId.ToString() == currentDeviceInformation.Id.ToString()).ToList();
                foreach (var psnDataInformation in possiblePsnDataToAdd)
                {
                    // Условие ниже исключает добавление уже присутствующих у секции логов:
                    if (section.Psns.All(pl => pl.Id.UnicString != psnDataInformation.Id.IdentyString))
                    {
                        try {
                            var data              = psnDatas.First(d => d.Id.ToString() == psnDataInformation.Id.ToString());                // TODO: can throw exception if data fail saved
                            var dataCustomInfo    = psnDataCustomInfos.First(pdci => pdci.Id.ToString() == psnDataInformation.Id.ToString());
                            var dataPsnConfig     = _psnConfigurationsStorage.StoredItems.First(pc => pc.Information.Id.IdentyString == dataCustomInfo.PsnConfigurationId.IdentyString);
                            var builder           = new PsnProtocolConfigBuilderFromLowLevel(dataPsnConfig);
                            var psnProtocolConfig = builder.Build();


                            var logToAdd = new PsnLogRelay(
                                psnDataInformation
                                , data
                                , psnProtocolConfig
                                , dataPsnConfig
                                , dataCustomInfo
                                , _uiNotifier
                                , _backWorker
                                , _psnConfigurationsStorage
                                , _psnDataCustomConfigurationsStorage
                                , _kvStorageHolder);

                            _uiNotifier.NotifyAndWait(() => section.Psns.Add(logToAdd));
                        }
                        catch {
                            // Значит ошибка получения данных ПСН, либо ошибка получения кастомной информации
                            continue;
                        }
                    }
                    // else log exist in list
                }
            }
        }
Example #8
0
        /// <summary>
        /// Inits this instance.
        /// </summary>
        private void init(Guid applicationId, UploadType uploadType, string applicationVersion)
        {
            this.applicationId = applicationId;
            this.applicationVersion = applicationVersion;
            this.sessionId = Guid.NewGuid();

            this.iStorageDal = new StorageSql(connectonString);
            this.iUploadDal = new UploadWS(baseUrl);

            this.iDeviceInformation = new DeviceInformation();
            this.iDeviceDynamicInformation = new DeviceDynamicInformation();
            this.iPlatform = new Platform();

            try
            {
                this.initDatabase();

                this.databaseExists = true;
            }
            catch (ExceptionDatabaseLayer) { }

            if (this.databaseExists)
            {
                AppactsPlugin.Data.Model.ApplicationMeta applicationMeta = null;
                bool applicationInitialSetup = false;

                try
                {
                    applicationMeta = this.iStorageDal.GetApplication(this.applicationId);

                    if (applicationMeta == null)
                    {
                        applicationMeta = new ApplicationMeta(this.applicationId, ApplicationStateType.Close, DateTime.Now, OptStatusType.OptIn);

                        this.iStorageDal.Save(applicationMeta);
                        applicationInitialSetup = true;
                    }
                }
                catch (ExceptionDatabaseLayer ex)
                {
                    this.logSystemError(ex);
                }

                try
                {
                    this.optStatusType = applicationMeta.OptStatus;

                    if (applicationMeta.State == ApplicationStateType.Open)
                    {
                        this.iStorageDal.Save(new Crash(this.applicationId, applicationMeta.SessionId, this.applicationVersion));
                    }

                    this.iStorageDal.Save(new EventItem(this.applicationId, null, null,
                        EventType.ApplicationOpen, 0, this.sessionId, this.applicationVersion));

                    applicationMeta.SessionId = this.sessionId;
                    applicationMeta.State = ApplicationStateType.Open;

                    if (applicationMeta.Version == null || applicationMeta.Version != this.applicationVersion)
                    {
                        applicationMeta.Version = this.applicationVersion;
                        applicationMeta.Upgraded = !applicationInitialSetup;
                    }

                    this.iStorageDal.Update(applicationMeta);

                    //#if DEBUG
                   // throw new ExceptionDatabaseLayer(new Exception("Random test"));
                    //#endif
                }
                catch (ExceptionDatabaseLayer exceptionDatabaseLayer)
                {
                    this.logSystemError(exceptionDatabaseLayer);
                }
            }

            this.session = new Session();
        }