public void AddDocumentToCouch(string rDocument)
 {
     try
     {
         bool   error;
         string retMSG;
         //  this.targetCouchVO.dbName = vo.TargetCouchDBName;
         SavedDoc       = CouchArchiverAddHelper.getInstance().Document_Add(rDocument, out error, out retMSG, JobAllocationHandlerMain.getTargetCouch(), vo.StorageID, vo.TargetCouchDBName);
         this.storageID = vo.StorageID;
         if (!SavedDoc)
         {
             if (retMSG != null && retMSG.Contains("already exists"))
             {
                 SavedDoc = true;
             }
             log.Error("Add Document failed:" + retMSG);
         }
     }
     catch (Exception e)
     {
         log.Error(string.Format("Save Doc failed for {0} target db{1}", vo.StorageID, vo.TargetCouchDBName), e);
         SavedDoc  = false;
         exception = e.Message;
     }
     finally
     {
         rDocument = null;
     }
 }
Example #2
0
        private void GetDocButton_Click(object sender, EventArgs e)
        {
            CouchVo vo = new CouchVo();

            vo.serverName    = "localhost";
            vo.serverport    = "5984";
            vo.userName      = "******";
            vo.pwd           = "pa55w0rd1";
            vo.serverName    = Properties.Settings.Default.CouchServerName;
            vo.serverport    = Properties.Settings.Default.CouchPort;
            vo.dbName        = "clx_cust_docs_dev";
            vo.adminUserName = "******";
            vo.adminPwd      = "adminadmin";
            PawnDocRegVO regvo = new PawnDocRegVO();

            if (string.IsNullOrEmpty(this.doctext.Text))
            {
                return;
            }
            regvo.StorageID = this.doctext.Text;
            string errorText = "";
            bool   isError   = false;

            /* Document doc=CouchArchiverGetHelper.getInstance().GetDocument(out errorText,out isError, vo, regvo);
             * MessageBox.Show("Is Error " + isError + " Text " + errorText);*/

            string rdoc = CouchArchiverGetHelper.getInstance().GetRawDocument(out errorText, out isError, vo, regvo);

            MessageBox.Show("Is Error " + isError + " Text " + errorText);

            bool   addDocError = false;
            string addError    = "";

            vo.dbName   = "clx_11_2010";
            vo.userName = "******";
            vo.pwd      = "pa55w0rd1";

            bool added = CouchArchiverAddHelper.getInstance().Document_Add(rdoc, out addDocError, out addError, vo, regvo.StorageID);

            if (added)
            {
                MessageBox.Show(" Added ,,,,,Is Error " + isError + " Text " + addError);
            }
            else
            {
                MessageBox.Show("Not Added ,,,,,Is Error " + isError + " Text " + addError);
            }
        }
        public void process()
        {
            //fileWithPath = "C:\\dev\\dev_jak2\\devwork_jkingsley\\Phase2App\\CouchConnectorApp\\test\\sample.pdf";
            bool         addedDocError;
            string       addError;
            string       geterrorText;
            bool         getisError;
            PawnDocRegVO regVO = new PawnDocRegVO();

            // regVO.StorageID = "f544ed6c-6c02-4711-9727-626dabe95a4a";
            regVO.StorageID = docID;
            string rdoc = CouchArchiverGetHelper.getInstance().GetRawDocument(out geterrorText, out getisError, srcvo, regVO);

            int successCount = 0;
            int failedCount  = 0;

            foreach (var doc in docList)
            {
                //addDocumentToCouch(fileWithPath, doc,out added);
                if (rdoc != null)
                {
                    //rdoc.Replace("f544ed6c-6c02-4711-9727-626dabe95a4a", doc);
                    rdoc.Replace(docID, doc);
                    regVO.StorageID = docID;
                }
                bool added = CouchArchiverAddHelper.getInstance().Document_Add(rdoc, out addedDocError, out addError, srcvo, doc);
                if (addedDocError)
                {
                    log.Error(string.Format("Doc Add failed for docid{0}, addedDocError{1} addError{2}", doc, addedDocError, addError));
                    failedCount++;
                }
                else
                {
                    successCount++;
                }
                //log.Info(string.Format("Doc Add for docid{0}, addedDocError{1} addError{2}",doc,addedDocError,addError));
                Thread.Sleep(50);
                //log.Debug("Processing ... "+doc);
            }
            log.Info(string.Format(" Success count {0} fail count {1} Total count {2}", successCount, failCount, docList.Count));
        }