Exemplo n.º 1
0
        /***
         * This method will be used for couch authentication functionality
         ***/
        private static string couchLoginVerification(String docName, out string msg, out bool added, bool isAdminVerify)
        {
            added = false;
            msg   = string.Empty;

            DocumentType = Document.DocTypeNames.PDF;
            string fileName     = docName;
            int    lastSlashIdx = fileName.LastIndexOf('\\');
            string fName        = fileName.Substring(lastSlashIdx + 1);
            var    sErrCode     = string.Empty;
            var    sErrText     = string.Empty;

            //byte[] fileBytes = File.ReadAllBytes(fileName);
            byte[]   fileBytes   = SimpleHash.convertToByteArr("This is connection test");
            Document couchDocObj = (Document) new Document_Couch(fileName, fName, DocumentType);

            couchDocObj.SetPropertyData("jak prop1", "value");
            string storageID = System.Guid.NewGuid().ToString();

            GldocName = storageID;
            // Console.WriteLine("Added doc name :" + GldocName);
            SecuredCouchConnector CouchConnectorObj = null;

            //StorageID = "1234";
            if (couchDocObj.SetSourceData(fileBytes, storageID, false))
            {
                var dStorage = new DocStorage_CouchDB();
                if (isAdminVerify)
                {
                    CouchConnectorObj = new SecuredCouchConnector(hostname, portName, secWebPort, dbName, adminUserid, adminPass, isSec);
                    dStorage.SecuredAddDocument(CouchConnectorObj, ref couchDocObj, out sErrCode, out sErrText);
                }
                else
                {
                    CouchConnectorObj = new SecuredCouchConnector(hostname, portName, secWebPort, dbName, userid, pass, isSec);
                    dStorage.SecuredAddDocument(CouchConnectorObj, ref couchDocObj, out sErrCode, out sErrText);
                }
                if (sErrCode == "0")
                {
                    added = true;
                    msg   = "Added" + fileName;
                }
                else
                {
                    added = false;
                    msg   = sErrText;
                }
            }
            return(storageID);
        }
Exemplo n.º 2
0
        private static string addDocumentToCouch(String docName, out string msg, out bool added, System.Windows.Forms.RichTextBox textBox)
        {
            added = false;
            msg   = string.Empty;

            DocumentType = Document.DocTypeNames.PDF;
            string fileName     = docName;
            int    lastSlashIdx = fileName.LastIndexOf('\\');
            string fName        = fileName.Substring(lastSlashIdx + 1);
            var    sErrCode     = string.Empty;
            var    sErrText     = string.Empty;

            byte[]   fileBytes   = File.ReadAllBytes(fileName);
            Document couchDocObj = (Document) new Document_Couch(fileName, fName, DocumentType);

            couchDocObj.SetPropertyData("jak prop1", "value");
            string storageID = System.Guid.NewGuid().ToString();

            GldocName = storageID;
            // Console.WriteLine("Added doc name :" + GldocName);
            SecuredCouchConnector CouchConnectorObj = null;

            //StorageID = "1234";
            if (couchDocObj.SetSourceData(fileBytes, storageID, false))
            {
                var dStorage = new DocStorage_CouchDB();

                CouchConnectorObj = new SecuredCouchConnector(hostname, portName, secWebPort, dbName, userid, pass, isSec);
                dStorage.SecuredAddDocument(CouchConnectorObj, ref couchDocObj, out sErrCode, out sErrText);
                if (sErrCode == "0")
                {
                    added = true;
                    msg   = "Added" + fileName;
                    textBox.AppendText("Document ID:" + GldocName);
                    textBox.AppendText("\n");
                }
                else
                {
                    added = false;
                    msg   = sErrText;
                }
            }
            return(storageID);
        }