/// <summary> /// Get All Users of current client and org /// </summary> /// <param name="searchText"></param> /// <param name="sortBy"></param> /// <param name="pageNo"></param> /// <param name="pageSize"></param> /// <returns></returns> public List <UserInfo> GetUserInfo(string searchText, int sortBy, int pageNo, int pageSize) { List <UserInfo> uInfo = new List <UserInfo>(); int UserTableID = MTable.Get_Table_ID("AD_User"); int UserWindowID = Convert.ToInt32(DB.ExecuteScalar("SELECT AD_Window_ID from AD_Window WHERE Name='User'", null, null)); if (!(bool)MRole.GetDefault(ctx).GetWindowAccess(UserWindowID)) { return(uInfo); } if (!MRole.GetDefault(ctx).IsTableAccess(UserTableID, false)) { return(uInfo); } string sql = @"SELECT AD_User.Name, AD_User.Email, AD_User.AD_User_ID, AD_User.IsActive, AD_User.AD_Image_ID, AD_User.AD_Client_ID, AD_User.AD_Org_ID, C_Country.Name as CName FROM AD_User LEFT OUTER JOIN C_LOcation ON AD_User.C_Location_ID=C_Location.C_Location_ID LEFT OUTER JOIN C_Country ON C_Country.C_Country_ID=C_Location.C_Country_ID WHERE IsLoginUser='******' "; if (!String.IsNullOrEmpty(searchText)) { sql += " AND ( upper(AD_User.Value) like Upper('%" + searchText + "%') OR upper(AD_User.Name) like Upper('%" + searchText + "%') OR upper(AD_User.Email) like Upper('%" + searchText + "%'))"; } sql += " ORDER BY AD_User.IsActive desc"; if (sortBy == -1 || sortBy == 1) { sql += " , upper(AD_User.Name) ASC"; } else if (sortBy == 2) { sql += " , upper(AD_User.Value) ASC"; } else if (sortBy == 3) { sql += " , upper(AD_User.Email) ASC"; } sql = MRole.GetDefault(ctx).AddAccessSQL(sql, "AD_User", true, false); DataSet ds = DB.ExecuteDatasetPaging(sql, pageNo, pageSize); if (ds != null && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { UserInfo userInfo = new UserInfo(); userInfo.HasAccess = MRole.GetDefault(ctx).IsRecordAccess(UserTableID, Convert.ToInt32(ds.Tables[0].Rows[i]["AD_User_ID"]), true); userInfo.Username = Convert.ToString(ds.Tables[0].Rows[i]["Name"]); userInfo.Email = Convert.ToString(ds.Tables[0].Rows[i]["Email"]); userInfo.AD_UserID = Convert.ToInt32(ds.Tables[0].Rows[i]["AD_User_ID"]); userInfo.AD_OrgID = Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Org_ID"]); userInfo.AD_ClientID = Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Client_ID"]); userInfo.Country = Convert.ToString(ds.Tables[0].Rows[i]["CName"]); userInfo.UserTableID = UserTableID; userInfo.UserWindowID = UserWindowID; userInfo.IsActive = ds.Tables[0].Rows[i]["IsActive"].ToString() == "Y" ? true : false; userInfo.IsUpdate = MRole.GetDefault(ctx).CanUpdate(userInfo.AD_ClientID, userInfo.AD_OrgID, userInfo.UserTableID, userInfo.AD_UserID, false); if (ds.Tables[0].Rows[i]["AD_Image_ID"] != DBNull.Value && ds.Tables[0].Rows[i]["AD_Image_ID"] != null && Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Image_ID"]) > 0) { MImage mimg = new MImage(ctx, Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Image_ID"]), null); var imgfll = mimg.GetThumbnailURL(46, 46); userInfo.UserImage = imgfll; if (userInfo.UserImage == "FileDoesn'tExist" || userInfo.UserImage == "NoRecordFound") { userInfo.UserImage = ""; } } else { userInfo.UserImage = ""; } uInfo.Add(userInfo); } } return(uInfo); }
/// <summary> /// Get History as text from data base using Html display formate /// </summary> /// <param name="ConfidentialType">confidential type</param> /// <returns>text from control</returns> public ChatInfo GetHistory(String confidentialType, MChat _chat, int page, int pageSize, Ctx ctx) { ChatInfo cinfo = new ChatInfo(); GetEntries(true, _chat.GetCM_Chat_ID(), page, pageSize, ctx);//array list status StringBuilder strName = new StringBuilder(); List <LatestSubscribedRecordChat> subscribedChat = new List <LatestSubscribedRecordChat>(); //List<int> imgIds = new List<int>(); List <UserImages> imgIds = new List <UserImages>(); DataSet ds = null; //ring img = null; int imgID = 0; for (int i = 0; i < _chatEntries.Length; i++) { //olean first = true; MChatEntry entry = _chatEntries[i]; //get the created date of a perticular chat from PO _createdDate = entry.GetCreated(); _format = DateTime.SpecifyKind(new DateTime(_createdDate.Year, _createdDate.Month, _createdDate.Day, _createdDate.Hour, _createdDate.Minute, _createdDate.Second), DateTimeKind.Utc); _createdDate = _format; if (!entry.IsActive() || !entry.IsConfidentialTypeValid(confidentialType)) { continue; } //status for first chat string sql = "SELECT au.name, aimg.ad_image_id FROM ad_user au LEFT OUTER JOIN ad_image aimg"; sql += " ON(au.ad_image_id= aimg.ad_image_id) where au.ad_user_id =" + entry.GetCreatedBy(); ds = DB.ExecuteDataset(sql, null); if (ds.Tables[0].Rows.Count > 0) { strName.Clear(); strName.Append(ds.Tables[0].Rows[0]["NAME"].ToString()); //if (ds.Tables[0].Rows[0]["BINARYDATA"] != null && ds.Tables[0].Rows[0]["BINARYDATA"] != DBNull.Value) //{ // img = Convert.ToBase64String((Byte[])ds.Tables[0].Rows[0]["BINARYDATA"]); //} imgID = Util.GetValueOfInt(ds.Tables[0].Rows[0]["ad_image_id"]); if (imgIds.Where(a => a.AD_Image_ID == imgID).Count() == 0) { UserImages uimsg = new UserImages(); uimsg.AD_Image_ID = imgID; MImage mimg = new MImage(ctx, imgID, null); uimsg.UserImg = mimg.GetThumbnailURL(46, 46); imgIds.Add(uimsg); } } subscribedChat.Add(new LatestSubscribedRecordChat() { //UserImg = img, UserName = strName.ToString(), ChatData = entry.GetCharacterData(), ChatDate = _createdDate, AD_Image_ID = imgID, AD_User_ID = entry.GetCreatedBy() } ); } cinfo.subChat = subscribedChat; cinfo.userimages = imgIds; return(cinfo); }