public static List <AttendeeData[]> Parse(string filePath, int batchSize = 1)
        {
            var batchList       = new List <AttendeeData[]>();
            var numTotalRecords = 0;

            using (StreamReader reader = new StreamReader(Environment.ExpandEnvironmentVariables(filePath)))
            {
                string line;
                int    idx = 0;

                var batch = new AttendeeData[batchSize];
                while ((line = reader.ReadLine()) != null)
                {
                    batch[idx] = ParseLine(line);
                    numTotalRecords++;
                    idx++;

                    if (idx == batchSize)
                    {
                        batchList.Add(batch);
                        //Console.WriteLine("{0}st batch (size: {1}) of {2} has been added", batchList.Count, batchSize, typeof(AttendeeModel).Name);
                        batch = new AttendeeData[batchSize];
                        idx   = 0;
                    }
                }

                if (idx > 0 && idx < batchSize)
                {
                    //Console.WriteLine("Remaining {0} records of {1} as the last batch", idx, typeof(AttendeeModel).Name);
                    batchList.Add(batch); // Add remaining batch
                }
            }
            System.Console.WriteLine("{0} records have been loaded into {1} batches", numTotalRecords, batchList.Count);
            return(batchList);
        }
Beispiel #2
0
        private void AddAttendeeDataToList(MailboxData mailboxData, FreeBusyQuery freeBusyQuery, List <AttendeeData> attendeeDataList)
        {
            if (freeBusyQuery.Result == null)
            {
                AvailabilityQuery.MeetingSuggestionsTracer.TraceError <object, EmailAddress>((long)this.GetHashCode(), "{0}: Null freebusyquery result for attendee {1}, treating as if we got no data for this attendee", TraceContext.Get(), freeBusyQuery.Email);
            }
            string text = (freeBusyQuery.Result != null) ? freeBusyQuery.Result.MergedFreeBusy : null;

            if (string.IsNullOrEmpty(text) || (this.desiredSuggestionsView.GlobalObjectId != null && mailboxData.AttendeeType == MeetingAttendeeType.Organizer))
            {
                text = MergedFreeBusy.GenerateMergedFreeBusyString(base.ClientContext.TimeZone, this.internalFreeBusyView.MergedFreeBusyIntervalInMinutes, new ExDateTime(base.ClientContext.TimeZone, this.internalFreeBusyView.TimeWindow.StartTime), new ExDateTime(base.ClientContext.TimeZone, this.internalFreeBusyView.TimeWindow.EndTime), (freeBusyQuery.Result != null) ? freeBusyQuery.Result.CalendarEventArrayInternal : null, freeBusyQuery.Result == null || freeBusyQuery.Result.ExceptionInfo != null, this.desiredSuggestionsView.GlobalObjectIdByteArray, base.ClientContext.RequestSchemaVersion);
            }
            AttendeeData item = new AttendeeData(mailboxData.AttendeeType, freeBusyQuery.Email.Address, mailboxData.ExcludeConflicts, new ExDateTime(base.ClientContext.TimeZone, this.internalFreeBusyView.TimeWindow.StartTime), new ExDateTime(base.ClientContext.TimeZone, this.internalFreeBusyView.TimeWindow.EndTime), text, base.ClientContext.RequestSchemaVersion, this.GetAttendeeWorkHours(freeBusyQuery));

            attendeeDataList.Add(item);
        }
 public Guid Add(AttendeeData model)
 {
     DbContext.Add(model);
     return(model.ID);
 }
        private static AttendeeData ParseLine(string line)
        {
            int[] columnType = new int[] { 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };

            String[] text    = new string[columnType.Where(x => x == 0).Count()];
            bool     boolVal = false;

            float[] numericalVal = new float[columnType.Where(x => x == 2).Count()];

            int  fieldToAnalyzeStart;
            int  fId;
            int  catId;
            int  numericalId;
            bool skipFieldSep;
            int  i;
            int  coundSeqLen;
            int  len;

            int stackTot;
            int stackTop;
            int stackBase;

            fieldToAnalyzeStart = 0;
            fId          = 0;
            catId        = 0;
            numericalId  = 0;
            skipFieldSep = false;
            i            = 0;
            coundSeqLen  = 0;
            len          = line.Length;
            stackTot     = 0;
            stackTop     = 0;
            stackBase    = 0;

            // parse initial '"'
            while (line[coundSeqLen] == '"')
            {
                coundSeqLen++;
            }
            i = coundSeqLen;

            stackTot  = stackTop = coundSeqLen;
            stackBase = coundSeqLen > 0 ? 1 : 0;

            while (i < len)
            {
                coundSeqLen = 0;
                while (i + coundSeqLen < len && line[i + coundSeqLen] == '"')
                {
                    coundSeqLen++;
                }
                i += coundSeqLen;

                int prevQoutSeqLen = coundSeqLen;
                if (coundSeqLen > 0)
                {
                    if (coundSeqLen > stackTot)
                    {
                        stackTot |= coundSeqLen;
                        stackTop  = coundSeqLen & (~coundSeqLen >> 1);
                    }
                    else if (coundSeqLen == stackTop / 2)
                    {
                        stackTot -= stackTop;
                        stackTot -= coundSeqLen;
                        stackTop  = coundSeqLen / 2;
                    }
                    else
                    {
                        stackTot ^= coundSeqLen;
                        stackTop  = stackTot & (~stackTot >> 1);
                    }
                    if (!Functions.IsContigBitmask(stackTot))
                    {
                        break;
                    }
                }
                skipFieldSep = stackTop > stackBase;

                if (!skipFieldSep && line[i] == ',')
                {
                    var startIdx = fieldToAnalyzeStart + prevQoutSeqLen + 1;
                    var length   = i - fieldToAnalyzeStart - prevQoutSeqLen * 2 - 1;
                    var token    = line.Substring(startIdx, length);

                    switch (columnType[fId])
                    {
                    case (0):     // categorical
                                  //int pos = strToIntMaps[catId].Get(text[fId]);
                                  //int offset = srcIdxToCounts[catId];
                        text[catId++] = token;
                        break;

                    case (1):     // bool
                        boolVal = ToBool(token);
                        break;

                    case (2):     // int
                        numericalVal[numericalId++] = ToInt(token);
                        break;

                    default:
                        throw new Exception("Field type not found");
                    }
                    fId++;
                    fieldToAnalyzeStart = i;
                }

                i++;
            }

            AttendeeData data = new AttendeeData()
            {
                ProgramOwner                  = text[0],
                Timezone                      = text[1],
                Timezonemapping               = text[2],
                Area                          = text[3],
                Country                       = text[4],
                LocalizationLanguage          = text[5],
                StartDateDayOfWeek            = text[6],
                StartDateHrofDay              = numericalVal[1],
                StartDateMonthOfYear          = numericalVal[2],
                Duration                      = numericalVal[3],
                DaysBetweenCreationandWebinar = numericalVal[4],
                RegisteredCount               = numericalVal[5],
                Label                         = numericalVal[0],
                SearchPublishToSearch         = boolVal,
                CeOnPremise                   = numericalVal[6],
                CloudPlatform                 = numericalVal[7],
                DeveloperTools                = numericalVal[8],
                DevicesXbox                   = numericalVal[9],
                DynamicsCloud                 = numericalVal[10],
                DynamicsOnPremise             = numericalVal[11],
                EnterpriseSolutions           = numericalVal[12],
                Hololens                      = numericalVal[13],
                MicrosoftAzure                = numericalVal[14],
                MicrosoftDynamics             = numericalVal[15],
                Office                        = numericalVal[16],
                OtherProductsNotListedAbove   = numericalVal[17],
                ProdUncategorized             = numericalVal[18],
                ServerManagement              = numericalVal[19],
                Skype                         = numericalVal[20],
                SmallBusinessSolutions        = numericalVal[21],
                Surface                       = numericalVal[22],
                Windows                       = numericalVal[23],
                WindowsPcTablet               = numericalVal[24],
                WindowsEmbeddedIot            = numericalVal[25],
                WindowsPhone                  = numericalVal[26],
                WindowsVolumeLicensing        = numericalVal[27],
                BusinessDecisionMaker         = numericalVal[28],
                BusinessProfessionals         = numericalVal[29],
                Consumers                     = numericalVal[30],
                Developers                    = numericalVal[31],
                Educators                     = numericalVal[32],
                ForHome                       = numericalVal[33],
                Government                    = numericalVal[34],
                InformationWorker             = numericalVal[35],
                ItDecisionMaker               = numericalVal[36],
                ItProfessionals               = numericalVal[37],
                OtherAudience                 = numericalVal[38],
                Partners                      = numericalVal[39],
                Students                      = numericalVal[40],
                TAUncategorized               = numericalVal[41]
            };

            return(data);
        }
Beispiel #5
0
 private void AssertAttendee(AttendeeData received, Registration stored)
 {
     received.Name.Should().Be(stored.Name);
     received.Email.Should().Be(stored.Email);
     received.PhoneNumber.Should().Be(stored.PhoneNumber);
 }