コード例 #1
0
        public Wraper GetUsers_log(long currentuserid, string usertype, int PageIndex, int PageSize)
        {
            try
            {
                string constr = ConfigurationManager.ConnectionStrings["HickConnectionString"].ConnectionString.ToString();
                Wraper objwp = new Wraper();
                List<Users> userlist = new List<Users>();
                Users user = null;

                using (SqlConnection conn = new SqlConnection())
                {

                    conn.ConnectionString = constr;
                    conn.Open();

                    StringBuilder sbu = new StringBuilder();

                    //sbu.AppendLine("select *,(select top 1 ConversationDate from Hick_user_Conversation where (Initiator=" + currentuserid + " and Answerer=U.ID) OR (Initiator=U.ID and Answerer=" + currentuserid + ") order by ConversationDate DESC) as ConvDate ");
                    //sbu.AppendLine("FROM Hick_Users as U ");
                    //sbu.AppendLine("WHERE U.ID<>" + currentuserid + " AND LOWER(U.user_type)<>CASE WHEN LOWER('" + usertype + "')='patient' THEN 'patient' ELSE '' END");
                    //sbu.AppendLine("ORDER BY Status DESC,ConvDate DESC,Firstname ASC");

                    using (SqlCommand command = new SqlCommand("hickFetchUsersByCriteria", conn))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.Add("@PageIndex", SqlDbType.Int).Value = PageIndex;
                        command.Parameters.Add("@PageSize", SqlDbType.Int).Value = PageSize;

                        command.Parameters.Add("@CurrentUserId", SqlDbType.VarChar).Value = currentuserid.ToString();
                        command.Parameters.Add("@FavouriteUsers", SqlDbType.SmallInt).Value = 0;
                        command.Parameters.Add("@UserType", SqlDbType.VarChar).Value = usertype;
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                user = new Users();
                                //User=reader["asd"]                        }

                                user.Username = ecd.DecryptData((reader["Username"].ToString()), ecd.GetEncryptType());
                                user.Firstname = ecd.DecryptData((reader["Firstname"].ToString()), ecd.GetEncryptType());
                                user.Status = Convert.ToInt32(reader["Status"]);
                                user.Lastname = ecd.DecryptData((reader["Lastname"].ToString()),ecd.GetEncryptType());
                                user.ID = Convert.ToInt32(reader["ID"]);
                                user.StatusMessage = reader["StatusMessage"].ToString();
                                user.Lastloggedin = reader["LastLoggedIN"].ToString();
                                user.Image = reader["Image"].ToString();
                                user.Password = ecd.DecryptData((reader["Password"].ToString()), ecd.GetEncryptType());
                                userlist.Add(user);
                            }

                        }
                    }

                }
                objwp.UsersColl = userlist;
                objwp.GroupsColl = GetGroups(currentuserid);
                return objwp;
            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #2
0
        public Wraper GetUsers(long currentuserid, int favouriteUsers, int PageIndex, int PageSize, string usertype)
        {
            try
            {

                string constr = ConfigurationManager.ConnectionStrings["HickConnectionString"].ConnectionString.ToString();
                Wraper objwp = new Wraper();
                List<Users> userlist = new List<Users>();
                Users user = null;

                using (SqlConnection conn = new SqlConnection())
                {

                    conn.ConnectionString = constr;
                    conn.Open();
                    StringBuilder sbu = new StringBuilder();

                    //if (favouriteUsers == 0)
                    //{
                    //    sbu.AppendLine("select U.ID,U.Username,Firstname,Status,Lastname,StatusMessage,LastLoggedIN,Image,Password,fav_status,phone_number,(select top 1 ConversationDate from Hick_user_Conversation where (Initiator=" + currentuserid + " and Answerer=U.ID) OR (Initiator=U.ID and Answerer=" + currentuserid + ") order by ConversationDate DESC) as ConvDate ");
                    //    sbu.AppendLine("FROM Hick_Users as U ");
                    //    sbu.AppendLine("LEFT OUTER JOIN hick_favourite_contacts as FC on U.ID=FC.fav_contact_id and FC.user_id=" + currentuserid + "");
                    //    sbu.AppendLine("WHERE U.ID<>" + currentuserid + "");
                    //    sbu.AppendLine("ORDER BY Status DESC,ConvDate DESC,Firstname ASC");
                    //}
                    //else
                    //{
                    //    sbu.AppendLine("select * from Hick_Users hu inner join hick_favourite_contacts hf on hf.fav_contact_id=hu.ID and hf.fav_status=1 where hf.user_id=" + currentuserid + "");
                    //}
                    //using (SqlCommand command = new SqlCommand(sbu.ToString(), conn))
                    using (SqlCommand command = new SqlCommand("hickFetchUsersByCriteria", conn))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        command.Parameters.Add("@PageIndex", SqlDbType.Int).Value = PageIndex;
                        command.Parameters.Add("@PageSize", SqlDbType.Int).Value = PageSize;

                        command.Parameters.Add("@CurrentUserId", SqlDbType.VarChar).Value = currentuserid.ToString();
                        command.Parameters.Add("@FavouriteUsers", SqlDbType.SmallInt).Value = favouriteUsers;
                        command.Parameters.Add("@UserType", SqlDbType.VarChar).Value = usertype;

                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                //ConsentedUsers user1 = new ConsentedUsers();
                                user = new Users();
                                //User=reader["asd"] }

                                user.Username = ecd.DecryptData(DBHelper.getString(reader, "Username"), ecd.GetEncryptType());
                                user.Firstname = ecd.DecryptData(DBHelper.getString(reader, "Firstname"), ecd.GetEncryptType());
                                user.Status = DBHelper.getInt(reader, "Status");
                                user.Lastname = ecd.DecryptData(DBHelper.getString(reader, "LastName"), ecd.GetEncryptType());
                                user.ID = DBHelper.getInt(reader, "Id") == 0 ? Convert.ToInt32(reader["Id"]) : DBHelper.getInt(reader, "Id");
                                user.StatusMessage = DBHelper.getString(reader, "StatusMessage");
                                user.Lastloggedin = DBHelper.getString(reader, "LastLoggedIN");
                                user.Image = DBHelper.getString(reader, "Image");
                                user.Password = ecd.DecryptData(DBHelper.getString(reader, "Password"), ecd.GetEncryptType());
                                user.ReferenceID = DBHelper.getInt64(reader, "ReferenceID");
                                user.Favorites = DBHelper.getInt16(reader, "fav_status");
                                user.PhoneNumber = DBHelper.getString(reader, "phone_number");
                                userlist.Add(user);



                                //user.Username = DBHelper.getString(reader, "Username");
                                //user.Firstname = DBHelper.getString(reader, "Firstname");
                                //user.Status = DBHelper.getInt(reader, "Status");
                                //user.Lastname = DBHelper.getString(reader, "LastName");
                                //user.ID = DBHelper.getInt(reader, "Id") == 0 ? Convert.ToInt32(reader["Id"]) : DBHelper.getInt(reader, "Id");
                                //user.StatusMessage = DBHelper.getString(reader, "StatusMessage");
                                //user.Lastloggedin = DBHelper.getString(reader, "LastLoggedIN");
                                //user.Image = DBHelper.getString(reader, "Image");
                                //user.Password = DBHelper.getString(reader, "Password");
                                //user.ReferenceID = DBHelper.getInt64(reader, "ReferenceID");
                                //user.Favorites = DBHelper.getInt(reader, "fav_status");
                                //user.PhoneNumber = DBHelper.getString(reader, "phone_number");
                                //user.FileExt = DBHelper.getString(reader, "ConsentFormExt");
                                //user.DateOfBirth = DBHelper.getDateTime(reader, "dateofbirth").ToString(Utility.GlobalDateFormat);
                                // user.ConsentFormUploaded = DBHelper.getBool(reader, "HasFormUploaded");
                                //user.showConsentButton = !DBHelper.getBool(reader, "HasFormUploaded") ? "block" : "none";
                                //user.showDownloadButton = DBHelper.getBool(reader, "HasFormUploaded") ? "block" : "none";
                                //userlist.Add(user);



                            }
                        }
                    }
                    if (userlist.Count > 0)
                    {
                        for (int i = 0; i < userlist.Count; i++)
                        {
                            int peerid = userlist[i].ID;

                            //StringBuilder sb = new StringBuilder();
                            //sb.AppendLine("select UC.ID from Hick_user_Conversation UC");
                            //sb.AppendLine("INNER JOIN Hick_Conversation_log CL on UC.ID=CL.Conversation_Id");
                            //sb.AppendLine("where ((UC.Initiator=" + currentuserid + " and UC.Answerer=" + peerid + ") or (UC.Initiator=" + peerid + " and UC.Answerer=" + currentuserid + ")) and UC.ConversationDate=CONVERT(date, @date)");
                            //sb.AppendLine("AND CL.peerid=" + peerid + " and CL.Read_Status=" + (int)ReadStatus.UnRead + " and CL.Message_Type=" + (int)MessageTypes.Text + "");

                            using (SqlCommand command = new SqlCommand("sp_hick_FetchUnreadMsgSts", conn))
                            {
                                command.CommandType = CommandType.StoredProcedure;

                                command.Parameters.AddWithValue("@CurUsr", currentuserid);
                                command.Parameters.AddWithValue("@PeerId", peerid);
                                command.Parameters.AddWithValue("@date", DateTime.UtcNow);
                                command.Parameters.AddWithValue("@ReadStatusUnread", (int)ReadStatus.UnRead);
                                command.Parameters.AddWithValue("@MsgTypeTxt", (int)MessageTypes.Text);
                                using (SqlDataReader reader = command.ExecuteReader())
                                {
                                    if (reader.HasRows)
                                    {
                                        userlist[i].UnReadMessages = true;
                                    }
                                }
                            }
                            //sb = null;
                            //sb = new StringBuilder();
                            //sb.AppendLine("select UC.ID,CL.PeerId from Hick_user_Conversation UC");
                            //sb.AppendLine("INNER JOIN Hick_VideoConversation_Log CL on UC.ID=CL.ConversationId");
                            //sb.AppendLine("where ((UC.Initiator=" + currentuserid + " and UC.Answerer=" + peerid + ") or (UC.Initiator=" + peerid + " and UC.Answerer=" + currentuserid + ")) and UC.ConversationDate=CONVERT(date, @date)");
                            //sb.AppendLine("and CL.Status=" + (int)ReadStatus.CallInitiated + "");
                            using (SqlCommand command = new SqlCommand("sp_hick_IncomingCall", conn))
                            {
                                command.CommandType = CommandType.StoredProcedure;

                                command.Parameters.AddWithValue("@CurUsrId", currentuserid);
                                command.Parameters.AddWithValue("@PeerId", peerid);
                                command.Parameters.AddWithValue("@date", DateTime.UtcNow);
                                command.Parameters.AddWithValue("@CallInitiateSts", (int)ReadStatus.CallInitiated);
                                using (SqlDataReader reader = command.ExecuteReader())
                                {
                                    if (reader.HasRows)
                                    {
                                        while (reader.Read())
                                        {
                                            if (currentuserid != Convert.ToInt32(reader["PeerId"]))
                                            {
                                                userlist[i].IncomingCall = true;
                                            }
                                        }
                                    }
                                }
                            }

                            string ChatDuration = TxtChatDuration(currentuserid, peerid).Trim();
                            string VidDuration = VideoDuration(currentuserid, peerid).Trim();
                            string TaskAssignDuration = TaskDuration(currentuserid, peerid).Trim();
                            string AudioDuration = AudioCallDuration(peerid).Trim();

                            TimeSpan TotalDuration = new TimeSpan();
                            //if (!string.IsNullOrEmpty(ChatDuration) && !string.IsNullOrEmpty(VidDuration))
                            //{
                            //    TotalDuration = TimeSpan.Parse(ChatDuration) + TimeSpan.Parse(VidDuration) + TimeSpan.Parse(TaskAssignDuration);
                            //}
                            //else if (string.IsNullOrEmpty(ChatDuration) && !string.IsNullOrEmpty(VidDuration))
                            //{
                            //    TotalDuration = TimeSpan.Parse(VidDuration);
                            //}
                            //else if (string.IsNullOrEmpty(VidDuration) && !string.IsNullOrEmpty(ChatDuration))
                            //{
                            //    TotalDuration = TimeSpan.Parse(ChatDuration);
                            //}

                            if (!string.IsNullOrEmpty(ChatDuration))
                            {
                                TotalDuration = TotalDuration.Add(TimeSpan.Parse(ChatDuration));
                            }
                            if (!string.IsNullOrEmpty(VidDuration))
                            {
                                TotalDuration = TotalDuration.Add(TimeSpan.Parse(VidDuration));
                            }
                            if (!string.IsNullOrEmpty(TaskAssignDuration))
                            {
                                TotalDuration = TotalDuration.Add(TimeSpan.Parse(TaskAssignDuration));
                            }
                            if (!string.IsNullOrEmpty(AudioDuration))
                            {
                                TotalDuration = TotalDuration.Add(TimeSpan.Parse(AudioDuration));
                            }

                            if (TotalDuration.Hours > 0 || TotalDuration.Minutes > 0)
                            {
                                userlist[i].VideoCallDuration = string.Format("{0:00}:{1:00}", TotalDuration.Hours, TotalDuration.Minutes);
                            }
                            else
                            {
                                userlist[i].VideoCallDuration = "";
                            }
                        }

                    }

                    objwp.UsersColl = userlist;
                    if (favouriteUsers == 0)
                    {
                        objwp.GroupsColl = GetGroups(currentuserid);
                    }
                    return objwp;
                }

            }
            catch (Exception)
            {

                throw;
            }
        }