Пример #1
0
        private void button11_Click(object sender, EventArgs e)
        {
            ArchJobErrorDesc edesc = ArchJobErrorDesc.getInstance();

            edesc.getErrorCode("");
            CouchUtil util = new CouchUtil();

            CouchVo vo = new CouchVo();

            vo.userName      = "******";
            vo.pwd           = "mydbuser";
            vo.serverName    = "localhost";
            vo.serverport    = "5984";
            vo.dbName        = "mydb";
            vo.adminUserName = "******";
            vo.adminPwd      = "adminadmin";
            PawnDocRegVO docRegVO = new PawnDocRegVO();

            docRegVO.DocID           = 1234;
            docRegVO.StorageID       = "05f4b578-d22b-4d1e-8e24-6fa0ee581b38";
            docRegVO.TargetCouchDBID = 4444;
            string   msg     = null;
            bool     retFlag = false;
            Document doc     = util.GetDocument(out msg, out retFlag, vo, docRegVO);

            log.Debug("Got Doc " + doc);
        }
Пример #2
0
        private void button8_Click(object sender, EventArgs e)
        {
            CouchVo vo = new CouchVo();

            vo.userName      = "******";
            vo.pwd           = "mydbuser";
            vo.serverName    = "localhost";
            vo.serverport    = "5984";
            vo.dbName        = "mydb";
            vo.adminUserName = "******";
            vo.adminPwd      = "adminadmin";


            CouchUtil util    = new CouchUtil();
            string    retMsg  = null;
            bool      retBool = false;

            for (int i = 0; i < 1; i++)
            {
                util.deleteDBInCouch("clx_jan_2011" + i, out retMsg, out retBool, vo);
                appendConsole("_____________________________");
                appendConsole("Ret MSG" + retMsg);
                appendConsole("Ret retBool" + retBool);
                appendConsole("_____________________________");
            }
        }
Пример #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.fileNameText.Text))
            {
                MessageBox.Show("Please select a valid file");
                return;
            }
            if (!File.Exists(this.fileNameText.Text))
            {
                MessageBox.Show("Entered file does not exist");
                return;
            }

            this.couchVO.fileWithPath = this.fileNameText.Text;
            var couchUtil = new CouchUtil(this.couchVO);

            this.resultText.AppendText("\n");
            this.resultText.AppendText("Adding document..." + DateTime.Now);
            Enabled = false;
            var sw = new Stopwatch();

            sw.Start();

            couchUtil.storeDocument(this.couchVO, this.resultText);

            sw.Stop();
            Enabled = true;
            this.resultText.AppendText("\n");
            this.resultText.AppendText("Completed At..." + DateTime.Now);
            this.resultText.AppendText("\n");
            this.resultText.AppendText("Time Taken :" + sw.ElapsedMilliseconds + " Msec's");
        }
        public void processDelete()
        {
            CouchUtil cUtil = new CouchUtil();

            bool   isError;
            string errorText;

            foreach (var doc in docList)
            {
                bool   SouceDocDeleted;
                string exception;
                //cUtil.DeleteDocument(srcvo, doc, out exception, out SouceDocDeleted);
                //new CouchUtil(srcvo).GetDocument(out msg, out gotDoc, srcvo, regVO);
                CouchArchiverDeleteHelper.getInstance().Document_Delete(out errorText, out isError, srcvo, doc);

                if (!isError)
                {
                    successCount++;
                }
                else
                {
                    failCount++;
                }
                //
            }
            log.Info(string.Format(" Success delete count {0} fail count {1} Total count {2}", successCount, failCount, docList.Count));
        }
Пример #5
0
        private bool connectAction(ref CouchVo vo)
        {
            if (!ValidateText())
            {
                MessageBox.Show("Please check input");
                return(false);
            }

            /*Properties.Settings.Default.CouchServerName = this.cServerNameTxt.Text;
             * Properties.Settings.Default.CouchPort = this.cServerPortTxt.Text;
             * Properties.Settings.Default.DBName = this.cDBNameTxt.Text;*/
            string userNameS = this.uname.Text;
            string pwdS      = this.pwd.Text;

            if (string.IsNullOrEmpty(userNameS) || string.IsNullOrEmpty(pwdS))
            {
                MessageBox.Show("Please enter valid user name and password");
                return(false);
            }

            //CouchVo vo = new CouchVo();
            vo.userName      = this.uname.Text;
            vo.pwd           = this.pwd.Text;
            vo.serverName    = this.cServerNameTxt.Text;
            vo.serverport    = this.cServerPortTxt.Text;
            vo.dbName        = this.cDBNameTxt.Text;
            vo.adminUserName = this.adminUserTxt.Text;
            vo.adminPwd      = this.adminPwdTxt.Text;

            CouchUtil util = new CouchUtil(vo);

            this.Enabled = false;
            if (isTargetCouchForm)
            {
                vo = util.couchDualLogin(vo);
            }
            else
            {
                vo = util.couchLogin(vo);
            }
            this.Enabled = true;
            String msg = "Failed to Connect";

            msg += "\n";
            msg += vo.errorMSG;
            if (vo.isError)
            {
                //this.mainForm.appendConsole(msg);
                log.Error(msg);
                MessageBox.Show(msg);
                return(false);
            }
            else
            {
                log.Info("Couch Connection Success!!" + vo.serverName + ":" + vo.dbName);
                return(true);
            }
        }
Пример #6
0
 private void button2_Click_1(object sender, EventArgs e)
 {
     //this.resultText.AppendText("\n");
     //this.resultText.AppendText("Getting document..." + DateTime.Now);
     if (string.IsNullOrEmpty(this.docIDText.Text))
     {
         MessageBox.Show("Please enter document ID to search.");
         return;
     }
     Enabled    = false;
     this.cUtil = new CouchUtil(this.couchVO);
     this.couchVO.documentID = this.docIDText.Text;
     this.cUtil.GetDocument(this.couchVO, this.resultText);
     Enabled = true;
     //this.resultText.AppendText("Completed..." + DateTime.Now);
 }
Пример #7
0
        private void button14_Click(object sender, EventArgs e)
        {
            ArchJobErrorDesc edesc = ArchJobErrorDesc.getInstance();

            edesc.getErrorCode("");
            CouchUtil util = new CouchUtil();


            CouchVo vo = new CouchVo();

            vo.userName      = "******";
            vo.pwd           = "pa55w0rd1";
            vo.serverName    = "couchdb-dev";
            vo.serverport    = "5985";
            vo.dbName        = "clx_cust_docs_dev";
            vo.adminUserName = "******";
            vo.adminPwd      = "adminadmin";

            PawnDocRegVO docRegVO = new PawnDocRegVO();

            docRegVO.DocID             = 1234;
            docRegVO.StorageID         = "30fcdd50-b81a-4dfa-b837-9da56e4c9e3f";
            docRegVO.TargetCouchDBID   = 4444;
            docRegVO.TargetCouchDBName = "clx_7_2010";
            string   msg     = null;
            bool     retFlag = false;
            Document doc     = util.GetDocument(out msg, out retFlag, vo, docRegVO);

            log.Debug("Got Doc " + doc);


            vo               = new CouchVo();
            vo.userName      = "******";
            vo.pwd           = "mydbuser";
            vo.serverName    = "localhost";
            vo.serverport    = "5984";
            vo.dbName        = docRegVO.TargetCouchDBName;
            vo.adminUserName = "******";
            vo.adminPwd      = "adminadmin";
            string msg1 = "";
            bool   ret  = false;

            util.addDocumentToCouch(vo, doc, out msg1, out ret);
        }
Пример #8
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string  dbName = this.dbNameText.Text;
            CouchVo vo     = new CouchVo();

            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";
            CouchUtil     util    = new CouchUtil();
            string        msg     = null;
            bool          retFlag = false;
            List <string> dbNames = new List <string>();

            dbNames.Add("clx_10_2010");
            dbNames.Add("clx_10_2011");
            dbNames.Add("clx_11_2010");
            dbNames.Add("clx_11_2011");
            dbNames.Add("clx_12_2010");
            dbNames.Add("clx_1_2011");
            dbNames.Add("clx_2_2011");
            dbNames.Add("clx_3_2011");
            dbNames.Add("clx_4_2008");
            dbNames.Add("clx_4_2011");
            dbNames.Add("clx_5_2010");
            dbNames.Add("clx_5_2011");
            dbNames.Add("clx_6_2011");
            dbNames.Add("clx_7_2010");
            dbNames.Add("clx_7_2011");
            dbNames.Add("clx_8_2010");
            dbNames.Add("clx_8_2011");
            dbNames.Add("clx_8_2010");
            dbNames.Add("clx_9_2010");
            dbNames.Add("clx_9_2011");
            foreach (var name in dbNames)
            {
                util.deleteDBInCouch(name, out msg, out retFlag, vo);
            }
            MessageBox.Show("DB deleted ");
        }
Пример #9
0
        private void createDBClick(object sender, EventArgs e)
        {
            string  dbName = this.dbNameText.Text;
            CouchVo vo     = new CouchVo();

            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";
            CouchUtil util    = new CouchUtil();
            string    msg     = null;
            bool      retFlag = false;

            util.createDBInCouch(dbName, out msg, out retFlag, vo);
            MessageBox.Show("DB Created " + retFlag + " Message " + msg);
            //util.
        }
        private bool addDBNameInCouchAndDB(string name, out PwnDocArchDBRepVO repvo)
        {
            CouchVo vo = this.mainForm.getMainForm().getTargetCouch();

            repvo = new PwnDocArchDBRepVO();
            if (string.IsNullOrEmpty(vo.adminUserName))
            {
                log.Error("Vo values are not set DB Creation Aborted");
                return(false);
            }
            CouchUtil util    = new CouchUtil();
            string    retMsg  = null;
            bool      retBool = false;

            try
            {
                util.createDBInCouch(name, out retMsg, out retBool, vo);

                if (!retBool)
                {
                    log.Error("Couch DB Creation failed due to :" + retMsg);
                    return(false);
                }
            }catch (Exception e)
            {
                log.Error("Couch DB Creation failed", e);
                log.Error(e.StackTrace);
                return(false);
            }

            try
            {
                List <PwnDocArchDBRepVO> list = new List <PwnDocArchDBRepVO>();
                repvo.DBName = name;
                repvo.DBInfo = vo.serverName + ":" + vo.serverport + ":" + vo.userName;
                string str = "";
                //repvo.Id = ConnDAO.getInstance().getUniqueID(ref str,connection1);
                list.Add(repvo);

                /*if (repvo.Id == 0)
                 * {
                 *  log.Error("Did not get unique id for db");
                 *  return false;
                 * }*/
                int dbID = 0;
                if (!CouchDAO.getInstance().AddCouchDbToRepos(list, out dbID))
                {
                    log.Error("create dbname in database failed");
                    return(false);
                }
                repvo.Id = dbID;
            }
            catch (Exception e)
            {
                log.Error("Couch DB Creation in DB failed", e);
                log.Error(e.StackTrace);
                return(false);
            }

            return(true);
        }