static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); CouchConnector conn = new CouchConnector(Properties.Settings.Default.CouchServerName, Properties.Settings.Default.CouchPort, Properties.Settings.Default.DBName); XmlConfigurator.Configure(); conn.FormBorderStyle = FormBorderStyle.FixedDialog; //conn.MaximizeBox = false; //conn.MinimizeBox = true; conn.StartPosition = FormStartPosition.CenterScreen; try { Application.Run(conn); }catch (Exception e) { MessageBox.Show("Critical Error occured, Application will exit.\n Please check the error log for details"); log.Error("Application level error occured: " + e.Message); log.Error("Detailed trace" + e.StackTrace); } /*CouchWebTestForm couchWebTestForm=new CouchWebTestForm(); * Application.Run(couchWebTestForm);*/ }
public FeedServiceWorker(ILogger <FeedServiceWorker> logger) { var couch = new CouchConnector(); var cluster = couch.InitializeCouchDatabase("http://127.0.0.1:8091/", "Administrator", "Sugenthran@09"); _bucket = cluster.OpenBucket("feeds"); _logger = logger; }
private void button6_Click(object sender, EventArgs e) { var conn = new CouchConnector(this); conn.FormBorderStyle = FormBorderStyle.FixedDialog; //conn.MaximizeBox = false; //conn.MinimizeBox = true; conn.StartPosition = FormStartPosition.CenterScreen; conn.Show(); }
private byte[] DocumentGet(string sDocumentId, bool isRetry, out bool sError, out string sErrorText, CouchVo cvo) { sError = false; sErrorText = ""; byte[] btData = null; HttpWebRequest webRequester = null; string sGetURL = null; try { string _connUri = String.Format("http://{0}:{1}/", cvo.serverName, cvo.serverport); string _dbName = cvo.dbName; sGetURL = _connUri + _dbName + "/" + sDocumentId; try { if (isRetry) { webRequester = CreateRequest(sGetURL, _connUri, cvo.userName, cvo.pwd, true); } else { webRequester = CreateRequest(sGetURL, _connUri, cvo.userName, cvo.pwd, false); } if (webRequester == null) { sError = true; sErrorText = "Document get aborted:" + sGetURL + ":" + "Session failure" + " : DocID :" + sDocumentId; return(btData); } } catch (Exception e) { if (webRequester != null) { try { webRequester.Abort(); }catch (Exception e1) { log.Info("Error aborting webrequst in get document" + e1.StackTrace + " : " + e1.Message); } webRequester = null; } sGetURL = null; sError = true; sErrorText = "Document get aborted:" + sGetURL + ":" + e.Message + " : DocID :" + sDocumentId; log.Error("Document get error:" + sDocumentId + ":" + e.Message); return(btData); } using (var response = (HttpWebResponse)webRequester.GetResponse()) { if (DocGetErrAndRetry(response.ResponseUri.ToString(), sDocumentId, out sError, out sErrorText, cvo, false)) { if ((!isRetry)) { //Console.WriteLine("Doing re-try"); btData = DocumentGet(sDocumentId, true, out sError, out sErrorText, cvo); //perform re-try since session expired unexpectedly return(btData); } else { return(btData); //return error since re-try also failed } } // Get the stream. using (Stream stream = response.GetResponseStream()) { // Use the ReadFully method from the link above: btData = CouchConnector.ReadFully(stream, response.ContentLength); sError = false; sErrorText = "Got Document"; } } } catch (Exception exp) { /* log.Debug(string.Format("Get Doc Failed:{0} url{1} user{2} pwd {3}", exp.StackTrace, * sGetURL,_userId,_password));*/ log.Error("Document get error:" + sDocumentId + ":" + exp.Message); DocGetErrAndRetry(exp.Message, sDocumentId, out sError, out sErrorText, cvo, true); }finally { if (webRequester != null) { try { webRequester.Abort(); } catch (Exception e1) { log.Info("Error aborting webrequst in get document" + e1.StackTrace + " : " + e1.Message); } webRequester = null; } } return(btData); }