コード例 #1
0
 private void loadImage(PictureInfoDTO picture)
 {
     if (downloadingPictures.TryAdd(picture.PictureId, picture))
     {
         ServicePool.Add(new PictureDownloadingServiceCommand(picture, this));
     }
 }
コード例 #2
0
        public static bool RemoveFromFavorites(this SupplementCycleDefinitionDTO definition)
        {
            if (!CanRemoveFromFavorites(definition))
            {
                return(false);
            }
            //ServiceManager.WorkoutPlanFavoritesOperation(plan, FavoriteOperation.Remove);

            ServiceCommand command = new ServiceCommand(() =>
            {
                try
                {
                    var param = new SupplementsCycleDefinitionOperationParam();
                    param.SupplementsCycleDefinitionId = definition.GlobalId;
                    param.Operation = SupplementsCycleDefinitionOperation.RemoveFromFavorites;
                    ServiceManager.SupplementsCycleDefinitionOperation(param);
                }
                catch (ObjectIsNotFavoriteException)
                {
                }
                catch
                {
                    SupplementsCycleDefinitionsReposidory.Instance.Add(definition);
                    throw;
                }
            });

            ServicePool.Add(command);
            SupplementsCycleDefinitionsReposidory.Instance.Remove(definition.GlobalId);
            return(true);
        }
コード例 #3
0
        public static bool AddToFavorites(this ExerciseDTO exercise)
        {
            if (!CanAddToFavorites(exercise))
            {
                return(false);
            }
            ServiceCommand command = new ServiceCommand(() =>
            {
                try
                {
                    ExerciseOperationParam param = new ExerciseOperationParam();
                    param.ExerciseId             = exercise.GlobalId;
                    param.Operation = FavoriteOperation.Add;
                    ServiceManager.ExerciseOperation(param);
                }
                catch (ObjectIsFavoriteException)
                {
                }
                catch
                {
                    ExercisesReposidory.Instance.Remove(exercise.GlobalId);
                    throw;
                }
            });

            ServicePool.Add(command);
            ExercisesReposidory.Instance.Add(exercise);
            return(true);
        }
コード例 #4
0
        void btnDeleteMessages_Click(object sender, EventArgs e)
        {
            if (!NetworkInterface.GetIsNetworkAvailable() || ApplicationState.Current.IsOffline)
            {
                BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork);
                return;
            }

            var messagesToDelete = lstMessages.SelectedItems.Cast <Message>().Select(x => x.MessageViewModel.Message).ToList();

            foreach (var message in messagesToDelete)
            {
                ApplicationState.Current.Cache.Messages.Remove(message.GlobalId);
            }

            ThreadPool.QueueUserWorkItem((a1) =>
            {
                foreach (var message in messagesToDelete)
                {
                    ServicePool.Add(new DeleteMessageServiceCommand(message.GlobalId));
                }
            });
            fill();
            lstMessages.IsSelectionEnabled = false;
        }
コード例 #5
0
ファイル: ServicePool.cs プロジェクト: LiZhengyan/liemo5
 public static ServicePool getIns()
 {
     if (_ins == null)
     {
         _ins = new ServicePool();
         _ins.init();
     }
     return(_ins);
 }
コード例 #6
0
ファイル: Startup.cs プロジェクト: adicto969/TemplateNetCore
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            Type type = typeof(GeneralContext);

            ServicePool.RegistryService(_Environment.ContentRootPath, Configuration, services);

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = Configuration["Jwt:Issuer"],
                    ValidAudience    = Configuration["Jwt:Issuer"],
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"]))
                };
            });

            services.AddCors(o => o.AddPolicy("PrestaQiPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            services.AddHttpContextAccessor();
            services.AddWebSocketManager();

            services.AddMvc(config =>
            {
                config.Filters.Add(new ExceptionHandling());
            });

            services.AddControllersWithViews()
            .AddNewtonsoftJson(options =>
                               options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                               );

            services.Configure <RequestLocalizationOptions>(options =>
            {
                options.DefaultRequestCulture = new Microsoft.AspNetCore.Localization.RequestCulture("es-MX");
                options.SupportedCultures     = new List <CultureInfo> {
                    new CultureInfo("es-MX")
                };
            });

            services.Configure <FormOptions>(opt =>
            {
                opt.MultipartBodyLengthLimit = Convert.ToInt64(Configuration["Configuration:FileSize"]);
            });
            services.AddControllers();
        }
コード例 #7
0
ファイル: ServicePoolFactory.cs プロジェクト: JPVenson/MSEF
        public static IServicePool CreatePool(string priorityKey, params string[] sublookuppaths)
        {
            if (sublookuppaths == null || !sublookuppaths.Any(Directory.Exists))
            {
                throw new InvalidOperationException("Please provided any valid path that points to a directory");
            }

            var pool = new ServicePool(priorityKey, sublookuppaths);
            ServicePool.Instance = pool;
            if (ServicePool.ApplicationContainer == null)
                ServicePool.ApplicationContainer = new ApplicationContext(ImportPool.Instance, MessageBroker.Instance, pool, null, VisualModuleManager.Instance);
            pool.InitLoading();
            return pool;
        }
コード例 #8
0
ファイル: ServiceContainer.cs プロジェクト: ciker/twino
        /// <summary>
        /// Adds a service pool to the container
        /// </summary>
        /// <param name="type">Implementation type</param>
        /// <param name="options">Options function</param>
        /// <param name="instance">After each instance is created, to do custom initialization, this method will be called.</param>
        private void AddPool <TService, TImplementation>(ImplementationType type, Action <ServicePoolOptions> options, Action <TService> instance)
            where TService : class
            where TImplementation : class, TService
        {
            ServicePool <TService, TImplementation> pool = new ServicePool <TService, TImplementation>(type, this, options, instance);
            ServiceDescriptor descriptor = new ServiceDescriptor
            {
                IsPool             = true,
                ServiceType        = typeof(TService),
                ImplementationType = typeof(ServicePool <TService, TImplementation>),
                Instance           = pool,
                Implementation     = ImplementationType.Singleton
            };

            Items.Add(typeof(TService), descriptor);
        }
コード例 #9
0
        public static IServicePool CreatePool(string priorityKey, params string[] sublookuppaths)
        {
            if (sublookuppaths == null || !sublookuppaths.Any(Directory.Exists))
            {
                throw new InvalidOperationException("Please provided any valid path that points to a directory");
            }

            var pool = new ServicePool(priorityKey, sublookuppaths);

            ServicePool.Instance = pool;
            if (ServicePool.ApplicationContainer == null)
            {
                ServicePool.ApplicationContainer = new ApplicationContext(ImportPool.Instance, MessageBroker.Instance, pool, null, VisualModuleManager.Instance);
            }
            pool.InitLoading();
            return(pool);
        }
コード例 #10
0
        /// <summary>
        /// Adds a service pool to the container
        /// </summary>
        /// <param name="type">Implementation type</param>
        /// <param name="options">Options function</param>
        /// <param name="instance">After each instance is created, to do custom initialization, this method will be called.</param>
        private void AddPool <TService, TImplementation>(ImplementationType type, Action <ServicePoolOptions> options, Action <TService> instance)
            where TService : class
            where TImplementation : class, TService
        {
            ServicePool <TService, TImplementation> pool = new ServicePool <TService, TImplementation>(type, this, options, instance);
            TwinoServiceDescriptor descriptor            = new TwinoServiceDescriptor(ImplementationType.Singleton,
                                                                                      typeof(TService),
                                                                                      typeof(TImplementation),
                                                                                      //typeof(ServicePool<TService, TImplementation>),
                                                                                      pool)
            {
                IsPool = true
            };

            _items.Add(descriptor);
            _provider = null;
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: LinkerOK/Onlink
        private static void Main()
        {
            SetupConsole();
            PrintIntro();

            var servicePool = new ServicePool();

            servicePool.Logger = ConsoleLogger.Instance;

            servicePool.AddService(new RawService(1337));
            // servicePool.AddService(new TelegramService());
            servicePool.StartServices();

            HandleInput();

            servicePool.StopServices();
            PrintOutro();

            Console.ReadKey(true);
        }
コード例 #12
0
        private void txtProfileStatus_LostFocus(object sender, RoutedEventArgs e)
        {
            string newStatus = txtProfileStatus.Text;

            if (string.IsNullOrEmpty(newStatus))
            {//normalize string. instead of "" use null always
                newStatus = null;
            }
            if (User.Statistics.Status.Status != newStatus)
            {//change status only if user type something else in the status textbox
                ServiceCommand command = new ServiceCommand(() =>
                {
                    var param           = new ProfileOperationParam();
                    param.Operation     = ProfileOperation.SetStatus;
                    param.ProfileId     = User.GlobalId;
                    param.Status        = new ProfileStatusDTO();
                    param.Status.Status = newStatus;
                    ServiceManager.ProfileOperation(param);
                    User.Statistics.Status.Status = newStatus;
                });
                ServicePool.Add(command);
            }
        }
コード例 #13
0
 private void loadImage(PictureInfoDTO picture)
 {
     ServicePool.Add(new PictureDownloadingServiceCommand(picture, this));
 }
コード例 #14
0
 public void Delete(ReminderItemDTO reminder)
 {
     ServicePool.Add(new ReminderOperationServiceCommand(reminder, ReminderOperationType.CloseAfterShow));
     NotificationsReposidory.Instance.Remove(reminder.GlobalId);
 }
コード例 #15
0
 /// <summary>
 /// Awake is called when the script instance is being loaded.
 /// </summary>
 void Awake()
 {
     ServicePool.getIns().getNotice().UiCtr = this;
 }
コード例 #16
0
        public void Execute(IJobExecutionContext context)
        {
            var item = (ReminderItemDTO)context.MergedJobDataMap["ReminderItemDTO"];

            if (NotificationsReposidory.Instance.GetItem(item.GlobalId) != null)
            {//this notification has been already shown so skip it
                return;
            }
            UIHelper.MainWindow.AddPerformanceMessage(item.Name + "," + item.DateTime);
            UIHelper.BeginInvoke(delegate
            {
                NotifyObject obj = new NotifyObject(item.DateTime.ToLocalTime().ToString(), item.Name, item.DateTime);
                obj.Image        = ReminderToIconConverter.GetReminderImage(item.Type).ToBitmap();
                obj.DeleteEvent  = (o) =>
                {
                    ServicePool.Add(new ReminderOperationServiceCommand(item, ReminderOperationType.CloseAfterShow));
                    NotificationsReposidory.Instance.Remove(item.GlobalId);
                };
                obj.ClickEvent = (o) =>
                {
                    if (!string.IsNullOrEmpty(item.ConnectedObject))
                    {
                        var arr = item.ConnectedObject.Split(':');
                        if (arr[0] == "CustomerDTO")
                        {
                            Guid customerId;
                            PageContext pageContext = null;
                            if (Guid.TryParse(arr[1], out customerId))
                            {
                                pageContext = new PageContext(null, CustomersReposidory.Instance.GetItem(customerId));
                            }
                            //CustomersView customerView = new CustomersView();
                            //UIHelper.MainWindow.ShowView( customerView,true,true);
                            UIHelper.MainWindow.ShowPage(new Uri("pack://application:,,,/BodyArchitect.Client.Module.Instructor;component/Controls/Customers/CustomersView.xaml"), () => pageContext, true);
                            return;
                        }
                        if (arr[0] == "ScheduleEntryDTO")
                        {
                            //ScheduleEntriesView view = new ScheduleEntriesView();
                            //UIHelper.MainWindow.ShowView(view, true, true);
                            ScheduleEntriesViewContext pageContext = new ScheduleEntriesViewContext(item.DateTime);
                            MainWindow.Instance.ShowPage(new Uri("pack://application:,,,/BodyArchitect.Client.Module.Instructor;component/Controls/ScheduleEntriesView.xaml"), () => pageContext, true);
                            return;
                        }
                        if (arr[0] == "EntryObjectDTO")
                        {
                            //ScheduleEntriesView view = new ScheduleEntriesView();
                            //UIHelper.MainWindow.ShowView(view, true, true);
                            //var day=ServiceManager.GetTrainingDay(new WorkoutDayGetOperation(){WorkoutDateTime = item.DateTime});
                            //var customer = day.CustomerId.HasValue?CustomersReposidory.Instance.GetItem(day.CustomerId.Value):null;
                            //var pageContext = new TrainingDayPageContext(null, customer, day, null);
                            var pageContext      = new TrainingDayPageContext(null, null, null, null);
                            pageContext.DateTime = item.DateTime;
                            MainWindow.Instance.ShowPage(new Uri("pack://application:,,,/BodyArchitect.Client.UI;component/Windows/TrainingDayWindow.xaml"), () => pageContext, true);
                            return;
                        }
                    }

                    MainWindow.Instance.ShowDashboard(typeof(usrUserReminders), true);
                };
                obj.GlobalId = item.GlobalId;
                obj.Tag      = item;
                NotificationsReposidory.Instance.Add(obj);

                UIHelper.MainWindow.ShowNotification(obj);
            }, UIHelper.MainWindow.Dispatcher);
        }