public IHttpActionResult Post(QuizParams qp) { string host_Quiz = string.Format("{0}:{1}" , ConfigurationManager.AppSettings["OrientProdHost"], ConfigurationManager.AppSettings["OrientPort"]); quizManager = new Managers.Manager( ConfigurationManager.AppSettings["IntranetDB"] , host_Quiz , ConfigurationManager.AppSettings["orient_dev_login"] , ConfigurationManager.AppSettings["orient_dev_pswd"] ); WebManagers.ReturnEntities response = null; string res = string.Empty; Quizes.QuizUOW qu = new Quizes.QuizUOW(quizManager.GetRepo()); try { // преобразуем строку в HttpResponseMessage со ReturnEntities с результатом в поле _value res = qu.GetQuizByMonthGap(qp.monthDepth); response = new WebManagers.ReturnEntities(res, Request); } catch (Exception e) { System.Diagnostics.Trace.WriteLine(e.Message); response = new WebManagers.ReturnEntities("Error: " + e.Message, Request); } return(response); }
//FUNCTIONAL TESTS public static void UOWFunctionalCheck() { //GET CLASS Managers.Manager mngCl = new Managers.Manager("dev_db", null); IOrientRepo rp = mngCl.GetRepo(); GetClass gc = rp.GetClass <Person>("dev_db", null); //Managers.Manager mng = new Managers.Manager(ConfigurationManager.AppSettings["OrientDevDB"],null); Managers.Manager mng = new Managers.Manager(ConfigurationManager.AppSettings["OrientUnitTestDB"], null); Managers.Manager mngSource = new Managers.Manager(ConfigurationManager.AppSettings["OrientSourceDB"], null); PersonUOWs.PersonUOW pu = mng.GetPersonUOW(); NewsUOWs.NewsRealUow nu = mng.GetNewsUOW(); Managers.Manager mngPerson = new Managers.Manager(ConfigurationManager.AppSettings["OrientSourceDB"]); PersonUOWs.PersonUOW personToGetUOW = mngPerson.GetPersonUOW(); POCO.News newsToAdd0 = new News() { GUID = "119", content = "s \"a \"a t " }; POCO.Person newsMaker = pu.SearchByName("Neprintsevia").FirstOrDefault(); POCO.Person likeMaker = pu.SearchByName("Person1").FirstOrDefault(); POCO.Person troubleMaker = pu.SearchByName("Person0").FirstOrDefault(); GETparameters gp = new GETparameters() { offest = 5, published = true, pinned = true, asc = true, author = newsMaker }; JSONManager jm = new JSONManager(); //ABSENT PERSON CHECK Random rnd = new Random(); //News ns = nu.GetNewsByGUID("2370b972-48d4-4e49-95ad-b99ba5382042"); //News ns = nu.GetNewsByGUID("e7bc87ec-f649-4748-b4cb-d2863f780f1c"); //nu.GetNewsByGUID("f7557c27-f889-4aab-91ce-ba15e34e3981"); //News ns = nu.GetNewsByGUID("f7557c27-f889-4aab-91ce-ba15e34e3981"); var a = nu.GetNews(5, null, null); int acc = (int)rnd.Next(0, 10000); Person personAbsent = new Person() { Name = "PersonAbsent", sAMAccountName = "absent" + acc }; string newsContent = "{\"conntent_\":\"news text\",\"name\":\"News name\"}"; }
public static OrientDatabase Migrate(Managers.Manager to_, Managers.Manager from_, List <IOrientObjects.IOrientDefaultObject> mooveClasses , List <IOrientObjects.IOrientDefaultObject> mooveObjects, bool dropAndCreateIfExists = false, bool generate = false) { OrientDatabase result = null; bool allreadyExists = false; if (to_ == null) { throw new Exception("No from DB passed"); } targetRepo_ = to_.GetRepo(); if (targetRepo_ == null) { throw new Exception("No from repo exists"); } OrientDatabase dbTo = targetRepo_.GetDb(); if (dropAndCreateIfExists == true) { //drop and create db if (dbTo != null) { targetRepo_.DeleteDb(); } targetRepo_.CreateDb(); if (targetRepo_.GetDb() == null) { throw new Exception("Db was not recreated"); } } if (from_ != null) { //moove db sourceRepo_ = from_.GetRepo(); if (sourceRepo_ == null) { throw new Exception("No from repo exists"); } OrientDatabase dbFrom = sourceRepo_.GetDb(); dbFrom = sourceRepo_.GetDb(); dbTo = targetRepo_.GetDb(); if (dbTo == null) { throw new Exception("No target database exists"); } if (dbFrom == null) { throw new Exception("No source database exists"); } if (mooveClasses != null && mooveClasses.Count() > 0) { MooveClasses(targetRepo_, sourceRepo_, mooveClasses); foreach (OrientDefaultObject oL_ in mooveClasses) { targetRepo_.CreateProperty <OrientDefaultObject>(oL_, null); } } if (mooveObjects != null && mooveObjects.Count() > 0) { ConditionalItemsInit(mooveObjects); MooveObject(); /* * MooveObjectsOfClass<Person>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<Unit>(targetRepo_,sourceRepo_); * * MooveObjectsOfClass<SubUnit>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<MainAssignment>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<OldMainAssignment>(targetRepo_,sourceRepo_); */ } /* * MooveObjectsOfClass<UserSettings>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<CommonSettings>(targetRepo_,sourceRepo_); * * * MooveObjectsOfClass<PersonRelation>(targetRepo_,sourceRepo_); */ } if (generate == true) { //generate scenery to existing to_.GenDB(false, false); to_.GenNewsComments(null, null); } targetRepo_.StoreDbStatistic(null, null); return(result); }
public static OrientDatabase Migrate(Managers.Manager to_, Managers.Manager from_, bool dropAndCreateIfExists = false, bool mooveClasses = false, bool mooveObjects = false, bool generate = false) { OrientDatabase result = null; bool allreadyExists = false; if (to_ == null) { throw new Exception("No from DB passed"); } targetRepo_ = to_.GetRepo(); if (targetRepo_ == null) { throw new Exception("No from repo exists"); } OrientDatabase dbTo = targetRepo_.GetDb(); if (dropAndCreateIfExists == true) { //drop and create db if (dbTo != null) { targetRepo_.DeleteDb(); } targetRepo_.CreateDb(); if (targetRepo_.GetDb() == null) { throw new Exception("Db was not recreated"); } } if (from_ != null) { //moove db sourceRepo_ = from_.GetRepo(); if (sourceRepo_ == null) { throw new Exception("No from repo exists"); } OrientDatabase dbFrom = sourceRepo_.GetDb(); dbFrom = sourceRepo_.GetDb(); dbTo = targetRepo_.GetDb(); if (dbTo == null) { throw new Exception("No target database exists"); } if (dbFrom == null) { throw new Exception("No source database exists"); } if (mooveClasses) { MooveClasses(targetRepo_, sourceRepo_); targetRepo_.CreateProperty <OrientEdge>(new OrientEdge(), null); //create all properties even if all null. targetRepo_.CreateProperty <MainAssignment>(new MainAssignment(), null); targetRepo_.CreateProperty <Unit>(new Unit(), null); targetRepo_.CreateProperty <Note>(new Note(), null); targetRepo_.CreateProperty <Authorship>(new Authorship(), null); targetRepo_.CreateProperty <Comment>(new Comment(), null); targetRepo_.CreateProperty <Commentary>(new Commentary(), null); targetRepo_.CreateProperty <News>(new News(), null); targetRepo_.CreateProperty <Person>(new Person(), null); targetRepo_.CreateProperty <Liked>(new Liked(), null); targetRepo_.CreateProperty <Tag>(new Tag(), null); targetRepo_.CreateProperty <Tagged>(new Tagged(), null); } if (mooveObjects) { MooveObjectsOfClass <Person>(targetRepo_, sourceRepo_); MooveObjectsOfClass <Unit>(targetRepo_, sourceRepo_); MooveObjectsOfClass <SubUnit>(targetRepo_, sourceRepo_); MooveObjectsOfClass <MainAssignment>(targetRepo_, sourceRepo_); MooveObjectsOfClass <OldMainAssignment>(targetRepo_, sourceRepo_); } /* * MooveObjectsOfClass<UserSettings>(targetRepo_,sourceRepo_); * MooveObjectsOfClass<CommonSettings>(targetRepo_,sourceRepo_); */ MooveObjectsOfClass <PersonRelation>(targetRepo_, sourceRepo_); } if (generate == true) { //generate scenery to existing to_.GenDB(false, false); to_.GenNewsComments(null, null); } targetRepo_.StoreDbStatistic(null, null); return(result); }