예제 #1
0
        public void Show()
        {
            Console.WriteLine("Example 7\n\n");
            Console.WriteLine("Example shows \"QueryMultiple\" method to select multiple data from db:\n\n");

            try
            {
                _initializationRepository.Initialize();
                Console.WriteLine("QueryMultiple method execution, press any key to begin:");
                Console.ReadKey();
                Console.WriteLine("\nQueryMultiple anonymous object after connecting two objects from query result:");
                try
                {
                    var multiple = _repository.GetEmployeeAndItsAddress();
                    ConsoleExtension.WriteObject(multiple);
                }
                catch (Exception exception)
                {
                    Console.WriteLine($"nQueryMultiple method has thrown an exception: \n\n{exception.Message}");
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(ConnectionStore.ConnectionErrorProvider(exception.Message));
            }

            GetBackChooser.GetBack();
        }
예제 #2
0
        private async Task SubscribeToGroupAsync(string groupChannel, ConnectionStore groupConnections)
        {
            RedisLog.Subscribing(_logger, groupChannel);
            var channel = await _bus.SubscribeAsync(groupChannel);

            channel.OnMessage(async(channelMessage) =>
            {
                try
                {
                    var invocation = _protocol.ReadInvocation((byte[])channelMessage.Message);

                    var tasks = new List <Task>();
                    foreach (var groupConnection in groupConnections)
                    {
                        if (invocation.ExcludedConnectionIds?.Contains(groupConnection.ConnectionId) == true)
                        {
                            continue;
                        }

                        tasks.Add(groupConnection.WriteAsync(invocation.Message, CancellationToken.None));
                    }

                    await Task.WhenAll(tasks);
                }
                catch (Exception ex)
                {
                    RedisLog.FailedWritingMessage(_logger, ex);
                }
            });
        }
예제 #3
0
        private static string GetActionName(IMacroAction macroAction)
        {
            Group       group       = null;
            Application application = null;

            switch (macroAction.Type)
            {
            case MacroActionType.Start:
            case MacroActionType.Stop:
            case MacroActionType.Restart:
                MacroProcessAction macroProcessAction = (MacroProcessAction)macroAction;
                Machine            machine            = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroProcessAction.MachineID);
                if (machine != null && ConnectionStore.ConnectionCreated(machine))
                {
                    group       = ConnectionStore.Connections[machine].Configuration.Groups.FirstOrDefault(x => x.ID == macroProcessAction.GroupID);
                    application = ConnectionStore.Connections[machine].Configuration.Applications.FirstOrDefault(x => x.ID == macroProcessAction.ApplicationID);
                }
                return(machine == null || group == null || application == null
                                                ? null
                                                : $"{group.Name} / {application.Name}");

            case MacroActionType.Distribute:
                MacroDistributionAction macroDistributionAction = (MacroDistributionAction)macroAction;
                Machine destinationMachine = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroDistributionAction.DestinationMachineID);
                if (destinationMachine == null || !ConnectionStore.ConnectionCreated(destinationMachine))
                {
                    return(null);
                }
                Machine sourceMachine = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroDistributionAction.SourceMachineID);
                if (sourceMachine != null && ConnectionStore.ConnectionCreated(sourceMachine))
                {
                    group       = ConnectionStore.Connections[sourceMachine].Configuration.Groups.FirstOrDefault(x => x.ID == macroDistributionAction.GroupID);
                    application = ConnectionStore.Connections[sourceMachine].Configuration.Applications.FirstOrDefault(x => x.ID == macroDistributionAction.ApplicationID);
                }
                return(sourceMachine == null || group == null || application == null
                                                ? null
                                                : $"{sourceMachine.HostName} / {group.Name} / {application.Name}");

            case MacroActionType.Wait:
                MacroWaitAction macroWaitAction = (MacroWaitAction)macroAction;
                if (!macroWaitAction.IsValid)
                {
                    throw new InvalidOperationException();
                }
                switch (macroWaitAction.WaitForEvent)
                {
                case MacroActionWaitForEvent.Timeout:
                    return($"{macroWaitAction.Type} for timeout, {macroWaitAction.TimeoutMilliseconds} ms");

                case MacroActionWaitForEvent.PreviousActionsCompleted:
                    return($"{macroWaitAction.Type} for previous actions completed");

                default:
                    throw new InvalidOperationException();
                }

            default:
                throw new InvalidOperationException();
            }
        }
예제 #4
0
        public void Show()
        {
            Console.WriteLine("Example 1\n\n");
            Console.WriteLine("Example shows Query method to get strongly typed instance on an mapped object:\n\n");

            try
            {
                Console.WriteLine("Single object:");
                var employee  = _repository.GetPerson();
                var employees = _repository.GetPeople();
                ConsoleExtension.WriteObject(employee);
                Console.WriteLine("\n\nPress any buttons to show all objects:/n");
                Console.ReadKey();
                Console.WriteLine();
                ConsoleExtension.WriteObject(employees);
                Console.WriteLine();
                bool result = false;
                do
                {
                    Console.WriteLine("The question is: Which ORM is faster Dapper, Entity Framework or Linq2SQL?");
                    Console.WriteLine("Press 1 for the first, 2 for the second and 3 for the third answer:");
                    var fasterORMQuestionAnswer = Console.ReadKey().KeyChar;
                    result = new QuestionAnswerHandler(EQuestionType.FastestORM)
                             .HandleAnswer(fasterORMQuestionAnswer);
                    Console.WriteLine();
                }while (!result);
            }
            catch (Exception exception)
            {
                Console.WriteLine(ConnectionStore.ConnectionErrorProvider(exception.Message));
            }

            GetBackChooser.GetBack();
        }
예제 #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, ILoggerFactory loggerFactory, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //Enable sessions
            app.UseSession();
            app.UseMvc();
            app.UseCors("AllowAll");

            GlobalConfiguration.Configuration.UseActivator(new HangfireActivator(serviceProvider));

            app.UseHangfireServer();
            app.UseHangfireDashboard();

            //RecurringJob.AddOrUpdate<ILadderService>(ls => ls.UpdateLadders(), Cron.MinuteInterval(1));

            app.UseSignalR(routes =>
            {
                routes.MapHub <PartyHub>("/hubs/party", options =>
                {
                    // 30Kb message buffer
                    options.ApplicationMaxBufferSize = 30 * 1024 * 1024;
                });
            });



            LadderStore.Initialize();
            ConnectionStore.Initialize();
            leagueTimer.Start();
        }
 private void RemoveNotification(Notification notification)
 {
     foreach (ConnectionInformation connectionInfo in ConnectionStore.GetConnections(notification.userName))
     {
         connectionInfo.Remove(notification);
     }
 }
예제 #7
0
        public FileSystemBrowserForm(Machine machine)
        {
            InitializeComponent();

            Machine                  = machine;
            SelectedPath             = string.Empty;
            Description              = "Select a file or folder...";
            BrowserMode              = Mode.File | Mode.Folder;
            Filter                   = DEFAULT_FILTER;
            _machineAvailable        = ConnectionStore.ConnectionCreated(Machine);
            _entryTree               = new Dictionary <IFileSystemEntry, IFileSystemEntry>();
            _entryNodes              = new Dictionary <IFileSystemEntry, FileSystemTreeNode>();
            _entryFilter             = new Dictionary <IFileSystemEntry, string>();
            _entryQueue              = new PrioritizedEntryQueue();
            _pathExpansionQueue      = null;
            _pathExpansionWaitCursor = null;
            _lastAutoExpandedNode    = null;
            _machineNode             = null;

            imageList.Images.Add(IMAGE_LIST_KEY_MACHINE, MakeIconImage(Resources.machine_16));
            imageList.Images.Add(IMAGE_LIST_KEY_FOLDER, MakeIconImage(Resources.folder_16));
            imageList.Images.Add(FileSystemDriveType.RemovableDisk.ToString(), MakeIconImage(Resources.drive_removable_disk_16));
            imageList.Images.Add(FileSystemDriveType.LocalDisk.ToString(), MakeIconImage(Resources.drive_local_disk_16));
            imageList.Images.Add(FileSystemDriveType.NetworkDrive.ToString(), MakeIconImage(Resources.drive_network_16));
            imageList.Images.Add(FileSystemDriveType.CompactDisc.ToString(), MakeIconImage(Resources.drive_compact_disc_16));
        }
예제 #8
0
 public static void WaitForConfiguration(List <Machine> machines)
 {
     if (machines != null && machines.Any(machine => machine != null && !ConnectionStore.ConfigurationAvailable(machine)))
     {
         Worker.WaitFor("Retrieving configuration...", () => machines.All(machine => ConnectionStore.Connections[machine].ServiceHandler.Status == ProcessManagerServiceHandlerStatus.Disconnected ||
                                                                          ConnectionStore.ConfigurationAvailable(machine)));
     }
 }
        private void UpdateNotificationList()
        {
            IEnumerable <Notification> userNotifications = NotificationStore.GetNotifications(UserIdentity.UserName);

            foreach (ConnectionInformation connectionInfo in ConnectionStore.GetConnections(UserIdentity.UserName))
            {
                connectionInfo.UpdateNotificationList(userNotifications);
            }
        }
        public void Connect(string connectionId, string clientAddress, string applicationVersion, string browserVersion)
        {
            ConnectionInformation info = new ConnectionInformation(UserIdentity, connectionId, clientAddress, applicationVersion, browserVersion);

            ConnectionStore.Connect(info);

            // Send updated notification list to all connected clients
            //UpdateNotificationList();
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="SixtyNineProtocolHandler" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="messageHandler">The message handler.</param>
 /// <param name="messageSender">The message sender.</param>
 /// <param name="connectionStore">The connection store.</param>
 /// <autogeneratedoc />
 public SixtyNineProtocolHandler(ILogger <SixtyNineProtocolHandler> logger, IMessageHandler messageHandler,
                                 IMessageSender messageSender, ConnectionStore connectionStore, IMessageReader <SixtyNineMessage> messageReader)
 {
     _logger          = logger;
     _messageHandler  = messageHandler;
     _messageSender   = messageSender;
     _connectionStore = connectionStore;
     _messageReader   = messageReader;
 }
        public void SendNotifications(string connectionId)
        {
            IEnumerable <Notification> userNotifications = NotificationStore.GetNotifications();
            var connection = ConnectionStore.GetAllConnections().FirstOrDefault(con => con.ConnectionId == connectionId);

            if (connection != null)
            {
                connection.UpdateNotificationList(userNotifications);
            }
        }
 private void UpdateSelectedGroup()
 {
     if (SelectedGroup != null)
     {
         SelectedGroup = SelectedSourceMachine == null || !ConnectionStore.ConfigurationAvailable(SelectedSourceMachine)
                                 ? null
                                 : ConnectionStore.Connections[SelectedSourceMachine].Configuration.Groups
                         .FirstOrDefault(group => Comparer.GroupsEqual(group, SelectedGroup));
     }
     UpdateLinkLabelGroup();
 }
        /// <summary>
        /// Send notification message to active clients
        /// </summary>
        /// <param name="notificationType">Type of notification</param>
        /// <param name="logLevel">Log level (UI display)</param>
        /// <param name="message">Message to display</param>
        /// <param name="data">Additional details (custom class)</param>
        public string Notify(string notificationType, INotificationDetail notificationDetail, LogLevel logLevel, IConvertible notificationId = null, bool broadcast = false)
        {
            string       userName     = (broadcast) ? null : UserIdentity.UserName;
            Notification notification = NotificationStore.AddUpdate(notificationId.ToString(), notificationType, notificationDetail, userName, logLevel);

            foreach (ConnectionInformation connectionInfo in ConnectionStore.GetAllConnections())
            {
                connectionInfo.Notify(notification);
            }

            return(notificationId.ToString());
        }
예제 #15
0
        public DistributionSourcesForm(Machine machine, Application application, Func <IEnumerable <Group> > getAllGroups)
        {
            InitializeComponent();

            Machine                    = machine;
            Application                = application;
            DistributionSources        = new List <DistributionSource>(application.Sources.Select(source => source.Clone()));
            DistributionSourcesChanged = false;
            _getAllGroups              = getAllGroups;
            _machineAvailable          = ConnectionStore.ConnectionCreated(Machine);
            _selectedSource            = null;
            _disableStateChangedEvents = false;
        }
 public List <Dictionary <string, object> > GetActiveSessions()
 {
     return(ConnectionStore.GetAllConnections().Select(session => new Dictionary <string, object>()
     {
         { "UserName", session.UserName },
         { "DomainName", session.DomainName },
         { "EnvironmentName", session.EnvironmentName },
         { "ClientAddress", session.ClientAddress },
         //{ "ClientHostName", ServiceMetrics.GetHostName(session.ClientAddress) },
         { "ApplicationVersion", session.ApplicationVersion },
         { "BrowserVersion", session.BrowserVersion },
         { "ConnectedDate", session.ConnectedDate }
     }).ToList());
 }
예제 #17
0
        public void Show()
        {
            Console.WriteLine("Example 3\n\n");
            Console.WriteLine("Example shows \"QueryFirst\" method to select data from Employee table:\n\n");

            try
            {
                Console.WriteLine("QueryFirst method execution, press any key to begin:");
                Console.ReadKey();
                Console.WriteLine();
                Console.WriteLine("I'm working, please be patient...\n");
                _repository.PopulateEmployeeWithFakeData();
                var watchDapper = new Stopwatch();
                watchDapper.Start();
                var dapperMethod = _repository.GetFirstEmployee();
                watchDapper.Stop();
                var watchLinq = new Stopwatch();
                watchLinq.Start();
                var linqMethod = _repository.GetFirstEmployeeFiltered();
                watchLinq.Stop();
                ConsoleExtension.WriteObject(dapperMethod);
                Console.WriteLine($"\nElapsed time: {watchDapper.ElapsedMilliseconds}\n");
                ConsoleExtension.WriteObject(linqMethod);
                Console.WriteLine($"\nElapsed time: {watchLinq.ElapsedMilliseconds}\n");
                bool result = false;;
                do
                {
                    Console.WriteLine("The question is: Which of two queries above was a Dapper query?");
                    Console.WriteLine("Press 1 for the first and 2 for the second answer:");
                    var dapperQuestionAnswer = Console.ReadKey().KeyChar;
                    result = new QuestionAnswerHandler(EQuestionType.QueryFirstQuestion)
                             .HandleAnswer(dapperQuestionAnswer);
                    Console.WriteLine();
                }while (!result);
                Console.WriteLine("\n");
                Console.WriteLine("Clearing db table");
                _repository.ClearAllEmployeeData();
                Console.WriteLine("Db table cleared");
                Console.WriteLine("Reinitializing db tables");
                _initializationRepository.Initialize();
                Console.WriteLine("Db tables reinitialized");
            }
            catch (Exception exception)
            {
                Console.WriteLine(ConnectionStore.ConnectionErrorProvider(exception.Message));
            }

            GetBackChooser.GetBack();
        }
예제 #18
0
        public void Show()
        {
            Console.WriteLine("Example 4\n\n");
            Console.WriteLine("Example shows \"QueryFirstOrDefault\" method to select data from Employee Table:\n\n");

            try
            {
                Console.WriteLine("First, answer the question\n");
                bool result = false;;
                do
                {
                    Console.WriteLine("The question is: What will happen in case if we use QueryFirsOrDefault method on more than 1 records?");
                    Console.WriteLine("Press 1 if it will return null, press 2 if it will return default value of queried type and press 3 if it will return first of found records");
                    var dapperQuestionAnswer = Console.ReadKey().KeyChar;
                    result = new QuestionAnswerHandler(EQuestionType.QueryFirstOrDefaultQuestion)
                             .HandleAnswer(dapperQuestionAnswer);
                    Console.WriteLine();
                }while (!result);

                _initializationRepository.Initialize();
                Console.WriteLine("QueryFirstOrDefault method execution, press any key to begin:");
                Console.ReadKey();
                Console.WriteLine("\nFirst or default object if found more than 1 records:");
                var firstOrDefaultEmployee = _repository.GetFirstOrDefaultEmployee();
                ConsoleExtension.WriteDynamicObject(firstOrDefaultEmployee);
                Console.WriteLine("\nSecond case, press any key to proceed:");
                Console.ReadKey();
                Console.WriteLine("\n");
                Console.WriteLine("Clearing db table");
                _repository.ClearAllEmployeeData();
                Console.WriteLine("Db table cleared");
                Console.WriteLine("\nFirst or default object if no records found:");
                var firstOrDefaultEmployeeIfEmpty = _repository.GetFirstOrDefaultEmployee();
                ConsoleExtension.WriteDynamicObject(firstOrDefaultEmployeeIfEmpty);
                Console.WriteLine("Reinitializing db tables");
                _initializationRepository.Initialize();
                Console.WriteLine("Db tables reinitialized");
            }
            catch (Exception exception)
            {
                Console.WriteLine(ConnectionStore.ConnectionErrorProvider(exception.Message));
            }

            GetBackChooser.GetBack();
        }
예제 #19
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (Prefs.UpdateInt(PrefName.ReportsPPOwriteoffDefaultToProcDate, comboReportWriteoff.SelectedIndex)
         | Prefs.UpdateBool(PrefName.ReportsShowPatNum, checkReportsShowPatNum.Checked)
         | Prefs.UpdateBool(PrefName.ReportPandIschedProdSubtractsWO, checkReportProdWO.Checked)
         | Prefs.UpdateBool(PrefName.ReportPandIhasClinicInfo, checkReportPIClinicInfo.Checked)
         | Prefs.UpdateBool(PrefName.ReportPandIhasClinicBreakdown, checkReportPIClinic.Checked)
         | Prefs.UpdateBool(PrefName.ProviderPayrollAllowToday, checkProviderPayrollAllowToday.Checked)
         | Prefs.UpdateBool(PrefName.NetProdDetailUseSnapshotToday, checkNetProdDetailUseSnapshotToday.Checked)
         | Prefs.UpdateBool(PrefName.ReportsWrapColumns, checkReportPrintWrapColumns.Checked)
         | Prefs.UpdateBool(PrefName.ReportsIncompleteProcsNoNotes, checkReportsIncompleteProcsNoNotes.Checked)
         | Prefs.UpdateBool(PrefName.ReportsIncompleteProcsUnsigned, checkReportsIncompleteProcsUnsigned.Checked)
         | Prefs.UpdateBool(PrefName.TreatFinderProcsAllGeneral, checkBenefitAssumeGeneral.Checked)
         | Prefs.UpdateBool(PrefName.ReportsShowHistory, checkReportsShowHistory.Checked)
         | Prefs.UpdateBool(PrefName.OutstandingInsReportDateFilterTab, checkOutstandingRpDateTab.Checked)
         | Prefs.UpdateBool(PrefName.ReportsDoShowHiddenTPPrepayments, checkReportDisplayUnearnedTP.Checked)
         )
     {
         changed = true;
     }
     if (UpdateReportingServer())
     {
         ConnectionStore.ClearConnectionDictionary();
         changed = true;
     }
     if (changed)
     {
         DataValid.SetInvalid(InvalidType.Prefs);
     }
     if (Security.IsAuthorized(Permissions.SecurityAdmin))
     {
         GroupPermissions.Sync(userControlReportSetup.ListGroupPermissionsForReports, userControlReportSetup.ListGroupPermissionsOld);
         if (userControlReportSetup.ListGroupPermissionsForReports.Exists(x => x.UserGroupNum == _userGroupNum))
         {
             HasReportPerms = true;
         }
         DataValid.SetInvalid(InvalidType.Security);
     }
     if (DisplayReports.Sync(userControlReportSetup.ListDisplayReportAll))
     {
         DataValid.SetInvalid(InvalidType.DisplayReports);
     }
     DialogResult = DialogResult.OK;
 }
예제 #20
0
        public void Show()
        {
            Console.WriteLine("Example 2\n\n");
            Console.WriteLine("Example shows \"Execute\" method to insert data through stored SQL DB procedure passing anonymous parameters:\n\n");

            try
            {
                Console.WriteLine("Procedure execution, press any key to begin:");
                Console.ReadKey();
                Console.WriteLine();
                var rows = _repository.GetInsertQueryRows();
                Console.WriteLine(string.Format("Number of affected rows: {0}", (rows <= 0)? 0 : rows));
            }
            catch (Exception exception)
            {
                Console.WriteLine(ConnectionStore.ConnectionErrorProvider(exception.Message));
            }

            GetBackChooser.GetBack();
        }
예제 #21
0
        public static void ConnectMachines()
        {
            if (!IsInitialized)
            {
                throw new InvalidOperationException("ServiceHelper not initialized");
            }

            ConnectionStore.Connections.Keys.Where(machine => !Settings.Client.Machines.Contains(machine)).ToList().ForEach(ConnectionStore.RemoveConnection);

            if (Settings.Client.Machines.Any(machine => !ConnectionStore.ConnectionCreated(machine)))
            {
                Worker.Do("Connecting to machines...", () =>
                {
                    foreach (Machine machine in Settings.Client.Machines.Where(machine => !ConnectionStore.ConnectionCreated(machine)))
                    {
                        MachineConnection connection = ConnectionStore.CreateConnection(ProcessManagerEventHandler, machine);
                        connection.ServiceHandler.Initialize();
                    }
                });
            }
        }
 private void UpdateSelectedApplications()
 {
     if (SelectedApplications != null)
     {
         SelectedApplications = SelectedSourceMachine == null || !ConnectionStore.ConfigurationAvailable(SelectedSourceMachine)
                                 ? null
                                 : SelectedApplications
                                .Select(selectedApplication => ConnectionStore.Connections[SelectedSourceMachine].Configuration
                                        .Applications
                                        .Where(application => ConnectionStore.Connections[SelectedSourceMachine].Configuration
                                               .Groups
                                               .Where(group => Comparer.GroupsEqual(group, SelectedGroup))
                                               .SelectMany(group => group.Applications)
                                               .Any(appID => ProcessManager.DataObjects.Comparers.Comparer <Application> .IDObjectsEqual(application, appID)))
                                        .FirstOrDefault(application => Comparer.ApplicationsEqual(application, selectedApplication)))
                                .Where(application => application != null)
                                .Distinct(new ApplicationEqualityComparer())
                                .ToList();
     }
     UpdateLinkLabelApplications();
 }
예제 #23
0
        private static IAction CreateAction(IMacroAction macroAction)
        {
            switch (macroAction.Type)
            {
            case MacroActionType.Start:
            case MacroActionType.Stop:
            case MacroActionType.Restart:
            {
                MacroProcessAction macroProcessAction = (MacroProcessAction)macroAction;
                Machine            machine            = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroProcessAction.MachineID);
                if (machine != null && ConnectionStore.ConnectionCreated(machine))
                {
                    Group       group       = ConnectionStore.Connections[machine].Configuration.Groups.FirstOrDefault(x => x.ID == macroProcessAction.GroupID);
                    Application application = ConnectionStore.Connections[machine].Configuration.Applications.FirstOrDefault(x => x.ID == macroProcessAction.ApplicationID);
                    return(new ProcessAction(Convert(macroAction.Type), machine, @group, application));
                }
                return(null);
            }

            case MacroActionType.Distribute:
            {
                MacroDistributionAction macroDistributionAction = (MacroDistributionAction)macroAction;
                Machine sourceMachine      = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroDistributionAction.SourceMachineID);
                Machine destinationMachine = Settings.Client.Machines.FirstOrDefault(x => x.ID == macroDistributionAction.DestinationMachineID);
                if (sourceMachine != null && ConnectionStore.ConnectionCreated(sourceMachine))
                {
                    Group       group       = ConnectionStore.Connections[sourceMachine].Configuration.Groups.FirstOrDefault(x => x.ID == macroDistributionAction.GroupID);
                    Application application = ConnectionStore.Connections[sourceMachine].Configuration.Applications.FirstOrDefault(x => x.ID == macroDistributionAction.ApplicationID);
                    return(new DistributionAction(Convert(macroAction.Type), sourceMachine, group, application, destinationMachine));
                }
                return(null);
            }

            default:
                return(null);
            }
        }
예제 #24
0
 public CommunicationService(ConnectionStore connectionStore)
 {
     _connectionStore = connectionStore;
 }
예제 #25
0
        public void Show()
        {
            Console.WriteLine("Example 6\n\n");
            Console.WriteLine("Example shows \"QuerySingleOrDefault\" method to select data from Address table:\n\n");

            try
            {
                Console.WriteLine("First, answer the question\n");
                bool result = false;;
                do
                {
                    Console.WriteLine("The question is: What will happen in case if we use QuerySingleOrDefault method on more than 1 records?");
                    Console.WriteLine("Press 1 if it will return null, press 2 if it will return an exception and press 3 if it will return any single of found records");
                    var dapperQuestionAnswer = Console.ReadKey().KeyChar;
                    result = new QuestionAnswerHandler(EQuestionType.QuerySingleOrDefaultQuestion)
                             .HandleAnswer(dapperQuestionAnswer);
                    Console.WriteLine();
                }while (!result);

                _initializationRepository.Initialize();
                Console.WriteLine("QuerySingleOrDefault method execution, press any key to begin:");
                Console.ReadKey();
                Console.WriteLine("\nSingleOrDefault object if found more than 1 records:");
                try
                {
                    var singleOrDefaultIfMany = _repository.GetSingleOrDefaultAddress();
                    ConsoleExtension.WriteObject(singleOrDefaultIfMany);
                }
                catch (Exception exception)
                {
                    Console.WriteLine($"QuerySingleOrDefault method has thrown an exception: \n\n{exception.Message}");
                }
                Console.WriteLine("\nSecond case, press any key to proceed:");
                Console.ReadKey();
                Console.WriteLine("\n");
                Console.WriteLine("Clearing db table");
                _repository.ClearAllAddressData();
                Console.WriteLine("Db table cleared");
                _repository.AddSingleFakeAddress();
                Console.WriteLine("Added single fake address to Address table");
                Console.WriteLine("\nSingleOrDefault object if single record found:");
                try
                {
                    var singleOrDefault = _repository.GetSingleOrDefaultAddress();
                    ConsoleExtension.WriteObject(singleOrDefault);
                }
                catch (Exception exception)
                {
                    Console.WriteLine($"QuerySingleOrDefault method has thrown an exception: \n\n{exception.Message}");
                }
                Console.WriteLine("\nThird case, press any key to proceed:");
                Console.ReadKey();
                Console.WriteLine("\n");
                Console.WriteLine("Clearing db table");
                _repository.ClearAllAddressData();
                Console.WriteLine("Db table cleared");
                Console.WriteLine("\nSingleOrDefault object if no records found:");
                try
                {
                    var singleOrDefaultIfEmpty = _repository.GetSingleOrDefaultAddress();
                    ConsoleExtension.WriteObject(singleOrDefaultIfEmpty);
                }
                catch (Exception exception)
                {
                    Console.WriteLine($"QuerySingleOrDefault method has thrown an exception: \n\n{exception.Message}");
                }
                Console.WriteLine("\n\nReinitializing db tables");
                _initializationRepository.Initialize();
                Console.WriteLine("Db tables reinitialized");
            }
            catch (Exception exception)
            {
                Console.WriteLine(ConnectionStore.ConnectionErrorProvider(exception.Message));
            }

            GetBackChooser.GetBack();
        }
예제 #26
0
 public SyncViewModel(RegistrationService registrationService, ConnectionStore connectionStore)
 {
     _registrationService = registrationService;
     _connectionStore     = connectionStore;
     Status = "未连接";
 }
예제 #27
0
 public SyncViewModel(RegistrationService registrationService, ConnectionStore connectionStore)
 {
     _registrationService = registrationService;
     _connectionStore = connectionStore;
     Status = "未连接";
 }
예제 #28
0
 private static bool MachineIsValid(Machine machine)
 {
     return(ConnectionStore.MachineIsValid(machine));
 }
예제 #29
0
 public CommunicationService(ConnectionStore connectionStore)
 {
     _connectionStore = connectionStore;
 }
 public void Disconnect(string connectionId)
 {
     ConnectionStore.Disconnect(connectionId);
 }