public async Task Server_ClientWebRepository_CommunicationValid() { using Server server = new Server(TEST_PORT, new DataRepository(), null); using AutoResetEvent clientConnEvent = new AutoResetEvent(false), clientDisconnEvent = new AutoResetEvent(false); server.ServerWebSocketConnection.OnError += (o, a) => Assert.Fail($"Server error! {a.Exception}"); server.ServerWebSocketConnection.OnClientConnected += (o, a) => clientConnEvent.Set(); server.ServerWebSocketConnection.OnClose += (o, a) => clientDisconnEvent.Set(); Task serverTask = Task.Run(server.RunServer); using (WebRepository client = new WebRepository()) { Assert.IsTrue(await client.OpenRepository(ClientUtil.CreateLocalConnectionString(TEST_PORT))); Assert.IsTrue(clientConnEvent.WaitOne(TEST_TIMEOUT)); Assert.AreEqual((await server.DataRepository.GetAllClients()).Count, (await client.GetAllClients()).Count); Assert.AreEqual((await server.DataRepository.GetAllProducts()).Count, (await client.GetAllProducts()).Count); Assert.AreEqual((await server.DataRepository.GetAllOrders()).Count, (await client.GetAllOrders()).Count); TestObserver testObserver = new TestObserver(); using (IDisposable _ = server.DataRepository.Subscribe((IObserver <DataChanged <IClient> >)testObserver), __ = server.DataRepository.Subscribe((IObserver <DataChanged <IProduct> >)testObserver)) { await client.RemoveClient((await client.GetAllClients()).First()); await client.RemoveProduct((await client.GetAllProducts()).First()); } Assert.AreEqual(0, testObserver.ClientErrors.Count); Assert.AreEqual(0, testObserver.ProductErrors.Count); Assert.AreEqual(1, testObserver.ClientNext.Count); Assert.AreEqual(1, testObserver.ProductNext.Count); Assert.AreEqual(DataChangedAction.Remove, testObserver.ClientNext.Dequeue().Action); Assert.AreEqual(DataChangedAction.Remove, testObserver.ProductNext.Dequeue().Action); } Assert.IsTrue(clientDisconnEvent.WaitOne(TEST_TIMEOUT)); }
private void button3_Click_1(object sender, EventArgs e) { try { var secondNumber = decimal.Parse(textBox1.Text); var productId = cbxGoods.SelectedValue.ToString(); decimal number = 0; if (dClienGoods.ContainsKey(productId)) { number = dClienGoods[productId] = dClienGoods[productId] + (ClientUtil.GetNumberBySecondNumber(mClientGoods, secondNumber) ?? 0); } else { dClienGoods.Add(cbxGoods.SelectedValue.ToString(), number = (ClientUtil.GetNumberBySecondNumber(mClientGoods, secondNumber) ?? 0)); } txtNumber.Text = number.ToString(); textBox1.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void RestRequestAsync <TResponse>(Request <TResponse> request, RestliCallback <TResponse> restliCallback) where TResponse : Response { HttpRequest httpRequest = ClientUtil.BuildHttpRequest(request, urlPrefix); TransportCallback transportCallback = new RestliCallbackAdapter <TResponse>(request.responseDecoder, restliCallback); transportClient.RestRequestAsync(httpRequest, transportCallback); }
public void ShouldCreateSocket() { var client = ClientUtil.FromSettingsFile(); var socket = Nakama.Socket.From(client); Assert.NotNull(socket); }
/// <summary> /// 根据部门生产计划同步存货 每次都删除重新创建 /// </summary> public static void SyncGoodsByDepartPlan() { var folder = Path.Combine(Util.DataFolder, typeof(ClientGoods).Name); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var files = Directory.GetFiles(folder, "*.xml"); foreach (var file in files) { File.Delete(file); } var list = RpcFacade.Call <IList <RpcObject> >("/MainSystem/B3Butchery/Rpcs/GoodsInfoRpc/GetByDepartPlan", SysConfig.Current.Department_ID); List <ClientGoods> clientList = list.Select(x => (ClientUtil.CreateClientGoods(x))).ToList <ClientGoods>(); XmlSerializer serializer = new XmlSerializer(typeof(List <ClientGoods>)); using (var stream = File.Open(Path.Combine(folder, DateTime.Now.ToString("yyyy-MM-dd") + ".xml"), FileMode.Create)) { serializer.Serialize(stream, clientList); } }
public static void Main(string[] args) { //TestNetwork(); if (args.Length == 0) { ServerUtil.RunServerInThread(typeof(Lockstep.Server.Servers.Program).Assembly, EServerType.DaemonServer); Thread.Sleep(TimeSpan.FromSeconds(3)); } else { FakeClient._RandomSeed = DateTime.Now.Millisecond; } client = GetDebugClient(); ClientUtil.RunClient(client); while (true) { var cmd = Console.ReadLine(); if (cmd == "kc") { client.DoDestroy(); } if (cmd == "nc") { client = GetDebugClient(); ClientUtil.RunClient(client); } Thread.Sleep(30); } }
public void SaveTexList(List <Tex> texes) { var db = ClientUtil.GetConnection(); db.Insertable(texes).ExecuteCommand(); db.Close(); }
//load created build request public void loadList() { ClientUtil.getTestFiles(); string testFilesPath = "..\\..\\..\\Repository\\TestFiles"; string driverFilesPath = "..\\..\\..\\Repository\\TestDrivers"; DirectoryInfo directoryInfo = new DirectoryInfo(testFilesPath); FileInfo[] testfiles = directoryInfo.GetFiles("*.*"); foreach (FileInfo file in testfiles) { if (!TestFileslistBox.Items.Contains(file.Name)) { TestFileslistBox.Items.Add(file.Name); } } DirectoryInfo directoryInfo1 = new DirectoryInfo(driverFilesPath); FileInfo[] driverFiles = directoryInfo1.GetFiles("*.*"); foreach (FileInfo file in driverFiles) { if (!TestDriverslistBox.Items.Contains(file.Name)) { TestDriverslistBox.Items.Add(file.Name); } } }
private async void ExecuteConnect() { StartLoading(); IsConnecting = true; try { if (!await DataRepository.OpenRepository(ClientUtil.CreateConnectionString(ConnectionAddress, uint.Parse(ConnectionPort)))) { IsConnecting = false; StopLoading(); DialogInformationViewModel.OpenDialog(DialogIdentifier1, "Failed to open the data repository!"); return; } IsConnected = true; Clients = new ObservableCollection <IClient>(await DataRepository.GetAllClients()); Orders = new ObservableCollection <IOrder>(await DataRepository.GetAllOrders()); Products = new ObservableCollection <IProduct>(await DataRepository.GetAllProducts()); OrderSentUnsubscriber = DataRepository.Subscribe((IObserver <OrderSent>) this); ClientUnsubscriber = DataRepository.Subscribe((IObserver <DataChanged <IClient> >) this); ProductUnsubscriber = DataRepository.Subscribe((IObserver <DataChanged <IProduct> >) this); OrderUnsubscriber = DataRepository.Subscribe((IObserver <DataChanged <IOrder> >) this); } catch (Exception e) { IsConnected = false; DialogInformationViewModel.OpenDialog(DialogIdentifier1, $"Connection initialization failed!\n{e}"); } IsConnecting = false; StopLoading(); }
public IEnumerable <dynamic> GetB() { var str = System.IO.File.ReadAllText("D:\\data.txt"); //var v1 = ClientUtil.ClientPost("http://localhost:56956/api/EDBData/JFlatTable", str); var v2 = ClientUtil.ClientPost("http://localhost:56956/api/EDBData/JFlatTableTwo", str); //var result = JsonConvert.DeserializeObject<List<ResponseModel>>(str); var str2 = System.IO.File.ReadAllText("D:\\a.txt"); var result = JsonConvert.DeserializeObject <List <ResponseModel> >(str); result.AddRange(result); var ie = result.Select(o => new ResponseModel { Code = o.Code, DataList = o.DataList.Select(x => new DataObject { ErrorMsg = x.ErrorMsg, FDate = x.FDate, Value = x.Value }) }); var a = JsonConvert.SerializeObject(result); var b = JsonConvert.SerializeObject(ie); return(result.Select(o => new ResponseModel { Code = o.Code, DataList = o.DataList.Select(x => new DataObject { ErrorMsg = x.ErrorMsg, FDate = x.FDate, Value = x.Value }) })); }
public List <Tex> GetTexList() { var db = ClientUtil.GetConnection(); var texes = db.Queryable <Tex>().ToList(); db.Close(); return(texes); }
//Function to send build request private void SendBuildRequest_Click(object sender, RoutedEventArgs e) { foreach (var file in BuildRequestlistBox.SelectedItems) { BuildRequests.Add(file.ToString()); } ClientUtil.ListUpdater(BuildRequests); ClientUtil.CommHandler(); BuildRequestlistBox.SelectedItems.Clear(); }
private void RemoveSelBtn_Click(object sender, EventArgs e) { DialogResult result1 = MessageBox.Show("Do you want to remove the selected Client?", "Warning", MessageBoxButtons.YesNo); if (result1 == System.Windows.Forms.DialogResult.Yes) { var selItem = ClientsListBox.SelectedItem as AuthClient; ClientUtil.RemoveClient(selItem); AuthClientsList_Load(null, null); MessageBox.Show("Client removed. Restart the server to apply it.", "Success", MessageBoxButtons.OK); } }
private void AuthClientsList_Load(object sender, EventArgs e) { var list = ClientUtil.GetClients(); if (list == null) { list = new List <AuthClient>(); } ClientsListBox.DataSource = list; ClientsListBox.Refresh(); }
//constructor public MainWindow() { InitializeComponent(); loadList(); client = new ClientUtil(); Thread fileCheck = new Thread(new ThreadStart(updateBuildRequestsOnUI)); fileCheck.Start(); SendBuildRequests.IsEnabled = true; FileNameTextBox.Text = "2"; FileNameTextBox.IsReadOnly = true; }
private void SetAbsNumber(int number, SpriteBundle bundle) { var digits = ClientUtil.GetDigits(number); for (int i = 0; i < digits.Count; i++) { var obj = Instantiate(DigitPrefab, NumberParent); obj.name = $"Digit{i}"; var image = obj.GetComponent <Image>(); image.sprite = bundle.Get(digits[i]); } }
public TResponse RestRequestSync <TResponse>(Request <TResponse> request) where TResponse : Response { HttpRequest httpRequest = ClientUtil.BuildHttpRequest(request, urlPrefix); HttpResponse httpResponse = transportClient.RestRequestSync(httpRequest); TransportResponse transportResponse = new TransportResponse(httpResponse); if (transportResponse.hasError()) { throw transportResponse.getError().error; } return(request.responseDecoder.DecodeResponse(transportResponse)); }
public List <PurchasedProductInfo> GetClientPurchasedProducts(ClientInfoRequest clientInfoRequest) { var url = $@"http://localhost:51790/api/order/?{clientInfoRequest.ClientId}"; using (HttpClient client = new HttpClient()) { var jsonResult = client.GetStringAsync(url).GetAwaiter().GetResult(); var clientOrderList = JsonConvert.DeserializeObject <List <OrderModel> >(jsonResult); var purchasedProductInfoList = ClientUtil.GetPurchasedProductInfoListBasingAtClientOrderList(clientOrderList); return(purchasedProductInfoList); } }
//start Up Setup public static void startUpSetup() { startUI(); int numChldBldr = 2; MainWindow UI = new MainWindow(); UI.StartupHandler(numChldBldr); ClientUtil.startMotherBuilder(numChldBldr); ClientUtil.startRepository(numChldBldr); ClientUtil.startTestHarness(numChldBldr); ClientUtil.startUpSetup(); ClientUtil.CommHandler(); ClientUtil.buildRequestClear(); }
public void ExpandForSaveWorks() { { var expand = ClientUtil.ExpandForSave <ResourceForSave>(); Assert.Equal("Units", expand); } { var expand = ClientUtil.ExpandForSave <DocumentForSave>(); Assert.Equal("Lines.Entries,LineDefinitionEntries,Attachments", expand); } { var expand = ClientUtil.ExpandForSave <UnitForSave>(); Assert.Equal("", expand); } }
private void button3_Click(object sender, EventArgs e) { try { var secondNumber = decimal.Parse(textBox1.Text); var number = ClientUtil.GetNumberBySecondNumber(mClientGoods, secondNumber); mSumNumber += number ?? 0; txtNumber.Text = mSumNumber.ToString(); textBox1.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//Function to handle create build request button on UI public void CreateBuildRequestButton_Click(object sender, RoutedEventArgs e) { foreach (var file in TestFileslistBox.SelectedItems) { testedFiles.Add(file.ToString()); } foreach (var file in TestDriverslistBox.SelectedItems) { driverFiles.Add(file.ToString()); } ClientUtil.ListUpdater(testedFiles, driverFiles); TestFileslistBox.SelectedIndex = -1; TestDriverslistBox.SelectedIndex = -1; ClientUtil.CreateBuildRequest(); testedFiles.Clear(); driverFiles.Clear(); }
public void ViewToModel() { if (ValidateData()) { #region 主表 CurMaster.CreateDate = ClientUtil.ToDateTime(txtCreateDate.Text); CurMaster.Descript = ClientUtil.ToString(this.txtRemark.Text); // CurMaster.BankAddress = ClientUtil.ToString(this.hdBankAddress.Value); CurMaster.IfProjectMoney = PaymentType; if (!string.IsNullOrEmpty(this.hdSupplyID.Value)) { ObjectQuery oQuery = new ObjectQuery(); oQuery.AddCriterion(Expression.Eq("Id", this.hdSupplyID.Value)); IList lst = GlobalClass.CommonMethodSrv.Query(typeof(SupplierRelationInfo), oQuery); SupplierRelationInfo oTheSupplierRelationInfo = (lst != null && lst.Count > 0) ? (lst[0] as SupplierRelationInfo):null; CurMaster.TheSupplierRelationInfo = oTheSupplierRelationInfo == null?"":oTheSupplierRelationInfo.Id; CurMaster.BankAccountNo = oTheSupplierRelationInfo == null ? "" : oTheSupplierRelationInfo.BankAccount; CurMaster.BankName = oTheSupplierRelationInfo == null?"":oTheSupplierRelationInfo.BankName; //CurMaster.BankAddress=CurMaster.TheSupplierRelationInfo. } CurMaster.BankAccountNo = ClientUtil.ToString(this.txtBankAcctNo.Text); CurMaster.BankName = ClientUtil.ToString(this.txtBankNo.Text); CurMaster.TheSupplierName = txtSupply.Text; if (!string.IsNullOrEmpty(cmbPaymentType.SelectedValue)) { AccountTitleTree currAccountTitle = GetAccountTitleTree(cmbPaymentType.SelectedValue); CurMaster.AccountTitleID = currAccountTitle == null ? "" : currAccountTitle.Id; CurMaster.AccountTitleName = currAccountTitle == null ? "" : currAccountTitle.Name; CurMaster.AccountTitleCode = currAccountTitle == null ? "" : currAccountTitle.Code; CurMaster.AccountTitleSyscode = currAccountTitle == null ? "" : currAccountTitle.SysCode; } #endregion #region 明细 //this.gvDetail.DataSource = this.CurMaster.Details; //this.gvDetail.DataBind(); #endregion } }
public static void Main(string[] args) { //TestNetwork(); if (args.Length == 0) { //ServerUtil.RunServerInThread(typeof(Lockstep.Server.Servers.Program).Assembly,EServerType.DaemonServer); //Thread.Sleep(TimeSpan.FromSeconds(3)); } else { } //ClientUtil.RunClient(GetDebugClient()); ClientUtil.RunClient(GetFakeUnityClient()); while (true) { Thread.Sleep(30); } }
void Start() { #if UNITY_IPHONE MAX_INLOADING_RESCOUNT = 5; if (ClientUtil.GetMemorySize() > 512) { MAX_INLOADING_RESCOUNT = 10; } #else MAX_INLOADING_RESCOUNT = 10; #endif curLoadingRes_background = new Resource[MAX_INLOADING_RESCOUNT]; for (int i = 0; i < MAX_INLOADING_RESCOUNT; i++) { curLoadingRes_background[i] = null; } }
private HttpRequestMessage ConstructHttpRequestMessage(HttpRequest httpRequest) { HttpRequestMessage httpRequestMessage = new HttpRequestMessage() { RequestUri = httpRequest.url, Method = ClientUtil.GetHttpMethod(httpRequest.httpMethod) }; if (httpRequest.entityBody != null) { httpRequestMessage.Content = new ByteArrayContent(httpRequest.entityBody); } httpRequestMessage.Headers.Clear(); foreach (KeyValuePair <string, string> header in httpRequest.headers) { httpRequestMessage.Headers.Add(header.Key, header.Value); } return(httpRequestMessage); }
public static void Main(string[] args) { //TestNetwork(); if (args.Length == 0) { ServerUtil.RunServerInThread(typeof(Lockstep.Server.Servers.Program).Assembly, EServerType.DaemonServer); Thread.Sleep(TimeSpan.FromSeconds(3)); } else { FakeClient._RandomSeed = DateTime.Now.Millisecond; } ClientUtil.RunClient(GetDebugClient()); while (true) { Thread.Sleep(30); } }
protected void gridProject_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[0].Text = (e.Row.RowIndex + 1).ToString(); CurrentProjectInfo project = e.Row.DataItem as CurrentProjectInfo; IList listWarningTarget = list[project]; Color warningTargetBySafeColor = (Color)listWarningTarget[0]; Color warningTargetByQualityColor = (Color)listWarningTarget[1]; Color warningTargetByDurationColor = (Color)listWarningTarget[2]; Color warningTargetByCostColor = (Color)listWarningTarget[3]; bool projectHasData = Convert.ToBoolean(listWarningTarget[11]); decimal warningTargetBySafe = decimal.Round((decimal)listWarningTarget[4], 4); decimal warningTargetByQuality = decimal.Round((decimal)listWarningTarget[5], 4); decimal warningTargetByDuration = decimal.Round((decimal)listWarningTarget[6], 4); decimal warningTargetByCostRealProfit = decimal.Round((decimal)listWarningTarget[7], 4); //成本指标:实际/平均实际利润率 decimal warningTargetByCostResTurnedOver = decimal.Round((decimal)listWarningTarget[8], 4); //成本指标:实际/平均责任上缴比率 decimal warningTargetByCostSumProfit = decimal.Round(ClientUtil.ToDecimal(listWarningTarget[17]) / 10000, 2); //利润额 = 合同收入-实际成本 decimal warningTargetByCostProfitRate = decimal.Round((decimal)listWarningTarget[18], 2); //利润率 = 利润额/合同收入 decimal warningTargetByCostSumLower = decimal.Round((decimal)(ClientUtil.ToDecimal(listWarningTarget[19]) / 10000), 2); //超成本降低额 = 责任成本-实际成本 decimal warningTargetByCostRateLower = decimal.Round((decimal)listWarningTarget[20], 2); //超成本降低率 = 超成本降低额/责任成本 e.Row.Cells[6].BackColor = warningTargetByCostColor; e.Row.Cells[6].ToolTip = ModelToolTip(3, warningTargetByCostColor) + ";" + "利润额:" + warningTargetByCostSumProfit + "万元;利润率:" + warningTargetByCostProfitRate + "%;超成本降低额:" + warningTargetByCostSumLower + "万元;超成本降低率:" + warningTargetByCostRateLower + "%"; //成本 e.Row.Cells[7].BackColor = warningTargetByDurationColor; e.Row.Cells[7].ToolTip = ModelToolTip(4, warningTargetByDurationColor) + ";" + GetWaringDesc2(4, project.OwnerOrg.OperationType, projectHasData, warningTargetByDurationColor, warningTargetByDuration, 0);;//工期 e.Row.Cells[8].BackColor = warningTargetByQualityColor; e.Row.Cells[8].ToolTip = ModelToolTip(2, warningTargetByQualityColor) + ";" + GetWaringDesc2(2, project.OwnerOrg.OperationType, projectHasData, warningTargetByQualityColor, warningTargetByQuality, 0);//质量 e.Row.Cells[9].BackColor = warningTargetBySafeColor; e.Row.Cells[9].ToolTip = ModelToolTip(1, warningTargetBySafeColor) + ";" + GetWaringDesc2(1, project.OwnerOrg.OperationType, projectHasData, warningTargetBySafeColor, warningTargetBySafe, 0);//安全 } }
//initialize setup //function to handle Start Mother builder button on UI private void CommandButton_Click(object sender, RoutedEventArgs e) { var h = FileNameTextBox.Text; int numOfChilds; if (!(Int32.TryParse(h, out numOfChilds))) { } else { int chldBuilderNum = 0; chldBuilderNum = Int32.Parse(FileNameTextBox.Text); SendBuildRequests.IsEnabled = true; ClientUtil.startMotherBuilder(chldBuilderNum); ClientUtil.startRepository(chldBuilderNum); ClientUtil.startTestHarness(chldBuilderNum); Thread.Sleep(500); //CommandButton.IsEnabled = false; } }
void _newServer_OnClientAskForConnection(xConnection conn) { Console.WriteLine("[FORM] Connection Request"); this.Invoke((MethodInvoker) delegate { string address = conn.socket.RemoteEndPoint.ToString(); address = address.Remove(address.IndexOf(':')); string msg = "Accept New Connection request from: " + address + " ?"; DialogResult result1 = MessageBox.Show(msg, "Connection Request", MessageBoxButtons.YesNo); if (result1 == System.Windows.Forms.DialogResult.Yes) { _newServer.SetAuth(true, conn); ClientUtil.AddClient(new AuthClient { IPaddress = address, HostName = "temp" }); } else { _newServer.SetAuth(false, conn); } }); }