public void SetUp() { service1 = new Mock<IProvidersService>();//Mock this services service2 = new Mock<IMemberService>();//Mock this services //Mocked services used in the members service constructor _mainService = new MainService(service1.Object, service2.Object); }
private static MainService GetService(string username, string password) { MainService service = new MainService(); service.Url = ConfigurationManager.AppSettings["ServiceUrl"]; service.ServiceHeaderValue = new ServiceHeader() { Username = username, Password = password, ApiVersion = "release7" }; service.Timeout = 100000000; return service; }
private void btnHead_Click(object sender, EventArgs e) { tmpText = txtHead.Text; RunPreview(); if (String.IsNullOrEmpty(txtHead.Text) || String.IsNullOrWhiteSpace(txtHead.Text)) { MainService.ChangeControlsEnable(false, cboFont, nudFsize, cboAlign, bnColor, cbUnderline, cbItalic, cbBold); } else { MainService.ChangeControlsEnable(true, cboFont, nudFsize, cboAlign, bnColor, cbUnderline, cbItalic, cbBold); } }
public ClientPage(Client c) { InitializeComponent(); this.c = c; mainService = MainService.Instance; this.uiTBId.Text = c.Id.ToString(); this.uiTBBudget.Text = c.Budget.ToString(); this.uiTBName.Text = c.Name.ToString(); List <Product> clientProducts = mainService.FindClientProducts(c); foreach (Product p in clientProducts) { c.Products.Add(p); ListViewItem l = new ListViewItem(); l.Content = p.Name; this.uiLBProducts.Items.Add(l); } }
/// <summary> /// 啟動服務 /// </summary> /// <param name="args"></param> protected override void OnStart(string[] args) { try { LogHelper.Logger.Trace(this.ServiceName + " OnStart."); LogHelper.Logger.Trace("Create MainService."); //建立執行物件 this.mainService = new MainService(); LogHelper.Logger.Trace("Initial MainService."); //初始化執行物件 this.mainService.Initialize(); } catch (Exception ex) { LogHelper.Logger.Fatal(ex, "Exception on OnStart()"); } }
public void Initialize() { Log.LogHandler = new ConsoleLogHandler(); _exeFolder = AppDomain.CurrentDomain.BaseDirectory; string dataFolder = Path.Combine(_exeFolder, "Data"); if (Directory.Exists(dataFolder)) { Directory.Delete(dataFolder, true); } MainService.CopyDirectory(Path.Combine("Content", "ProgramData"), "Data", true); _settings = new SettingModel { DataFolder = dataFolder }; }
private void OpenPdfFile() { if (!isInit) { Cursor.Hide(); Cursor.Position = new Point(800, 400); LoadingForm.ShowSplashScreen(); } DocPdfViewer.Document?.Dispose(); MainService.ExecuteLatexCommand(pathTexFile, cls); DocPdfViewer.Document = OpenDocument(pathTexFile + cls + "_preview" + ".pdf"); ReloadPdf = false; if (!isInit) { LoadingForm.CloseForm(); Cursor.Show(); } }
public ActionResult Post(JobParam query) { try { if (query == null) { return(Problem("Empty Params passed to RunJob method!", "Error", StatusCodes.Status500InternalServerError)); } MainService.RunJobNow(query.Group, query.Name); return(Ok($"Job {query.Name} Launched!")); } catch (Exception e) { log.Info(e.ToString()); return(Problem(e.ToString(), "Error", StatusCodes.Status500InternalServerError)); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //打开服务 MainService.Open(this); plTabPanel.Top = (Screen.PrimaryScreen.Bounds.Height - plTabPanel.Height) / 2; plTabPanel.Left = (Screen.PrimaryScreen.Bounds.Width - plTabPanel.Width) / 2; BackButton.NoFocusImage = null; BackButton.FocusImage = null; ibAbout.NoFocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\machine1.png")); ibAbout.FocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\machine2.png")); ibGo.NoFocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\go1.png")); ibGo.FocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\go2.png")); ibFace.NoFocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\face1.png")); ibFace.FocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\face2.png")); ibVoice.NoFocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\voice1.png")); ibVoice.FocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\voice2.png")); ibSetting.NoFocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\set1.png")); ibSetting.FocusImage = MainService.GetImage(Path.Combine(Application.StartupPath, @"Images\set2.png")); if (SuperObject.Config.EnabledSwitchToLockUIOnStartup) { System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(delegate(object stateObj) { System.Threading.Thread.Sleep(1500); if (IsHandleCreated) { Invoke(new MethodInvoker(delegate() { new LockUI().Show(); })); } })); } }
private void SectionTab_Load(object sender, EventArgs e) { db = new DbService(); fontList = new List <string>(); fontList = FontFamily.Families.Select(x => x.Name).Where(x => !x.Contains("Bahnschrift")).ToList(); cboFont.DataSource = fontList; alignData = db.GetDocOptionData(lbAlign.Text); cboAlign.DataSource = alignData; cboAlign.DisplayMember = Constants.Name; cboAlign.ValueMember = Constants.Option; cboAlign.SelectedIndex = 0; caseData = db.GetDocOptionData(lbCase.Text); cboCase.DataSource = caseData; cboCase.DisplayMember = Constants.Name; cboCase.ValueMember = Constants.Option; cboCase.SelectedIndex = 0; formatData = db.GetDocOptionData(lbFormat.Text); cboFormat.DataSource = formatData; cboFormat.DisplayMember = Constants.Name; cboFormat.ValueMember = Constants.Option; cboFormat.SelectedIndex = 0; nudFsize.Value = 16; MainService.ChangeControlsEnable(false, cboAlign, cboCase, cboFont, nudFsize, bnColor, cbUnderline, cbItalic, cbBold, cboFormat); tfFrontOption = ""; colorDialog1.Color = Color.Black; colorR = colorDialog1.Color.R.ToString(); colorG = colorDialog1.Color.G.ToString(); colorB = colorDialog1.Color.B.ToString(); fontColor = String.Format("{0},{1},{2}", colorR, colorG, colorB); parentForm = this.ParentForm as DocStyleForm; isFormLoad = false; }
public ActionResult PostSignal() { Task <string> response = null; SignalInfo signal = null; try { using (var reader = new StreamReader(Request.Body)) { response = reader.ReadToEndAsync(); if (string.IsNullOrEmpty(response.Result)) { return(Problem("NULL Signal passed as a parameter", "Error", StatusCodes.Status500InternalServerError)); } signal = SignalInfo.Create(response.Result); if (signal == null) { return(Problem("Broken Signal passed as a parameter", "Error", StatusCodes.Status500InternalServerError)); } MainService.PostSignalTo(signal); } return(Ok()); } catch (Exception e) { if (response != null && !string.IsNullOrEmpty(response.Result)) { log.Error($"Result error:{response.Result} {e}"); if (signal != null) { log.Error($"Signal.Data={signal.Data}"); } } else { log.Error(e.ToString()); } return(Problem(e.ToString(), "Error", StatusCodes.Status500InternalServerError)); } }
public void Login(Personal personal, IObserver client) { var ok = MainService.handleLogin(personal.UserName, personal.Password); //Console.WriteLine(client.ToString()+" incearca sa se lo" ); if (ok) { if (_clientsDictionary.ContainsKey(personal.UserName)) { throw new Exception("User already logged in!"); } _clientsDictionary[personal.UserName] = client; } else { throw new AppException("Auth failed!"); } }
public HttpResponseMessage Post(JobParam query) { try { if (query == null) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Empty Params passed to RunJob method!")); } MainService.RunJobNow(query.Group, query.Name); return(Request.CreateResponse(HttpStatusCode.OK, $"Job {query.Name} Launched!")); } catch (Exception e) { log.Info(e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.ToString())); } }
public IActionResult Edit(int id) { MainService mainService = mainServicesService.GetById(id); if (mainService == null) { return(RedirectToIndex()); } EditMainServiceViewModel vm = new EditMainServiceViewModel { Id = id, Title = mainService.Title, Description = mainService.Description, Icon = mainService.Icon }; return(View(vm)); }
private void Change_Wallet_Address(object sender, EventArgs e) { Task.Run(() => { //This will request a change to all the addresses if (MainService.MyOpenOrderList.Count > 0) { MainService.MessageBox("Notice!", "Cannot change addresses with open orders present.", "OK", false); return; } bool result = MainService.PromptUser("Confirmation", "Are you sure you want to change all your wallet addresses?", "OK", "Cancel"); if (result == true) { MainService.ChangeWalletAddresses(); MainService.MessageBox("Notice!", "Wallet addresses have been changed to new ones.", "OK", false); } }); }
public async Task Test_Service_Get_Games() { var mock = new Mock <ILogger <MainService> >(); var service = new MainService(mock.Object); Player player1 = new Player(); Player player2 = new Player(); Game game1 = new Game(player1, player2); Game game2 = new Game(player1, player2); await service.AddGameAsync(game1); await service.AddGameAsync(game2); var gameList = service.GetGamesAsync().Result.ToList(); Assert.AreEqual(2, gameList.Count); }
public void rx_GetDrugDrugInteractionsTest() { MainService ms = new MainService(); var ds = ms.rx_GetDrugDrugInteractions(1286, "d03826", "xy1000#dr"); if (ds.Count == 0) { Assert.Fail("No Data returned"); } ds = ms.rx_GetDrugDrugInteractions(0, "d03826", "xy1000#dr"); if (ds != null) { if (ds.Count != 0) { Assert.Fail("Data returned in error"); } } }
public void PrepareHideOptions() { if (InvokeRequired) { Invoke(new Action(PrepareHideOptions)); return; } while (tsmiHide.DropDownItems.Count > 2) { tsmiHide.DropDownItems.RemoveAt(2); } var options = MainService.GetOptions(); var i = new ToolStripMenuItem() { Name = $"tsmiHideAll", Text = "All", CheckOnClick = true, Checked = options.HideOptions.Contains($"{MainViewModel.SourceType}_All") }; i.Click += HideOptionClick; tsmiHide.DropDownItems.Add(i); foreach (var item in XmlDal.DataModel.HideOptionsModel.Options.Where(n => n.SourceTypes.Count == 0 || n.SourceTypes.Contains(Keywords.ALL) || n.SourceTypes.Contains(MainViewModel.SourceType)).OrderBy(n => n.Name)) { i = new ToolStripMenuItem() { Name = $"tsmi{item.Name}", Text = item.Name, CheckOnClick = true, Checked = options.HideOptions.Contains($"{MainViewModel.SourceType}_{item.Name}") }; i.Click += HideOptionClick; tsmiHide.DropDownItems.Add(i); } }
private void Change_DNS_Seed(object sender, EventArgs e) { Task.Run(() => { string user_seed = MainService.UserPrompt("Enter A New DNS Seed (URL or IP)", "OK", "Cancel", false, MainService.DNS_SEED); if (user_seed.Length > 0 && user_seed.Equals(MainService.DNS_SEED) == false) { MainService.DNS_SEED = user_seed.Trim(); MainService.DNS_SEED_TYPE = 0; IPAddress ip_result; if (IPAddress.TryParse(MainService.DNS_SEED, out ip_result)) { MainService.DNS_SEED_TYPE = 1; //This is an IP address } File.Delete(MainService.App_Path + "/cn_list.dat"); //Delete the old list, then reload from the new seed MainService.FindCNServers(true); MainService.MessageBox("Notice!", "CN List has been fully updated", "OK", false); } }); }
private void btnSaveRun_Click(object sender, RoutedEventArgs e) { this.SaveConfiguration(); foreach (ProjectFolderInfo folder in this.CurrentMapping.ProjectFolders) { MainService.ProcessFolder(this.CurrentMapping, folder); } foreach (TridionFolderInfo tridionFolder in this.CurrentMapping.TridionFolders) { MainService.ProcessTridionFolder(this.CurrentMapping, tridionFolder); } MainService.ProcessHelper(); this.SaveConfiguration(); MessageBox.Show("Synchronization finished for mapping \"" + this.CurrentMapping.Name + "\"", "Finish", MessageBoxButton.OK, MessageBoxImage.Information); }
public void UnmaintainRelease_ShouldNotDeleteAndIsNotStored_DoNothing() { // Arrange var modName = "TestMod"; var version = new FactorioVersion(1, 2, 3); var shouldDelete = false; var isStored = false; var modsStorageService = new Mock <IModsStorageService>(); modsStorageService.Setup(mss => mss.ReleaseIsStored(modName, version)).Returns(isStored); var mainService = new MainService(null, null, null, null, null, modsStorageService.Object); // Act mainService.UnmaintainRelease(modName, version, shouldDelete); // Assert modsStorageService.Verify(mss => mss.DiscardRelease(modName, version), Times.Never); }
private void cbEnableLabel_CheckedChanged(object sender, EventArgs e) { if (cbEnableLabel.Checked) { MainService.ChangeControlsEnable(true, txtLabel, btnName, cbBold, cbItalic, cboSep, cboNumbering); } else { MainService.ChangeControlsEnable(false, txtLabel, btnName, cbBold, cbItalic, cboSep, cboNumbering); } if (!isFormLoad) { RunPreview("Label"); } }
public IEnumerable <ScheduledJobView> GetRunning() { try { var jobs = new List <ScheduledJobView>(); var list = MainService.GetRunningJobs(); var i = 1; foreach (var job in list) { jobs.Add(CreateJobView(i++, job.Value)); } return(jobs); } catch (Exception e) { log.Info(e.ToString()); } return(null); }
public ActionResult RefreshAll() { try { List <object> mss = (List <object>)MainService.GetObjects(EntitiesEnum.MetaSymbol); foreach (var m in mss) { MetaSymbol ms = (MetaSymbol)m; SignalInfo signalC = MainService.CreateSignal(SignalFlags.Cluster, ms.Id, EnumSignals.SIGNAL_ACTIVE_ORDERS); MainService.PostSignalTo(signalC); } return(Ok(HttpStatusCode.OK)); } catch (Exception e) { log.Error(e.ToString()); return(Problem(e.ToString(), "Error", StatusCodes.Status500InternalServerError)); } }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var serviceComp = new Service() { Id = Id }; dstManager.AddComponentData(entity, serviceComp); var assetRef = EntityUtil.CreateArrayAssetRef(DataIds); //var assetRef = EntityAuthoringUtil.CreateEntitiesAsset(DataIds); var mainService = new MainService() { StartStage = (byte)StartStage, DataIdsAssetRef = assetRef }; dstManager.AddComponentData(entity, mainService); }
private void FieldStyleTab_Load(object sender, EventArgs e) { TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; string tmp = fieldName + " style"; lbTab.Text = textInfo.ToTitleCase(tmp); txtEnd.Text = ". "; parentForm = this.ParentForm as BibStyleForm; MainService.ChangeControlsEnable(false, cbPrefixB, cbPrefixI, cbPrefixU, cbSuffixB, cbSuffixI, cbSuffixU); isEndClick = false; isPrefixClick = false; isSuffixCilck = false; strPrefix = txtPrefix.Text; strSuffix = txtSuffix.Text; strEnd = txtEnd.Text; }
public async Task Test_Service_Get_Players_Not_In_Game() { var mock = new Mock <ILogger <MainService> >(); var service = new MainService(mock.Object); Player player1 = new Player(); Player player2 = new Player(); Player player3 = new Player(); Player player4 = new Player(); Player player5 = new Player(); Player player6 = new Player(); player1.ConnectionId = "1"; player2.ConnectionId = "2"; player3.ConnectionId = "3"; player4.ConnectionId = "4"; player5.ConnectionId = "5"; player6.ConnectionId = "6"; await service.AddPlayerAsync(player1); await service.AddPlayerAsync(player2); await service.AddPlayerAsync(player3); await service.AddPlayerAsync(player4); await service.AddPlayerAsync(player5); await service.AddPlayerAsync(player6); Game game1 = new Game(player1, player2); await service.AddGameAsync(game1); Game game2 = new Game(player3, player5); await service.AddGameAsync(game2); var playersNotInGame = service.GetPlayersNotInGameAsync().Result.ToList(); Assert.AreEqual(2, playersNotInGame.Count); }
public ActionResult UpdateAdviserState(Adviser adviser) { try { if (adviser == null) { return(Problem("Empty Adviser passed to UpdateAdviserState method!", "Error", StatusCodes.Status417ExpectationFailed)); } if (MainService.UpdateObject(EntitiesEnum.Adviser, adviser.Id, JsonConvert.SerializeObject(adviser)) > 0) { return(Ok()); } return(Problem("Failed to update", "Error", StatusCodes.Status417ExpectationFailed)); } catch (Exception e) { log.Info(e.ToString()); return(Problem(e.ToString(), "Error", StatusCodes.Status500InternalServerError)); } }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; var bufferSize = 1024 * 67 + 128; Stream inputStream = Console.OpenStandardInput(bufferSize); Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, bufferSize)); var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("config.json", true) .Build(); Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(config) .CreateLogger(); var cronLogger = new CronLogger(Log.Logger); var mainService = new MainService(cronLogger); mainService.Run(args); }
public Isolated() { Type type = typeof(T); AppDomainSetup appSetup = new AppDomainSetup() { ApplicationName = type.Name, ApplicationBase = MainService.GetProgramFolder(), PrivateBinPath = @".", ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile }; string name = "Isolated:" + Guid.NewGuid(); _domain = AppDomain.CreateDomain( name, AppDomain.CurrentDomain.Evidence, appSetup); _value = (T)_domain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName); }
public HttpResponseMessage RefreshAll() { try { List <ExpertsCluster> clusters = MainService.GetClusters(); SignalInfo signalC = null; foreach (var cluster in clusters) { signalC = MainService.CreateSignal(SignalFlags.Cluster, cluster.Id, EnumSignals.SIGNAL_ACTIVE_ORDERS); MainService.PostSignalTo(signalC); } return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception e) { log.Error(e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.ToString())); } }
public async Task Test_Service_Get_Players() { var mock = new Mock <ILogger <MainService> >(); var service = new MainService(mock.Object); var player1 = new Player("Felix"); var player2 = new Player("Niklas"); var player3 = new Player("Yannick"); var player1Returned = await service.AddPlayerAsync(player1); var player2Returned = await service.AddPlayerAsync(player2); var player3Returned = await service.AddPlayerAsync(player3); var players = service.GetPlayersAsync().Result.ToList(); Assert.Contains(player1Returned, players); Assert.Contains(player2Returned, players); Assert.Contains(player3Returned, players); Assert.AreEqual(3, players.Count); }
private static MainService GetService() { MainService service = new MainService(); service.ServiceHeaderValue = new ServiceHeader() { Username = "******", Password = "******", ApiVersion = "release7" }; service.Timeout = 100000000; return service; }
public override void TestInit() { this.MainService = new MainService(); this.currentUser = new TestUser(); }
public PreCacher(MainService service) { this.service = service; }