/// <summary> /// 执行更新操作 /// </summary> /// <param name="doc"></param> /// <returns></returns> public InvokeResult Update(BsonDocument doc) { var storageData = new StorageData() { Name = tableName, Document = doc, Type = StorageType.Update, Query = Query.EQ(keyFieldName, doc.Text(keyFieldName)) }; //调用基类的_commonDbChangeHelper进行保存 // var result = CommonDbChangeHelper.CommonSubmitChange(storageData); if (CommonDbChangeHelper.NeedQueue) { var result = NetQHelper.Broadcast <string>(doc.ToJson()); return(new InvokeResult() { Status = Status.Successful }); } else { var result = CommonDbChangeHelper.CommonSubmitChange(storageData); return(new InvokeResult() { Status = Status.Successful }); } }
void Awake() { //PlayerPrefs.DeleteAll (); if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(transform.gameObject); if (PlayerPrefs.HasKey("CatID") || PlayerPrefs.HasKey("BirdieID")) { //We had a previous session catID = PlayerPrefs.GetInt("CatID"); birdieID = PlayerPrefs.GetInt("BirdieID"); highestScore = PlayerPrefs.GetInt("High"); currency = PlayerPrefs.GetInt("Currency"); availabilityC = PlayerPrefs.GetInt("AvailabilityCat"); availabilityB = PlayerPrefs.GetInt("AvailabilityBirdie"); //PlayerPrefs.Save (); } else { Save(); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { ProcessCheckStatus.data = StorageData.FromXmlFile <Data>(System.Windows.Forms.Application.StartupPath + "\\LocalData.xml"); command = ProcessCheckStatus.data.command; od_command = command; Settings.Content = "伺服器批次檔: " + ProcessCheckStatus.data.ServerFileLocationName + "\n" + "伺服器位置: " + ProcessCheckStatus.data.ServerFileLocation + "\n" + "伺服器資料夾: " + ProcessCheckStatus.data.ServerFileLocationFloder + "\n" + "使用者停滯自動掌管: " + ProcessCheckStatus.data.UserFroceTiming + "\n" + "Server Crash Report - Server: " + ProcessCheckStatus.data.SQLServerLoaction + "\n" + "RestartTimes: " + ProcessCheckStatus.data.ServerRestartTimes; ValueSearch.Text = ProcessCheckStatus.data.Memory; odMemory = ProcessCheckStatus.data.Memory; UserFroceCheck.IsChecked = ProcessCheckStatus.data.UserFroceTiming; SQLServerLocation.Text = ProcessCheckStatus.data.SQLServerLoaction; ServerRestartTimes.Text = ProcessCheckStatus.data.ServerRestartTimes.ToString(); ServerFileName = ProcessCheckStatus.data.ServerFileLocationName; ServerFilePath = ProcessCheckStatus.data.ServerFileLocation; parameter.Text = ProcessCheckStatus.data.parameter; ServerFileFloder = ProcessCheckStatus.data.ServerFileLocationFloder; if (File.Exists(ProcessCheckStatus.data.ServerFileLocationName)) { parameter.Text = StorageBatch.Batch.LoadBatch(); } foreach (var item in od_command) { CommandEditList.Items.Add(item); } }
public ActionResult SaveResultMatRelInfo() { InvokeResult result = new InvokeResult(); PageJson json = new PageJson(); int retId = PageReq.GetFormInt("retId"); string matIds = PageReq.GetForm("matIds"); //材料Id列表 List <StorageData> allDataList = new List <StorageData>(); List <string> matIdList = matIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList(); foreach (var matId in matIdList) { BsonDocument tempBson = new BsonDocument(); tempBson.Add("retId", retId.ToString()); tempBson.Add("matId", matId); StorageData tempData = new StorageData(); tempData.Document = tempBson; tempData.Name = "StandardResult_ResultMatRelation"; tempData.Type = StorageType.Insert; allDataList.Add(tempData); } result = dataOp.BatchSaveStorageData(allDataList); json = TypeConvert.InvokeResultToPageJson(result); return(Json(json)); }
private void Awake() { Storage3D.s_Instance = this; for (int i = 0; i < 2; i++) { StorageData storageData = new StorageData(); storageData.m_Type = (Storage3D.StorageType)i; storageData.m_Grid = new PocketGrid(); storageData.m_Model = base.transform.Find(storageData.m_Type.ToString()).gameObject; storageData.m_Plane = storageData.m_Model.transform.GetChild(0).GetComponent <Collider>(); storageData.m_Grid.m_Grid = storageData.m_Plane.gameObject; Storage3D.StorageType type = storageData.m_Type; if (type != Storage3D.StorageType.Box) { if (type == Storage3D.StorageType.Bag) { storageData.m_Grid.m_GridSize = new Vector2(5f, 7.5f); } } else { storageData.m_Grid.m_GridSize = new Vector2(10f, 15f); } storageData.m_Grid.Initialize(this.m_GridCellPrefab, BackpackPocket.Storage); this.m_Datas.Add(storageData); } base.gameObject.SetActive(false); }
public override UncollectableCompilationMode.ConstantInfo GetContext() { lock (StorageData.Contexts) { int index = StorageData.ContextCount++; int arrIndex = index - StorageData.ContextTypes * StorageData.StaticFields; Type storageType = StorageData.ContextStorageType(index); MSAst.Expression expr; FieldInfo fieldInfo; if (arrIndex < 0) { fieldInfo = storageType.GetField(string.Format("Context{0:000}", index % StorageData.StaticFields)); expr = Ast.Field(null, fieldInfo); } else { fieldInfo = typeof(StorageData).GetField(nameof(StorageData.Contexts)); expr = Ast.ArrayIndex( Ast.Field(null, fieldInfo), Ast.Constant(arrIndex, typeof(int)) ); } return(new ConstantInfo(new CodeContextExpression(expr), fieldInfo, index)); } }
/// <summary> /// 新增存储设备信息 /// </summary> public void InsertStorage() { StorageData storageDataNew = new StorageData(); storageDataNew.存储ID = SqlHelper.GetCmpUID(); storageDataNew.存储名称 = txtStorageName.Text; storageDataNew.存储信息.设备类型 = cbxType.Text; storageDataNew.存储信息.IP地址 = txtIp.Text; storageDataNew.存储信息.端口 = txtPort.Text; storageDataNew.存储信息.目录 = txtCatalogue.Text; storageDataNew.存储信息.用户名 = txtUserName.Text; storageDataNew.存储信息.密码 = txtPassword.Text; storageDataNew.存储信息.创建时间 = DateTime.Now; storageDataNew.存储信息.是否停用 = chkStopUse.Checked; storageDataNew.存储信息.CopyBasePro(storageDataNew); //更新数据库 _storageModel.InsertStorage(storageDataNew); //更新表格 DataTable dtBind = dgvStorage.DataSource as DataTable; DataRow drNew = dtBind.NewRow(); drNew["存储ID"] = storageDataNew.存储ID; drNew["存储名称"] = storageDataNew.存储名称; //新增显示在列表的列 drNew["IP地址"] = storageDataNew.存储信息.IP地址; drNew["端口"] = storageDataNew.存储信息.端口; drNew["分类目录"] = storageDataNew.存储信息.目录; drNew["存储信息"] = storageDataNew.存储信息.ToString(); dtBind.Rows.Add(drNew); }
//遊戲資料更新 USed! public bool Game_Update(UserModel user, StorageData Storage_data, int WeekNum) { var StorageItgem = StorageList.Where(p => p.RoomId == user.RoomID).FirstOrDefault(); if (StorageItgem != null) { switch (Storage_data.Role) { case "Manufacturer": StorageItgem.Manufacturer = Storage_data; StorageItgem.Manufacturer.IsUpdate = true; break; case "Distribution": StorageItgem.Distribution = Storage_data; StorageItgem.Distribution.IsUpdate = true; break; case "Wholesale": StorageItgem.Wholesale = Storage_data; StorageItgem.Wholesale.IsUpdate = true; break; case "Retailer": StorageItgem.Retailer = Storage_data; StorageItgem.Retailer.IsUpdate = true; break; } } else { return(false); } //等待所有人資料更新 if (StorageItgem.Manufacturer.IsUpdate && StorageItgem.Distribution.IsUpdate && StorageItgem.Wholesale.IsUpdate && StorageItgem.Retailer.IsUpdate ) { //改回待更新狀態 StorageItgem.Manufacturer.IsUpdate = false; StorageItgem.Distribution.IsUpdate = false; StorageItgem.Wholesale.IsUpdate = false; StorageItgem.Retailer.IsUpdate = false; //修改 Retailer 的資料 RetailerItemHandle(user.RoomID, WeekNum); //更新所有人資料 //Clients.All.UpdateClienData(StorageItgem); Clients.Group(user.RoomID).UpdateClienData(StorageItgem); //結算 累計盈餘與累計罰金 GameSettlement SettlementData = GetSettlement(user.RoomID); //Clients.All.UpdateClienSettlement(SettlementData); Clients.Group(user.RoomID).UpdateClienSettlement(SettlementData); } return(true); }
/// <summary> /// 初始化数据库中品牌表 /// </summary> public void InitTable(string tableName) { string[] brands = new string[] { "A品牌", "B品牌", "C品牌", "D品牌", "E品牌", "F品牌" }; string[] attValueTypes = new string[] { "不详", "双门", "单门", "净水", "直饮水", "普通", "自动", "妇洗", "按摩", "分体", "大中央", "VRV独立新风", "空调自带新风", "原装进口", "合资", "国产", "观光梯", "客梯", "普通", "IC卡", "指纹识别" }; List <StorageData> storageDatas = new List <StorageData>(); string[] dataArr = null; string columnName = ""; if (tableName == "Device_brand") { dataArr = brands; columnName = "name"; } else if (tableName == "Device_attrType") { dataArr = attValueTypes; columnName = "value"; } foreach (string data in dataArr) { StorageData storageData = new StorageData(); BsonDocument brand = new BsonDocument().Add(columnName, data); storageData.Name = tableName; storageData.Type = StorageType.Insert; storageData.Document = brand; storageDatas.Add(storageData); } dataOp.BatchSaveStorageData(storageDatas); }
public bool SimulateLogin() { if (this.Settings.LandFangIUserId == 0) { BsonDocument bsonDoc = this.dataop.FindOneByQuery(this.DataTableNameAccount, Query.EQ("userName", "savegod523")); if (bsonDoc != null) { this.Settings.LandFangIUserId = bsonDoc.Int("LandFangIUserId"); } if (this.Settings.LandFangIUserId == 0) { this.Settings.LandFangIUserId = 0xa68e; } } this.Settings.LandFangIUserId = new Random().Next(0xd05, 0x2310e); this.Settings.MaxAccountCrawlerCount = new Random().Next(50, 200); StorageData target = new StorageData { Name = this.DataTableNameAccount, Document = new BsonDocument().Add("LandFangIUserId", this.Settings.LandFangIUserId.ToString()), Query = Query.EQ("userName", "savegod523"), Type = StorageType.Update }; DBChangeQueue.Instance.EnQueue(target); this.StartDBChangeProcess(); return(true); }
/// <summary> /// 保存任务 /// </summary> /// <returns></returns> public ActionResult SaveStageTask() { InvokeResult result = new InvokeResult(); var tasks = PageReq.GetString("tasks"); var customerCode = PageReq.GetString("customerCode"); var taskList = tasks.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList(); result = dataOp.Delete("CustomerStageTask", Query.EQ("customerCode", customerCode)); var storList = new List <StorageData>(); foreach (var task in taskList) { var taskArr = task.Split(new string[] { "|#|" }, StringSplitOptions.RemoveEmptyEntries); if (taskArr.Count() == 2) { StorageData stor = new StorageData(); stor.Name = "CustomerStageTask"; stor.Type = StorageType.Insert; stor.Document = new BsonDocument().Add("name", taskArr[0]).Add("nodeKey", taskArr[1]).Add("customerCode", customerCode); storList.Add(stor); } } if (storList.Count > 0) { result = dataOp.BatchSaveStorageData(storList); } return(Json(TypeConvert.InvokeResultToPageJson(result))); }
/// <summary> /// 生成最新档案编号SJBG-201402-003 /// </summary> /// <param name="flowId"></param> /// <param name="step"></param> /// <returns></returns> public InvokeResult GenerateFileNum(string tableName, string referFieldName, string referFieldValue, string code) { var year = DateTime.Now.Year.ToString(); var day = DateTime.Now.Day.ToString(); var month = DateTime.Now.Month.ToString(); var num = GetAvaibaleNum(tableName, referFieldName, referFieldValue, code, year, month, day).ToString(); var fileNumCode = string.Format("{0}-{1}-{2}", code, DateTime.Now.ToString("yyyyMM"), num.PadLeft(3, '0')); var addBson = new BsonDocument(); var saveBsonDocumentList = new List <StorageData>(); StorageData tempData = new StorageData(); tempData.Name = "BusFlowFileNumber"; BsonDocument dataBson = new BsonDocument(); dataBson.Add("tableName", tableName); dataBson.Add("referFieldName", referFieldName); dataBson.Add("referFieldValue", referFieldValue); dataBson.Add("num", num); dataBson.Add("code", code); dataBson.Add("year", year); dataBson.Add("month", month); dataBson.Add("day", day); dataBson.Add("fileNumCode", fileNumCode); tempData.Type = StorageType.Insert; tempData.Document = dataBson; saveBsonDocumentList.Add(tempData); var result = dataOp.BatchSaveStorageData(saveBsonDocumentList); return(result); }
private void Loaded() { try { data = Interface.Oxide.DataFileSystem.ReadObject <StorageData>(Name); defaultOrders = Interface.Oxide.DataFileSystem.ReadObject <StorageData>(Name + "_default"); } catch { } if (data == null) { data = new StorageData(); } if (defaultOrders == null) { defaultOrders = new StorageData(); } if (data.VendingMachinesOrders == null) { data.VendingMachinesOrders = new Dictionary <string, Order[]>(); } if (defaultOrders.VendingMachinesOrders == null) { defaultOrders.VendingMachinesOrders = new Dictionary <string, Order[]>(); } }
public void LoadPlayerData() { BinaryFormatter bf = new BinaryFormatter(); if (File.Exists(Application.persistentDataPath + "/NRJ_gamesave.save")) { FileStream file = File.Open(Application.persistentDataPath + "/NRJ_gamesave.save", FileMode.Open); StorageData data = new StorageData(); data = (StorageData)bf.Deserialize(file); this.score = data.score; this.playerName = data.playerName; file.Close(); //DisplayLeaderboard(); Debug.Log("#############################################"); for (int i = 0; i < this.score.Length; i++) { Debug.Log(i + ") " + this.playerName[i]); } Debug.Log("#############################################"); } else { Debug.Log("----------No File-----------"); } }
public void AddOrReplace(StorageData storageData) { var blob = _blobContainer.Value; var blobRef = GetBlobRef(storageData.StorageFileId, blob); blobRef.UploadFromByteArray(storageData.Data, 0, storageData.Data.Length); }
private static bool PaintVoxels(MyVoxelBase target, Vector3 localPos, float radius, Plane plane, byte material, bool[] filter, int[] amounts) { var minCorner = new Vector3I(localPos - radius - 1); var maxCorner = new Vector3I(localPos + radius + 1); Vector3I storageSize = target.Storage.Size - 1; Vector3I.Clamp(ref minCorner, ref Vector3I.Zero, ref storageSize, out minCorner); Vector3I.Clamp(ref maxCorner, ref Vector3I.Zero, ref storageSize, out maxCorner); StorageData.Resize(minCorner, maxCorner); target.Storage.ReadRange(StorageData, MyStorageDataTypeFlags.ContentAndMaterial, 0, minCorner, maxCorner); var pos = plane.Normal * -plane.D + target.SizeInMetresHalf; var localPlane = new Plane(pos - minCorner - .5f, plane.Normal); var changed = PaintVoxelsChange(StorageData, localPos - minCorner, localPlane, radius, material, filter, amounts); if (changed) { target.Storage.WriteRange(StorageData, MyStorageDataTypeFlags.Material, minCorner, maxCorner); } return(changed); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { Global.GlobalSigh.ConnectToSQLServer(); ProcessCheckStatus.data = StorageData.FromXmlFile <Data>(System.Windows.Forms.Application.StartupPath + "\\LocalData.xml"); Global.GlobalSigh.SS.ConnectToServer(); Global.GlobalSigh._client.Connect(ProcessCheckStatus.data.SQLServerLoaction, 10127); ProcessCheckStatus.CheckUserExit.Elapsed += CheckUserExit_Elapsed; ProcessCheckStatus.CheckUserExit.Enabled = ProcessCheckStatus.data.UserFroceTiming; SideMenu.Width = 60; Global.GlobalSigh.lf = this.LoadingFrame; this.WindowState = WindowState.Normal; Global.GlobalSigh.sidem = this.SideMenu; Global.GlobalSigh.sidem.CPMenu = this.SideMenu.CPMenu; Global.GlobalSigh.sidem.CPMenu = new RelayCommand(Global.GlobalSigh.ChangeSideMenu); Global.GlobalSigh.fr = this.MainFrame; Global.GlobalSigh.mw = this; cir = new Ellipse(); cir.StrokeThickness = 1; cir.Stroke = Brushes.AliceBlue; cir.Height = 300; cir.Width = 300; Point R = new Point(_MainPage.DrawCanvas.Height / 2, _MainPage.DrawCanvas.Width / 2); Move_Control(sender, R); _MainPage.DrawCanvas.Children.Add(cir); }
public void Load() { Type fieldsType = this.GetType(); FieldInfo[] fields = fieldsType.GetFields(BindingFlags.Public | BindingFlags.Instance); ListValue = StorageData.LoadData(ID); if (ListValue == null) { ListValue = new BaseModel(); for (int i = 0; i < fields.Length; i++) { //Debug.Log(fields[i].Name + " : " + fields[i].GetValue(this) + " : " + fields[i].ReflectedType + " : " + fields[i].FieldType); AddValueToList(fields[i]); } } else { for (int i = 0; i < fields.Length; i++) { if (ListValue[fields[i].Name] != null) { fields[i].SetValue(this, ListValue[fields[i].Name].value); } } } }
private void Load() { if (File.Exists(FilePath)) { StorageData data = JsonUtility.FromJson <StorageData>(File.ReadAllText(FilePath)); if (data == null || data.variables == null) { Debug.LogWarningFormat(this, "Saved data found but not loaded. Format change?"); return; } if (data.variables.Length != m_SavedVariables.Length) { Debug.LogErrorFormat(this, "Saved data and variable counts don't match!"); return; } for (int i = 0; i < data.variables.Length; i++) { BaseGameVariable variable = m_SavedVariables[i]; VariableData variableData = data.variables[i]; variableData.Load(variable); } } }
/// <summary> /// 判断是否要更新,频繁读取的加入到队列中进行保存 /// </summary> /// <returns></returns> // ReSharper disable once InconsistentNaming public HttpResponseMessage CFGChange() { var ipAddress = IpHelper.GetIPAddress;; string customerCode = PageReq.GetString("customerCode"); BsonDocument customerInfo = dataOp.FindOneFieldsByQuery("CustomerInfo", Query.EQ("customerCode", customerCode), new List <string> () { "customerCode", "needChange" }); var updateDoc = new BsonDocument().Add("serviceActiveDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).Add("ip", ipAddress); if (customerInfo.Int("needChange") != 0) { //needChange后续优化在队列中进行更新 updateDoc.Add("needChange", "0"); } var storageData = new StorageData() { Document = updateDoc, Name = "CustomerInfo", Query = Query.EQ("customerCode", customerCode), Type = StorageType.Update }; CommonDbChange._().SubmitChangeRouter(storageData);//通过配置是否进入队列更新或者直接更新 //easyNetQHelper.VH_CommonDBChangeQueue.Broadcast<StorageDataForSerialize>(storageData.ToStorageDataForSerialize()); //BsonDocument dataBson = result.BsonInfo; //customerInfo.Set("id", dataBson.String("_id")).Remove("_id"); var resultInfo = new ResultInfo { status = "true", message = "成功", data = customerInfo.ToJson() }; return(DataEncode(resultInfo)); }
public FileStorageApi() { Storage = PlayerFiles.ReadFromFile <StorageData>(StorageName); if (Storage == null) { Storage = new StorageData(); } }
/// <summary> /// 执行更新操作 /// </summary> /// <param name="doc"></param> /// <returns></returns> public InvokeResult SubmitChange(StorageData doc) { var result = _dataOp.BatchSaveStorageData(new List <StorageData> { doc }); return(result); }
//超出庫存計算 public void Storage_Overflow(string StorageName, string RoomId) { //總庫存設定 int MaxCount = 0; switch (StorageName) { case "Retailer": MaxCount = 180; break; case "Wholesale": MaxCount = 250; break; case "Distribution": MaxCount = 400; break; // 工廠(Manufacturer)生產沒有爆倉的問題 //case "Manufacturer": // MaxCount = 500; // break; default: break; } ; var GameData = StorageList.Where(p => p.RoomId == RoomId).FirstOrDefault(); if (GameData != null) { StorageData StorageItem = (StorageData)GameData[StorageName]; //檢查單位是否超出庫存!若有直接扣最大項之庫存至符合倉庫數量 int[] ItemStock = { StorageItem.ProductItem.dumpling.Stock, StorageItem.ProductItem.salad.Stock, StorageItem.ProductItem.riceball.Stock }; int _index = 0; if (ItemStock.Sum() > MaxCount) { while (ItemStock.Sum() > MaxCount) { int maxValue = ItemStock.Max(); int maxIndex = ItemStock.ToList().IndexOf(maxValue); ItemStock[maxIndex] = ItemStock[maxIndex] - 1; } //加入遊戲紀錄內 ((RecordData)GameRecord[StorageName]).dumpling.overrun = StorageItem.ProductItem.dumpling.Stock - ItemStock[0]; ((RecordData)GameRecord[StorageName]).salad.overrun = StorageItem.ProductItem.salad.Stock - ItemStock[1]; ((RecordData)GameRecord[StorageName]).riceball.overrun = StorageItem.ProductItem.riceball.Stock - ItemStock[2]; //複寫原有庫存 StorageItem.ProductItem.dumpling.Stock = ItemStock[0]; StorageItem.ProductItem.salad.Stock = ItemStock[1]; StorageItem.ProductItem.riceball.Stock = ItemStock[2]; } } }
public void OnLoad(StorageData data) { adsInfos.Clear(); for (int i = 0; i < data.AdsData.Ads.Count; i++) { var adsInfo = data.AdsData.Ads[i]; adsInfos.Add(adsInfo); } }
/// <summary> /// 执行更新操作 /// </summary> /// <param name="doc"></param> /// <returns></returns> public InvokeResult SubmitChangeViaQueue(StorageData doc) { var success = NetQHelper.Broadcast <StorageDataForSerialize>(doc.ToStorageDataForSerialize()); return(new InvokeResult() { Status = success ? Status.Successful:Status.Failed }); }
public void AddOrReplace(StorageData storageData) { if (_localStore.ContainsKey(GetKey(storageData.StorageFileId))) { _localStore.Remove(GetKey(storageData.StorageFileId)); } _localStore.Add(GetKey(storageData.StorageFileId), storageData); }
/// <summary> /// 设置文档标签 /// </summary> /// <param name="fileIds"></param> /// <param name="tags"></param> /// <returns></returns> public ActionResult SetProjNodeFileTag(string fileIds, string tags) { string tbName = "ProjFileTags"; InvokeResult result = new InvokeResult(); List <string> fileIdList = fileIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList(); List <string> tagList = tags.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList(); List <StorageData> saveList = new List <StorageData>(); foreach (var tempFileId in fileIdList) { StorageData tempSave = new StorageData(); tempSave.Name = "FileLibrary"; tempSave.Query = Query.EQ("fileId", tempFileId); tempSave.Document = new BsonDocument().Add("tags", tags.ToString()); tempSave.Type = StorageType.Update; saveList.Add(tempSave); } foreach (var tempTag in tagList) { BsonDocument oldTag = dataOp.FindOneByQuery(tbName, Query.EQ("name", tempTag)); if (oldTag == null) { StorageData tempSave = new StorageData(); tempSave.Name = tbName; tempSave.Document = new BsonDocument().Add("name", tempTag) .Add("fileIds", fileIds); tempSave.Type = StorageType.Insert; saveList.Add(tempSave); } else { StorageData tempSave = new StorageData(); tempSave.Name = tbName; tempSave.Query = Query.EQ("tagId", oldTag.String("tagId")); tempSave.Document = new BsonDocument().Add("fileIds", oldTag.String("fileIds").TrimEnd(',') + "," + fileIds); tempSave.Type = StorageType.Update; saveList.Add(tempSave); } } result = dataOp.BatchSaveStorageData(saveList); return(Json(TypeConvert.InvokeResultToPageJson(result))); }
/// <summary> /// 更新事例实例 /// </summary> /// <returns></returns> public InvokeResult Delete(string id) { var storageData = new StorageData() { Name = tableName, Type = StorageType.Delete, Query = Query.EQ(keyFieldName, id) }; var result = CommonDbChangeHelper.CommonSubmitChange(storageData); return(result); }
public void OnSave(StorageData data) { data.ShopData.ActiveItems.Clear(); foreach (var item in activeItems) { data.ShopData.ActiveItems.Add($"{item.Key}.{item.Value}"); } data.ShopData.BoughtItems.Clear(); data.ShopData.BoughtItems.AddRange(BoughtItems); }
private void AddVendingOrders(NPCVendingMachine vending, bool def = false) { if (vending == null || vending.IsDestroyed) { Puts("Null or destroyed machine..."); return; } if (!def) { if (data.VendingMachinesOrders.ContainsKey(vending.vendingOrders.name)) { return; } } List <Order> orders = new List <Order>(); foreach (var order in vending.vendingOrders.orders) { orders.Add(new Order { _comment = $"Sell {order.sellItem.displayName.english} x {order.sellItemAmount} for {order.currencyItem.displayName.english} x {order.currencyAmount}", sellAmount = order.currencyAmount, currencyAmount = order.sellItemAmount, sellId = order.sellItem.itemid, sellAsBP = order.sellItemAsBP, currencyId = order.currencyItem.itemid, weight = 100, refillAmount = 100, refillDelay = 10.0f }); } if (def) { if (orders == null) { return; } Puts($"Trying to save default vendingOrders for {vending.vendingOrders.name}"); if (defaultOrders == null) { defaultOrders = new StorageData(); } if (defaultOrders.VendingMachinesOrders.ContainsKey(vending.vendingOrders.name)) { return; } defaultOrders.VendingMachinesOrders.Add(vending.vendingOrders.name, orders.ToArray()); } else { data.VendingMachinesOrders.Add(vending.vendingOrders.name, orders.ToArray()); } Puts($"Added Vending Machine: {vending.vendingOrders.name} to data file!"); dataChanged = true; }
public static void Write(StorageData storageData, HyvesApplication hyvesApplication) { try { hyvesApplication.Version = getVersion(); // Todo : add security and encryption IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly(); Stream writer = new IsolatedStorageFileStream(EnumHelper.GetDescription(storageData), FileMode.Create, isf); IFormatter formatter = new BinaryFormatter(); formatter.Serialize(writer, hyvesApplication); writer.Close(); } catch (Exception ex) { //ToDo: Add logging //throw new ApplicationException("Write", ex); } }
public static HyvesApplication Read(StorageData storageData) { try { // Todo : add security and encryption IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly(); Stream reader = new IsolatedStorageFileStream(EnumHelper.GetDescription(storageData), FileMode.Open, isf); IFormatter formatter = new BinaryFormatter(); HyvesApplication hyvesApplication = (HyvesApplication)formatter.Deserialize(reader); reader.Close(); if (!CheckVersion(hyvesApplication)) { throw new ApplicationException("version are not same"); } return hyvesApplication; } catch (Exception ex) { throw new ApplicationException("Read", ex); } }