public MeterViewModel(ApplicationEvents.ShowOverlay showOverlayRequest)
 {
     this.ShowPopupGraphCommand = new DelegateCommand(() => { });
     this.ShowPopupRosterCommand = new DelegateCommand(() => showOverlayRequest.Publish(PageNames.RosterPopUp));
     this.LevelIncreaseCommand = new DelegateCommand(() => this.Competitor.RequiredImpactLevel += 5);
     this.LevelDecreaseCommand = new DelegateCommand(() => this.Competitor.RequiredImpactLevel -= 5);
 }
示例#2
0
        public void Deactivate()
        {
            // Release objects.
            if (_activeProjectType == MultiUserModeEnum.kVaultMode)
            {
                UnSubscribeEvents();
            }

            _applicationEvents.OnActiveProjectChanged -= ApplicationEvents_OnActiveProjectChanged;

            _userInputEvents       = null;
            _dockableWindowsEvents = null;
            _applicationEvents     = null;

            _vaultAddin = null;

            _myVaultBrowserButton = null;
            _myVaultBrowser       = null;

            _hwndDic = null;
            Hook.Clear();

            Marshal.ReleaseComObject(_inventorApplication);
            _inventorApplication = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
示例#3
0
        public CodeDto GetPreview(int id)
        {
            var docType     = ApplicationContext.Services.ContentTypeService.GetAllContentTypes(id).Single();
            var contentPath = ApplicationContext.Services.ContentTypeService.GetAllContentTypes(docType.Path.Split(',').Select(p => Convert.ToInt32(p)).ToArray());
            var defPath     = "~/usync/" + "DocumentType/" + String.Join("/", contentPath.Select(c => c.Alias)) + "/def.config";
            var inputPath   = HttpContext.Current.Server.MapPath(defPath);

            var typeConfig = inputPath.Contains("DocumentType")
                ? Integration.Configuration.CodeGen.DocumentTypes
                : Integration.Configuration.CodeGen.MediaTypes;

            Definitions.ContentType contentType;
            using (var reader = File.OpenText(inputPath))
                contentType = serializer.Deserialize(reader);

            var generatorFactory = ApplicationEvents.CreateFactory <CodeGeneratorFactory>(Integration.Configuration.CodeGen.GeneratorFactory);
            var classGenerator   = new CodeGenerator(typeConfig, Integration.Configuration.DataTypesProvider, generatorFactory);
            var builder          = new StringBuilder();

            using (var stream = new StringWriter(builder))
                classGenerator.Generate(contentType, stream);

            return(new CodeDto {
                Name = docType.Name, Code = builder.ToString()
            });
        }
        public SettingsPage(IFileRepository fileRepository, IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents)
        {
            Title = "Settings";
            _fileRepository = fileRepository;
            _applicationEvents = applicationEvents;

            InitializeStorageSettings(fileRepository);
            InitializeDropboxSettings(externalBrowserService, applicationEvents);

            var autoSyncValue = new EntryCell
            {
                Label = "Interval in minutes",
                IsEnabled = PersistedState.SyncInterval > 0,
                Text = PersistedState.SyncInterval > 0 ? PersistedState.SyncInterval.ToString() : string.Empty
            };
            var autoSyncSwitch = new SwitchCell
            {
                Text = "Auto sync",
                On = PersistedState.SyncInterval > 0
            };
            autoSyncSwitch.OnChanged += (sender, args) =>
            {
                if (args.Value)
                {
                    autoSyncValue.Text = "10";
                    autoSyncValue.IsEnabled = true;
                    SetSyncInterval(10);
                }
                else
                {
                    autoSyncValue.Text = string.Empty;
                    autoSyncValue.IsEnabled = false;
                    SetSyncInterval(0);
                }
            };
            autoSyncValue.Completed += (sender, args) =>
            {
                int value;
                SetSyncInterval(int.TryParse(autoSyncValue.Text, out value) ? value : 0);
            };

            Content = new TableView
            {
                Intent = TableIntent.Settings,
                Root = new TableRoot
                {
                    new TableSection("Storage")
                    {
                        _customStorageSwitch,
                        _customStorageDirectoryEntry
                    },
                    new TableSection("Cloud sync")
                    {
                        autoSyncSwitch,
                        autoSyncValue,
                        _dropboxSwitch
                    }
                }
            };
        }
示例#5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            ApplicationEvents.ApplicationStart(app.ApplicationServices, Configuration);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors("AllowCors");
            app.UseRequestLocalization(options =>
            {
                options.AddSupportedCultures("en");
                options.AddSupportedUICultures("en");
                options.DefaultRequestCulture   = new RequestCulture("en", "en");
                options.RequestCultureProviders = null;

                /*options.RequestCultureProviders = new List<IRequestCultureProvider>
                 * {
                 *  new CustomRequestCultureProvider(context => Task.FromResult(new ProviderCultureResult("fa", "fa")))
                 * };*/
            });

            app.UseMiddleware <ExceptionMiddleware>();
            app.UseSwagger();
            app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Mergen Admin API V1"); });
            app.UseAuthentication();
            app.UseMiddleware <PrincipalWrapperMiddleware>();
            app.UseAuthorization();
            app.UseMvc();

            AutoMapper.Mapper.Initialize(config => { config.CreateMissingTypeMaps = true; });
        }
示例#6
0
        private void transactionsDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                int no             = (int)transactionsDataGridView.Rows[e.RowIndex].Cells[CashBookTransaction.fNo].Value;
                int userNo         = (int)transactionsDataGridView.Rows[e.RowIndex].Cells[CashBookTransaction.fUserNo].Value;
                int categoryNo     = (int)transactionsDataGridView.Rows[e.RowIndex].Cells[CashBookTransaction.fCategoryNo].Value;
                int verificationNo = (int)transactionsDataGridView.Rows[e.RowIndex].Cells[CashBookTransaction.fVerificationNo].Value;

                var          form   = new CashBookTransactionForm(DataCache, MainForm.Guesser, no, verificationNo);
                DialogResult result = form.ShowDialog();

                if (result == DialogResult.OK)
                {
                    CashBookTransaction transaction;
                    using (var core = new StandardBusinessLayer(DataCache))
                    {
                        core.Connect();
                        transaction = core.UpdateCashBookTransaction(no, form.VerificationDate, form.AccountingDate, form.UserNo, form.CategoryNo, form.Amount, form.Note);
                    }

                    LoadTransactionGrid();
                    SelectGridTransaction(no);

                    ApplicationEvents.OnCashBookTransactionUpdated(no, transaction.VerificationNo);
                }
            }
        }
示例#7
0
        /// <summary>
        /// 初始化Http全局事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="events"></param>
        public void InitHttpApplicationEvents(object sender, ApplicationEvents events)
        {
            var applicationArgs = new EventArgs()
            {
            };

            switch (events)
            {
            case ApplicationEvents.BeginRequest:
                BeginRequest(sender, applicationArgs);
                break;

            case ApplicationEvents.EndRequest:
                EndRequest(sender, applicationArgs);
                break;

            case ApplicationEvents.Error:
                Error(sender, applicationArgs);
                break;

            case ApplicationEvents.PostResolveRequestCache:
                PostResolveRequestCache(sender, applicationArgs);
                break;

            default:
                break;
            }
        }
        public AppConfigService(ApplicationEvents.ApplicationClosing appClosingEvent)
        {
            this.Settings = new AppSettingsModel();

            // this.Load();
            // appClosingEvent.Subscribe(e => this.Save(), true);
        }
示例#9
0
        public InventorEvents()
        {
            cmd = addin.m_inventorApplication.CommandManager;

            uInterfaceEv = addin.m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;
            appEv        = addin.m_inventorApplication.ApplicationEvents;
        }
        public FeatureMigratorDockWnd(
            Inventor.ApplicationAddInSite addInSite,
            Inventor.DockingStateEnum initialDockingState)
        {
            if (addInSite == null) // We can't build the dockable window without the add-in site object.
            {
                throw new ArgumentNullException("addInSite");
            }

            _addInSite = addInSite;

            _applicationEvents = addInSite.Application.ApplicationEvents;

            _applicationEvents.OnActivateDocument += ApplicationEvents_OnActivateDocument;

            _applicationEvents.OnCloseDocument += _applicationEvents_OnCloseDocument;

            InitializeComponent();

            _browserControl.Initialize();

            _browserControl.RefreshControl(addInSite.Application.ActiveDocument);

            // Make sure the components object is created. (The designer doesn't always create it.)
            if (components == null)
            {
                components = new Container();
            }

            // Create the DockableWindow using a managed wrapper and add it to the components collection.
            components.Add(
                new DockableWindowWrapper(addInSite, this, initialDockingState),
                typeof(DockableWindowWrapper).Name);
        }
示例#11
0
        public async Task <Unit> ExecuteAsync(DeleteTab command)
        {
            var query = new QueryObject(TabQueries.DeleteTab, command);

            await _repository.ExecuteAsync(query);

            ApplicationEvents.Raise(new TabDeleted(command.Id));

            return(Unit.Value);
        }
        private static async Task DispatchEvent(object data, ApplicationEvents applicationEvent)
        {
            foreach (var client in _clients ?? new ConcurrentBag <StreamWriter>())
            {
                string eventData = string.Format("{0}\n", JsonConvert.SerializeObject(new { data, applicationEvent = $"{applicationEvent}" }));
                await client.WriteAsync(eventData);

                await client.FlushAsync();
            }
        }
 public static void Initialize(PageService pageService, IFileRepository fileRepository, IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents)
 {
     Current = new PageFactory
     {
         _pageService = pageService,
         _fileRepository = fileRepository,
         _externalBrowserService = externalBrowserService,
         _applicationEvents = applicationEvents
     };
 }
示例#14
0
 public Application(GameSettings settings) {
     DeterminePlatform();
     if (Instance != null) {
         throw new Exception();
     }
     Instance = this;
     Settings = settings;
     Events = new ApplicationEvents();
     Scenes = new List<Scene>();
 }
示例#15
0
        private void DeleteSelectedTransaction()
        {
            DialogResult result = MessageBox.Show("Du kommer att ta bort den markerade kontotransaktionen. Vill du även ta bort den aktuella affärshändelsen med alla associerade konto- och kassabokstransaktioner?\n\nJa: Alla assicierade transaktioner kommer att tas bort.\nNej: Endast den markerade transaktionen kommer att tas bort.", CurrentApplication.Name, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3);

            int transactionNo  = (int)transactionsDataGridView.SelectedRows[0].Cells[AccountTransaction.fNo].Value;
            int verificationNo = (int)transactionsDataGridView.SelectedRows[0].Cells[AccountTransaction.fVerificationNo].Value;

            try
            {
                if (result == DialogResult.Yes)
                {
                    using (var core = new StandardBusinessLayer(DataCache))
                    {
                        core.Connect();
                        core.DeleteVerificationAndAssociatedTransactions(verificationNo);
                    }

                    ApplicationEvents.OnVerificationDeleted(verificationNo);
                }
                else if (result == DialogResult.No)
                {
                    using (var core = new StandardBusinessLayer(DataCache))
                    {
                        core.Connect();

                        int noOfTransactions = core.CountAccountTransactionsByVerificationNo(verificationNo) +
                                               core.CountCashBookTransactionsByVerificationNo(verificationNo);

                        if (noOfTransactions > 1)
                        {
                            //var accountTransaction = core.GetAccountTransaction(transactionNo);
                            var  accountTransaction = DataCache.GetAccountTransaction(transactionNo);
                            bool accountHasTags     = core.CountAccountTagsByAccountNo(accountTransaction.AccountNo) > 0;

                            if (accountTransaction.Amount != 0 && accountHasTags)
                            {
                                throw new VerificationException("Du försöker ta bort en kontotransaktion från ett konto som har kontomärkningar och vars belopp inte är 0. Detta är inte tillåtet eftersom befintliga kontomärkningar kan bli felaktiga. Sätt transaktionsbeloppet för transaktionen till 0 och försök igen.");
                            }

                            DataCache.DeleteAccountTransaction(transactionNo);
                            ApplicationEvents.OnAccountTransactionDeleted(transactionNo, verificationNo);
                        }
                        else
                        {
                            core.DeleteVerificationAndAssociatedTransactions(verificationNo);
                            ApplicationEvents.OnVerificationDeleted(verificationNo);
                        }
                    }
                }
            }
            catch (VerificationException ex)
            {
                MessageBox.Show(ex.Message, CurrentApplication.Name, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
示例#16
0
 private void Update()
 {
     if (_interaction)
     {
         if (_animator.GetBool("Eat"))
         {
             _interaction = false;
             ApplicationEvents.LevelEnded(true);
         }
     }
 }
 public ComponentInstanceViewModelFactory(
     TestComponentInstanceFactory componentInstanceFactory, OutputFactory outputFactory,
     OperationViewModelFactory operationViewModelFactory, BackgroundTasks backgroundTasks,
     OperationMachinesByControlObject operationMachinesByControlObject,
     ApplicationEvents applicationEvents)
 {
     _componentInstanceFactory         = componentInstanceFactory;
     _outputFactory                    = outputFactory;
     _operationViewModelFactory        = operationViewModelFactory;
     _backgroundTasks                  = backgroundTasks;
     _operationMachinesByControlObject = operationMachinesByControlObject;
     _applicationEvents                = applicationEvents;
 }
示例#18
0
        private async Task Log(int logLevel, string userId, string message, ApplicationEvents e)
        {
            await dataContext.Logs.AddAsync(new Log()
            {
                EventDate = DateTime.Now,
                EventId   = (int)e,
                LogLevel  = logLevel,
                Message   = message,
                UserId    = userId
            });

            await dataContext.SaveChangesAsync();
        }
        /// <summary>
        /// invoke user call back
        /// </summary>
        /// <param name="wnd"></param>
        /// <param name="appEvent"></param>
        private static void ApplicationStatus(WindowData wnd, ApplicationEvents appEvent)
        {
            var timeStamp = DateTime.Now;

            wnd.AppTitle = appEvent == ApplicationEvents.Closed ? wnd.AppTitle : WindowHelper.GetWindowText(wnd.HWnd);
            wnd.AppPath  = appEvent == ApplicationEvents.Closed ? wnd.AppPath : WindowHelper.GetAppPath(wnd.HWnd);
            wnd.AppName  = appEvent == ApplicationEvents.Closed ? wnd.AppName : WindowHelper.GetAppDescription(wnd.AppPath);

            OnApplicationWindowChange?.Invoke(null, new ApplicationEventArgs()
            {
                ApplicationData = wnd, Event = appEvent
            });
        }
示例#20
0
        public MainViewModel(IRegionManager regionManager, ApplicationEvents.ShowOverlay showOverlayRequest)
        {
            showOverlayRequest.Subscribe(
                viewName =>
                    {
                        object view = regionManager.Regions[RegionNames.OverlayRegion].GetView(viewName);
                        regionManager.Regions[RegionNames.OverlayRegion].Activate(view);
                        this.PopupVisible = true;
                    }, 
                ThreadOption.UIThread, 
                true);

            this.CloseCommand = new DelegateCommand(delegate { this.PopupVisible = false; });
        }
示例#21
0
        /// <summary>
        ///     invoke user call back
        /// </summary>
        private void ApplicationStatus(WindowData wnd, ApplicationEvents appEvent)
        {
            var timeStamp = DateTime.Now;

            if (appEvent != ApplicationEvents.Closed)
            {
                UpdateWindowData(wnd);
            }

            OnApplicationWindowChange?.Invoke(null,
                                              new ApplicationEventArgs {
                ApplicationData = wnd, Event = appEvent
            });
        }
示例#22
0
        public WatchingFileReaderProvider(ApplicationEvents events)
        {
            this.events = events;

            configFileWatcher = new FileSystemWatcher(GetConfigDirectory(), WatchedFilesFilter)
            {
                NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.DirectoryName | NotifyFilters.FileName
            };
            configFileWatcher.Created            += OnFileChanged;
            configFileWatcher.Changed            += OnFileChanged;
            configFileWatcher.Renamed            += (sender, e) => events.OnConfigurationChanged();
            configFileWatcher.Deleted            += (sender, e) => events.OnConfigurationChanged();
            configFileWatcher.EnableRaisingEvents = true;
        }
示例#23
0
        public async Task <ApplicationEvents> GetApplicationEventsAsync(long appId, int?pageNumber = null,
                                                                        int?pageSize          = null, string keywords = null, DateTime?fromDate = null, DateTime?toDate = null,
                                                                        EventLevel?eventLevel = null)
        {
            if (UnitOfWork == null)
            {
                throw new InvalidOleVariantTypeException("Unit of work is not provided.");
            }

            var          result = new ApplicationEvents();
            const string getAppByIdSprocName = "GETAPPEVENTS";

            using (DbConnection connection = UnitOfWork.Connection)
            {
                await connection.OpenAsync();

                var command = connection.CreateCommand() as SqlCommand;
                if (command != null)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = getAppByIdSprocName;
                    command.Parameters.AddWithValue("@AppId", appId);
                    command.Parameters.AddWithValue("@PAGENUMBER", pageNumber.HasValue ? pageNumber.Value : 0);
                    command.Parameters.AddWithValue("@PAGESIZE",
                                                    pageSize.HasValue ? pageSize.Value : Constants.SpecialValues.MaxRowCount);
                    command.Parameters.AddWithValue("@KEYWORD", keywords);
                    command.Parameters.AddWithValue("@FDATE", fromDate);
                    command.Parameters.AddWithValue("@TODATE", toDate);
                    command.Parameters.AddWithValue("@EVENTLEVEL", (int)eventLevel);

                    using (SqlDataReader reader = await command.ExecuteReaderAsync())
                    {
                        while (await reader.ReadAsync())
                        {
                            result.TopEvents.Add(reader.GetString(reader.GetOrdinal("MESSAGE")),
                                                 reader.GetInt32(reader.GetOrdinal("CNT")));
                        }

                        await reader.NextResultAsync();

                        while (await reader.ReadAsync())
                        {
                            result.Events.Add(Mapper.Map <Event>(reader));
                        }
                    }
                }
            }
            return(result);
        }
示例#24
0
 public KickAndPunch(
     ReceiverEvents.DeviceRegistered deviceRegisteredEvent,
     ReceiverEvents.ButtonPressed buttonPressedEvent,
     ReceiverEvents.RegisterDevice registerDeviceRequest,
     ReceiverEvents.SensorHit deviceSensorHit,
     ReceiverEvents.DeviceStatusUpdate deviceStatusNotify,
     ApplicationEvents.ApplicationClosing appClosingEvent)
 {
     this.deviceRegisteredEvent = deviceRegisteredEvent;
     this.buttonPressedEvent = buttonPressedEvent;
     this.registerDeviceRequest = registerDeviceRequest;
     this.deviceSensorHit = deviceSensorHit;
     this.deviceStatusNotify = deviceStatusNotify;
     this.appClosingEvent = appClosingEvent;
 }
示例#25
0
        public async Task CheckSchema()
        {
            IServiceCollection services      = new ServiceCollection();
            IConfiguration     configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();

            services.RegisterMergenServices(configuration, true);
            var sp = services.BuildServiceProvider();

            ApplicationEvents.ApplicationStart(sp, configuration);

            using var context = sp.GetRequiredService <DataContext>();
            var comparer  = new CompareEfSql();
            var hasErrors = comparer.CompareEfWithDb(context);

            hasErrors.ShouldBeFalse(comparer.GetAllErrors);
        }
示例#26
0
        private void transactionsDataGridView_SelectionChanged(object sender, EventArgs e)
        {
            int transactionNo  = 0;
            int verificationNo = 0;

            if (transactionsDataGridView.SelectedRows.Count > 0)
            {
                transactionNo  = (int)transactionsDataGridView.SelectedRows[0].Cells[AccountTransaction.fNo].Value;
                verificationNo = (int)transactionsDataGridView.SelectedRows[0].Cells[AccountTransaction.fVerificationNo].Value;
            }

            ApplicationEvents.OnAccountTransactionSelectionChanged(transactionNo, verificationNo);
            _selectionChanged = true;

            EnableDisableControls();
        }
示例#27
0
        public async Task <ActionResult> AppEvents(long appId, int pageNumber = 0, string keywords          = "",
                                                   DateTime?fromDate          = null, EventLevel?eventLevel = null,
                                                   bool returnPartial         = false)
        {
            try
            {
                fromDate = !fromDate.HasValue
                    ? DateTime.UtcNow.AddDays(-1 * Util.GetRetentionDays())
                    : fromDate.Value.ToUniversalTime();

                if (!eventLevel.HasValue)
                {
                    eventLevel = EventLevel.Fatal | EventLevel.Error | EventLevel.Warning | EventLevel.Information;
                }


                ApplicationEvents events =
                    await
                    ApplicationBusiness.GetApplicationEventsAsync(appId, pageNumber,
                                                                  Constants.SpecialValues.PageSize, keywords, fromDate, DateTime.UtcNow, eventLevel);

                if (returnPartial)
                {
                    return(PartialView("EventGrid", events.Events));
                }

                int pNumber = pageNumber + 1;

                NameValueCollection nameValues = HttpUtility.ParseQueryString(Request.QueryString.ToString());
                nameValues.Set("pageNumber", pNumber.ToString(CultureInfo.InvariantCulture));
                nameValues.Set("returnPartial", "true");
                nameValues.Set("fromDate", fromDate.Value.ToLocalTime().ToString(CultureInfo.InvariantCulture));
                nameValues.Set("eventLevel", ((int)eventLevel.Value).ToString(CultureInfo.InvariantCulture));
                nameValues.Set("keywords", keywords);

                string url = Request.Url.AbsolutePath;
                events.NewQueryString = string.Format("{0}?{1}", url, nameValues);
                return(View(events));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                return(new ContentResult {
                    Content = "An error occured."
                });
            }
        }
示例#28
0
        private void DeleteSelectedTransaction()
        {
            DialogResult result = MessageBox.Show("Du kommer att ta bort den markerade kassabokstransaktionen. Vill du även ta bort den aktuella affärshändelsen med alla associerade konto- och kassabokstransaktioner?\n\nJa: Alla assicierade transaktioner kommer att tas bort.\nNej: Endast den markerade transaktionen kommer att tas bort.", CurrentApplication.Name, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3);

            int transactionNo  = (int)transactionsDataGridView.SelectedRows[0].Cells[CashBookTransaction.fNo].Value;
            int verificationNo = (int)transactionsDataGridView.SelectedRows[0].Cells[CashBookTransaction.fVerificationNo].Value;

            try
            {
                if (result == DialogResult.Yes)
                {
                    using (var core = new StandardBusinessLayer(DataCache))
                    {
                        core.Connect();
                        core.DeleteVerificationAndAssociatedTransactions(verificationNo);
                    }

                    ApplicationEvents.OnVerificationDeleted(verificationNo);
                }
                else if (result == DialogResult.No)
                {
                    using (var core = new StandardBusinessLayer(DataCache))
                    {
                        core.Connect();

                        int noOfTransactions = core.CountAccountTransactionsByVerificationNo(verificationNo) +
                                               core.CountCashBookTransactionsByVerificationNo(verificationNo);

                        if (noOfTransactions > 1)
                        {
                            DataCache.DeleteCashBookTransaction(transactionNo);
                            ApplicationEvents.OnCashBookTransactionDeleted(transactionNo, verificationNo);
                        }
                        else
                        {
                            core.DeleteVerificationAndAssociatedTransactions(verificationNo);
                            ApplicationEvents.OnVerificationDeleted(verificationNo);
                        }
                    }
                }
            }
            catch (VerificationException ex)
            {
                MessageBox.Show(ex.Message, CurrentApplication.Name, MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
示例#29
0
 public void InitApplicationEvents(object sender, ApplicationEvents events)
 {
     var applicationArgs = new ApplicationArgs()
     {
         ApplicationContext = GlobalApplicationObject.Current.ApplicationContext
     };
     switch (events)
     {
         case ApplicationEvents.OnApplication_PreInitialize:
             OnApplication_PreInitialize(sender, applicationArgs);
             break;
         case ApplicationEvents.OnApplication_InitializeComplete:
             OnApplication_InitializeComplete(sender, applicationArgs);
             break;
         default:
             break;
     }
 }
示例#30
0
        static async Task Main(string[] args)
        {
            try
            {
                IServiceCollection services      = new ServiceCollection();
                IConfiguration     configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();
                services.RegisterMergenServices(configuration, true);
                var sp = services.BuildServiceProvider();
                ApplicationEvents.ApplicationStart(sp, configuration);

                var db            = sp.GetRequiredService <DataContext>();
                var gamingService = new GamingService(db);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
示例#31
0
        public CashBookTransaction AddCashBookTransaction(int verificationNo, DateTime verificationDate, DateTime accountingDate, int userNo, int categoryNo, decimal amount,
                                                          string note)
        {
            Verification        verification;
            CashBookTransaction transaction;

            if (verificationNo > 0)
            {
                verification = DataCache.GetVerification(verificationNo);
            }
            else
            {
                verification = CreateNewVerification(verificationDate.Year);
            }

            if (verification.Date.Year != verificationDate.Year)
            {
                throw new InvalidOperationException("Datumet på verifikationen stämmer inte överens med dess värde.");
            }

            using (var transactionScope = new TransactionScope(TransactionScopeOption.Required, TransactionHelper.Options(System.Transactions.IsolationLevel.ReadCommitted)))
            {
                Database.TheConnection.EnlistTransaction(Transaction.Current);

                verification.Date           = DanielEiserman.DateAndTime.Date.FloorDateTime(verificationDate);
                verification.AccountingDate = DanielEiserman.DateAndTime.Date.FloorDateTime(accountingDate);
                DataCache.Save(verification);

                transaction = new CashBookTransaction(userNo, categoryNo, verification.No, verification.Date, verification.AccountingDate, amount,
                                                      note, CurrentApplication.DateTimeNow);
                DataCache.Save(transaction);

                transactionScope.Complete();
            }

            // Alert all listeners that a transaction was created
            ApplicationEvents.OnCashBookTransactionCreated(transaction.No, transaction.VerificationNo);

            // Update the new verification
            CurrentApplication.CurrentVerification = DataCache.GetVerification(verification.No);

            return(transaction);
        }
示例#32
0
        public void InitApplicationEvents(object sender, ApplicationEvents events)
        {
            var applicationArgs = new ApplicationArgs()
            {
                ApplicationContext = GlobalApplicationObject.Current.ApplicationContext
            };

            switch (events)
            {
            case ApplicationEvents.OnApplication_PreInitialize:
                OnApplication_PreInitialize(sender, applicationArgs);
                break;

            case ApplicationEvents.OnApplication_InitializeComplete:
                OnApplication_InitializeComplete(sender, applicationArgs);
                break;

            default:
                break;
            }
        }
示例#33
0
        private void transactionsDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                int no             = (int)transactionsDataGridView.Rows[e.RowIndex].Cells[AccountTransaction.fNo].Value;
                int verificationNo = (int)transactionsDataGridView.Rows[e.RowIndex].Cells[AccountTransaction.fVerificationNo].Value;
                int userNo         = (int)transactionsDataGridView.Rows[e.RowIndex].Cells[AccountTransaction.fUserNo].Value;
                int accountNo      = (int)transactionsDataGridView.Rows[e.RowIndex].Cells[AccountTransaction.fAccountNo].Value;

                var          form   = new DepositWithdrawalForm(DataCache, MainForm.Guesser, accountComboBox.Text, (int)accountComboBox.ComboBox.SelectedValue, no, verificationNo);
                DialogResult result = form.ShowDialog();

                if (result == DialogResult.OK)
                {
                    AccountTransaction transaction = null;
                    using (var core = new StandardBusinessLayer(DataCache))
                    {
                        try
                        {
                            core.Connect();
                            transaction = core.UpdateAccountTransaction(no, form.VerificationDate, form.AccountingDate, userNo, accountNo,
                                                                        form.Amount, form.Note, form.GetTagComboBoxItem.Action,
                                                                        form.GetTagComboBoxItem.AccountTag != null ? form.GetTagComboBoxItem.AccountTag.No : 0);
                        }
                        catch (MoneyTagException ex)
                        {
                            MessageBox.Show(ex.Message, "Felaktig transaktion", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }

                    LoadTransactionGrid();
                    SelectGridTransaction(no);

                    if (transaction != null)
                    {
                        ApplicationEvents.OnAccountTransactionUpdated(no, transaction.VerificationNo);
                    }
                }
            }
        }
 private void InitializeDropboxSettings(IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents)
 {
     _dropboxSwitch = new SwitchCell
     {
         Text = "Use Dropbox",
         On = PersistedState.UserLogin != null && !string.IsNullOrEmpty(PersistedState.UserLogin.Secret)
     };
     _dropboxSwitch.OnChanged += (sender, args) =>
     {
         if (args.Value)
         {
             applicationEvents.Resumed += ApplicationEventsOnResumed;
             _dropboxUserPermission = new DropboxUserPermission();
             _dropboxUserPermission.AskUserForPermission(externalBrowserService);
             //(continue in ApplicationEventsOnResumed())
         }
         else
         {
             PersistedState.UserLogin = null;
         }
         SyncBootstrapper.RefreshDropboxSync(_fileRepository);
     };
 }
示例#35
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                int accountingYear = int.Parse(accountingYearTextBox.Text.Trim());

                using (var core = new StandardBusinessLayer(DataCache))
                {
                    core.Connect();

                    CashBoxSettings settings = core.GetCashBoxSettings(CashBoxSettingsNo.CurrentApplicationNo);
                    settings.AccountingYear = accountingYear;

                    core.Save(settings);

                    //CurrentApplication.CurrentVerification = core.GetFullVerification(core.GetLastVerification(accountingYear).No);
                    //CurrentApplication.CurrentVerification = DataCache.GetVerification(DataCache.GetLastVerification().No);
                }

                if (accountingYear != _fromAccountingYear)
                {
                    var settings = DataCache.Settings;
                    settings.AccountingYear = accountingYear;
                    DataCache.Save(settings);

                    ApplicationEvents.OnAccountingYearChanged(_fromAccountingYear, accountingYear);
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                MessageBox.Show("Formuläret innehåller fel.", "Valideringsfel", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
示例#36
0
 /// <summary>
 /// 初始化Http全局事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="events"></param>
 public void InitHttpApplicationEvents(object sender, ApplicationEvents events)
 {
     var applicationArgs = new EventArgs()
     {
         
     };
     switch (events)
     {
         case ApplicationEvents.BeginRequest:
             BeginRequest(sender, applicationArgs);
             break;
         case ApplicationEvents.EndRequest:
             EndRequest(sender, applicationArgs);
             break;
         case ApplicationEvents.Error:
             Error(sender, applicationArgs);
             break;
         case ApplicationEvents.PostResolveRequestCache:
             PostResolveRequestCache(sender, applicationArgs);
             break;
         default:
             break;
     }
 }
示例#37
0
        public CashBookTransaction UpdateCashBookTransaction(int cashBookTransactionNo, DateTime verificationDate, DateTime accountingDate, int userNo, int categoryNo, decimal amount,
                                                             string note)
        {
            CashBookTransaction transaction = GetCashBookTransaction(cashBookTransactionNo);

            transaction.UserNo     = userNo;
            transaction.CategoryNo = categoryNo;
            transaction.Amount     = amount;
            transaction.Note       = note;

            Verification verification = DataCache.GetVerification(transaction.VerificationNo);

            //Verification verification = GetVerification(transaction.VerificationNo);
            verification.Date           = DanielEiserman.DateAndTime.Date.FloorDateTime(verificationDate);
            verification.AccountingDate = DanielEiserman.DateAndTime.Date.FloorDateTime(accountingDate);

            if (verification.Date.Year != verificationDate.Year || verification.AccountingDate.Year != verificationDate.Year)
            {
                throw new InvalidOperationException("Datumet på verifikationen stämmer inte överens med dess värde.");
            }

            using (var transactionScope = new TransactionScope(TransactionScopeOption.Required, TransactionHelper.Options(System.Transactions.IsolationLevel.ReadCommitted)))
            {
                Database.TheConnection.EnlistTransaction(Transaction.Current);

                DataCache.Save(verification);
                DataCache.Save(transaction);

                transactionScope.Complete();
            }

            // Alert all listeners that a transaction was updated
            ApplicationEvents.OnCashBookTransactionUpdated(cashBookTransactionNo, verification.No);

            return(transaction);
        }
示例#38
0
        public OneToOneBattleTests()
        {
            IServiceCollection services      = new ServiceCollection();
            IConfiguration     configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();

            services.RegisterMergenServices(configuration, true);
            var sp = services.BuildServiceProvider();

            ApplicationEvents.ApplicationStart(sp, configuration);

            var db = sp.GetRequiredService <DataContext>();

            _gamingService = new GamingService(db);

            _player1 = new Account
            {
                Id = 1
            };

            _player2 = new Account
            {
                Id = 2
            };

            for (int i = 0; i < 100; i++)
            {
                db.Categories.Add(new Category {
                    Title = "Cat " + i
                });
                db.Questions.Add(new Question {
                    Body = "Body " + i, Answer1 = "Answer1 " + i, Answer2 = "Answer2 " + i
                });
            }

            db.SaveChanges();
        }
        public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.

            // Initialize AddIn members.
            _inventorApplication = addInSiteObject.Application;

            try
            {
                _vaultAddin = _inventorApplication.ApplicationAddIns.ItemById["{48b682bc-42e6-4953-84c5-3d253b52e77b}"];
            }
            catch
            {
                MessageBox.Show(Resources.VaultAddinNotFound, @"MyVaultBrowser", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                throw;
            }

            _applicationEvents = _inventorApplication.ApplicationEvents;
            _dockableWindowsEvents = _inventorApplication.UserInterfaceManager.DockableWindows.Events;
            _userInterfaceEvents = _inventorApplication.UserInterfaceManager.UserInterfaceEvents;

            _activeProjectType = _inventorApplication.DesignProjectManager.ActiveDesignProject.ProjectType;

            _hwndDic = new Dictionary<Document, IntPtr>();
            Hook.Initialize(this);

            _myVaultBrowser =
                _inventorApplication.UserInterfaceManager.DockableWindows.Add("{ffbbb57a-07f3-4d5c-97b0-e8e302247c7a}",
                    "myvaultbrowser", "MyVaultBrowser");
            _myVaultBrowser.Title = "Vault";
            _myVaultBrowser.ShowTitleBar = true;
            _myVaultBrowser.DisabledDockingStates = DockingStateEnum.kDockBottom | DockingStateEnum.kDockTop;
            _myVaultBrowser.SetMinimumSize(200, 150);

            SetShortCut();

            if (!_myVaultBrowser.IsCustomized)
            {
                _myVaultBrowser.DockingState = DockingStateEnum.kDockRight;
                _myVaultBrowser.Visible = true;
            }

            _applicationEvents.OnActiveProjectChanged += ApplicationEvents_OnActiveProjectChanged;
            _userInterfaceEvents.OnResetShortcuts += UserInterfaceEvents_OnResetShortcuts;

            if (_inventorApplication.Ready)
            {
                if (_activeProjectType == MultiUserModeEnum.kVaultMode)
                    TryLoadVaultAddin();
            }
            else
                _applicationEvents.OnReady += ApplicationEvents_OnReady;

        }
示例#40
0
 public async Task LogWarning(string userId, string message, ApplicationEvents e)
 {
     await Log((int)LogLevels.Warning, userId, message, e);
 }
        public void Deactivate()
        {
            // Release objects.
            if (_activeProjectType == MultiUserModeEnum.kVaultMode)
                UnSubscribeEvents();
            _applicationEvents.OnActiveProjectChanged -= ApplicationEvents_OnActiveProjectChanged;
            _userInterfaceEvents.OnResetShortcuts -= UserInterfaceEvents_OnResetShortcuts;

            _userInterfaceEvents = null;
            _dockableWindowsEvents = null;
            _applicationEvents = null;

            _vaultAddin = null;

            _myVaultBrowser = null;

            _hwndDic = null;
            Hook.Clear();

            Marshal.ReleaseComObject(_inventorApplication);
            _inventorApplication = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }