예제 #1
0
        public static IDataReader SearchChat(int iUserId, int iChatId, DateTime dtFrom, DateTime dtTo,
                                             string sKeyWord, int iOrder)
        {
            int DefaultBias = UserReport.GetTimeZoneBias(Security.CurrentUser.TimeZoneId);

            return(DBUserReport.SearchChat(iUserId, iChatId, dtFrom, dtTo, sKeyWord, iOrder, DefaultBias));
        }
예제 #2
0
        public static DataView GetTop10Users(DateTime StartDate, DateTime EndDate)
        {
            int       DefaultBias = UserReport.GetTimeZoneBias(Security.CurrentUser.TimeZoneId);
            DataTable dt          = new DataTable("Top10writers");

            dt.Columns.Add("Place");
            dt.Columns.Add("Group");
            dt.Columns.Add("Name");
            dt.Columns.Add("TotalMessages");

            using (IDataReader reader = DBUserReport.GetTop10Users(StartDate, EndDate, DefaultBias))
            {
                int place = 1;
                while (reader.Read())
                {
                    int    iUserId    = reader.GetInt32(0);
                    string sName      = "";
                    int    iIMGroupId = 0;
                    using (IDataReader _obj = UserReport.GetUserInfoByOriginalId(iUserId))
                    {
                        if (_obj.Read())
                        {
                            sName      = _obj["FirstName"].ToString() + " " + _obj["LastName"].ToString();
                            iIMGroupId = (int)_obj["IMGroupId"];
                        }
                        else
                        {
                            continue;
                        }
                    }
                    DataRow dr = dt.NewRow();
                    dr["Place"]         = place.ToString();
                    dr["TotalMessages"] = reader.GetInt32(1).ToString();
                    dr["Name"]          = sName;
                    if (iIMGroupId > 0)
                    {
                        using (IDataReader _obj = UserReport.GetIMGroup(iIMGroupId))
                        {
                            if (_obj.Read())
                            {
                                dr["Group"] = _obj["IMGroupName"].ToString();
                            }
                        }
                    }
                    dt.Rows.Add(dr);
                    place++;
                }
            }

            return(dt.DefaultView);
        }
예제 #3
0
        public static int GetCountIMMessages(bool getInternal)
        {
            int DefaultBias = UserReport.GetTimeZoneBias(Security.CurrentUser.TimeZoneId);

            return(DBUserReport.GetCountIMMessages(DefaultStartDate, DefaultEndDate, getInternal, DefaultBias));
        }
예제 #4
0
        /// <summary>
        /// LoginsClient, MsgSent, MsgReceived, ConfCreated,
        /// ConfMsgSent, FilesSent, FSBytes, FilesReceived, FRBytes
        /// </summary>
        public static DataTable GetUserStats(int UserID, DateTime fromDate, DateTime toDate)
        {
            DataTable table = new DataTable();
            DataRow   row;

            table.Columns.Add("LoginsClient", typeof(int));
            table.Columns.Add("MsgSent", typeof(int));
            table.Columns.Add("MsgReceived", typeof(int));
            table.Columns.Add("ConfCreated", typeof(int));
            table.Columns.Add("ConfMsgSent", typeof(int));
            table.Columns.Add("FilesSent", typeof(int));
            table.Columns.Add("FSBytes", typeof(long));
            table.Columns.Add("FilesReceived", typeof(int));
            table.Columns.Add("FRBytes", typeof(long));

            row = table.NewRow();

            int DefaultBias = UserReport.GetTimeZoneBias(Security.CurrentUser.TimeZoneId);

            using (IDataReader reader = DBUserReport.GetUserStats(UserID, fromDate, toDate, DefaultBias))
            {
                if (reader != null)
                {
                    if (reader.Read())
                    {
                        if (reader["LoginsClient"] != DBNull.Value)
                        {
                            row["LoginsClient"] = (int)reader["LoginsClient"];
                        }
                        else
                        {
                            row["LoginsClient"] = 0;
                        }
                        if (reader["MsgSent"] != DBNull.Value)
                        {
                            row["MsgSent"] = (int)reader["MsgSent"];
                        }
                        else
                        {
                            row["MsgSent"] = 0;
                        }
                        if (reader["MsgReceived"] != DBNull.Value)
                        {
                            row["MsgReceived"] = (int)reader["MsgReceived"];
                        }
                        else
                        {
                            row["MsgReceived"] = 0;
                        }
                        if (reader["ConfCreated"] != DBNull.Value)
                        {
                            row["ConfCreated"] = (int)reader["ConfCreated"];
                        }
                        else
                        {
                            row["ConfCreated"] = 0;
                        }
                        if (reader["ConfMsgSent"] != DBNull.Value)
                        {
                            row["ConfMsgSent"] = (int)reader["ConfMsgSent"];
                        }
                        else
                        {
                            row["ConfMsgSent"] = 0;
                        }
                        if (reader["FilesSent"] != DBNull.Value)
                        {
                            row["FilesSent"] = (int)reader["FilesSent"];
                        }
                        else
                        {
                            row["FilesSent"] = 0;
                        }
                        if (reader["FSBytes"] != DBNull.Value)
                        {
                            row["FSBytes"] = (long)reader["FSBytes"];
                        }
                        else
                        {
                            row["FSBytes"] = 0;
                        }
                        if (reader["FilesReceived"] != DBNull.Value)
                        {
                            row["FilesReceived"] = (int)reader["FilesReceived"];
                        }
                        else
                        {
                            row["FilesReceived"] = 0;
                        }
                        if (reader["FRBytes"] != DBNull.Value)
                        {
                            row["FRBytes"] = (long)reader["FRBytes"];
                        }
                        else
                        {
                            row["FRBytes"] = 0;
                        }
                    }
                }
            }

            table.Rows.Add(row);
            return(table);
        }
예제 #5
0
        public static int GetAuthenticatedUsers(DateTime StartDate, DateTime EndDate)
        {
            int DefaultBias = UserReport.GetTimeZoneBias(Security.CurrentUser.TimeZoneId);

            return(DBUserReport.GetAuthenticatedUsers(StartDate, EndDate, DefaultBias));
        }
예제 #6
0
        public static int GetFilesTransferred()
        {
            int DefaultBias = UserReport.GetTimeZoneBias(Security.CurrentUser.TimeZoneId);

            return(DBUserReport.GetFilesTransferred(DefaultStartDate, DefaultEndDate, DefaultBias));
        }
예제 #7
0
        public static int GetCountChatMessages()
        {
            int DefaultBias = UserReport.GetTimeZoneBias(Security.CurrentUser.TimeZoneId);

            return(DBUserReport.GetCountChatMessages(DefaultStartDate, DefaultEndDate, DefaultBias));
        }
예제 #8
0
        /// <summary>
        /// Returns ArrayList of UserActivityInfo objects.
        /// </summary>
        public static ArrayList GetUsersActivity(DateTime fromDate, DateTime toDate, ActivityReportType type, int topCount)
        {
            ArrayList        list = new ArrayList();
            UserActivityInfo user;

            using (IDataReader reader = GetUsersByCompany())
            {
                while (reader.Read())
                {
                    string sDisplayName = reader["DisplayName"].ToString();
                    int    iIMGroupId   = (int)reader["IMGroupId"];
                    int    user_id      = (int)reader["UserId"];
                    user = new UserActivityInfo(sDisplayName, iIMGroupId);
                    list.Add(user);
                    using (IDataReader _obj = UserReport.GetUserInfoByOriginalId(user_id))
                    {
                        if (_obj.Read())
                        {
                            user_id = (int)_obj["UserId"];
                        }
                        else
                        {
                            continue;
                        }
                    }

                    int DefaultBias = UserReport.GetTimeZoneBias(Security.CurrentUser.TimeZoneId);
                    switch (type)
                    {
                    case ActivityReportType.Messages:
                        using (IDataReader _obj = DBUserReport.GetUserStats(user_id, fromDate, toDate, DefaultBias))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["MsgSent"];
                            }
                        }
                        break;

                    case ActivityReportType.FilesExchanged:
                        using (IDataReader _obj = DBUserReport.GetUserStats(user_id, fromDate, toDate, DefaultBias))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["FilesSent"];
                            }
                        }
                        break;

                    case ActivityReportType.IMLogins:
                        using (IDataReader _obj = DBUserReport.GetUserStats(user_id, fromDate, toDate, DefaultBias))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["LoginsClient"];
                            }
                        }
                        break;

                    case ActivityReportType.PortalLogins:
                        using (IDataReader _obj = GetQuickSnapshotReport(fromDate, toDate, user_id))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["PortalLogins"];
                            }
                        }
                        break;

                    case ActivityReportType.CalendarEntries:
                        using (IDataReader _obj = GetQuickSnapshotReport(fromDate, toDate, user_id))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["NewEventsCount"];
                            }
                        }
                        break;

                    case ActivityReportType.ActiveProjects:
                        using (IDataReader _obj = GetQuickSnapshotReport(fromDate, toDate, user_id))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["NewProjectsCount"];
                            }
                        }
                        break;

                    case ActivityReportType.FilesPublished:
                        using (IDataReader _obj = GetQuickSnapshotReport(fromDate, toDate, user_id))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["NewAssetsCount"];
                            }
                        }
                        break;

                    case ActivityReportType.FileVersionsPublished:
                        using (IDataReader _obj = GetQuickSnapshotReport(fromDate, toDate, user_id))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["NewAssetVersionsCount"];
                            }
                        }
                        break;

                    case ActivityReportType.NewIssues:
                        using (IDataReader _obj = GetQuickSnapshotReport(fromDate, toDate, user_id))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["NewIncidentsCount"];
                            }
                        }
                        break;

                    case ActivityReportType.NewTasks:
                        using (IDataReader _obj = GetQuickSnapshotReport(fromDate, toDate, user_id))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["NewTasksCount"];
                            }
                        }
                        break;

                    case ActivityReportType.NewToDos:
                        using (IDataReader _obj = GetQuickSnapshotReport(fromDate, toDate, user_id))
                        {
                            if (_obj.Read())
                            {
                                user.Count = (int)_obj["NewToDosCount"];
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
            }

            // Leave only topCount items
            if (topCount > 0)
            {
                list.Sort();
                if (list.Count > topCount)
                {
                    list.RemoveRange(topCount, list.Count - topCount);
                }
            }

            // Remove items with zero counter
            for (int i = 0; i < list.Count;)
            {
                if (((ActivityInfo)list[i]).Count == 0)
                {
                    list.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }

            return(list);
        }
예제 #9
0
        public static DataTable SearchHistory(DateTime fromDate, DateTime toDate,
                                              int userID, int userGroupId,
                                              int contUserID, int contUserGroupId,
                                              int msgType, string keyword, bool displayLastEventsFirst)
        {
            ArrayList UserList    = new ArrayList();
            ArrayList ContactList = new ArrayList();

            using (IDataReader rdr = UserReport.GetListAllUsersInGroup(userGroupId))
            {
                while (rdr.Read())
                {
                    if (rdr["OriginalId"] != DBNull.Value)
                    {
                        UserList.Add((int)rdr["OriginalId"]);
                    }
                }
            }

            using (IDataReader rdr = UserReport.GetListAllUsersInGroup(contUserGroupId))
            {
                while (rdr.Read())
                {
                    if (rdr["OriginalId"] != DBNull.Value)
                    {
                        ContactList.Add((int)rdr["OriginalId"]);
                    }
                }
            }

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("FromFirst", typeof(string)));
            dt.Columns.Add(new DataColumn("FromLast", typeof(string)));
            dt.Columns.Add(new DataColumn("ToFirst", typeof(string)));
            dt.Columns.Add(new DataColumn("ToLast", typeof(string)));
            dt.Columns.Add(new DataColumn("mess_text", typeof(string)));
            dt.Columns.Add(new DataColumn("send_time", typeof(DateTime)));
            DataRow dr;

            int DefaultBias = UserReport.GetTimeZoneBias(Security.CurrentUser.TimeZoneId);

            using (IDataReader reader = DBUserReport.SearchHistory(fromDate, toDate,
                                                                   userID, contUserID,
                                                                   msgType, keyword, displayLastEventsFirst,
                                                                   DefaultBias))
            {
                while (reader.Read())
                {
                    dr = dt.NewRow();
                    int FromId = (int)reader["FromID"];
                    int ToId   = (int)reader["ToID"];
                    if (msgType == 1)                           //in + out
                    {
                        if ((!UserList.Contains(FromId) || !ContactList.Contains(ToId)) &&
                            (!UserList.Contains(ToId) || !ContactList.Contains(FromId)))
                        {
                            continue;
                        }
                    }
                    else if (msgType == 2)                     //in
                    {
                        if (!UserList.Contains(ToId) || !ContactList.Contains(FromId))
                        {
                            continue;
                        }
                    }
                    else                     //out
                    {
                        if (!UserList.Contains(FromId) || !ContactList.Contains(ToId))
                        {
                            continue;
                        }
                    }
                    dr["FromFirst"] = reader["FromFirst"].ToString();
                    dr["FromLast"]  = reader["FromLast"].ToString();
                    dr["ToFirst"]   = reader["ToFirst"].ToString();
                    dr["ToLast"]    = reader["ToLast"].ToString();
                    dr["mess_text"] = reader["mess_text"].ToString();
                    dr["send_time"] = (DateTime)reader["send_time"];
                    dt.Rows.Add(dr);
                }
            }

            return(dt);
        }