public void InsertThenUpdate10KStates() { InstrumentationContext.Reset(); const int count = 10000; var grainStateMap = CreateGrainStateMap(); var grains = new List<Tuple<GrainIdentity, IDictionary<string, object>>>(); for (int i = 0; i < count; ++i) { var state = CreateState(i); grains.Add(new Tuple<GrainIdentity, IDictionary<string, object>>(RandomIdentity(), state)); } using (var dataManager = new SqlDataManager(logger, grainStateMap, ConnectionString, ShardCredentials, ShardMapDefault)) { var stopwatch = Stopwatch.StartNew(); var tasks = grains.Select(grain => dataManager.UpsertStateAsync(grain.Item1, grain.Item2)).ToArray(); Task.WaitAll(tasks); stopwatch.Stop(); Console.WriteLine(" Insert elapsed: {0}", stopwatch.Elapsed); stopwatch = Stopwatch.StartNew(); tasks = grains.Select(grain => dataManager.UpsertStateAsync(grain.Item1, grain.Item2)).ToArray(); Task.WaitAll(tasks); stopwatch.Stop(); Console.WriteLine(" Update elapsed: {0}", stopwatch.Elapsed); } }
/// <summary> /// Check to see if there are any related Sentences, and load them if requested /// </summary> public static void CheckExpandSentences(SqlDataManager sdm, IEnumerable <Telegraph> telegraphs, string expandString) { var telegraphsWhere = CreateTelegraphWhere(telegraphs); expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("sentences", StringComparison.OrdinalIgnoreCase) >= 0) { var childSentences = sdm.GetAllSentences <Sentence>(telegraphsWhere); telegraphs.ToList() .ForEach(feTelegraph => feTelegraph.LoadSentences(childSentences)); } }
/// <summary> /// Check to see if there are any related Telegraphs, and load them if requested /// </summary> public static void CheckExpandTelegraphs(SqlDataManager sdm, IEnumerable <TelegraphOperator> telegraphOperators, string expandString) { var telegraphOperatorsWhere = CreateTelegraphOperatorWhere(telegraphOperators); expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("telegraphs", StringComparison.OrdinalIgnoreCase) >= 0) { var childTelegraphs = sdm.GetAllTelegraphs <Telegraph>(telegraphOperatorsWhere); telegraphOperators.ToList() .ForEach(feTelegraphOperator => feTelegraphOperator.LoadTelegraphs(childTelegraphs)); } }
/// <summary> /// Check to see if there are any related Characters, and load them if requested /// </summary> public static void CheckExpandCharacters(SqlDataManager sdm, IEnumerable <Alphabet> alphabets, string expandString) { var alphabetsWhere = CreateAlphabetWhere(alphabets); expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("characters", StringComparison.OrdinalIgnoreCase) >= 0) { var childCharacters = sdm.GetAllCharacters <Character>(alphabetsWhere); alphabets.ToList() .ForEach(feAlphabet => feAlphabet.LoadCharacters(childCharacters)); } }
/// <summary> /// Check to see if there are any related Words, and load them if requested /// </summary> public static void CheckExpandWords(SqlDataManager sdm, IEnumerable <Sentence> sentences, string expandString) { var sentencesWhere = CreateSentenceWhere(sentences); expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("words", StringComparison.OrdinalIgnoreCase) >= 0) { var childWords = sdm.GetAllWords <Word>(sentencesWhere); sentences.ToList() .ForEach(feSentence => feSentence.LoadWords(childWords)); } }
/// <summary> /// Check to see if there are any related Persons, and load them if requested /// </summary> public static void CheckExpandPersons(SqlDataManager sdm, IEnumerable <Company> companies, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("persons", StringComparison.OrdinalIgnoreCase) >= 0) { var companiesWhere = CreateCompanyWhere(companies, "Company"); var childPersons = sdm.GetAllPersons <Person>(companiesWhere) .OrderBy(orderBy => orderBy.Name) ; companies.ToList() .ForEach(feCompany => feCompany.LoadPersons(childPersons)); } }
/// <summary> /// Check to see if there are any related AgencyContacts, and load them if requested /// </summary> public static void CheckExpandAgencyContacts(SqlDataManager sdm, IEnumerable <Agency> agencies, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("agencyContacts", StringComparison.OrdinalIgnoreCase) >= 0) { var agenciesWhere = CreateAgencyWhere(agencies, "Agency"); var childAgencyContacts = sdm.GetAllAgencyContacts <AgencyContact>(agenciesWhere) .OrderBy(orderBy => orderBy.Name) ; agencies.ToList() .ForEach(feAgency => feAgency.LoadAgencyContacts(childAgencyContacts)); } }
/// <summary> /// Check to see if there are any related FeedbackSessions, and load them if requested /// </summary> public static void CheckExpandFeedbackSessions(SqlDataManager sdm, IEnumerable <Person> persons, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("feedbackSessions", StringComparison.OrdinalIgnoreCase) >= 0) { var personsWhere = CreatePersonWhere(persons, "PersonInterviewed"); var childFeedbackSessions = sdm.GetAllFeedbackSessions <FeedbackSession>(personsWhere) .OrderBy(orderBy => orderBy.Name) ; persons.ToList() .ForEach(fePerson => fePerson.LoadPersonInterviewed_FeedbackSessions(childFeedbackSessions)); } }
/// <summary> /// Check to see if there are any related Applicants, and load them if requested /// </summary> public static void CheckExpandApplicants(SqlDataManager sdm, IEnumerable <Interviewer> interviewers, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("applicants", StringComparison.OrdinalIgnoreCase) >= 0) { var interviewersWhere = CreateInterviewerWhere(interviewers, "OnsiteInterviewer"); var childApplicants = sdm.GetAllApplicants <Applicant>(interviewersWhere) .OrderBy(orderBy => orderBy.Name) ; interviewers.ToList() .ForEach(feInterviewer => feInterviewer.LoadOnsiteInterviewer_Applicants(childApplicants)); } }
/// <summary> /// Check to see if there are any related Applicants, and load them if requested /// </summary> public static void CheckExpandApplicants(SqlDataManager sdm, IEnumerable <Position> positions, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("applicants", StringComparison.OrdinalIgnoreCase) >= 0) { var positionsWhere = CreatePositionWhere(positions, "Applyingfor"); var childApplicants = sdm.GetAllApplicants <Applicant>(positionsWhere) .OrderBy(orderBy => orderBy.Name) ; positions.ToList() .ForEach(fePosition => fePosition.LoadApplyingfor_Applicants(childApplicants)); } }
/// <summary> /// Check to see if there are any related InventoryItems, and load them if requested /// </summary> public static void CheckExpandInventoryItems(SqlDataManager sdm, IEnumerable <StaffDirectory> staffDirectories, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("inventoryItems", StringComparison.OrdinalIgnoreCase) >= 0) { var staffDirectoriesWhere = CreateStaffDirectoryWhere(staffDirectories, "Whocurrentlyhasit"); var childInventoryItems = sdm.GetAllInventoryItems <InventoryItem>(staffDirectoriesWhere) .OrderBy(orderBy => orderBy.Name) ; staffDirectories.ToList() .ForEach(feStaffDirectory => feStaffDirectory.LoadWhocurrentlyhasit_InventoryItems(childInventoryItems)); } }
/// <summary> /// Check to see if there are any related Assignments, and load them if requested /// </summary> public static void CheckExpandAssignments(SqlDataManager sdm, IEnumerable <Course> courses, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("assignments", StringComparison.OrdinalIgnoreCase) >= 0) { var coursesWhere = CreateCourseWhere(courses, "Course"); var childAssignments = sdm.GetAllAssignments <Assignment>(coursesWhere) .OrderBy(orderBy => orderBy.Name) ; courses.ToList() .ForEach(feCourse => feCourse.LoadAssignments(childAssignments)); } }
/// <summary> /// Check to see if there are any related Shots, and load them if requested /// </summary> public static void CheckExpandShots(SqlDataManager sdm, IEnumerable <Scene> scenes, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("shots", StringComparison.OrdinalIgnoreCase) >= 0) { var scenesWhere = CreateSceneWhere(scenes, "Scene"); var childShots = sdm.GetAllShots <Shot>(scenesWhere) .OrderBy(orderBy => orderBy.Name) ; scenes.ToList() .ForEach(feScene => feScene.LoadShots(childShots)); } }
/// <summary> /// Check to see if there are any related EventDates, and load them if requested /// </summary> public static void CheckExpandEventDates(SqlDataManager sdm, IEnumerable <Venue> venues, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("eventDates", StringComparison.OrdinalIgnoreCase) >= 0) { var venuesWhere = CreateVenueWhere(venues, "Venue"); var childEventDates = sdm.GetAllEventDates <EventDate>(venuesWhere) .OrderBy(orderBy => orderBy.Name) ; venues.ToList() .ForEach(feVenue => feVenue.LoadEventDates(childEventDates)); } }
/// <summary> /// Check to see if there are any related Attendances, and load them if requested /// </summary> public static void CheckExpandAttendances(SqlDataManager sdm, IEnumerable <EventDate> eventDates, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("attendances", StringComparison.OrdinalIgnoreCase) >= 0) { var eventDatesWhere = CreateEventDateWhere(eventDates, "Event"); var childAttendances = sdm.GetAllAttendances <Attendance>(eventDatesWhere) .OrderBy(orderBy => orderBy.Name) ; eventDates.ToList() .ForEach(feEventDate => feEventDate.LoadEvent_Attendances(childAttendances)); } }
/// <summary> /// Check to see if there are any related StaffDirectories, and load them if requested /// </summary> public static void CheckExpandStaffDirectories(SqlDataManager sdm, IEnumerable <InventoryItem> inventoryItems, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("staffDirectories", StringComparison.OrdinalIgnoreCase) >= 0) { var inventoryItemsWhere = CreateInventoryItemWhere(inventoryItems, "PropsEquipmentinPossession"); var childStaffDirectories = sdm.GetAllStaffDirectories <StaffDirectory>(inventoryItemsWhere) .OrderBy(orderBy => orderBy.Name) ; inventoryItems.ToList() .ForEach(feInventoryItem => feInventoryItem.LoadPropsEquipmentinPossession_StaffDirectories(childStaffDirectories)); } }
private Avatar GetOrAvatar(SqlDataManager sdm) { var avatarWhere = String.Format("AvatarId = '{0}'", this.PersonId); var avatar = sdm.GetAllAvatars <Avatar>(avatarWhere).FirstOrDefault(); if (ReferenceEquals(avatar, null)) { avatar = new Avatar(); avatar.AvatarId = this.PersonId; avatar.Nickname = avatar.Handle = this.PreferredHandle; sdm.Insert(avatar); } return(avatar); }
/// <summary> /// Check to see if there are any related Attendances, and load them if requested /// </summary> public static void CheckExpandAttendances(SqlDataManager sdm, IEnumerable <VIP> vIPs, string expandString) { expandString = expandString.SafeToString(); if (String.Equals(expandString, "all", StringComparison.OrdinalIgnoreCase) || expandString.IndexOf("attendances", StringComparison.OrdinalIgnoreCase) >= 0) { var vIPsWhere = CreateVIPWhere(vIPs, "Person"); var childAttendances = sdm.GetAllAttendances <Attendance>(vIPsWhere) .OrderBy(orderBy => orderBy.Name) ; vIPs.ToList() .ForEach(feVIP => feVIP.LoadPerson_Attendances(childAttendances)); } }
public static void CheckExpand(SqlDataManager sdm, IEnumerable <StaffDirectory> staffDirectories, string expandString) { CheckExpandVideos(sdm, staffDirectories, expandString); CheckExpandVideos(sdm, staffDirectories, expandString); CheckExpandVideos(sdm, staffDirectories, expandString); CheckExpandVideos(sdm, staffDirectories, expandString); CheckExpandInventoryItems(sdm, staffDirectories, expandString); }
public SMQSqlServerCRUDHandler(string amqps, string dbcs, String rootPath) { this.OnlineSince = DateTime.UtcNow; this.BasePath = new DirectoryInfo(rootPath); SMQSqlServerCRUDHandler.DBConnectionString = dbcs; this.APIWrapper = new SqlDataManager(dbcs); this.Roles = "Guest,ServiceCoordinator,User,Admin,CRUDCoordinator".Split(",".ToCharArray()).ToList(); this.CRUDCoordinator = new SMQCRUDCoordinator(amqps); this.CRUDCoordinator.GuestRequestTokenReceived += Cc_GuestCRUDRequestTokenReceived; this.CRUDCoordinator.GuestValidateTemporaryAccessTokenReceived += Cc_GuestCRUDValidateTemporaryAccessTokenReceived; this.CRUDCoordinator.GuestWhoAmIReceived += CRUDCoordinator_GuestWhoAmIReceived; this.CRUDCoordinator.GuestWhoAreYouReceived += CRUDCoordinator_GuestWhoAreYouReceived; this.CRUDCoordinator.GuestStoreTempFileReceived += CRUDCoordinator_GuestStoreTempFileReceived; //this.CRUDCoordinator.DefaultJsonSerializerSettings.ContractResolver = new AirtableExtensions.CustomContractResolver<StandardPayload>(); this.InitActions(); }
internal void ParseSequence(SqlDataManager sdm, List <Signal> allSignals) { var signalDict = allSignals.ToDictionary(signal => signal.Symbol); this.DeleteSequence(sdm); foreach (var sequenceChar in this.SequenceCode) { var cs = new CharacterSquence() { Name = sequenceChar.ToString(), Description = signalDict[sequenceChar.ToString()].Name, CharacterId = this.CharacterId, SignalId = signalDict[sequenceChar.ToString()].SignalId, SignalIndex = this.CharacterSquences.Count() + 1 }; this.CharacterSquences.Add(cs); sdm.Insert(cs); } }
private void EnsureLoaded() { var sdm = new SqlDataManager(); var charWhere = String.Format("AlphabetId = '{0}'", this.AlphabetId); var chars = sdm.GetAllCharacters <Character>(charWhere); this.Characters.Clear(); chars.ForEach(feChar => this.Characters.Add(feChar)); var charSequenceWhere = String.Format("CharacterId IN (SELECT CharacterId from Character where AlphabetId = '{0}')", this.AlphabetId); var charSequences = sdm.GetAllCharacterSquences <CharacterSquence>(charSequenceWhere); foreach (var charToCheck in this.Characters) { charToCheck.LoadCharacterSquences(charSequences); } }
private void Upsert10KStates(string mapName, int count, BatchingOptions batchingOptions) { //InstrumentationContext.Reset(); GrainStateMap grainStateMap = CreateGrainStateMap(); using (var dataManager = new SqlDataManager(logger, grainStateMap, ConnectionString, ShardCredentials, mapName, batchingOptions)) { Stopwatch stopwatch = Stopwatch.StartNew(); List<Task> tasks = new List<Task>(); for (int i = 0; i < count; ++i) { var state = CreateState(i); tasks.Add(dataManager.UpsertStateAsync(RandomIdentity(), state)); } Task.WaitAll(tasks.ToArray()); stopwatch.Stop(); output.WriteLine(" [{0}] {1} Upserts. {2} max concurrent writes. Elapsed: {3}", mapName, count, batchingOptions.MaxConcurrentWrites, stopwatch.Elapsed); } }
private void Upsert10KStates(string mapName, int count, BatchingOptions batchingOptions) { //InstrumentationContext.Reset(); GrainStateMap grainStateMap = CreateGrainStateMap(); using (var dataManager = new SqlDataManager(logger, grainStateMap, ConnectionString, ShardCredentials, mapName, batchingOptions)) { Stopwatch stopwatch = Stopwatch.StartNew(); List <Task> tasks = new List <Task>(); for (int i = 0; i < count; ++i) { var state = CreateState(i); tasks.Add(dataManager.UpsertStateAsync(RandomIdentity(), state)); } Task.WaitAll(tasks.ToArray()); stopwatch.Stop(); Console.WriteLine(" [{0}] {1} Upserts. {2} max concurrent writes. Elapsed: {3}", mapName, count, batchingOptions.MaxConcurrentWrites, stopwatch.Elapsed); } }
public void ReadNonExistentState() { Task.Run(async() => { InstrumentationContext.Reset(); var grainStateMap = CreateGrainStateMap(); var grainIdentity = RandomIdentity(); using (var dataManager = new SqlDataManager(logger, grainStateMap, ConnectionString, ShardCredentials, ShardMapDefault)) { // now read var stopwatch = Stopwatch.StartNew(); var state = await dataManager.ReadStateAsync(grainIdentity); stopwatch.Stop(); Console.WriteLine(" Read elapsed: {0}", stopwatch.Elapsed); Assert.IsNull(state); } }).Wait(); }
public static void SaveNow() { var sdm = new SqlDataManager(); var mcms = new MorseCodeMetaSnapshot(); var allCharacters = sdm.GetAllCharacters <Character>(); var allSignals = sdm.GetAllSignals <Signal>(); mcms.Alphabets = sdm.GetAllAlphabets <Alphabet>(); foreach (var alphabet in mcms.Alphabets) { alphabet.LoadCharacters(allCharacters); alphabet.ParseCharacters(sdm, allSignals); } mcms.Signals = sdm.GetAllSignals <Signal>(); mcms.Save("../../../SSoT/MorseCodeMetaSnapshot.json"); }
public static IServiceCollection AddSqlReader(this IServiceCollection services, Action <MiCakeSqlReaderOptions> optionsAction = null) { MiCakeSqlReaderOptions options = new(); optionsAction?.Invoke(options); var providers = (options as IHasAccessor <IEnumerable <ISqlDataProvider> >).Instance; var manager = new SqlDataManager(); foreach (var provider in providers) { manager.AddSqlDataProvider(provider); } manager.PopulateSql(); services.TryAddSingleton <ISqlDataManager>(manager); services.TryAddSingleton <ISqlReader, DefaultSqlReader>(); return(services); }
public static Person GetPerson(SqlDataManager sdm, Person person) { if (String.IsNullOrEmpty(person.EmailAddress)) { throw new ArgumentException("Invalid Person request - Email Address is required to find a person"); } else if (person.EmailAddress.IndexOf("@") <= 1) { throw new ArgumentException("Invalid person request - Email address is invalid."); } // Lookup the person by their email address var personWhere = string.Format("EmailAddress LIKE '{0}'", person.EmailAddress.ToSqlSafeString()); var dbPerson = sdm.GetAllPersons <Person>(personWhere).FirstOrDefault(); if (ReferenceEquals(dbPerson, null)) { dbPerson = new Person(); dbPerson.Name = person.EmailAddress; dbPerson.EmailAddress = person.EmailAddress; dbPerson.PreferredHandle = person.EmailAddress.Substring(0, person.EmailAddress.IndexOf("@")); dbPerson.IsEmailVerified = false; dbPerson.IsPhoneerified = false; dbPerson.PhoneNumber = String.Empty; dbPerson.SSN = String.Empty; dbPerson.Avatar = dbPerson.GetOrAvatar(sdm); sdm.Insert(dbPerson); } else { dbPerson.Avatar = dbPerson.GetOrAvatar(sdm); } return(dbPerson); }
private void button1_Click(object sender, EventArgs e) { var sdm = new SqlDataManager(); var alphabet = this.listBox1.SelectedItem as Alphabet; IEnumerable <Character> chars = this.listBox2.DataSource as IEnumerable <Character>; var standardChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-. "; foreach (var standardChar in standardChars) { if (!chars.Any(anyChar => anyChar.Symbol == standardChar.ToString())) { var newChar = new Character() { AlphabetId = alphabet.AlphabetId, Description = String.Format("{0} char {1}", alphabet.Name, standardChar), Name = standardChar.ToString(), Symbol = standardChar.ToString() }; sdm.Insert(newChar); } } }
public FeedbackSessionsController() { this.SDM = new SqlDataManager(); this.OnConstructor(); }
public static void CheckExpand(SqlDataManager sdm, IEnumerable <AgencyContact> agencyContacts, string expandString) { }
public static void CheckExpand(SqlDataManager sdm, IEnumerable <Course> courses, string expandString) { CheckExpandAssignments(sdm, courses, expandString); }
public void OneWriteThenReadState() { Task.Run(async () => { InstrumentationContext.Reset(); var grainStateMap = CreateGrainStateMap(); var grainIdentity = RandomIdentity(); var state = CreateState(); using (var dataManager = new SqlDataManager(logger, grainStateMap, ConnectionString, ShardCredentials, ShardMapDefault)) { var stopwatch = Stopwatch.StartNew(); await dataManager.UpsertStateAsync(grainIdentity, state); stopwatch.Stop(); output.WriteLine(" Insert elapsed: {0}", stopwatch.Elapsed); // now read stopwatch = Stopwatch.StartNew(); var state2 = await dataManager.ReadStateAsync(grainIdentity); stopwatch.Stop(); output.WriteLine(" Read elapsed: {0}", stopwatch.Elapsed); Assert.AreEqual(state, state2); } }).Wait(); }
public void ReadNonExistentState() { Task.Run(async () => { InstrumentationContext.Reset(); var grainStateMap = CreateGrainStateMap(); var grainIdentity = RandomIdentity(); using (var dataManager = new SqlDataManager(logger, grainStateMap, ConnectionString, ShardCredentials, ShardMapDefault)) { // now read var stopwatch = Stopwatch.StartNew(); var state = await dataManager.ReadStateAsync(grainIdentity); stopwatch.Stop(); output.WriteLine(" Read elapsed: {0}", stopwatch.Elapsed); Assert.IsNull(state); } }).Wait(); }