private void Submit(object sender, RoutedEventArgs e) { try { var emsDevice = ConbineDevice(); var service = new UnicomService(); var result = service.PushDevices(new[] { emsDevice }); if (result.result[0].value.ToString().Contains("ERROR")) { MessageBox.Show(result.result[0].value.ToString()); return; } emsDevice.code = result.result[0].key.ToString(); var dev = ConbineStoreDevice(emsDevice); _context.AddOrUpdate(dev); var range = new EmsAutoDust { DevSystemCode = dev.SystemCode, RangeMinValue = long.Parse(TxtRangeMinValue.Text), RangeMaxValue = long.Parse(TxtRangeMaxValue.Text) }; _context.AddOrUpdate(range); MessageBox.Show("添加成功。"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private static void RefreashPrjType() { var types = Service.PullProjectType(); foreach (var emsPrjType in types) { var ret = Context.GetId <EmsPrjType>($"Code = {emsPrjType.code}"); if (ret != null) { var id = (long)ret; Context.AddOrUpdate(new EmsPrjType { Code = emsPrjType.code.ToString(), Id = id, Name = emsPrjType.name }); } else { Context.AddOrUpdate(new EmsPrjType { Code = emsPrjType.code.ToString(), Id = -1, Name = emsPrjType.name }); } } }
private void SwitchProjectsTransfer(object sender, RoutedEventArgs e) { var projectId = (long)CmbProjects.SelectedValue; var project = _context.FirstOrDefault <EmsProject>($"Id = {projectId}"); project.onTransfer = !project.onTransfer; _projectOnTransfer[projectId] = project.onTransfer; var result = _context.AddOrUpdate(project); if (result > 0) { LblProjectOnTransfer.Content = project.onTransfer; } }
private void Submit(object sender, RoutedEventArgs e) { try { var emsProject = new emsProject { code = $"{TxtShortTitle.Text}-{TxtBjCode.Text}", name = $"{TxtPrjName.Text}", district = $"{CmbDistrict.Text}", prjType = int.Parse(CmbPrjType.SelectedValue.ToString()), prjTypeSpecified = true, prjCategory = int.Parse(CmbPrjCategory.SelectedValue.ToString()), prjCategorySpecified = true, prjPeriod = int.Parse(CmbPrjPeriod.SelectedValue.ToString()), prjPeriodSpecified = true, region = int.Parse(CmbRegion.SelectedValue.ToString()), regionSpecified = true, street = TxtStreet.Text, longitude = TxtLongitude.Text, latitude = TxtLatitude.Text, contractors = TxtContractors.Text, superintendent = TxtSuperintendent.Text, telephone = TxtTelephone.Text, address = TxtAddress.Text, siteArea = float.Parse(TxtSiteArea.Text), siteAreaSpecified = true, buildingArea = float.Parse(TxtBuildingArea.Text), buildingAreaSpecified = true, startDate = DpStartDate.DisplayDate, startDateSpecified = true, endDate = DpEndDate.DisplayDate, endDateSpecified = true, stage = TxtStage.Text, status = true, statusSpecified = true, isCompleted = CbCompleted.IsChecked == true, isCompletedSpecified = true }; var service = new UnicomService(); var result = service.PushProjects(new[] { emsProject }); if (result.result[0].value.ToString().Contains("ERROR")) { MessageBox.Show(result.result[0].value.ToString()); return; } var prj = new EmsProject { SystemCode = TxtSystemCode.Text, onTransfer = false, code = emsProject.code, name = emsProject.name, district = emsProject.district, prjType = emsProject.prjType, prjTypeSpecified = true, prjCategory = emsProject.prjCategory, prjCategorySpecified = true, prjPeriod = emsProject.prjPeriod, prjPeriodSpecified = true, region = emsProject.region, regionSpecified = true, street = emsProject.street, longitude = emsProject.longitude, latitude = emsProject.latitude, contractors = emsProject.contractors, superintendent = emsProject.superintendent, telephone = emsProject.telephone, address = emsProject.address, siteArea = emsProject.siteArea, siteAreaSpecified = true, buildingArea = emsProject.buildingArea, buildingAreaSpecified = true, startDate = emsProject.startDate, startDateSpecified = true, endDate = emsProject.endDate, endDateSpecified = true, stage = emsProject.stage, status = emsProject.status, statusSpecified = emsProject.statusSpecified, isCompleted = emsProject.isCompleted, isCompletedSpecified = true }; _context.AddOrUpdate(prj); MessageBox.Show("添加成功。"); } catch (Exception ex) { MessageBox.Show(ex.Message); var innerException = ex.InnerException; while (innerException != null) { MessageBox.Show(innerException.Message); innerException = innerException.InnerException; } } }