Пример #1
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
    private void init()
    {
        if (m_freeWorkers == null)
        {
            m_freeWorkers = GameObject.Find("FreeWorkerText").GetComponent <Text>();
        }
        if (m_busyWorkers == null)
        {
            m_busyWorkers = GameObject.Find("BusyWorkersText").GetComponent <Text>();
        }
        if (m_space == null)
        {
            m_space = GameObject.Find("SpaceText").GetComponent <Text>();
        }
        if (m_hireButtonText == null)
        {
            m_hireButton     = GameObject.Find("BuyButton").GetComponent <Button>();
            m_hireButtonText = m_hireButton.transform.FindChild("BuyButtonText").GetComponent <Text>();
        }
        if (m_fireButton == null)
        {
            m_fireButton     = GameObject.Find("FireButton").GetComponent <Button>();
            m_fireButtonText = m_fireButton.transform.FindChild("FireButtonText").GetComponent <Text>();
        }
        if (m_monthlyMoney == null)
        {
            Image monthlyMoneyImage = GameObject.Find("MonthMoneyImage").GetComponent <Image>();
            m_monthlyMoney = monthlyMoneyImage.transform.FindChild("MonthMoneyText").GetComponent <Text>();
        }
        WorkerManager.GetInstance().addOnWorkerChangeListener(updatePanel);
        TimeManager timeManager = GameObject.FindGameObjectWithTag("Logic").GetComponent <TimeManager>();

        timeManager.addListenerToMonthChange(updatePanel);
        updatePanel();
    }
        public void TestNotAllowMetalWorker()
        {
            GameObject    placeholder = new GameObject();
            WorkerManager wm          = placeholder.AddComponent <WorkerManager>();

            Assert.False(wm.AllowWorker(ResourceType.Metal));
        }
Пример #4
0
        public void TestResult()
        {
            var stepInfo = new Mock <IStepInformation>();

            var final = new ResultInfo();

            stepInfo.SetupGet(m => m.Keyword).Returns("Hah");

            var manager = new WorkerManager(new Mock <ILogger>().Object);

            manager.StepManager.Register(stepInfo.Object);
            manager.StepManager.Register(final);

            manager.TaskManager.TaskCollection.Add(new Task {
                KeyWord   = ""
                , Records = new List <Core.Data.Record> {
                    new Core.Data.Record {
                        ContentHint = "Hello"
                    }
                }
            });

            manager.Start();

            while (final.Results.IsEmpty)
            {
            }

            final.Results.First().ContentHint.ShouldBe("Hello");
        }
Пример #5
0
        public void TestStartStop()
        {
            var stepInfo = new Mock <IStepInformation>();

            stepInfo.SetupGet(m => m.Keyword).Returns("Hah");

            var task = new Task();

            task.KeyWord = "Hah";

            var manager = new WorkerManager(new Mock <ILogger>().Object);

            manager.StepManager.Register(stepInfo.Object);

            manager.TaskManager.TaskCollection.Add(task);

            manager.Start();
            manager.IsRunning.ShouldBeTrue();

            Thread.Sleep(500);

            manager.TaskManager.TaskCollection.Empty.ShouldBeTrue();

            manager.Stop();

            manager.IsRunning.ShouldBeFalse();
        }
        public override object CommandBody(params object[] paras)
        {
            if (paras.Length < 2)
            {
                throw new ArgumentException();
            }

            WorkerSearchCondtion searchCondition = new WorkerSearchCondtion();

            searchCondition.WorkerCode = paras[0] as string;
            searchCondition.WorkerName = paras[1] as string;

            if (OnProgress != null)
            {
                string TaskName = ProjectAllocationResource.Message.Worker_TaskMessage_Load;
                ProjectAllocationFramework.Statues.ProgressChangedEventArgs args = new ProjectAllocationFramework.Statues.ProgressChangedEventArgs(TaskName);
                OnProgress(null, args);
            }

            WorkerManager       manager = new WorkerManager();
            List <WorkerEntity> data    = manager.GetDataFromDB(OnProgress, searchCondition);

            Core.CoreData[CoreDataType.WORKER_SEARCH] = data;
            return(data);
        }
Пример #7
0
        public void Test2()
        {
            IWorker worker = new WorkerManager(2);

            int value = 0;

            worker.Add(new Job <int>(job => {
                value += 2;

                return(value);
            }));

            worker.Add(new Job <int>(job => {
                throw new NotImplementedException();
            }).Subscribe(
                           (int x) => { },
                           (Exception e) => {
                value += 8;
            },
                           () => { }));

            value += -10;

            worker.WaitForIdle();

            Assert.Equal(0, value);
        }
        private void btnUpd_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("是否确认修改员工信息?", "修改提醒", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                #region 员工信息代码块
                Worker worker = new Worker
                {
                    WorkerId        = WorkerNo.Text.Trim(),
                    WorkerSex       = cboSex.Text == "女" ? 0 : 1,
                    WorkerTel       = WorkerTel.Text,
                    WorkerAddress   = txtAddress.Text,
                    WorkerPwd       = Pwd.Text,
                    WorkerFace      = cboWorkerFace.Text,
                    WorkerEducation = cboEducation.Text
                };
                int i = WorkerManager.UpdateWorker(worker);
                if (i > 0)
                {
                    MessageBox.Show("信息修改成功!");
                }
                else
                {
                    MessageBox.Show("服务器繁忙!");
                }
                #endregion
            }
            else
            {
                MessageBox.Show("修改操作已取消!");
            }
        }
Пример #9
0
    new private void Update()
    {
        if (CurrentAction != null)
        {
            CurrentAction(transform, currentTargrtPoint, (x) =>
            {
                if (x == "wellDone")
                {
                    CurrentAction   = null;
                    base.haveAction = false;
                    base.SetInitPos();

                    m_ActionName = WorkerManager.getNextAction(m_ActionName);
                    ActionTime   = WorkerManager.getActionTime(m_ActionName);

                    CurrentAction   = Commands.getAction(m_ActionName);
                    base.haveAction = true;
                }
                return(true);
            }

                          );
        }
        base.Update();
    }
        public override object CommandBody(params object[] paras)
        {
            if (paras.Length < 1)
            {
                throw new ArgumentException();
            }
            List <WorkerEntity> SaveData = paras[0] as List <WorkerEntity>;

            WorkerManager manager = new WorkerManager();

            if (OnProgress != null)
            {
                string TaskName = ProjectAllocationResource.Message.Worker_TaskMessage_Validate;
                ProjectAllocationFramework.Statues.ProgressChangedEventArgs args = new ProjectAllocationFramework.Statues.ProgressChangedEventArgs(TaskName);
                OnProgress(null, args);
            }
            //check
            manager.DataValidation(OnProgress, SaveData);

            if (OnProgress != null)
            {
                string TaskName = ProjectAllocationResource.Message.Worker_TaskMessage_Save;
                ProjectAllocationFramework.Statues.ProgressChangedEventArgs args = new ProjectAllocationFramework.Statues.ProgressChangedEventArgs(TaskName);
                OnProgress(null, args);
            }
            //save
            manager.SaveDataToDB(OnProgress, SaveData);

            return(SaveData);
        }
Пример #11
0
        static void Main(string[] args)
        {
            // Initialize Ninject (the DI framework)
            var kernel = new StandardKernel(new CommonModule(), new WinFormsModule());

            Paths.ClearTemp();

            // Parse the command-line arguments and see if we're doing something other than displaying the main form
            var lifecycle = kernel.Get <Lifecycle>();

            //lifecycle.ParseArgs(args);
            //lifecycle.ExitIfRedundant();

            // Start a pending worker process
            WorkerManager.Init();

            // Set up basic application configuration
            kernel.Get <CultureInitializer>().InitCulture(Thread.CurrentThread);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException           += UnhandledException;
            TaskScheduler.UnobservedTaskException += UnhandledTaskException;

            // Show the main form
            var formFactory = kernel.Get <IFormFactory>();
            var desktop     = formFactory.Create <Form1>();

            Invoker.Current = desktop;
            Application.Run(desktop);
        }
Пример #12
0
        public Instance()
        {
            workerManager     = new WorkerManager();
            intervalProxyPool = new IntervalProxyPool();
            sqlServerTaskPool = new SQLServerTaskPool();
//			sqlServerTaskPool.ConnectionString = dbConnectionString;
            sqlServerTaskPool.InitTable();
            sqlServerTaskPool.DaemonRestTime = 2000;
            sqlServerTaskPool.MaxDaemonEnqueueThreadCount = 2;


            amazonPictureTaskGuide = new AmazonPictureTaskGuide(storePath);
            amazonPictureTaskGuide.GlobalTimeout = 60000;
            amazonPictureTaskGuide.MaxWorkers    = 1;

            proxyManager = new ProxyManager();
            proxyManager.DaemonRestTime = 1000;
            proxyManager.LoadProxyProviders(ProxyProviderParser.ReadConfig("config/proxyprovider.xml"));
            proxyManager.ProxyValidator = new ProxyValidator();
            proxyManager.ProxyValidator.LoadProxyValidations(ProxyValidateConditionParser.ReadConfig("config/proxyvalidate.xml"));
            proxyManager.MaxValidateThreadCount = 20;

            workerManager.ProxyPool = intervalProxyPool;
            workerManager.TaskPool  = sqlServerTaskPool;
            workerManager.TaskGuide = amazonPictureTaskGuide;

            intervalProxyPool.ProxyManager   = proxyManager;
            intervalProxyPool.DaemonRestTime = 1000;
            intervalProxyPool.ProxyRestTime  = new TimeSpan(0, 0, 20);
        }
 public MT4ServerApplication(
     WorkerManager workerManager, MT4Manager mt4Manager, MT4SymbolInfoService symbolService)
 {
     _workerManager = workerManager;
     _mt4Manager    = mt4Manager;
     _symbolService = symbolService;
 }
Пример #14
0
    private void updateCounter()
    {
        int freeWorkers = WorkerManager.GetInstance().FreeWorkers;
        int workers     = WorkerManager.GetInstance().Workers;

        m_workerCounterText.text = freeWorkers.ToString() + "/" + workers.ToString();
    }
Пример #15
0
        public void Test4()
        {
            WorkerManager worker = new WorkerManager(1);


            var job1 = new Job <int>(j => {
                Thread.Sleep(500);
                return(1);
            });
            var job2 = new Job <int>(j => {
                Thread.Sleep(500);
                return(2);
            });

            worker.Add(job1);
            worker.Add(job2);

            Assert.Equal(2, worker.JobQueue.Count);

            Assert.True(worker.JobQueue.First().Id == job1.Id);

            worker.Remove(job2);
            worker.WaitForIdle();

            Assert.False(worker.IsDead);

            Assert.True(worker.IsIdle);

            Assert.Empty(worker.JobQueue);
        }
Пример #16
0
    public Panel()
    {
        workers = 0;
        roomID  = 0;

        sacrificeButtonText   = "";
        faithUpgradeOneText   = "";
        faithUpgradeTwoText   = "";
        faithUpgradeThreeText = "";

        isFUOne   = false;
        isFUTwo   = false;
        isFUThree = false;

        rm = ResourceManager.Instance;
        wm = WorkerManager.Instance;

        workerTypeZero = 0;
        workerTypeOne  = 0;
        workerTypeTwo  = 0;

        um = UpgradeManager.Instance;

        faithUpgradeOne   = um.GetFaithUpgrade();
        faithUpgradeTwo   = um.GetFaithUpgrade();
        faithUpgradeThree = um.GetFaithUpgrade();

        upgradeStatus = new bool[] { false, false, false, false };
    }
        static async Task Main(string[] args)
        {
            var workerManager = new WorkerManager(args);

            workerManager.Begin();
            await workerManager.CloseRequestedAsync();
        }
Пример #18
0
        private string FindAvailableWorker()
        {
            var hosts = new WorkerManager(Database).GetWorkers();

            if (hosts == null)
            {
                return(null);
            }

            var jobManager = new JobManager(Database);

            if (hosts.Any())
            {
                var jobs = jobManager.GetJobs().Where(a => !a.Completed).ToList();

                foreach (var host in hosts)
                {
                    if (jobs.Any(a => a.AssignedHost == host.Name))
                    {
                        continue;
                    }

                    return(host.Name);
                }

                return(Constants.UNASSIGNED_JOB);
            }

            return(Constants.UNASSIGNED_JOB);
        }
Пример #19
0
 protected override void InitializationHumanClass()
 {
     inventory    = GetComponent <Inventory>();
     human        = GetComponent <Human>();
     creatureMove = gameObject.GetComponent <CreatureMove>();
     WorkerManager.Initialize(this);
 }
Пример #20
0
        public void RUN(string[] args)
        {
            var kernel = new StandardKernel(new CommonModule(), new WinFormsModule());

            NAPS2.Paths.ClearTemp();

            // Parse the command-line arguments and see if we're doing something other than displaying the main form
            var lifecycle = kernel.Get <Lifecycle>();

            lifecycle.ParseArgs(args);
            lifecycle.ExitIfRedundant();

            // Start a pending worker process

            WorkerManager.Init();

            // Set up basic application configuration
            kernel.Get <CultureInitializer>().InitCulture(Thread.CurrentThread);
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.ThreadException += UnhandledException;

            // Show the main form
            var formFactory = kernel.Get <IFormFactory>();
            var desktop     = formFactory.Create <FDesktop>();

            Invoker.Current = desktop;
            //Application.Run(desktop);
            desktop.setInitialPath(args);
            desktop.ShowDialog();
        }
Пример #21
0
        /// <summary>
        /// Starts the Distributor.
        /// </summary>
        public void Start()
        {
            MessageBusTransport.TransportMessageReceived += messageBusTransport_TransportMessageReceived;
            MessageBusTransport.Start(DataTransportInputQueue);

            WorkerManager.Start();
        }
Пример #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Home"/> class.
        /// </summary>
        internal Home()
        {
            this.HomeBaseLevel = Resources.GameSettings.HomeBaseLevelFile;

            this.Time              = new Time();
            this.WorkerManager     = new WorkerManager();
            this.GameObjectManager = new GameObjectManager(this);
        }
    public new void kill()
    {
        WorkerManager.GetInstance().removeOnWorkerChangeListener(updatePanel);
        TimeManager timeManager = GameObject.FindGameObjectWithTag("Logic").GetComponent <TimeManager>();

        timeManager.removeListenerToMonthChange(updatePanel);
        Destroy(this.gameObject.transform.parent.gameObject);
    }
Пример #24
0
        public Level(long id)
        {
            VillageWorkerManager = new WorkerManager();
            BuilderWorkerManager = new WorkerManager_V2();
            GameObjectManager    = new GameObjectManager(this);

            Avatar = new Avatar(id);
        }
Пример #25
0
        public override void Load()
        {
            // Import
            Bind <IScannedImageImporter>().To <ScannedImageImporter>();
            Bind <IPdfImporter>().To <PdfSharpImporter>();
            Bind <IImageImporter>().To <ImageImporter>();
            Bind <IPdfRenderer>().To <GhostscriptPdfRenderer>().InSingletonScope();

            // Export
            Bind <IPdfExporter>().To <PdfSharpExporter>();
            Bind <IScannedImagePrinter>().To <PrintDocumentPrinter>();
            Bind <IEmailProviderFactory>().To <NinjectEmailProviderFactory>();
            Bind <OcrManager>().ToSelf().InSingletonScope();
            Bind <OcrRequestQueue>().ToSelf().InSingletonScope();

            // Scan
            Bind <IScanPerformer>().To <ScanPerformer>();
#if DEBUG && false
            Bind <IScanDriverFactory>().To <Scan.Stub.StubScanDriverFactory>();
#else
            Bind <IScanDriverFactory>().To <NinjectScanDriverFactory>();
#endif
            Bind <IScanDriver>().To <WiaScanDriver>().InSingletonScope().Named(WiaScanDriver.DRIVER_NAME);
            Bind <IScanDriver>().To <TwainScanDriver>().InSingletonScope().Named(TwainScanDriver.DRIVER_NAME);
            Bind <IScanDriver>().To <SaneScanDriver>().InSingletonScope().Named(SaneScanDriver.DRIVER_NAME);
            Bind <IScanDriver>().To <ProxiedScanDriver>().InSingletonScope().Named(ProxiedScanDriver.DRIVER_NAME);

            // Config
            Bind <IProfileManager>().To <ProfileManager>().InSingletonScope();
            Bind <AppConfigManager>().ToSelf().InSingletonScope();
            Bind <IUserConfigManager>().To <UserConfigManager>().InSingletonScope();
            Bind <PdfSettingsContainer>().ToSelf().InSingletonScope();
            Bind <ImageSettingsContainer>().ToSelf().InSingletonScope();
            Bind <EmailSettingsContainer>().ToSelf().InSingletonScope();

            // Host
            Bind <IWorkerServiceFactory>().To <NinjectWorkerServiceFactory>();
            Bind <WorkerContext>().ToMethod(ctx => WorkerManager.NextWorker());

            // Misc
            Bind <IFormFactory>().To <NinjectFormFactory>();
            Bind <NotificationManager>().ToSelf().InSingletonScope();
            Bind <IOperationFactory>().To <NinjectOperationFactory>();
            Bind <ILogger>().To <NLogLogger>().InSingletonScope();
            Bind <ChangeTracker>().ToSelf().InSingletonScope();
            Bind <StillImage>().ToSelf().InSingletonScope();
            Bind <IBlankDetector>().To <ThresholdBlankDetector>();
            Bind <IAutoSave>().To <AutoSave>();

            Log.Logger = new NLogLogger();
            if (PlatformCompat.System.CanUseWin32)
            {
                Log.EventLogger = Kernel.Get <WindowsEventLogger>();
            }
#if DEBUG
            Debug.Listeners.Add(new NLogTraceListener());
#endif
        }
Пример #26
0
        public void CreateWorkerSupervisor_CreatesAWorkerSupervisorWithGivenParameters()
        {
            var manager = new WorkerManager(_sharedContext, WorkerCount);
            var context = new WorkerContext(_sharedContext, 1);

            var worker = manager.CreateWorkerSupervisor(context);

            Assert.NotNull(worker);
        }
Пример #27
0
 protected void Awake()
 {
     BlazeEngine.Initialize();
     DOTween.Init();
     UIManager.Initialize(UIRootCanvas, UIEffectCamera);
     InputManager.Initialize(UIRootCanvas.GetComponent <GraphicRaycaster>());
     WorkerManager.Init();
     Debug.logger.logEnabled = Debug.isDebugBuild;
 }
Пример #28
0
        public void TestMoqNoUnity()
        {
            var m = new Mock<IWorker>();
            m.Setup(f => f.DoWork(It.IsAny<string>()))
             .Callback<string>(str => { Debug.WriteLine("MoqWorker: " + str); });

            var mgr = new WorkerManager(m.Object);
            mgr.WorkerDoWork("TestMoqNoUnity");
        }
Пример #29
0
    public static WorkerManager GetInstance()
    {
        if (instance == null)
        {
            instance = new WorkerManager();
        }

        return(instance);
    }
Пример #30
0
 internal void Command(string ActionName, string targetName, Vector3 targetPoint)
 {
     m_ActionName       = ActionName;
     currentTargrtPoint = targetPoint;
     currentTarget      = targetName;
     CurrentAction      = Commands.getAction(ActionName);
     ActionTime         = WorkerManager.getActionTime(ActionName);
     base.haveAction    = true;
 }
Пример #31
0
 public Worker(WorkerManager executor, int index)
 {
     this.executor       = executor;
     thread              = new Thread(() => { SecureLaunchThread(ThreadMethod, "Worker FrameUpdater [" + index + "]"); });
     thread.Name         = "Worker FrameUpdater [" + index + "]";
     thread.Priority     = ThreadPriority.AboveNormal;
     thread.IsBackground = true;
     thread.Start();
 }
Пример #32
0
        protected override void OnStart(string[] args)
        {
            var url = ConfigurationManager.AppSettings["SignalrUrl"];
            worker = new WorkerManager(DAL.MessagePriority.Normal);
            worker2 = new WorkerManager(DAL.MessagePriority.High);

            worker.Start();
            worker2.Start();

            webApp = WebApp.Start(url);
        }
Пример #33
0
    // Use this for initialization
    void Awake()
    {
        if(pathManager == null) {
            pathManager = GameObject.Find (vars.path_manager_name).GetComponent<wp_manager>();
        }

        if(baseManager == null) {
            baseManager = GameObject.Find (vars.base_name).GetComponent<base_manager>();
        }

        if(workerManager == null) {
            workerManager = GameObject.Find (vars.worker_manager_name).GetComponent<WorkerManager>();
        }
        navMeshAgent = GetComponent<NavMeshAgent>();
    }
Пример #34
0
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(new[] { new NotificationsService() });
                return;
            }

            var url = ConfigurationManager.AppSettings["SignalrUrl"];
            var worker = new WorkerManager(DAL.MessagePriority.Normal);
            var worker2 = new WorkerManager(DAL.MessagePriority.High);

            worker.Start();
            worker2.Start();

            using (WebApp.Start(url))
            {
                Console.WriteLine("Server running on {0}", url);
                Console.ReadLine();
            }
        }
Пример #35
0
    void Start()
    {
        if(workerManager == null) {
            workerManager = GameObject.Find (vars.worker_manager_name).GetComponent<WorkerManager>();
        }

        workerManager.addRessource(this);

        click_collider.SetActive(false);
        is_selected_by_res_manager = false;
        ressource_pos = this.gameObject.transform.position;
        res = new res_info();
        //res = vars.res_type_a;
        res.target_collection_ants = 0;
        //hier node registeren
        this.name = vars.res_name + "_" + ressource_id;
        refresh_res_info();
        show_complete_model();

        //	ressource_id = this.GetComponent<path_point>().waypoint_id;
    }
Пример #36
0
    // Use this for initialization
    void Start()
    {
        if(pathManager == null) {
            pathManager = GameObject.Find (vars.path_manager_name).GetComponent<wp_manager>();
        }

        if(baseManager == null) {
            baseManager = GameObject.Find (vars.base_name).GetComponent<base_manager>();
        }

        if(workerManager == null) {
            workerManager = GameObject.Find (vars.worker_manager_name).GetComponent<WorkerManager>();
        }

        workerManager.addWorker(this);
        navMeshAgent = GetComponent<NavMeshAgent>();
        navMeshObstacle = GetComponent<NavMeshObstacle>();
    }