Esempio n. 1
0
        private void XCCUpload(FileInfo file)
        {
            Logger.Info("Entering XCCUpload");
            ContentCreateOptions options = null;
            Session session = null;

            try
            {
                Uri           uri = new Uri(ConfigurationManager.AppSettings["XCC_Connection"]);
                ContentSource cs  = ContentSourceFactory.NewContentSource(uri);
                session = cs.NewSession();
                Logger.Debug("Logging results for ContentSource");
                this.LoadFile(session, file, options);
            }
            catch (Exception ex)
            {
                CMSException excption = new CMSException(ex.Message, ex);
                Logger.Error("Error on XCCUpload" + ex.Message);
                throw excption;
            }
            finally
            {
                session.Close();
            }
        }
Esempio n. 2
0
        public Delta GetLatestDeltaInDatabase()
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(_connectionString));


            using (var session = contentSource.NewSession())
            {
                const string xqueryToExcecute = @"xquery version ""1.0-ml"";
                                           declare namespace m=""http://mldeploy.org"";
                                           for $doc in //*:LatestDelta 
                                           return $doc/m:Number/text()";

                Request request = session.NewAdhocQuery(xqueryToExcecute);
                string  result  = session.SubmitRequest(request).AsString();

                if (result == string.Empty)
                {
                    return(new NoDelta());
                }

                var number      = Int64.Parse(result);
                var description = GetLatestDeltaDescriptionFromDatabase();
                return(new Delta(number, string.Format("{0}\\{1}.xqy", _path, number), description));
            }
        }
Esempio n. 3
0
        private void Run(string script)
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(_connectionString));

            using (var session = contentSource.NewSession())
            {
                Request request = session.NewAdhocQuery(script);
                session.SubmitRequest(request).AsString();
            }
        }
 private void setXCCRequestHandle(Uri serverUri)
 {
     try
     {
         ContentSource cs = ContentSourceFactory.NewContentSource(serverUri);
         session = cs.NewSession();
         request = session.NewModuleInvoke(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 5
0
        public void UpdateLatestDeltaAs(Delta delta)
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(_connectionString));

            using (var session = contentSource.NewSession())
            {
                string xqueryToExcecute =
                    string.Format(
                        @"xdmp:document-insert(""/mldeploy/latest.xml"", <LatestDelta xmlns:m=""http://mldeploy.org""><m:Number>{0}</m:Number><m:Description>{1}</m:Description></LatestDelta>, ())", delta.Number, delta.Description);
                Request request = session.NewAdhocQuery(xqueryToExcecute);
                session.SubmitRequest(request).AsString();
            }
        }
        private void AssertThatTheDeltaWasApplied(string xmlString)
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(_connectionString));


            using (var session = contentSource.NewSession())
            {
                Request request = session.NewAdhocQuery(@"xquery version ""1.0-ml"";
                                                          for $doc in //*:shouldapplydelta return $doc");
                var     result  = session.SubmitRequest(request).AsString();

                Assert.AreEqual(xmlString, result);
            }
        }
        private void AssertThatTheDatabaseHasADocumentWithContent(string xmlString)
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(ConnectionString));


            using (var session = contentSource.NewSession())
            {
                Request request = session.NewAdhocQuery(@"xquery version ""1.0-ml"";
                                                          for $doc in //*:shouldrunquery return $doc");
                var     result  = session.SubmitRequest(request).AsString();

                Assert.AreEqual(xmlString, result);
            }
        }
Esempio n. 8
0
        public void ApplyDelta(Delta delta)
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(_connectionString));

            Console.WriteLine(string.Format("[mldeploy] Applying delta {0}  ({1})", delta.Number, delta.Description));


            using (var session = contentSource.NewSession())
            {
                string  xqueryToExcecute = File.ReadAllText(delta.Path);
                Request request          = session.NewAdhocQuery(xqueryToExcecute);
                session.SubmitRequest(request).AsString();
            }
        }
        private void AssertThatTheLatestDeltaDescriptionIs(string expectedDescription)
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(_connectionString));


            using (var session = contentSource.NewSession())
            {
                Request request = session.NewAdhocQuery(@"xquery version ""1.0-ml"";
                                                        declare namespace m=""http://mldeploy.org"";
                                                        for $doc in //*:LatestDelta return $doc/m:Description/text()"
                                                        );
                var result = session.SubmitRequest(request).AsString();

                Assert.AreEqual(expectedDescription, result);
            }
        }
        private void SetupLatestDeltaAs(long deltaNumber, string description)
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(_connectionString));


            using (var session = contentSource.NewSession())
            {
                string xquery = string.Format(@"xquery version ""1.0-ml"";
                                              xdmp:document-insert(""/mldeploy/latest.xml"", <LatestDelta xmlns:m=""http://mldeploy.org""><m:Number>{0}</m:Number><m:Description>{1}</m:Description></LatestDelta>
                                                                   ,()
                                                                   );"
                                              , deltaNumber, description);
                Request request = session.NewAdhocQuery(xquery);
                session.SubmitRequest(request).AsString();
            }
        }
Esempio n. 11
0
        private string GetLatestDeltaDescriptionFromDatabase()
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(_connectionString));


            using (var session = contentSource.NewSession())
            {
                const string xqueryToExcecute = @"xquery version ""1.0-ml"";
                                           declare namespace m=""http://mldeploy.org"";
                                           for $doc in //*:LatestDelta 
                                           return $doc/m:Description/text()";

                Request request = session.NewAdhocQuery(xqueryToExcecute);
                string  result  = session.SubmitRequest(request).AsString();
                return(result);
            }
        }
        private void DeleteTheLatestDeltaInTheDatabase()
        {
            ContentSource contentSource = ContentSourceFactory.NewContentSource(new Uri(_connectionString));


            using (var session = contentSource.NewSession())
            {
                try
                {
                    Request request = session.NewAdhocQuery(@"xquery version ""1.0-ml"";
                                                         xdmp:document-delete(""/mldeploy/latest.xml"")");
                    session.SubmitRequest(request).AsString();
                }
                catch
                {
                    //Do Nothing, since ML will throw exception if document doesn't exist
                    //Guarantees the isolation of the integration tests
                }
            }
        }