private async Task Add(object arg)
        {
            viewModel.SubmitAttempted = true;
            if (!viewModel.ValidationTemplate.Validate())
            {
                viewModel.NotifyOfPropertyChange(string.Empty);
                viewModel.SubmitAttempted = false;
                windowManager.ScrollFirstErrorIntoView(viewModel);

                return;
            }

            viewModel.InProgress = true;

            var instanceMetadata = new ServiceControlInstanceMetadata
            {
                DisplayName          = viewModel.InstanceName,
                Name                 = viewModel.InstanceName.Replace(' ', '.'),
                ServiceDescription   = viewModel.Description,
                DBPath               = viewModel.DatabasePath,
                LogPath              = viewModel.LogPath,
                InstallPath          = viewModel.DestinationPath,
                HostName             = viewModel.HostName,
                Port                 = Convert.ToInt32(viewModel.PortNumber),
                VirtualDirectory     = null, // TODO
                AuditLogQueue        = viewModel.AuditForwarding.Value ? viewModel.AuditForwardingQueueName  : null,
                AuditQueue           = viewModel.AuditQueueName,
                ForwardAuditMessages = viewModel.AuditForwarding.Value,
                ErrorQueue           = viewModel.ErrorQueueName,
                ErrorLogQueue        = viewModel.ErrorForwarding.Value ? viewModel.ErrorForwardingQueueName : null,
                TransportPackage     = viewModel.SelectedTransport.Name,
                ConnectionString     = viewModel.ConnectionString,
                ErrorRetentionPeriod = viewModel.ErrorRetentionPeriod,
                AuditRetentionPeriod = viewModel.AuditRetentionPeriod,
                ServiceAccount       = viewModel.ServiceAccount,
                ServiceAccountPwd    = viewModel.Password
            };

            using (var progress = viewModel.GetProgressObject("ADDING INSTANCE"))
            {
                var reportCard = await Task.Run(() => installer.Add(instanceMetadata, progress, PromptToProceed));

                if (reportCard.HasErrors || reportCard.HasWarnings)
                {
                    windowManager.ShowActionReport(reportCard, "ISSUES ADDING INSTANCE", "Could not add new instance because of the following errors:", "There were some warnings while adding the instance:");
                    return;
                }

                if (reportCard.CancelRequested)
                {
                    return;
                }
            }

            viewModel.TryClose(true);

            eventAggregator.PublishOnUIThread(new RefreshInstances());
        }
Exemplo n.º 2
0
 public PMode3v1() :
     base("神兽模式", 4, new int[] { 1, 1, 1, 2 })
 {
     Bonus = 5;
     Seats[3].DefaultType = PPlayerType.AI;
     Seats[3].Name        = "青龙/白虎/朱雀/玄武";
     Installer.Add(new PTrigger("神兽提前获取土地和房屋")
     {
         IsLocked = true,
         Time     = PTime.InstallModeTime,
         Effect   = (PGame Game) => {
             // 随机获得8个土地和2个商业用地
             List <PBlock> LandList     = Game.Map.BlockList.FindAll((PBlock _Block) => _Block.CanPurchase && !_Block.IsBusinessLand);
             List <PBlock> BusinessList = Game.Map.BlockList.FindAll((PBlock _Block) => _Block.CanPurchase && _Block.IsBusinessLand);
             PMath.Wash(LandList);
             PMath.Wash(BusinessList);
             int TotalLandCount = (LandList.Count + BusinessList.Count) / 3;
             int BusinessCount  = BusinessList.Count / 3;
             int LandCount      = TotalLandCount - BusinessCount;
             PLogger.Log("  获得" + LandCount.ToString() + "领地;" + BusinessCount.ToString() + "商业用地");
             List <PBlock> GotList = LandList.GetRange(0, LandCount);
             GotList.AddRange(BusinessList.GetRange(0, BusinessCount));
             GotList.ForEach((PBlock Block) => {
                 Block.Lord        = Game.PlayerList[PlayerNumber - 1];
                 Block.HouseNumber = 1;
                 if (Block.IsBusinessLand)
                 {
                     Block.BusinessType = PBusinessType.Institute;
                 }
                 PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(Block));
             });
         }
     });
     Installer.Add(new PTrigger("生成神兽")
     {
         IsLocked = true,
         Time     = PTime.InstallModeTime,
         Effect   = (PGame Game) => {
             List <PGeneral> PossibleBoss = new List <PGeneral>()
             {
                 new P_QingLong(),
                 new P_BaiHu(),
                 new P_ZhuQue(),
                 new P_XuanWu()
             };
             PMath.Wash(PossibleBoss);
             Game.PlayerList[PlayerNumber - 1].General = PossibleBoss[0];
             PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder("BOSS:" + PossibleBoss[0].Name));
         }
     });
 }
Exemplo n.º 3
0
 public PMode3v2() :
     base("约会模式", 5, new int[] { 2, 2, 1, 1, 1 })
 {
     Bonus = 20;
     Seats[0].DefaultType = PPlayerType.AI;
     Seats[0].Name        = "诱宵美九";
     Seats[1].DefaultType = PPlayerType.AI;
     Seats[1].Name        = "破军歌姬";
     Installer.Add(new PTrigger("破军歌姬启动")
     {
         IsLocked = true,
         Time     = PTime.InstallModeTime,
         Effect   = (PGame Game) => {
             Game.PlayerList[1].General = new P_Gabriel();
             Game.PlayerList[0].General = new P_IzayoiMiku();
         }
     });
 }