Beispiel #1
0
    private void SetItemAsUsed()
    {
        string[] items = MarkUsedInfo.Value.Split('|');
        IRepository <IIndexStatistics> rep = EntityFactory.GetRepository <IIndexStatistics>();
        IQueryable         qry             = (IQueryable)rep;
        IExpressionFactory ef    = qry.GetExpressionFactory();
        ICriteria          crit  = qry.CreateCriteria();
        IIndexStatistics   stats = crit.Add(ef.Eq("Id", items[0])).UniqueResult <IIndexStatistics>();

        if (stats != null)
        {
            stats.TotalCount++;
            stats.LastHitDate = DateTime.Now.ToUniversalTime();
            if (_UserType == 0)
            {
                stats.CustomerHitCount++;
            }
            else
            {
                stats.EmployeeHitCount++;
            }
            stats.Save();
        }
        else
        {
            string       SQL     = "INSERT INTO INDEXSTATS (DOCUMENTID, SEARCHINDEX, IDENTIFIER, CUSTOMERHITCOUNT, EMPLOYEEHITCOUNT, TOTALCOUNT, LASTHITDATE, DBID) VALUES (?,?,?,?,?,?,?,?)";
            IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get <IDataService>();
            using (var conn = service.GetOpenConnection() as OleDbConnection)
                using (var cmd = conn.CreateCommand(SQL) as OleDbCommand)
                {
                    if (cmd != null)
                    {
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@DOCUMENTID", items[0]);
                        cmd.Parameters.AddWithValue("@SEARCHINDEX", items[1]);
                        cmd.Parameters.AddWithValue("@IDENTIFIER", items[2]);
                        if (_UserType == 0)
                        {
                            cmd.Parameters.AddWithValue("@CUSTOMERHITCOUNT", 1);
                            cmd.Parameters.AddWithValue("@EMPLOYEEHITCOUNT", 0);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@CUSTOMERHITCOUNT", 0);
                            cmd.Parameters.AddWithValue("@EMPLOYEEHITCOUNT", 1);
                        }
                        cmd.Parameters.AddWithValue("@TOTALCOUNT", 1);
                        cmd.Parameters.AddWithValue("@LASTHITDATE", DateTime.Now.ToUniversalTime());
                        cmd.Parameters.AddWithValue("@DBID", items[3]);
                        cmd.ExecuteNonQuery();
                    }
                }
        }
    }
Beispiel #2
0
 public bool Equals(IIndexStatistics other)
 {
     return(ID == other.ID && RelationID == other.RelationID && DatabaseID == other.DatabaseID &&
            IndexScanCount == other.IndexScanCount && IndexTupleFetchCount == other.IndexTupleFetchCount && IndexTupleReadCount == other.IndexTupleReadCount);
 }