Пример #1
0
 public override IDbTransaction BeginTransaction(IsolationLevel isoLevel)
 {
     try
     {
         IDbTransaction trn = InternalConnection.BeginTransaction(isoLevel);
         return(trn);
     }
     catch (Exception e)
     {
         GXLogging.Warn(log, "BeginTransaction Error ", e);
         IDbTransaction trn = InternalConnection.BeginTransaction(IsolationLevel.Unspecified);
         if (trn.IsolationLevel != isoLevel)
         {
             GXLogging.Error(log, "BeginTransaction Error, could not open new transaction isoLevel=" + isoLevel, e);
             throw new GxADODataException("Begin transaction error in informix", e);
         }
         return(trn);
     }
 }
Пример #2
0
        public SearchResult Search(string query, int itemsPerPage, int pageNumber, IGxContext context)
        {
            if (string.IsNullOrEmpty(query))
            {
                return(SearchResult.Empty);
            }
            if (context != null)
            {
                query = TranslateQuery(query, context);
            }

            IndexSearcher searcher = GetSearcher();

            if (searcher == null)
            {
                return(new EmptySearchResult());
            }

            try
            {
                QueryParser qp = new QueryParser(Indexer.LUCENE_VERSION, IndexRecord.CONTENTFIELD, m_analyzer);

                qp.AllowLeadingWildcard = true;
                qp.DefaultOperator      = QueryParser.Operator.AND;
                Query    q  = qp.Parse(IndexRecord.ProcessContent(query));
                DateTime t1 = DateTime.Now;

                TopDocs  results = searcher.Search(q, int.MaxValue);
                DateTime t2      = DateTime.Now;

                return(new LuceneSearchResult(results, itemsPerPage, pageNumber, TimeSpan.FromTicks(t2.Ticks - t1.Ticks).TotalMilliseconds));
            }
            catch (ParseException)
            {
                GXLogging.Error(log, "Search error", new SearchException(SearchException.PARSEERROR));
                return(SearchResult.Empty);
            }
            catch (Exception ex)
            {
                GXLogging.Debug(log, "Search error", ex);
                throw new SearchException(SearchException.IOEXCEPTION);
            }
        }
Пример #3
0
        public override IDataReader GetDataReader(
            IGxConnectionManager connManager,
            IGxConnection con,
            GxParameterCollection parameters,
            string stmt, ushort fetchSize,
            bool forFirst, int handle,
            bool cached, SlidingTime expiration,
            bool hasNested,
            bool dynStmt)
        {
            IDataReader idatareader;

#if !NETCORE
            GXLogging.Debug(log, "ExecuteReader: client cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode() + " PreparedStmt " + preparedStmts);
            if (preparedStmts)
            {
                idatareader = new GxMySQLCursorDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, hasNested, dynStmt);
            }
            else
            {
                idatareader = new GxMySQLDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt, preparedStmts);
            }
#else
            if (!hasNested)//Client Cursor
            {
                GXLogging.Debug(log, "ExecuteReader: client cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode() + " PreparedStmt " + preparedStmts);
                if (preparedStmts)
                {
                    idatareader = new GxMySQLCursorDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, hasNested, dynStmt);
                }
                else
                {
                    idatareader = new GxMySQLDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt, preparedStmts);
                }
            }
            else //Server Cursor
            {
                GXLogging.Debug(log, "ExecuteReader: server cursor=" + hasNested + ", handle '" + handle + "'" + ", hashcode " + this.GetHashCode());
                idatareader = new GxMySqlMemoryDataReader(connManager, this, con, parameters, stmt, fetchSize, forFirst, handle, cached, expiration, dynStmt);
            }
#endif
            return(idatareader);
        }
Пример #4
0
 public static WMIApplicationServer Instance()
 {
     lock (syncObj)
     {
         if (instance == null)
         {
             try
             {
                 instance = new WMIApplicationServer();
                 Instrumentation.Publish(instance);
             }
             catch (Exception e)
             {
                 GXLogging.Error(log, "WMI Error", e);
             }
         }
     }
     return(instance);
 }
Пример #5
0
 public string Get(string key)
 {
     key = GXUtil.NormalizeKey(key);
     if (_httpSession != null)
     {
         GXLogging.Debug(log, "GetObject SessionId : " + _httpSession.SessionID);
         if (_httpSession[key] == null)
         {
             GXLogging.Debug(log, "Get key: " + key + " is Empty");
             return(string.Empty);
         }
         else
         {
             object value = _httpSession[key];
             GXLogging.Debug(log, "Get key: " + key + "=" + value.ToString());
             return(value.ToString());
         }
     }
     return(string.Empty);
 }
Пример #6
0
 private void DeleteFiles(object odirectory)
 {
     try
     {
         GxDirectory directory = (GxDirectory)odirectory;
         long        now       = DateTime.Now.Ticks;
         foreach (GxFile file in directory.GetFiles("*.*"))
         {
             if (ExpiredFile(file.GetAbsoluteName(), now))
             {
                 file.Delete();
             }
             GXLogging.Debug(log, "DeleteFiles ", file.GetName());
         }
     }
     catch (Exception ex)
     {
         GXLogging.Error(log, "DeleteFiles error", ex);
     }
 }
Пример #7
0
 public void ajax_rspEndCmp()
 {
     context.CmpDrawLvl--;
     try
     {
         GXCmpContent cmp = (GXCmpContent)cmpContents.Pop();
         WebComponents.Put(cmp.Id, cmp.Content);
         if (context.isSpaRequest())
         {
             if (context.CmpDrawLvl > 0)
             {
                 ((GXCmpContent)cmpContents.Peek()).Content += cmp.Content;
             }
         }
     }
     catch (Exception ex)
     {
         GXLogging.Error(log, "ajax_rspEndCmp error", ex);
     }
 }
Пример #8
0
 private void Enqueue(IndexAction action)
 {
     lock (syncObj)
     {
         if (!worker.IsAlive)
         {
             worker = new Thread(new ThreadStart(BackgroundIndexer));
             worker.Start();
         }
     }
     if ((m_queue.Count > Settings.Instance.MaxQueueSize))
     {
         GXLogging.Debug(log, "Indexer Enqueue waiting...");
     }
     while (m_queue.Count > Settings.Instance.MaxQueueSize)
     {
         Thread.Sleep(50);
     }
     m_queue.Enqueue(action);
 }
Пример #9
0
 override public void Open()
 {
     try
     {
         InternalConnection.Open();
         if (!m_autoCommit)
         {
             m_transaction = InternalConnection.BeginTransaction(m_isolationLevel);
         }
         else
         {
             m_transaction = null;
         }
     }
     catch (Exception e)
     {
         GXLogging.Error(log, "Return GxConnection.Open Error ", e);
         throw (new GxADODataException(e));
     }
 }
Пример #10
0
 public string HtmlClean()
 {
     try
     {
         object rawDoc = Assembly.LoadFrom(GXUtil.ProcessorDependantAssembly("NTidy.dll")).CreateInstance("NTidy.TidyDocument");
         if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tidy.cfg")))
         {
             rawDoc.GetType().GetMethod("LoadConfig").Invoke(rawDoc, new object[] { Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tidy.cfg") });
         }
         rawDoc.GetType().GetMethod("LoadFile").Invoke(rawDoc, new object[] { _file.FullName });
         rawDoc.GetType().GetMethod("CleanAndRepair").Invoke(rawDoc, null);
         String htmlcleaned = (string)rawDoc.GetType().GetMethod("ToString").Invoke(rawDoc, null);
         return(htmlcleaned);
     }
     catch (Exception ex)
     {
         GXLogging.Error(log, "HTMLClean error, file:" + _file.FullName, ex);
         return("");
     }
 }
Пример #11
0
        public static IGXWebSocketAsync GetWebSocketProvider()
        {
            IGXWebSocketAsync ws = null;

            try
            {
#if NETCORE
                ws = new WSHandler();
#else
                Type t = Type.GetType("GeneXus.Http.WebSocket.WSHandler,gxwebsocket");
                ws = (IGXWebSocketAsync)Activator.CreateInstance(t);
#endif
                GXLogging.Debug(log, "ASP.NET Websocket instance created ok");
            }
            catch (Exception e)
            {
                GXLogging.Error(log, "Could not initialize ASP.NET WebSocket ", e);
            }
            return(ws);
        }
Пример #12
0
        public static List <string> GetAddress(String location)
        {
            String urlString = MAPS_URI + "geocode/json?latlng=" + GXUtil.UrlEncode(location) + "&sensor=false";
            String ApiKey    = "";

            if (Config.GetValueOf("GoogleApiKey", out ApiKey))
            {
                urlString += "&key=" + ApiKey;
            }
            String response = GXGeolocation.GetContentFromURL(urlString);

            List <string> result = new List <string>();

            try
            {
                if (!string.IsNullOrEmpty(response))
                {
                    StringReader   sr   = new StringReader(response);
                    JsonTextReader tr   = new JsonTextReader(sr);
                    JObject        json = (JObject)(tr.DeserializeNext());
                    if (json.Contains("results"))
                    {
                        JArray results = (JArray)json["results"];
                        for (int i = 0; i < results.Length; i++)
                        {
                            JObject jo = (JObject)results[i];
                            if (jo.Contains("formatted_address"))
                            {
                                result.Add((string)jo["formatted_address"]);
                            }
                        }
                    }
                }
            }
            catch (JsonException ex)
            {
                GXLogging.Error(log, "getAddress error json:" + response, ex);
            }

            return(result);
        }
Пример #13
0
 internal short NovellConnect()
 {
     try
     {
         if (_conn != null)
         {
             _conn.Disconnect();
             _conn = null;
         }
         _conn = new LdapConnection();
         _conn.SecureSocketLayer = (_secure == 1);
         _conn.Connect(_server, getLdapConnectionPort());
         _conn.Bind(_user, _password);
         return((short)((_conn.Connected) ? 1 : 0));
     }
     catch (Exception ex)
     {
         GXLogging.Error(log, "Connect Method Error.", ex);
         return(0);
     }
 }
Пример #14
0
 private JObject GetGXStateTokens(string state)
 {
     try
     {
         if (!string.IsNullOrEmpty(state))
         {
             if (Preferences.UseBase64ViewState())
             {
                 state = Encoding.UTF8.GetString(Convert.FromBase64String(state));
             }
             return(JSONHelper.ReadJSON <JObject>(state));
         }
     }
     catch (Exception e)
     {
         GXLogging.Debug(log, "Error parsing GXState");
         GXLogging.Debug(log, e.ToString());
         GXLogging.Debug(log, state);
     }
     return(null);
 }
Пример #15
0
 public override long GetInt64(int i)
 {
     if (reader.GetFieldType(i) == typeof(decimal))
     {
         try
         {
             return(reader.GetInt64(i));
         }
         catch (Exception fe)
         {
             GXLogging.Debug(log, "GetInt64 fieldtype Error, decimal value", fe);
             decimal result = GxInformix.GetIfxDecimal(reader, i);
             GXLogging.Debug(log, "GetInt64 decimal:" + result);
             return(Convert.ToInt64(result));
         }
     }
     else
     {
         return(base.GetInt64(i));
     }
 }
Пример #16
0
 private void Logout()
 {
     SendAndWaitResponse("QUIT", MailConstants.MAIL_ServerReplyInvalid);
     count = 0;
     try
     {
         connection.Close();//Don't use .Shutdown(SocketShutdown.Both); SocketController calls Shutdown(SocketShutdown.Both)on onReceive method.
     }
     catch (Exception exc)
     {
         GXLogging.Error(log, "Error logging out", exc);
         throw new GXMailException(exc.Message, MailConstants.MAIL_ConnectionLost);
     }
     finally
     {
         if (connection != null)
         {
             connection.Close();
         }
     }
 }
Пример #17
0
        public void Skip(GXPOP3Session session)
        {
            try
            {
                Skip();
            }
            catch (NoMessagesException exc)
            {
#if DEBUG
                GXLogging.Debug(log, "Receive error", exc);
#endif
                session.HandleMailException(exc);
            }
            catch (GXMailException exc)
            {
#if DEBUG
                GXLogging.Error(log, "Skip error", exc);
#endif
                session.HandleMailException(exc);
            }
        }
Пример #18
0
        public void Receive(GXPOP3Session session, GXMailMessage msg)
        {
            try
            {
                Receive(msg);
            }
            catch (NoMessagesException exc)
            {
#if DEBUG
                GXLogging.Debug(log, "Receive error", exc);
#endif
                session.HandleMailException(exc);
            }
            catch (GXMailException exc)
            {
#if DEBUG
                GXLogging.Error(log, "Receive error", exc);
#endif
                session.HandleMailException(exc);
            }
        }
Пример #19
0
 private void Delete()
 {
     GXLogging.Debug(log, "Deleting message");
     if (message != null)
     {
         try
         {
             message.Delete(true);
             message = null;
         }
         catch (Exception exc)
         {
             GXLogging.Error(log, "Error deleting message", exc);
         }
     }
     else
     {
         GXLogging.Error(log, "No current message");
         throw new GXMailException("No current message", 26);
     }
 }
Пример #20
0
        private void Logout()
        {
            SendNL("QUIT");

            try
            {
                connection.Close();//Don't use .Shutdown(SocketShutdown.Both); SocketController calls Shutdown(SocketShutdown.Both)on onReceive method.
            }
            catch (Exception exc)
            {
                GXLogging.Error(log, "Error logging out", exc);
                throw new GXMailException(exc.Message, MAIL_ConnectionLost);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
        }
Пример #21
0
 public double STArea()
 {
     if (_innerValue != null &&
         !_innerValue.ToString().Equals(EMPTY_GEOGRAPHY) &&
         GeographicType == GeoGraphicTypeValue.Polygon)
     {
         try {
             return(((SqlDouble)(ClassLoader.Invoke(_innerValue, "STArea", Array.Empty <object>()))).Value);
         }
         catch (Exception ex) {
             GXLogging.Debug(log, "Error calling Area() exception:");
             GXLogging.Debug(log, ex.ToString());
             return(0);
         }
     }
     else
     {
         GXLogging.Debug(log, "STArea: _innerValue is not valid");
         return(0);
     }
 }
Пример #22
0
        private void SendAttachment(string sTime, string fileNamePath, string attachDir)
        {
            GXLogging.Debug(log, "Sending attachment: " + fileNamePath);
            string fileName     = fileNamePath;
            string fullfileName = fileName;

            fileName = Path.GetFileName(fileNamePath);

            if (!Path.IsPathRooted(fullfileName))
            {
                fullfileName = attachDir + fullfileName;
            }

            SendNL(getNextMessageIdMixed(sTime, false));
            SendNL("Content-Type: " + "application/octet-stream");
            SendNL("Content-Transfer-Encoding: " + "base64");
            SendNL("Content-Disposition: " + "attachment; filename=\"" + ToEncodedString(fileName) + "\"");
            SendNL("");
            SendBase64Encoded(fullfileName);
            SendNL("");
        }
Пример #23
0
 private void MarkAsRead()
 {
     GXLogging.Debug(log, "Marking as read");
     if (message != null)
     {
         try
         {
             message.Unread = true;
             message.Update(optional, optional);
         }
         catch (Exception exc)
         {
             GXLogging.Error(log, "Error marking as read", exc);
         }
     }
     else
     {
         GXLogging.Error(log, "No current message");
         throw new GXMailException("No current message", 26);
     }
 }
Пример #24
0
 public override object GetValue(int i)
 {
     if (reader.GetFieldType(i) == typeof(decimal))
     {
         try
         {
             return(reader.GetDecimal(i));
         }
         catch (Exception fe)
         {
             GXLogging.Debug(log, "GetValues fieldtype Error, decimal value", fe);
             decimal result = GxInformix.GetIfxDecimal(reader, i);
             GXLogging.Debug(log, "GetValues decimal:" + result);
             return(result);
         }
     }
     else
     {
         return(base.GetValue(i));
     }
 }
Пример #25
0
 public void ajax_rsp_assign_attri(String CmpContext, bool IsMasterPage, String AttName, Object AttValue)
 {
     if (isJsOutputEnabled)
     {
         if (!context.isSpaRequest() || (context.isSpaRequest() && String.IsNullOrEmpty(CmpContext)))
         {
             try
             {
                 JObject obj = GetGxObject(AttValues, CmpContext, IsMasterPage);
                 if (obj != null)
                 {
                     obj.Put(AttName, AttValue);
                 }
             }
             catch (Exception ex)
             {
                 GXLogging.Error(log, "ajax_rsp_assign_attri error", ex);
             }
         }
     }
 }
Пример #26
0
        public bool BuildDictionary()
        {
            try
            {
                IndexReader my_luceneReader = IndexReader.Open(Settings.Instance.StoreFolder, true);

                SpellChecker.Net.Search.Spell.SpellChecker spell = GetSpelling(true);
                if (spell != null)
                {
                    spell.IndexDictionary(new LuceneDictionary(my_luceneReader, IndexRecord.CONTENTFIELD));
                }
                my_luceneReader.Dispose();

                return(true);
            }
            catch (Exception ex)
            {
                GXLogging.Error(log, "BuildDictionary Error", ex);
                return(false);
            }
        }
Пример #27
0
 public static T ReadJavascriptJSON <T>(string json, GXBaseCollection <SdtMessages_Message> Messages = null) where T : class
 {
     try
     {
         if (!string.IsNullOrEmpty(json))
         {
             return(GXJsonSerializer.Instance.ReadJSON <T>(json));
         }
         else
         {
             GXUtil.ErrorToMessages("FromJson Error", "Empty json", Messages);
             return(default(T));
         }
     }
     catch (Exception ex)
     {
         GXUtil.ErrorToMessages("FromJson Error", ex, Messages);
         GXLogging.Error(log, "FromJsonError ", ex);
         return(default(T));
     }
 }
        public override void execute()
        {
            GXLogging.Debug(log, "UpdateCursor.Execute, name'" + _name + "'");
            if (_state < 2)
            {
                throw (new GxADODataException("Could not execute UpdateCursor:" + _name + " not defined."));
            }
            _status = 0;
            _gxDbCommand.CursorDef = _cursorDef;
            _gxDbCommand.ExecuteStmt();

            if (_gxDbCommand.Status == 1 || _gxDbCommand.Status == 103 || _gxDbCommand.Status == 500)
            {
                _status = _gxDbCommand.Status;
            }
            else if (!_gxDbCommand.HasMoreRows)
            {
                _status = Cursor.EOF;
            }
            _closed = false;
        }
Пример #29
0
        private void commitDataStore(IGxDataStore ds, String auditObjectName)
        {
            GXLogging.Debug(log, "DataStoreProvider commit auditObjectName:" + auditObjectName);
            GxCommand cmd = new GxCommand(ds.Db, "commit", ds, 0, false, true, _errorHandler);

            cmd.ErrorMask = GxErrorMask.GX_NOMASK;
            try
            {
                ds.Commit();
            }
            catch (Exception dbEx)
            {
                //If commit fails it should not retry, it makes no sense because it will no longer be possible. just close the existing connection.
                int status           = 0;
                GxADODataException e = new GxADODataException(dbEx);
                bool retry           = false;
                int  retryCount      = 0;
                bool pe = ds.Connection.DataRecord.ProcessError(e.DBMSErrorCode, e.ErrorInfo, cmd.ErrorMask, ds.Connection, ref status, ref retry, retryCount);
                GXLogging.Error(log, "Commit Transaction Error", e);
                retryCount++;
                cmd.processErrorHandler(status, e.DBMSErrorCode, e.SqlState, e.ErrorInfo, cmd.ErrorMask, "FETCH", ref pe, ref retry);
                if (!pe)
                {
                    try
                    {
                        ds.Connection.Close();
                        if (retry)
                        {
                            ds.Connection.Open();
                        }
                    }
                    catch (Exception ex)
                    {
                        GXLogging.Error(log, "beginTransaction in commit transaction failed", ex);
                        throw (new GxADODataException(e.ToString(), e));
                    }
                }
            }
            cmd.Dispose();
        }
        public override void execute()
        {
            GXLogging.Debug(log, "BatchUpdateCursor.Execute, name'" + _name + "'");
            if (_state < 2)
            {
                throw (new GxADODataException("Could not execute BatchUpdateCursor:" + _name + " not defined."));
            }
            _status = 0;
            _gxDbCommand.ExecuteBatch();
            _gxDbCommand.Conn.UncommitedChanges = true;

            if (_gxDbCommand.Status == 1 || _gxDbCommand.Status == 103 || _gxDbCommand.Status == 500)
            {
                _status = _gxDbCommand.Status;
            }
            else if (!_gxDbCommand.HasMoreRows)
            {
                _status = Cursor.EOF;
            }
            _closed          = false;
            _fldBufferGetter = new GXFatErrorFieldGetter(_gxDbCommand);
        }