public void SavePersonnelToUser() { Log.Info(LogTags.BaseData, "获取人员信息..."); Bll bll = new Bll(); List <Personnel> list = bll.Personnels.ToList(); List <user> users = new List <user>(); for (int i = 0; i < list.Count; i++) { Personnel p = list[i]; user user = new user(); BaseDataHelper.SetUser(p, user); users.Add(user); if (i % 5 == 0) { Log.Info(LogTags.BaseData, string.Format("device:{0}({1}/{2})", user.name, i, list.Count)); } } Log.Info(LogTags.BaseData, "保存人员信息..."); BaseDataDb db = new BaseDataDb(); var r = db.SetTable(db.users, users); }
public void ImportData(WillowTwoPlayerSaveGame saveGame, Platform platform) { this.Slots.Clear(); this._BrokenSlots.Clear(); foreach (var bankSlot in saveGame.BankSlots) { IPackableSlot slot; try { slot = BaseDataHelper.Decode(bankSlot.InventorySerialNumber, platform); } catch (Exception e) { this._BrokenSlots.Add(new KeyValuePair <BankSlot, Exception>(bankSlot, e)); continue; } var test = BaseDataHelper.Encode(slot, platform); if (bankSlot.InventorySerialNumber.SequenceEqual(test) == false) { throw new FormatException("bank slot reencode mismatch"); } if (slot is BaseWeapon) { var viewModel = new BaseWeaponViewModel((BaseWeapon)slot); this.Slots.Add(viewModel); } else if (slot is BaseItem) { var viewModel = new BaseItemViewModel((BaseItem)slot); this.Slots.Add(viewModel); } } }
public void ExportData(WillowTwoPlayerSaveGame saveGame) { saveGame.BankSlots.Clear(); foreach (var viewModel in this.Slots) { var slot = viewModel.BaseSlot; if (slot is BaseWeapon) { var weapon = (BaseWeapon)slot; var data = BaseDataHelper.Encode(weapon); saveGame.BankSlots.Add(new BankSlot() { Data = data, }); } else if (slot is BaseItem) { var item = (BaseItem)slot; var data = BaseDataHelper.Encode(item); saveGame.BankSlots.Add(new BankSlot() { Data = data, }); } else { throw new NotSupportedException(); } } }
public void SaveDevInfoToDevice() { Bll bll = new Bll(); Log.Info(LogTags.BaseData, "获取设备信息..."); var archors = bll.Archors.ToList(); var cameras = bll.Dev_CameraInfos.ToList(); var list = bll.DevInfos.GetListWithDetail(archors, cameras); List <device> devices = new List <device>(); for (int i = 0; i < list.Count; i++) { DevInfo item = list[i]; device device = new device(); BaseDataHelper.SetDevice(device, item); //db.devices.Add(device); devices.Add(device); if (i % 20 == 0) { Log.Info(LogTags.BaseData, string.Format("device:{0}({1}/{2})", device.name, i, list.Count)); } } Log.Info(LogTags.BaseData, "保存设备信息..."); BaseDataDb db = new BaseDataDb(); var r = db.SetTable(db.devices, devices); //db.AddRange(devices); }
public void ImportData(WillowTwoPlayerSaveGame saveGame) { this.Slots.Clear(); foreach (var bankSlot in saveGame.BankSlots) { var slot = BaseDataHelper.Decode(bankSlot.Data); var test = BaseDataHelper.Encode(slot); if (bankSlot.Data.SequenceEqual(test) == false) { throw new FormatException("bank slot reencode mismatch"); } if (slot is BaseWeapon) { var viewModel = new BaseWeaponViewModel((BaseWeapon)slot); this.Slots.Add(viewModel); } else if (slot is BaseItem) { var viewModel = new BaseItemViewModel((BaseItem)slot); this.Slots.Add(viewModel); } } }
public IEnumerable <IResult> CopySelectedSlotCode() { yield return(new DelegateResult(() => { if (this.SelectedSlot == null || (this.SelectedSlot.BaseSlot is IPackable) == false) { if (MyClipboard.SetText("") != MyClipboard.Result.Success) { MessageBox.Show("Clipboard failure.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } return; } // just a hack until I add a way to override the unique ID in Encode() var copy = (IPackable)this.SelectedSlot.BaseSlot.Clone(); copy.UniqueId = 0; var data = BaseDataHelper.Encode(copy); var sb = new StringBuilder(); sb.Append("BL2("); sb.Append(Convert.ToBase64String(data, Base64FormattingOptions.None)); sb.Append(")"); if (MyClipboard.SetText(sb.ToString()) != MyClipboard.Result.Success) { MessageBox.Show("Clipboard failure.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } })); }
// GET: ChartBoard public async Task <ActionResult> Index() { //30天收益图 ViewBag.MonthLabels = JsonConvert.SerializeObject(BaseDataHelper.getLastMonthDate(DateTime.Now).Select(x => x.ToString("MM月dd日")).ToArray()); ViewBag.MonthData = JsonConvert.SerializeObject(await outRecordServer.searchLastMonthProfit()); //昨日收益饼图 ViewBag.YesterdayData = JsonConvert.SerializeObject(await outRecordServer.searchYesterdayNum()); //异常订单半年线图 ViewBag.HarfYearMonthLabel = JsonConvert.SerializeObject(BaseDataHelper.getSixMnthDate(DateTime.Now).Select(x => x.ToString("yyyy-MM")).ToArray()); var orderData = await orderInfoServer.getHalfYearOrderNum(); ViewBag.NormalOrderData = JsonConvert.SerializeObject(orderData.produceOrderNum); ViewBag.ExceptOrderData = JsonConvert.SerializeObject(orderData.exceptedOrderNum); ViewBag.CompletedOrderData = JsonConvert.SerializeObject(orderData.completedOrderNum); //库存不足柱状图 var inventoryData = await inventoryServer.searchTenInventoryCount(); ViewBag.InventoryLabels = JsonConvert.SerializeObject(inventoryData.materialName); ViewBag.InventoryAlarmCount = JsonConvert.SerializeObject(inventoryData.alarmCount); ViewBag.InventoryRealCount = JsonConvert.SerializeObject(inventoryData.inventoryCount); return(View()); }
public void ExportData(WillowTwoPlayerSaveGame saveGame, Platform platform) { saveGame.BankSlots.Clear(); foreach (var viewModel in this.Slots) { var slot = viewModel.BaseSlot; if (slot is BaseWeapon weapon) { var data = BaseDataHelper.Encode(weapon, platform); saveGame.BankSlots.Add(new BankSlot() { InventorySerialNumber = data, }); } else if (slot is BaseItem item) { var data = BaseDataHelper.Encode(item, platform); saveGame.BankSlots.Add(new BankSlot() { InventorySerialNumber = data, }); } else { throw new NotSupportedException(); } } this._BrokenSlots.ForEach(kv => saveGame.BankSlots.Add(kv.Key)); }
public OrderTool getHalfYearOrderNum() { DateTime startTime = DateTime.Now.AddMonths(-5).AddDays(1 - DateTime.Now.Day).Date; List <DateTime> MonthDate = new List <DateTime>(); MonthDate = BaseDataHelper.getSixMnthDate(DateTime.Now); LayerDbContext context = new LayerDbContext(); //异常订单数 var exceptOrderTemp = context.orderInfo.Where(x => x.status == "excepted" && x.receivedDate > startTime).GroupBy(x => x.createdDate.Month).Select(x => new { createdDate = x.Max(item => item.createdDate), count = x.Count() }).ToList(); //所有订单 var orderTemp = context.orderInfo.Where(x => x.createdDate > startTime).GroupBy(x => x.createdDate.Month).Select(x => new { createdDate = x.Max(item => item.createdDate), count = x.Count() }).ToList(); //完成订单 var completedOrderTemp = context.orderInfo.Where(x => x.status == "completed" && x.receivedDate > startTime).GroupBy(x => x.createdDate.Month).Select(x => new { createdDate = x.Max(item => item.createdDate), count = x.Count() }).ToList(); List <LineDataTool> orderData = new List <LineDataTool>(); List <LineDataTool> exceptedOrderData = new List <LineDataTool>(); List <LineDataTool> completedOrderData = new List <LineDataTool>(); LineDataTool model = null; foreach (var item in orderTemp) { model = new LineDataTool(); model.intData = item.count; model.date = item.createdDate.AddDays(1 - item.createdDate.Day).Date; orderData.Add(model); } foreach (var item in exceptOrderTemp) { model = new LineDataTool(); model.intData = item.count; model.date = item.createdDate.AddDays(1 - item.createdDate.Day).Date; exceptedOrderData.Add(model); } foreach (var item in completedOrderTemp) { model = new LineDataTool(); model.intData = item.count; model.date = item.createdDate.AddDays(1 - item.createdDate.Day).Date; completedOrderData.Add(model); } var normalData = (from x in MonthDate.OrderBy(x => x) join y in orderData on x equals y.date into Temp from t in Temp.DefaultIfEmpty() select t == null ? 0 : t.intData).ToArray(); var exceptData = (from x in MonthDate.OrderBy(x => x) join y in exceptedOrderData on x equals y.date into Temp from t in Temp.DefaultIfEmpty() select t == null ? 0 : t.intData).ToArray(); var copmpletedData = (from x in MonthDate.OrderBy(x => x) join y in completedOrderData on x equals y.date into Temp from t in Temp.DefaultIfEmpty() select t == null ? 0 : t.intData).ToArray(); OrderTool result = new OrderTool(); result.exceptedOrderNum = exceptData; result.produceOrderNum = normalData; result.completedOrderNum = copmpletedData; return(result); }
public float[] searchLastMonthProfit() { DateTime startDate = DateTime.Now.AddDays(-30).Date; DateTime endDate = DateTime.Now.Date; List <DateTime> dateList = BaseDataHelper.getLastMonthDate(DateTime.Now); LayerDbContext context = new LayerDbContext(); var profitData = context.profitRecord.Where(x => x.createdDate >= startDate && x.createdDate < endDate).GroupBy(x => x.createdDate.Day).Select(x => new { createdDate = x.Max(item => item.createdDate), profit = x.Sum(item => item.profit) }).ToList(); List <LineDataTool> profitData1 = new List <LineDataTool>(); LineDataTool model = null; foreach (var item in profitData) { model = new LineDataTool(); model.date = item.createdDate.Date; model.floatData = item.profit; profitData1.Add(model); } var result = (from x in dateList.OrderBy(x => x) join y in profitData1 on x equals y.date into Temp from temp in Temp.DefaultIfEmpty() select(temp == null ? 0 : temp.floatData)).ToArray(); return(result); }
public IEnumerable <IResult> PasteCode() { bool containsText; bool containsUnicodeText = false; if (MyClipboard.ContainsText(TextDataFormat.Text, out containsText) != MyClipboard.Result.Success || MyClipboard.ContainsText(TextDataFormat.UnicodeText, out containsUnicodeText) != MyClipboard.Result.Success) { yield return(new MyMessageBox("Clipboard failure.", "Error") .WithIcon(MessageBoxImage.Error)); } if (containsText == false && containsUnicodeText == false) { yield break; } var errors = 0; var viewModels = new List <IBaseSlotViewModel>(); yield return(new DelegateResult( () => { string codes; if (MyClipboard.GetText(out codes) != MyClipboard.Result.Success) { MessageBox.Show("Clipboard failure.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } // strip whitespace codes = Regex.Replace(codes, @"\s+", ""); foreach (var match in _CodeSignature.Matches(codes).Cast <Match>() .Where(m => m.Success == true)) { var code = match.Groups["data"].Value; IPackableSlot packable; try { var data = Convert.FromBase64String(code); packable = BaseDataHelper.Decode(data, Platform.PC); } catch (Exception) { errors++; continue; } // TODO: check other item unique IDs to prevent rare collisions packable.UniqueId = new Random().Next(int.MinValue, int.MaxValue); if (packable is BaseWeapon) { var weapon = (BaseWeapon)packable; var viewModel = new BaseWeaponViewModel(weapon); viewModels.Add(viewModel); } else if (packable is BaseItem) { var item = (BaseItem)packable; var viewModel = new BaseItemViewModel(item); viewModels.Add(viewModel); } } })); if (viewModels.Count > 0) { viewModels.ForEach(vm => this.Slots.Add(vm)); this.SelectedSlot = viewModels.First(); } if (errors > 0) { yield return (new MyMessageBox("Failed to load " + errors.ToString(CultureInfo.InvariantCulture) + " codes.", "Warning") .WithIcon(MessageBoxImage.Warning)); } else if (viewModels.Count == 0) { yield return (new MyMessageBox("Did not find any codes in clipboard.", "Warning") .WithIcon(MessageBoxImage.Warning)); } }