Пример #1
0
        public Class[] GetClasses(DateTime startDate, DateTime endDate)
        {
            var sourceCredentials = new ClassService.SourceCredentials()
            {
                SourceName = Credentials.SourceName,
                Password   = Credentials.Password,
                SiteIDs    = new int[] { -99 }
            };

            var userCredentials = new UserCredentials()
            {
                Password = "******", Username = "******", SiteIDs = new int[] { -99 }
            };

            var classService = new ClassService.ClassService();
            var results      =
                classService.GetClasses(new GetClassesRequest()
            {
                SourceCredentials = sourceCredentials,
                StartDateTime     = new DateTime(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0),
                EndDateTime       = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59)
            });

            return(results.Classes);
        }
Пример #2
0
        public Dictionary <String, int> GetNames(Class[] classes)
        {
            var sourceCredentials = new ClassService.SourceCredentials()
            {
                SourceName = Credentials.SourceName,
                Password   = Credentials.Password,
                SiteIDs    = new int[] { -99 }
            };
            var userCredentials = new UserCredentials()
            {
                Password = "******", Username = "******", SiteIDs = new int[] { -99 }
            };

            var classService = new ClassService.ClassService();
            var names        = new Dictionary <String, int>();

            foreach (var _class in classes)
            {
                var classID = _class.ID.Value;

                var results =
                    classService.GetClassVisits(new GetClassVisitsRequest()
                {
                    ClassID           = classID,
                    SourceCredentials = sourceCredentials,
                    UserCredentials   = userCredentials
                });

                if (results.Class?.Visits != null)
                {
                    foreach (var classVisit in results.Class.Visits)
                    {
                        if (classVisit.Client != null)
                        {
                            var client   = classVisit.Client;
                            int numberOf = 0;
                            if (names.ContainsKey(client.FirstName))
                            {
                                names.TryGetValue(client.FirstName, out numberOf);
                                names.Remove(client.FirstName);
                            }
                            names.Add(client.FirstName, numberOf + 1);
                        }
                    }
                }
            }
            return(names);
        }