private void UpdateField(Object Message) { UpdateFields uf = (UpdateFields)Message; List <Element> row = Global.CloudStorage.GetRowToDatabaseServer( Global.CloudStorage.GetServerIdByCellId(uf.cellId[0]), new GetRowMessageWriter(uf.cellId)).row; List <Object> values = FieldType.getValues(row, uf.typeList); int index1 = this.columnNames.IndexOf(uf.fildNames[0]); int index2 = this.columnNames.IndexOf(uf.fildNames[1]); int serverID; if (uf.con.getResult(values)) { Element ele1 = new Element { }; using (var req = new GetElementMessageWriter(uf.cellId[index1])) { serverID = Global.CloudStorage.GetServerIdByCellId(uf.cellId[index1]); using (var responce = Global.CloudStorage.GetElementToDatabaseServer(serverID, req)) { ele1 = responce.ele; ele1.intField = uf.Value1; } } Element ele2 = new Element { }; using (var req = new GetElementMessageWriter(uf.cellId[index2])) { serverID = Global.CloudStorage.GetServerIdByCellId(uf.cellId[index2]); using (var responce = Global.CloudStorage.GetElementToDatabaseServer(serverID, req)) { ele2 = responce.ele; ele2.doubleField = uf.Value2; } } ElementCell eleCell1 = FieldType.getElementCell(ele1); Global.CloudStorage.SaveElementCell(uf.cellId[index1], eleCell1); ElementCell eleCell2 = FieldType.getElementCell(ele2); Global.CloudStorage.SaveElementCell(uf.cellId[index2], eleCell1); } }
private void UpdateFunction(Object Message) { UpdateMessage um = (UpdateMessage)Message; List <Element> row = Global.CloudStorage.GetRowToDatabaseServer( Global.CloudStorage.GetServerIdByCellId(um.cellId[0]), new GetRowMessageWriter(um.cellId)).row; List <Object> values = FieldType.getValues(row, um.typeList); int index = this.columnNames.IndexOf(um.fieldname); int serverID; if (um.con.getResult(values)) { Element ele = new Element { }; using (var req = new GetElementMessageWriter(um.cellId[index])) { serverID = Global.CloudStorage.GetServerIdByCellId(um.cellId[index]); using (var responce = Global.CloudStorage.GetElementToDatabaseServer(serverID, req)) { ele = responce.ele; } } if (um.flag == 1) { switch (um.op) { case '+': ele.intField += um.operationNum; break; case '-': ele.intField -= um.operationNum; break; case '*': ele.intField *= um.operationNum; break; case '/': ele.intField /= um.operationNum; break; default: throw new Exception(String.Format("不合法的操作")); } } else { switch (um.op) { case '+': ele.intField += um.operationNum; break; case '-': ele.intField = um.operationNum - ele.intField; break; case '*': ele.intField *= um.operationNum; break; case '/': ele.intField = um.operationNum / ele.intField; break; default: throw new Exception(String.Format("不合法的操作")); } } ElementCell eleCell = FieldType.getElementCell(ele); Global.CloudStorage.SaveElementCell(um.cellId[index], eleCell); } }