private void CreateAndInsertDeltaOperation(string mrid, ResourceDescription rd) { long negGid = 0; DeltaOpType deltaOp = DeltaOpType.Insert; DMSType type = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id); if (ModelCodeHelper.ExtractEntityIdFromGlobalId(rd.Id) < 0 && !NegativeGidToMrid.ContainsKey(rd.Id)) { negGid = rd.Id; NegativeGidToMrid.Add(rd.Id, mrid); } if (MridToPositiveGidFromServer.ContainsKey(mrid)) { rd.Id = MridToPositiveGidFromServer[mrid]; deltaOp = DeltaOpType.Update; } delta.AddDeltaOperation(deltaOp, rd, true); if (!MridsFromConcreteModel.Contains(mrid)) { MridsFromConcreteModel.Add(mrid); } report.Report.Append("Operation: ").Append(deltaOp).Append(" ").Append(type) .Append(" mrid: ").Append(mrid) .Append(" ID: ").Append(string.Format("0x{0:X16}", negGid)) .Append(" after correction is GID: ").AppendLine($"0x{rd.Id:X16}"); }
public void AddDeltaOperation(DeltaOpType type, ResourceDescription rd, bool addAtEnd) { List <ResourceDescription> operations = null; switch (type) { case DeltaOpType.Insert: operations = insertOps; break; case DeltaOpType.Update: operations = updateOps; break; case DeltaOpType.Delete: operations = deleteOps; break; } if (addAtEnd) { operations.Add(rd); } else { operations.Insert(0, rd); } }
public Tuple <bool, long> ContainsDeltaOperation1(DeltaOpType type, string id) { Tuple <bool, long> search = null; switch (type) { case DeltaOpType.Insert: { foreach (ResourceDescription resDesc in this.InsertOperations) { for (int i = 0; i < resDesc.Properties.Count - 1; i++) { if (resDesc.Properties[i].Id.Equals(ModelCode.IDOBJ_MRID)) { if (resDesc.Properties[i].PropertyValue.StringValue.Equals(id)) { search = new Tuple <bool, long>(true, resDesc.Id); return(search); } } } } break; } case DeltaOpType.Update: { //foreach (ResourceDescription resDesc in this.UpdateOperations) //{ // if (resDesc.Id == id) // { // return true; // } //} break; } case DeltaOpType.Delete: { //foreach (ResourceDescription resDesc in this.DeleteOperations) //{ // if (resDesc.Id == id) // { // return true; // } //} break; } } search = new Tuple <bool, long>(false, 0); return(search); }
public ResourceDescription GetDeltaOperation(DeltaOpType type, long id) { switch (type) { case DeltaOpType.Insert: { foreach (ResourceDescription resDesc in this.InsertOperations) { if (resDesc.Id == id) { return(resDesc); } } break; } case DeltaOpType.Update: { foreach (ResourceDescription resDesc in this.UpdateOperations) { if (resDesc.Id == id) { return(resDesc); } } break; } case DeltaOpType.Delete: { foreach (ResourceDescription resDesc in this.DeleteOperations) { if (resDesc.Id == id) { return(resDesc); } } break; } } string message = string.Format("There is no {0} delta operation with GID = 0x{1:x16}.", type.ToString(), id); CommonTrace.WriteTrace(CommonTrace.TraceError, message); throw new Exception(message); }
public ResourceDescription GetDeltaOperation(DeltaOpType type, long id) { switch (type) { case DeltaOpType.Insert: { foreach (ResourceDescription resDesc in this.InsertOperations) { if (resDesc.Id == id) { return(resDesc); } } break; } case DeltaOpType.Update: { foreach (ResourceDescription resDesc in this.UpdateOperations) { if (resDesc.Id == id) { return(resDesc); } } break; } case DeltaOpType.Delete: { foreach (ResourceDescription resDesc in this.DeleteOperations) { if (resDesc.Id == id) { return(resDesc); } } break; } } string message = string.Format($"There is no {type.ToString()} delta operation with GID: 0x{id:X16}."); Logger.LogError(message); throw new Exception(message); }
public void Add(long globalId, DeltaOpType type) { if (type == DeltaOpType.Insert) { HandleInsert(globalId); } else if (type == DeltaOpType.Update) { HandleUpdate(globalId); } else { HandleDelete(globalId); } }
public bool ContainsDeltaOperation(DeltaOpType type, long id) { switch (type) { case DeltaOpType.Insert: { foreach (ResourceDescription resDesc in this.InsertOperations) { if (resDesc.Id == id) { return(true); } } break; } case DeltaOpType.Update: { foreach (ResourceDescription resDesc in this.UpdateOperations) { if (resDesc.Id == id) { return(true); } } break; } case DeltaOpType.Delete: { foreach (ResourceDescription resDesc in this.DeleteOperations) { if (resDesc.Id == id) { return(true); } } break; } } return(false); }
public bool RemoveResourceDescription(long id, DeltaOpType opType) { bool removed = false; switch (opType) { case DeltaOpType.Insert: for (int i = 0; i < this.insertOps.Count; i++) { if (this.insertOps[i].Id == id) { this.insertOps.RemoveAt(i--); removed = true; } } break; case DeltaOpType.Update: for (int i = 0; i < this.updateOps.Count; i++) { if (this.updateOps[i].Id == id) { this.updateOps.RemoveAt(i--); removed = true; } } break; case DeltaOpType.Delete: for (int i = 0; i < this.deleteOps.Count; i++) { if (this.deleteOps[i].Id == id) { this.deleteOps.RemoveAt(i--); removed = true; } } break; } return(removed); }
private void CreateAndInsertDeleteOperations() { foreach (string mrid in MridToPositiveGidFromServer.Keys) { if (!MridsFromConcreteModel.Contains(mrid)) { long serverGid = MridToPositiveGidFromServer[mrid]; ResourceDescription rd = new ResourceDescription(serverGid); DMSType type = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id); DeltaOpType deltaOp = DeltaOpType.Delete; delta.AddDeltaOperation(deltaOp, rd, true); report.Report.Append("Operation: ").Append(deltaOp).Append(" ").Append(type) .Append(" mrid: ").Append(mrid) .Append(" ID: ").AppendLine(string.Format("0x{0:X16}", serverGid)); } } }
public void AddScadaDeltaOperation(DeltaOpType type, ScadaElement element, bool addAtEnd) { List <ScadaElement> operations = null; switch (type) { case DeltaOpType.Insert: operations = insertOps; break; case DeltaOpType.Update: operations = updateOps; break; } if (addAtEnd) { operations.Add(element); } else { operations.Insert(0, element); } }