public NetworkP2PMessage(NetBuffer buffer, NetConnection connection, NetChannel channel) { flags = 0; // read header from stream: var headerFlags = (HeaderFlags)buffer.ReadByte(); internCode = (InternalCode)(headerFlags & HeaderFlags.InternalCode); isTypeSafe = ((headerFlags & HeaderFlags.IsTypeSafe) == HeaderFlags.IsTypeSafe); isReliable = ((int)channel & (int)NetChannel.ReliableUnordered) == (int)NetChannel.ReliableUnordered; if (!isInternal) { name = buffer.ReadString(); } else { name = String.Empty; } stream = new BitStream(buffer, isTypeSafe); this.connection = connection; this.channel = channel; }
public NetworkP2PMessage(NetworkFlags flags, string name, InternalCode internCode) { this.flags = flags; // TODO: optimize by calculating initial buffer size by bit-flags & args // TODO: remove the default 4 bytes allocated by the default NetBuffer constructor. stream = new BitStream(isTypeSafe); var buffer = stream._buffer; connection = null; channel = (isReliable) ? NetChannel.ReliableInOrder1 : NetChannel.Unreliable; this.name = name; this.internCode = internCode; // write header to stream: HeaderFlags headerFlags = (HeaderFlags)internCode; if (isTypeSafe) { headerFlags |= HeaderFlags.IsTypeSafe; } buffer.Write((byte)headerFlags); if (internCode == InternalCode.None) { buffer.Write(name); } buffer.PositionBits = buffer.LengthBits; }
public UnconnectedMessage(NetBuffer buffer, NetworkEndPoint endpoint) { this.endpoint = endpoint; stream = new BitStream(buffer, false); internCode = (InternalCode)buffer.ReadByte(); }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((IFloorViewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } if (Name_P != null) { ((Floor_cu)ActiveDBItem).Name_P = Name_P.ToString(); } if (Name_S != null) { ((Floor_cu)ActiveDBItem).Name_S = Name_S.ToString(); } if (InternalCode != null) { ((Floor_cu)ActiveDBItem).InternalCode = InternalCode.ToString(); } if (Description != null) { ((Floor_cu)ActiveDBItem).Description = Description.ToString(); } if (Location_CU_ID != null) { ((Floor_cu)ActiveDBItem).Location_CU_ID = Convert.ToInt32(Location_CU_ID); } if (UserID != null) { ((Floor_cu)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID); } ((Floor_cu)ActiveDBItem).IsOnDuty = true; switch (((IFloorViewer)ActiveCollector.ActiveViewer).CommonTransactionType) { case DB_CommonTransactionType.DeleteExisting: ((Floor_cu)ActiveDBItem).IsOnDuty = false; break; } RelatedViewers = ((IFloorViewer)ActiveCollector.ActiveViewer).RelatedViewers; return(true); }
protected override string[] GetContent() { return(new[] { ID.ToString(), Name, InternalCode.ToString("000"), IsoCode }); }
// Outgoing message public NetworkMessage(NetworkBaseLocal network, InternalCode internCode) : this( network, NetworkFlags.TypeUnsafe | NetworkFlags.NoTimestamp | NetworkFlags.Unbuffered, Channel.RPC, String.Empty, internCode, NetworkPlayer.unassigned, NetworkPlayer.unassigned, NetworkViewID.unassigned) { }
public NetworkMasterMessage(InternalCode internCode) { this.internCode = internCode; // TODO: optimize by calculating initial buffer size by bit-flags & args // TODO: remove the default 4 bytes allocated by the default NetBuffer constructor. stream = new BitStream(false); var buffer = stream._buffer; buffer.Write((byte)internCode); buffer.PositionBits = buffer.LengthBits; }
// Constructor used when creating and destroying network objects public NetworkMessage(NetworkBaseLocal network) { flags = 0; stream = null; connection = null; channel = NetChannel.ReliableUnordered; localTimeSent = NetworkTime.localTime; monotonicServerTimeSent = network._GetMonotonicServerTime(localTimeSent); rawServerTimeSent = network._GetRawServerTime(localTimeSent); name = String.Empty; internCode = InternalCode.None; sender = network._localPlayer; target = NetworkPlayer.unassigned; exclude = NetworkPlayer.unassigned; viewID = NetworkViewID.unassigned; }
// Outgoing forwarded message (non-auth server uses this) public NetworkMessage(NetworkBaseLocal network, NetworkMessage msg, NetworkPlayer originalSender) { flags = msg.flags; connection = msg.connection; channel = msg.channel; localTimeSent = msg.localTimeSent; monotonicServerTimeSent = msg.monotonicServerTimeSent; rawServerTimeSent = msg.rawServerTimeSent; name = msg.name; internCode = msg.internCode; sender = originalSender; target = msg.target; exclude = msg.exclude; viewID = msg.viewID; stream = new BitStream(isTypeSafe); var buffer = stream._buffer; HeaderFlags headerFlags = 0; if (sender != network._localPlayer) { headerFlags |= HeaderFlags.HasOriginalSenderPlayerID; } if (isBroadcast) { headerFlags |= (hasExcludeID) ? HeaderFlags.HasBroadcastExcludePlayerID : HeaderFlags.Broadcast; } else if (hasTargetID) { headerFlags |= HeaderFlags.HasTargetPlayerID; } if (hasViewID && isInternal) { headerFlags |= HeaderFlags.HasInternalCodeAndViewID; } else if (hasViewID) { headerFlags |= (isBuffered) ? HeaderFlags.HasNameAndViewIDAndIsBuffered : HeaderFlags.HasNameAndViewID; } else { headerFlags |= HeaderFlags.HasInternalCode; } // TODO: use 24bit timestamp if needed if (hasTimestamp) { headerFlags |= HeaderFlags.Has16BitTimestamp; } if (isTypeSafe) { headerFlags |= HeaderFlags.HasTypeCodes; } buffer.Write((byte)headerFlags); if (sender != network._localPlayer) { sender._Write(buffer); } if (hasTargetID) { target._Write(buffer); } if (hasExcludeID) { exclude._Write(buffer); } if (hasViewID) { viewID._Write(buffer); } if (internCode == InternalCode.None) { buffer.Write(name); } else { buffer.Write((byte)internCode); } if (hasTimestamp) { #if PIKKO_BUILD ulong timestampInMillis = (ulong)NetTime.ToMillis(localTimestamp); #else ulong timestampInMillis = (ulong)NetTime.ToMillis(rawServerTimeSent); #endif // TODO: use 24bit timestamp if needed buffer.Write(timestampInMillis, 16); } buffer.PositionBits = buffer.LengthBits; int argpos = msg.stream._buffer.PositionBytes; stream._buffer.Write(msg.stream._buffer.Data, argpos, msg.stream._buffer.LengthBytes - argpos); }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((IInventoryItemViewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } if (Name_P != null) { ((InventoryItem_cu)ActiveDBItem).Name_P = Name_P.ToString(); } if (Name_S != null) { ((InventoryItem_cu)ActiveDBItem).Name_S = Name_S.ToString(); } if (InventoryHousing_CU_ID != null) { ((InventoryItem_cu)ActiveDBItem).InventoryHousing_CU_ID = Convert.ToInt32(InventoryHousing_CU_ID); } if (InventoryItemCategory_CU_ID != null) { ((InventoryItem_cu)ActiveDBItem).InventoryItemCategory_CU_ID = Convert.ToInt32(InventoryItemCategory_CU_ID); } if (InventoryItemBrand_CU_ID != null) { ((InventoryItem_cu)ActiveDBItem).InventoryItemBrand_CU_ID = Convert.ToInt32(InventoryItemBrand_CU_ID); } if (DefaultUnitMeasurment_CU_ID != null) { ((InventoryItem_cu)ActiveDBItem).InventoryTrackingUnitMeasurment_CU_ID = Convert.ToInt32(DefaultUnitMeasurment_CU_ID); } if (InventoryItemType_P_ID != null) { ((InventoryItem_cu)ActiveDBItem).InventoryItemType_P_ID = Convert.ToInt32(InventoryItemType_P_ID); } if (InternalCode != null) { ((InventoryItem_cu)ActiveDBItem).InternalCode = InternalCode.ToString(); } if (DefaultBarcode != null) { ((InventoryItem_cu)ActiveDBItem).DefaultBarcode = DefaultBarcode.ToString(); } if (DefaultSellingPrice != null) { ((InventoryItem_cu)ActiveDBItem).DefaultSellingPrice = Convert.ToDouble(DefaultSellingPrice); } if (DefaultCost != null) { ((InventoryItem_cu)ActiveDBItem).DefaultCost = Convert.ToDouble(DefaultCost); } if (RorderedPoint != null) { ((InventoryItem_cu)ActiveDBItem).RorderedPoint = Convert.ToDouble(RorderedPoint); } if (StockMinLevel != null) { ((InventoryItem_cu)ActiveDBItem).StockMinLevel = Convert.ToDouble(StockMinLevel); } if (AcceptOverrideMinAmount != null) { ((InventoryItem_cu)ActiveDBItem).AcceptOverrideMinAmount = Convert.ToBoolean(AcceptOverrideMinAmount); } if (CanBeSold != null) { ((InventoryItem_cu)ActiveDBItem).CanBeSold = Convert.ToBoolean(CanBeSold); } if (IsAvailable != null) { ((InventoryItem_cu)ActiveDBItem).IsAvailable = Convert.ToBoolean(IsAvailable); } if (AcceptPartingSelling != null) { ((InventoryItem_cu)ActiveDBItem).AcceptPartingSelling = Convert.ToBoolean(AcceptPartingSelling); } if (IsCountable != null) { ((InventoryItem_cu)ActiveDBItem).IsCountable = Convert.ToBoolean(IsCountable); } if (SellingStartDate != null) { ((InventoryItem_cu)ActiveDBItem).SellingStartDate = Convert.ToDateTime(SellingStartDate); } if (SellingEndDate != null) { ((InventoryItem_cu)ActiveDBItem).SellingEndDate = Convert.ToDateTime(SellingEndDate); } if (ExpirationDate != null) { ((InventoryItem_cu)ActiveDBItem).ExpirationDate = Convert.ToDateTime(ExpirationDate); } if (Description != null) { ((InventoryItem_cu)ActiveDBItem).Description = Description.ToString(); } if (Width != null) { ((InventoryItem_cu)ActiveDBItem).Width = Convert.ToDouble(Width); } if (Height != null) { ((InventoryItem_cu)ActiveDBItem).Height = Convert.ToDouble(Height); } if (Depth != null) { ((InventoryItem_cu)ActiveDBItem).Depth = Convert.ToDouble(Depth); } ((InventoryItem_cu)ActiveDBItem).IsOnDuty = true; switch (((IInventoryItemViewer)ActiveCollector.ActiveViewer).CommonTransactionType) { case DB_CommonTransactionType.DeleteExisting: ((InventoryItem_cu)ActiveDBItem).IsOnDuty = false; break; } RelatedViewers = ((IInventoryItemViewer)ActiveCollector.ActiveViewer).RelatedViewers; return(true); }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((IRawMaterial_Viewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } if (Name_P != null) { ((RawMaterials_cu)ActiveDBItem).Name_P = Name_P.ToString(); } if (Name_S != null) { ((RawMaterials_cu)ActiveDBItem).Name_S = Name_S.ToString(); } if (RawTypeID != null) { ((RawMaterials_cu)ActiveDBItem).RawTypeID = Convert.ToInt32(RawTypeID); } if (InternalCode != null) { ((RawMaterials_cu)ActiveDBItem).InternalCode = InternalCode.ToString(); } if (Width != null) { ((RawMaterials_cu)ActiveDBItem).Width = Convert.ToDouble(Width); } if (Thickness != null) { ((RawMaterials_cu)ActiveDBItem).Thickness = Convert.ToDouble(Thickness); } if (Height != null) { ((RawMaterials_cu)ActiveDBItem).Height = Convert.ToDouble(Height); } if (Weight != null) { ((RawMaterials_cu)ActiveDBItem).Weight = Convert.ToDouble(Weight); } if (ExpirationDate != null) { ((RawMaterials_cu)ActiveDBItem).ExpirationDate = Convert.ToDateTime(ExpirationDate); } if (IsStockAvailable != null) { ((RawMaterials_cu)ActiveDBItem).IsStockAvailable = Convert.ToBoolean(IsStockAvailable); } if (IsCountable != null) { ((RawMaterials_cu)ActiveDBItem).IsCountable = Convert.ToBoolean(IsCountable); } if (ColorID != null) { ((RawMaterials_cu)ActiveDBItem).Color_CU_ID = Convert.ToInt32(ColorID); } if (DividedTypeID != null) { ((RawMaterials_cu)ActiveDBItem).DividedByType_P_ID = Convert.ToInt32(DividedTypeID); } if (Description != null) { ((RawMaterials_cu)ActiveDBItem).Description = Description.ToString(); } if (UserID != null) { ((RawMaterials_cu)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID); } ((RawMaterials_cu)ActiveDBItem).IsOnDuty = true; switch (((IRawMaterial_Viewer)ActiveCollector.ActiveViewer).CommonTransactionType) { case DB_CommonTransactionType.DeleteExisting: ((RawMaterials_cu)ActiveDBItem).IsOnDuty = false; break; } RelatedViewers = ((IRawMaterial_Viewer)ActiveCollector.ActiveViewer).RelatedViewers; return(true); }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((IServiceCategoryViewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } if (NameP != null) { ((ServiceCategory_cu)ActiveDBItem).Name_P = NameP.ToString(); } if (NameS != null) { ((ServiceCategory_cu)ActiveDBItem).Name_S = NameS.ToString(); } if (InternalCode != null) { ((ServiceCategory_cu)ActiveDBItem).InternalCode = InternalCode.ToString(); } if (ServiceType != null) { ((ServiceCategory_cu)ActiveDBItem).ServiceType_P_ID = Convert.ToInt32(ServiceType); } ((ServiceCategory_cu)ActiveDBItem).IsMedical = Convert.ToBoolean(IsMedical); ((ServiceCategory_cu)ActiveDBItem).AllowAdmission = Convert.ToBoolean(AlloAdmission); if (Description != null) { ((ServiceCategory_cu)ActiveDBItem).Description = Description.ToString(); } if (UserID != null) { ((ServiceCategory_cu)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID); } ((ServiceCategory_cu)ActiveDBItem).IsOnDuty = true; switch (((IServiceCategoryViewer)ActiveCollector.ActiveViewer).CommonTransactionType) { case DB_CommonTransactionType.DeleteExisting: ((ServiceCategory_cu)ActiveDBItem).IsOnDuty = false; break; } RelatedViewers = ((IServiceCategoryViewer)ActiveCollector.ActiveViewer).RelatedViewers; return(true); }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((IInventoryItem_Area_Viewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } if (InventoryItemID != null) { ((InventoryItem_Area)ActiveDBItem).InventoryItemID = Convert.ToInt32(InventoryItemID); } if (Width != null) { ((InventoryItem_Area)ActiveDBItem).Width = Convert.ToDouble(Width); } if (Height != null) { ((InventoryItem_Area)ActiveDBItem).Height = Convert.ToDouble(Height); } if (Count != null) { ((InventoryItem_Area)ActiveDBItem).Count = Convert.ToInt32(Count); } if (InternalCode != null) { ((InventoryItem_Area)ActiveDBItem).InternalCode = InternalCode.ToString(); } if (SizeUnitMeasure_P_ID != null) { ((InventoryItem_Area)ActiveDBItem).SizeUnitMeasure_P_ID = Convert.ToInt32(SizeUnitMeasure_P_ID); } if (UserID != null) { ((InventoryItem_Area)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID); } ((InventoryItem_Area)ActiveDBItem).IsOnDuty = true; switch (((IInventoryItem_Area_Viewer)ActiveCollector.ActiveViewer).CommonTransactionType) { case DB_CommonTransactionType.DeleteExisting: ((InventoryItem_Area)ActiveDBItem).IsOnDuty = false; break; } RelatedViewers = ((IInventoryItem_Area_Viewer)ActiveCollector.ActiveViewer).RelatedViewers; return(true); }
// Outgoing message public NetworkMessage(NetworkBaseLocal network, NetworkFlags flags, Channel channel, InternalCode internCode, NetworkPlayer target) : this( network, flags, channel, String.Empty, internCode, target, NetworkPlayer.unassigned, NetworkViewID.unassigned) { }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((IDoctorViewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } if (((Person_cu)ActiveDBItem).Doctor_cu == null) { ((Person_cu)ActiveDBItem).Doctor_cu = new Doctor_cu(); } if (((Person_cu)ActiveDBItem).User_cu == null) { ((Person_cu)ActiveDBItem).User_cu = new User_cu(); } #region General Person Details if (FirstName_P != null) { ((Person_cu)ActiveDBItem).FirstName_P = FirstName_P.ToString(); } if (SecondName_P != null) { ((Person_cu)ActiveDBItem).SecondName_P = SecondName_P.ToString(); } if (ThirdName_P != null) { ((Person_cu)ActiveDBItem).ThirdName_P = ThirdName_P.ToString(); } if (FourthName_P != null) { ((Person_cu)ActiveDBItem).FourthName_P = FourthName_P.ToString(); } if (Gender != null) { ((Person_cu)ActiveDBItem).Gender = Convert.ToBoolean(Gender); } if (MaritalStatusID != null) { ((Person_cu)ActiveDBItem).MaritalStatus_P_ID = Convert.ToInt32(MaritalStatusID); } if (BirthDate != null) { ((Person_cu)ActiveDBItem).BirthDate = Convert.ToDateTime(BirthDate); } if (Phone1 != null) { ((Person_cu)ActiveDBItem).Phone1 = Phone1.ToString(); } if (Phone2 != null) { ((Person_cu)ActiveDBItem).Phone2 = Phone2.ToString(); } if (Address != null) { ((Person_cu)ActiveDBItem).Address = Address.ToString(); } if (EMail != null) { ((Person_cu)ActiveDBItem).EMail = EMail.ToString(); } if (IdentificationCardTypeID != null) { ((Person_cu)ActiveDBItem).IdentificationCardType_P_ID = Convert.ToInt32(IdentificationCardTypeID); } if (IdentificationCardNumber != null) { ((Person_cu)ActiveDBItem).IdentificationCardNumber = IdentificationCardNumber.ToString(); } if (IdentificationCardIssuingDate != null) { ((Person_cu)ActiveDBItem).IdentificationCardIssuingDate = Convert.ToDateTime(IdentificationCardIssuingDate); } if (IdentificationCardExpirationDate != null) { ((Person_cu)ActiveDBItem).IdentificationCardExpirationDate = Convert.ToDateTime(IdentificationCardExpirationDate); } if (Mobile1 != null) { ((Person_cu)ActiveDBItem).Mobile1 = Mobile1.ToString(); } if (Mobile2 != null) { ((Person_cu)ActiveDBItem).Mobile2 = Mobile2.ToString(); } ((Person_cu)ActiveDBItem).IsOnDuty = true; #endregion #region User Details if (InternalCode != null) { ((Person_cu)ActiveDBItem).User_cu.InternalCode = InternalCode.ToString(); } if (LoginName != null) { ((Person_cu)ActiveDBItem).User_cu.LoginName = LoginName.ToString(); } if (Password != null) { ((Person_cu)ActiveDBItem).User_cu.Password = Password.ToString(); } ((Person_cu)ActiveDBItem).User_cu.OragnizationID = (int)ApplicationStaticConfiguration.Organization; ((Person_cu)ActiveDBItem).User_cu.IsOnDuty = true; #endregion #region Doctor Details if (InternalCode != null) { ((Person_cu)ActiveDBItem).Doctor_cu.InternalCode = InternalCode.ToString(); } if (DoctorRankID != null) { ((Person_cu)ActiveDBItem).Doctor_cu.DoctorRank_P_ID = Convert.ToInt32(DoctorRankID); } if (DoctorSpecializationID != null) { ((Person_cu)ActiveDBItem).Doctor_cu.DoctorSpecialization_P_ID = Convert.ToInt32(DoctorSpecializationID); } if (DoctorCategoryID != null) { ((Person_cu)ActiveDBItem).Doctor_cu.DoctorCategory_CU_ID = Convert.ToInt32(DoctorCategoryID); } if (DoctorProfessionalFees != null) { ((Person_cu)ActiveDBItem).Doctor_cu.DoctorProfessionalFeesIssuingType_P_ID = Convert.ToInt32(DoctorProfessionalFees); } if (DoctorTaxTypeID != null) { ((Person_cu)ActiveDBItem).Doctor_cu.DoctorTaxType_CU_ID = Convert.ToInt32(DoctorTaxTypeID); } if (PrivateMobile != null) { ((Person_cu)ActiveDBItem).Doctor_cu.PrivateMobile = PrivateMobile.ToString(); } if (Description != null) { ((Person_cu)ActiveDBItem).Doctor_cu.Description = Description.ToString(); } ((Person_cu)ActiveDBItem).Doctor_cu.IsOnDuty = true; #endregion switch (((IDoctorViewer)ActiveCollector.ActiveViewer).CommonTransactionType) { case DB_CommonTransactionType.DeleteExisting: ((Person_cu)ActiveDBItem).IsOnDuty = false; ((Person_cu)ActiveDBItem).User_cu.IsOnDuty = false; ((Person_cu)ActiveDBItem).Doctor_cu.IsOnDuty = false; break; } RelatedViewers = ((IDoctorViewer)ActiveCollector.ActiveViewer).RelatedViewers; return(true); }
//Incoming message public NetworkMessage(NetworkBaseLocal network, NetBuffer buffer, NetConnection connection, NetChannel channel, bool wasEncrypted, double localTimeRecv) { flags = 0; if (!wasEncrypted) { flags |= NetworkFlags.Unencrypted; } flags = (((int)channel & (int)NetChannel.ReliableUnordered) == (int)NetChannel.ReliableUnordered) ? flags &= ~NetworkFlags.Unreliable : flags |= NetworkFlags.Unreliable; var headerFlags = (HeaderFlags)buffer.ReadByte(); // TODO: make sure a regular uLink server doesn't accept messages with a original sender. We should create static create Message methods instead of the constructor? if ((headerFlags & HeaderFlags.HasOriginalSenderPlayerID) == HeaderFlags.HasOriginalSenderPlayerID) { sender = new NetworkPlayer(buffer); } else { sender = NetworkBaseLocal._GetConnectionPlayerID(connection); } switch (headerFlags & HeaderFlags.DestinationType) { case HeaderFlags.ToServer: target = NetworkPlayer.server; exclude = NetworkPlayer.unassigned; break; case HeaderFlags.HasTargetPlayerID: target = new NetworkPlayer(buffer); exclude = NetworkPlayer.unassigned; break; case HeaderFlags.Broadcast: target = NetworkPlayer.unassigned; exclude = NetworkPlayer.unassigned; break; case HeaderFlags.HasBroadcastExcludePlayerID: target = NetworkPlayer.unassigned; exclude = new NetworkPlayer(buffer); break; } switch (headerFlags & HeaderFlags.ExecutionType) { case HeaderFlags.HasInternalCode: viewID = NetworkViewID.unassigned; name = String.Empty; internCode = (InternalCode)buffer.ReadByte(); flags |= NetworkFlags.Unbuffered; break; case HeaderFlags.HasNameAndViewID: viewID = new NetworkViewID(buffer); name = buffer.ReadString(); internCode = InternalCode.None; flags |= NetworkFlags.Unbuffered; break; case HeaderFlags.HasInternalCodeAndViewID: viewID = new NetworkViewID(buffer); name = String.Empty; internCode = (InternalCode)buffer.ReadByte(); if (internCode != InternalCode.Create) { flags |= NetworkFlags.Unbuffered; } break; case HeaderFlags.HasNameAndViewIDAndIsBuffered: viewID = new NetworkViewID(buffer); name = buffer.ReadString(); internCode = InternalCode.None; break; } if ((headerFlags & HeaderFlags.TimestampType) != HeaderFlags.NoTimestamp) { int numberOfBits; switch (headerFlags & HeaderFlags.TimestampType) { case HeaderFlags.Has16BitTimestamp: numberOfBits = 16; break; case HeaderFlags.Has24BitTimestamp: numberOfBits = 24; break; case HeaderFlags.Has40BitTimestamp: numberOfBits = 40; break; default: numberOfBits = 0; break; // something is wrong } ulong encodedTimestamp = buffer.ReadUInt64(numberOfBits); #if PIKKO_BUILD double serverTimeRecv = localTimeRecv; #else double serverTimeRecv = network._EnsureAndUpdateMonotonicTimestamp(localTimeRecv + network.rawServerTimeOffset); #endif double monotonicTransitTime = _GetElapsedTimeFromEncodedTimestamp(serverTimeRecv, encodedTimestamp, numberOfBits); #if !PIKKO_BUILD monotonicServerTimeSent = serverTimeRecv - monotonicTransitTime; // TODO: ugly hack: double rawServerTimeRecv = localTimeRecv + network.rawServerTimeOffset; double rawTransitTime = _GetElapsedTimeFromEncodedTimestamp(rawServerTimeRecv, encodedTimestamp, numberOfBits); rawServerTimeSent = rawServerTimeRecv - rawTransitTime; localTimeSent = localTimeRecv - rawTransitTime; #endif } if ((headerFlags & HeaderFlags.HasTypeCodes) == 0) { flags |= NetworkFlags.TypeUnsafe; } stream = new BitStream(buffer, isTypeSafe); this.connection = connection; this.channel = channel; }
private string buildInternalCode(InternalCode internalCode) { return(internalCode.Value); }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((ILocationViewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } if (Name_P != null) { ((Location_cu)ActiveDBItem).Name_P = Name_P.ToString(); } if (Name_S != null) { ((Location_cu)ActiveDBItem).Name_S = Name_S.ToString(); } if (InternalCode != null) { ((Location_cu)ActiveDBItem).InternalCode = InternalCode.ToString(); } if (Description != null) { ((Location_cu)ActiveDBItem).Description = Description.ToString(); } if (Address != null) { ((Location_cu)ActiveDBItem).Address = Address.ToString(); } if (Country_CU_ID != null) { ((Location_cu)ActiveDBItem).Country_CU_ID = Convert.ToInt32(Country_CU_ID); } if (City_CU_ID != null) { ((Location_cu)ActiveDBItem).City_CU_ID = Convert.ToInt32(City_CU_ID); } if (Region_CU_ID != null) { ((Location_cu)ActiveDBItem).Region_CU_ID = Convert.ToInt32(Region_CU_ID); } if (Territory_CU_ID != null) { ((Location_cu)ActiveDBItem).Territory_CU_ID = Convert.ToInt32(Territory_CU_ID); } ((Location_cu)ActiveDBItem).Organization_P_ID = Convert.ToInt32(ApplicationStaticConfiguration.Organization); if (UserID != null) { ((Location_cu)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID); } ((Location_cu)ActiveDBItem).IsOnDuty = true; switch (((ILocationViewer)ActiveCollector.ActiveViewer).CommonTransactionType) { case DB_CommonTransactionType.DeleteExisting: ((Location_cu)ActiveDBItem).IsOnDuty = false; break; } RelatedViewers = ((ILocationViewer)ActiveCollector.ActiveViewer).RelatedViewers; return(true); }
public BadRequestException(InternalCode code, string message) : base(message) { Code = code; ExceptionMessage = message; }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((IServiceViewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } if (Name_P != null) { ((Service_cu)ActiveDBItem).Name_P = Name_P.ToString(); } if (Name_S != null) { ((Service_cu)ActiveDBItem).Name_S = Name_S.ToString(); } if (ServiceCategory_CU_ID != null) { ((Service_cu)ActiveDBItem).ServiceCategory_CU_ID = Convert.ToInt32(ServiceCategory_CU_ID); } if (ServiceType_P_ID != null) { ((Service_cu)ActiveDBItem).ServiceType_P_ID = Convert.ToInt32(ServiceType_P_ID); } if (ParentService_CU_ID != null) { ((Service_cu)ActiveDBItem).ParentService_CU_ID = Convert.ToInt32(ParentService_CU_ID); } if (InternalCode != null) { ((Service_cu)ActiveDBItem).InternalCode = InternalCode.ToString(); } if (DefaultPriceFrom != null) { ((Service_cu)ActiveDBItem).DefaultPrice = Convert.ToDouble(DefaultPriceFrom); } ((Service_cu)ActiveDBItem).EnforceCategorization = Convert.ToBoolean(EnforceCategorization); ((Service_cu)ActiveDBItem).IsDailyCharged = Convert.ToBoolean(IsDailyCharged); ((Service_cu)ActiveDBItem).AllowAddmission = Convert.ToBoolean(AllowAddmission); if (Description != null) { ((Service_cu)ActiveDBItem).Description = Description.ToString(); } if (UserID != null) { ((Service_cu)ActiveDBItem).InsertedBy = Convert.ToInt32(UserID); } ((Service_cu)ActiveDBItem).IsOnDuty = true; switch (((IServiceViewer)ActiveCollector.ActiveViewer).CommonTransactionType) { case DB_CommonTransactionType.DeleteExisting: ((Service_cu)ActiveDBItem).IsOnDuty = false; break; } RelatedViewers = ((IServiceViewer)ActiveCollector.ActiveViewer).RelatedViewers; return(true); }
public override bool Collect(AbstractDataCollector <TEntity> collector) { if (collector == null) { return(false); } ActiveCollector = collector; ID = ((ISupplierViewer)ActiveCollector.ActiveViewer).ID; if (ActiveDBItem == null) { return(false); } if (FirstName != null) { ((Person_cu)ActiveDBItem).FirstName_P = FirstName.ToString(); } if (SecondName != null) { ((Person_cu)ActiveDBItem).SecondName_P = SecondName.ToString(); } if (ThirdName != null) { ((Person_cu)ActiveDBItem).ThirdName_P = ThirdName.ToString(); } if (FourthName != null) { ((Person_cu)ActiveDBItem).FourthName_P = FourthName.ToString(); } if (MaritalStatus != null) { ((Person_cu)ActiveDBItem).MaritalStatus_P_ID = Convert.ToInt32(MaritalStatus); } if (Gender != null) { ((Person_cu)ActiveDBItem).Gender = Convert.ToBoolean(Gender); } if (BirthDate != null) { ((Person_cu)ActiveDBItem).BirthDate = Convert.ToDateTime(BirthDate); } if (Mobile1 != null) { ((Person_cu)ActiveDBItem).Mobile1 = Mobile1.ToString(); } if (Mobile2 != null) { ((Person_cu)ActiveDBItem).Mobile2 = Mobile2.ToString(); } if (Phone1 != null) { ((Person_cu)ActiveDBItem).Phone1 = Phone1.ToString(); } if (Phone2 != null) { ((Person_cu)ActiveDBItem).Phone2 = Phone2.ToString(); } if (Address != null) { ((Person_cu)ActiveDBItem).Address = Address.ToString(); } if (Email != null) { ((Person_cu)ActiveDBItem).EMail = Email.ToString(); } if (IdentificationCardType != null) { ((Person_cu)ActiveDBItem).IdentificationCardType_P_ID = Convert.ToInt32(IdentificationCardType); } if (IdentificationCardNumber != null) { ((Person_cu)ActiveDBItem).IdentificationCardNumber = IdentificationCardNumber.ToString(); } if (IdentificationCardIssueDate != null) { ((Person_cu)ActiveDBItem).IdentificationCardIssuingDate = Convert.ToDateTime(IdentificationCardIssueDate); } if (IdentificationCardExpirationDate != null) { ((Person_cu)ActiveDBItem).IdentificationCardExpirationDate = Convert.ToDateTime(IdentificationCardExpirationDate); } if (((Person_cu)ActiveDBItem).Supplier_cu == null) { ((Person_cu)ActiveDBItem).Supplier_cu = new Supplier_cu(); } if (InternalCode != null) { ((Person_cu)ActiveDBItem).Supplier_cu.InternalCode = InternalCode.ToString(); } if (((Person_cu)ActiveDBItem).Supplier_cu != null) { ((Person_cu)ActiveDBItem).Supplier_cu.IsOnDuty = true; } ((Person_cu)ActiveDBItem).IsOnDuty = true; switch (((ISupplierViewer)ActiveCollector.ActiveViewer).CommonTransactionType) { case DB_CommonTransactionType.DeleteExisting: ((Person_cu)ActiveDBItem).IsOnDuty = false; if (((Person_cu)ActiveDBItem).Supplier_cu != null) { ((Person_cu)ActiveDBItem).Supplier_cu.IsOnDuty = false; } break; } RelatedViewers = ((ISupplierViewer)ActiveCollector.ActiveViewer).RelatedViewers; return(true); }
// Outgoing message public NetworkMessage(NetworkBaseLocal network, NetworkFlags flags, Channel channel, string name, InternalCode internCode, NetworkPlayer target, NetworkPlayer exclusion, NetworkViewID viewID) { if (target != NetworkPlayer.unassigned) { flags |= NetworkFlags.Unbuffered; } this.flags = flags; this.channel = ((flags & NetworkFlags.Unreliable) == 0) ? (NetChannel)channel : NetChannel.Unreliable; if (isBuffered) { if (!(isReliable)) { Utility.Exception("Message can not be buffered and unreliable"); } } // TODO: optimize by calculating initial buffer size by bit-flags & args // TODO: optimize by stripping unnecessary data if we have a direct connection i.e. is server // TODO: remove the default 4 bytes allocated by the default NetBuffer constructor. #if !NO_POOLING if (isReliable) { stream = new BitStream(true, isTypeSafe); //The Bitstream for reliable RPCs (including buffered RPCs) should not be written to pooled Bitreams, that would be dangerous during resend. } else { stream = (isTypeSafe) ? _bitStreamPoolOutgoingTypeSafe.GetNext() : _bitStreamPoolOutgoing.GetNext(); } #else stream = new BitStream(true, isTypeSafe); #endif var buffer = stream._buffer; connection = null; this.name = name; this.internCode = internCode; sender = network._localPlayer; this.target = target; exclude = exclusion; this.viewID = viewID; // write header to stream: HeaderFlags headerFlags = 0; // TODO: optimize away exclude and target PlayerID when sent from a regular uLink Server by faking it into a simple broadcast message if (isBroadcast) { headerFlags |= (hasExcludeID)? HeaderFlags.HasBroadcastExcludePlayerID : HeaderFlags.Broadcast; } else if (hasTargetID) { headerFlags |= HeaderFlags.HasTargetPlayerID; } if (hasViewID && isInternal) { headerFlags |= HeaderFlags.HasInternalCodeAndViewID; } else if (hasViewID) { headerFlags |= (isBuffered) ? HeaderFlags.HasNameAndViewIDAndIsBuffered : HeaderFlags.HasNameAndViewID; } else { headerFlags |= HeaderFlags.HasInternalCode; } if (hasTimestamp) { headerFlags |= (isBuffered) ? HeaderFlags.Has40BitTimestamp : HeaderFlags.Has16BitTimestamp; } if (isTypeSafe) { headerFlags |= HeaderFlags.HasTypeCodes; } buffer.Write((byte)headerFlags); if (hasTargetID) { this.target._Write(buffer); } if (hasExcludeID) { exclude._Write(buffer); } if (hasViewID) { this.viewID._Write(buffer); } if (isInternal) { buffer.Write((byte)internCode); } else { buffer.Write(name); } if (hasTimestamp) { localTimeSent = NetworkTime.localTime; rawServerTimeSent = localTimeSent + network.rawServerTimeOffset; #if PIKKO_BUILD ulong timestampInMillis = (ulong)NetTime.ToMillis(localTimestamp); #else rawServerTimeSent = localTimeSent + network.rawServerTimeOffset; ulong timestampInMillis = (ulong)NetTime.ToMillis(rawServerTimeSent); #endif buffer.Write(timestampInMillis, (isBuffered) ? 40 : 16); } buffer.PositionBits = buffer.LengthBits; }
// Outgoing message public NetworkMessage(NetworkBaseLocal network, NetworkFlags flags, Channel channel, InternalCode internCode, RPCMode mode, NetworkPlayer exclusion) : this( network, ((mode & RPCMode.Buffered) != 0) ? flags : (flags | NetworkFlags.Unbuffered), channel, String.Empty, internCode, (mode == RPCMode.Server) ? NetworkPlayer.server : NetworkPlayer.unassigned, exclusion, NetworkViewID.unassigned) { }
public NetworkMasterMessage(NetBuffer buffer) { stream = new BitStream(buffer, false); internCode = (InternalCode)buffer.ReadByte(); }