Exemplo n.º 1
0
        /// <summary>
        /// Adds package to the database
        /// </summary>
        /// <param name="package">Package value represents package object with necessary information.</param>
        public Training AddPackage(Package package)
        {
            PackageItemIdentifier packageId;
            ValidationResults importLog;

            using (PackageReader packageReader = package.GetPackageReader())
            {
                AddPackageResult result = PStore.AddPackage(packageReader, new PackageEnforcement(false, false, false));
                packageId = result.PackageId;
                importLog = result.Log;
            }

            // fill in the application-specific columns of the PackageItem table
            LearningStoreJob job = LStore.CreateJob();
            Dictionary<string, object> properties = new Dictionary<string, object>();
            properties[Schema.PackageItem.Owner] = new UserItemIdentifier(package.Owner);
            properties[Schema.PackageItem.FileName] = package.FileName;
            properties[Schema.PackageItem.UploadDateTime] = package.UploadDateTime;
            job.UpdateItem(packageId, properties);
            job.Execute();

            // retrieve information about the package
            job = LStore.CreateJob();
            RequestMyTraining(job, packageId);

            DataTable dataTableResults = job.Execute<DataTable>();
            Training training = new Training(dataTableResults.Rows[0]);

            return training;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves collection of trainings for given user.
        /// </summary>
        /// <param name="userID">Long integer value representing user id.</param>
        /// <returns>IEnumerable collection of Training objects.</returns>
        public IEnumerable<Training> GetTrainings(long userID)
        {
            this.UserKey = userID.ToString();
            LearningStoreJob job = LStore.CreateJob();
            RequestMyTraining(job, null);
            DataTable results = job.Execute<DataTable>();
            List<Training> packages = new List<Training>();
            foreach (DataRow dataRow in results.AsEnumerable())
            {
                // Create Training object
                Training training = new Training(dataRow);
                packages.Add(training);
            }

            return packages;
        }