/// <summary> /// 扩展方法:获得证件类型编码 /// </summary> /// <param name="pCaller"></param> /// <returns></returns> public static string GetCode(this IDTypes pCaller) { switch (pCaller) { case IDTypes.IDCard: return("01"); case IDTypes.MilitaryID: return("02"); case IDTypes.Passport: return("03"); case IDTypes.HVPs: return("04"); case IDTypes.MTPs: return("05"); case IDTypes.PoliceOfficerID: return("06"); case IDTypes.CardSoldiers: return("07"); default: throw new NotImplementedException(); } }
public IdData(IDTypes idType, int lastGeneratedId, HashSet <int> freeIDs, HashSet <int> usedIDs, HashSet <int> reservedIDs) { IdType = idType; FreeIDs = freeIDs; UsedIDs = usedIDs; ReservedIds = reservedIDs; }
public void RequestFreeIDs(int numToRequest, IDTypes IdType) { //Go through redis, regardless of whether this instance is the master server var request = new MessageIDRequest() { IDType = IdType, RequestingServerID = SlaveID.Value, NumIDsRequested = numToRequest }; var msg = new NetworkMessageContainer(); msg.MessageType = MessageTypes.Redis_IDRequest; msg.MessageData = request; _redisServer.PublishObject(MessageTypes.Redis_IDRequest, msg); }
public LocalIDManager(INetworkIDSupplier networkIDSupplier, IDTypes IDType) { _IDType = IDType; _networkIDSupplier = networkIDSupplier; if (networkIDSupplier != null) { _networkIDSupplier.RequestFreeIDs(_minIDCount * 2, _IDType); } else { ConsoleManager.WriteLine("Warning: networkIDSupplier is null in LocalIDManager constructor. This should only be the case when running DBFiller.", ConsoleMessageType.Warning); } }
public LocalIDManager_MS(GlobalAccountIDManager globalAccountIDManager, IDTypes IDType) { _IDSupplier = globalAccountIDManager; if (_IDSupplier != null) { _IDSupplier.GetFreeIDs(_minIDCount * 2); } else { ConsoleManager.WriteLine("Warning: networkIDSupplier is null in LocalIDManager constructor. This should only be the case when running DBFiller.", ConsoleMessageType.Warning); } _IDType = IDType; }
public InsertData(string etat, IDTypes ele, IDTypesViewModel view) { InitializeComponent(); this.DataContext = viewVM = view; Etat = etat; if (etat == "AJOUT") { this.Title = "Enregistrement d'un Quartier"; } else { this.Title = "Modification d'un Quartier"; } }
private void btnValider_Click(object sender, RoutedEventArgs e) { try { IDTypesViewModel vm = this.DataContext as IDTypesViewModel; IDTypes ent = vm.SelectedData; if (Etat == "AJOUT") { try { ent.Etat = "ACTIF"; ent.idHotel = 1; viewVM.model.IDTypes.Add(ent); viewVM.model.SaveChanges(); Msg = "OK"; this.Close(); } catch (Exception ex) { Msg = "Error"; ErrorMsg = ex.Message; } } else { try { viewVM.model.SaveChanges(); Msg = "OK"; this.Close(); } catch (Exception ex) { Msg = "Error"; ErrorMsg = ex.Message; } } } catch (Exception) { } }
public GlobalIDManager(IDbIdIoService dbIdIoService, IDTypes idType) { _dbIdIoService = dbIdIoService; IDType = idType; var idData = _dbIdIoService.GetIdData(idType); if (idData == null) { throw new Exception("ID data for IdType " + idType + " not initialized in database."); } _lastIdGenerated = idData.LastIdGenerated; _reservedIDs = idData.ReservedIds; _freeIDs = new ConcurrentStack <int>(idData.FreeIDs); _generatedIDs = new ConcurrentStack <int>(idData.UsedIDs); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { //if (GlobalData.VerificationDroit("CanAddIDTypes")) //{ var result = MessageBox.Show("Voulez vous vraiment supprimer ?", "Message", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { if (dataGrid.SelectedItem != null) { try { viewM = this.Main.DataContext as IDTypesViewModel; IDTypes ent = dataGrid.SelectedItem as IDTypes; ent.Etat = "SUPPRIMER"; viewM.model.SaveChanges(); viewM.Refresh(); MessageBox.Show("Opération effectuée avec succès", "IDTypes", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "IDTypes", MessageBoxButton.OK, MessageBoxImage.Warning); viewM.Refresh(); } } else { MessageBox.Show("Aucune ligne selectionnée dans la liste", "IDTypes", MessageBoxButton.OK, MessageBoxImage.Warning); } } //} }
public IDbIdData GetIdData(IDTypes idType) { return(_idDataC.FindSync(Builders <IDbIdData> .Filter.Eq("_id", idType)).FirstOrDefault()); }
public async Task <IDbIdData> GetIdDataAsync(IDTypes idType) { return(await(await _idDataC.FindAsync(Builders <IDbIdData> .Filter.Eq(c => c.IdType, idType))).FirstOrDefaultAsync()); }