Inheritance: Subject
Example #1
0
        public User CreateUser(User user)
        {
            using (IUnitOfWork uow = this.GetUnitOfWork())
            {
                IRepository<User> usersRepo = uow.GetRepository<User>();
                usersRepo.Put(user);

                uow.Commit();
            }

            return (user);
        }
Example #2
0
        public void queryAuthorAndVariables(ref User user, ref string variableNames, string dataSetID, string DataBase)
        {
            string mySelectQuery = "select X.* from explorer.datasets, XMLTABLE ('$METADATA/*:metaProfile' Columns " +
                                        "Author varchar(256) Path '*:general/*:metadataCreator'," +
                                        "VarNames varchar(1028) Path 'string-join(*:data/*:dataStructure/*:variables/*:variable/*:name,\",\")'" +
                                    ") as X where datasetid = " + dataSetID + ";";

            DB2Connection connect = new DB2Connection(DataBase);
            DB2Command myCommand = new DB2Command(mySelectQuery, connect);
            connect.Open();
            DB2DataReader myReader = myCommand.ExecuteReader();

            string author = "";
            while (myReader.Read())
            {
                author = myReader.GetString(0);
                variableNames = myReader.GetString(1);
            }
            myReader.Close();
            connect.Close();

            SubjectManager subjectManager = new SubjectManager();
            user = subjectManager.UsersRepo.Get(u => author.Equals(u.FullName)).FirstOrDefault();
        }
Example #3
0
        public static UserGridRowModel Convert(User user)
        {
            return new UserGridRowModel()
            {
                Id = user.Id,
                Username = user.Name,
                FullName = user.FullName,
                Email = user.Email,

                IsApproved = user.IsApproved,
                IsBlocked = user.IsBlocked,
                IsLockedOut = user.IsLockedOut
            };
        }
Example #4
0
 public static MyAccountModel Convert(User user)
 {
     return new MyAccountModel()
     {
         UserId = user.Id,
         Username = user.Name,
         FullName = user.FullName,
         Email = user.Email,
         AuthenticatorId = user.Authenticator.Id,
         SecurityQuestionId = user.Authenticator.Id == 1 ? user.SecurityQuestion.Id : 0
     };
 }
Example #5
0
        /// <summary>
        /// CAUTION !!!!!!!!!!!!!!!!!
        /// upload bezieht sich derzeit nur auf daten mit einem block (einer tabelle)
        /// umsetzung von mehreren blöckes noch nicht geklärt.
        /// (für einen wert gibt es eine weitere tabelle)
        /// </summary>
        /// <param name="dataSetID"></param>
        /// <param name="DataBase"></param>
        public void uploadData(string dataSetID, string DataBase)
        {
            DatasetManager datasetManager = new DatasetManager();
            DataStructureManager dataStructureManager = new DataStructureManager();
            XmlDataReader xmlDataReader = new XmlDataReader();

            User user = new User();
            string variableNames = "";
            // query metadataAuthor and variable names from explorer.datasets
            queryAuthorAndVariables(ref user, ref variableNames, dataSetID, DataBase);
            List<string> varNames = variableNames.Split(',').ToList();

            // get all dataStructures with equal variables count
            List<StructuredDataStructure> dataStructures = dataStructureManager.StructuredDataStructureRepo.Get(s =>
                varNames.Count().Equals(s.Variables.Count)).ToList();

            // get all Ids of dataStructures with equal variables
            List<long> dataStructureIds = new List<long>();
            foreach (StructuredDataStructure dataStructure in dataStructures)
            {
                bool isSimilarStructure = true;
                foreach (Variable variable in dataStructure.Variables)
                {
                    if (!varNames.Contains(variable.Label))
                    {
                        isSimilarStructure &= false;
                        break;
                    }
                }
                if (isSimilarStructure)
                    dataStructureIds.Add(dataStructure.Id);
            }

            // get the wanted dataset by comparing the old B1 datasetId out of the datasets with similar dataStructure
            Dataset dataset = null;
            List<Dataset> datasets = datasetManager.DatasetRepo.Get(d => dataStructureIds.Contains(d.DataStructure.Id)).ToList();
            foreach (Dataset ds in datasets)
            {
                string oldDatasetId = "";
                try
                {
                    XmlNode extraID = ds.Versions.FirstOrDefault().Metadata.SelectSingleNode("Metadata/general/general/id/id");
                    oldDatasetId = extraID.InnerText;
                }
                catch
                {
                }
                if (oldDatasetId == dataSetID)
                {
                    dataset = ds;
                    break;
                }
            }

            if (dataset != null)
            {
                // get distinct and ascending ordered insertdates from DB
                List<DB2TimeStamp> distInsertDates = queryDistInsertDates(dataSetID, DataBase);

                bool checkObsIds = false;
                foreach (DB2TimeStamp insertDate in distInsertDates)
                {
                    List<DataTuple> createdDataTuples = new List<DataTuple>();
                    List<DataTuple> editedDataTuples = new List<DataTuple>();
                    List<DataTuple> deletedDataTuples = new List<DataTuple>();

                    DatasetVersion workingCopy = datasetManager.GetDatasetLatestVersion(dataset.Id); // get dataset
                    // get obsid, data, deleted and newest for each observation from DB
                    List<Observation> observations = queryObservation(dataSetID, DataBase, insertDate.ToString());
                    Dictionary<long, long> obsIdMapsToTupleId = new Dictionary<long, long>();
                    if (checkObsIds)
                    {
                        // get all EffectiveTupleIds
                        List<long> datasetTupleIds = datasetManager.GetDatasetVersionEffectiveTupleIds(workingCopy).ToList();
                        // id-mapping-list key=obsId, value=TupleId foreach EffectiveTupleId and obsId from Tuple.Extra
                        obsIdMapsToTupleId = idMapping(datasetTupleIds, ref datasetManager);
                    }
                    // observation counter
                    int observationIndex = 0;
                    bool isNewest = true;
                    foreach (Observation observation in observations) //////////////parallel
                    {
                        isNewest = (isNewest && observation.newest != 'Y') ? false : isNewest;
                        // create dataTuple with xmlDataReader
                        // split xml to string list and use DataReader.ReadRow
                        DataTuple dataRow = xmlDataReader.XmlRowReader(observation.data, dataset.DataStructure.Id, observationIndex);
                        // check if observation.obsid is in id-mapping-list
                        long TupleId;
                        if (checkObsIds && obsIdMapsToTupleId.TryGetValue(observation.obsid, out TupleId))
                        {
                            DataTuple dataTuple = datasetManager.DataTupleRepo.Get(TupleId);
                            if (observation.deleted != 'Y')
                            {
                                dataTuple.VariableValues = dataRow.VariableValues;
                                // edit tuple if observation exists as tuple in EffectiveTuple and observation is not deleted
                                editedDataTuples.Add(dataTuple);
                            }
                            else
                            {
                                // delete tuple if observation exists as tuple in EffectiveTuple and observ. is deleted
                                deletedDataTuples.Add(dataTuple);
                            }
                        }
                        else
                        {
                            // write the obsId and oldBExISdatasetId in Extra: <extra><obsid>[obsid]</obsid><oldBExISdatasetId>[dataSetID]</oldBExISdatasetId></extra>
                            dataRow.Extra = oldIdsIntoExtra(observation.obsid, dataSetID, dataRow.Extra);
                            // create tuple if observation exists not in EffectiveTuple
                            createdDataTuples.Add(dataRow);
                        }
                        observationIndex++; // observation counter
                    }
                    checkObsIds = (!checkObsIds && !isNewest) ? true : checkObsIds;

                    // checkOut
                    if (datasetManager.IsDatasetCheckedOutFor(dataset.Id, user.Name) || datasetManager.CheckOutDataset(dataset.Id, user.Name))
                    {
                        workingCopy = datasetManager.GetDatasetWorkingCopy(dataset.Id); // get dataset
                        datasetManager.EditDatasetVersion(workingCopy, createdDataTuples, editedDataTuples, deletedDataTuples); // edit dataset
                        datasetManager.CheckInDataset(dataset.Id, "Primary data row was submited.", user.Name); // checkIn
                    }
                }
            }
        }
Example #6
0
        public static GroupMembershipGridRowModel Convert(User user, bool isUserInGroup)
        {
            return new GroupMembershipGridRowModel()
            {
                Id = user.Id,
                Username = user.Name,
                FullName = user.FullName,
                Email = user.Email,

                IsUserInGroup = isUserInGroup
            };
        }