private GetUser GetUser(string currentUser) { GetUser result = new GetUser(); try { string url = SPContext.Current.Site.Url; using (SPSite site = new SPSite(url)) { using (SPWeb web = site.OpenWeb()) { List<string> phongBan = new List<string>(); string pb = string.Empty; SPList list = web.Lists["NguoiDung"]; SPQuery query = new SPQuery(); query.Query = "<OrderBy><FieldRef Name='ID' Ascending='TRUE' /></OrderBy>"; query.ViewFields = "<FieldRef Name='ID'/><FieldRef Name='User'/><FieldRef Name='NhomNguoiDung'/><FieldRef Name='HoVaTen'/>"; query.ViewFieldsOnly = true; DataTable dtGetData = list.GetItems(query).GetDataTable(); var _node = dtGetData.AsEnumerable().Where(x => !string.IsNullOrEmpty(x.Field<string>("User")) && x.Field<string>("User").Equals(currentUser) && !string.IsNullOrEmpty(x.Field<string>("NhomNguoiDung"))); //count.Add(_countDangXuLy); if (_node.Any()) { DataTable temp = _node.CopyToDataTable(); phongBan = temp.AsEnumerable().Select(x => x.Field<string>("NhomNguoiDung")).ToList(); for (int i = 0; i < phongBan.ToArray().Length; i++) { pb = phongBan.ToArray()[i]; } } if (!string.IsNullOrEmpty(pb)) { var _temp = dtGetData.AsEnumerable().Where(x => !string.IsNullOrEmpty(x.Field<string>("NhomNguoiDung")) && x.Field<string>("NhomNguoiDung").Equals(pb)); if (_temp.Any()) { DataTable totemp = _temp.CopyToDataTable(); result.User = totemp.AsEnumerable().Select(x => x.Field<string>("User")).ToArray(); result.HoVaTen = totemp.AsEnumerable().Select(x => x.Field<string>("HoVaTen")).ToArray(); } } } } } catch (Exception) { } return result; }
private void Page_Load(object sender, EventArgs e) { try { DateTime today = DateTime.Now; int tuan = GetWeekOrderInYear(today); DateTime firstDay = GetFirstDayOfWeek(DateTime.Now.Year.ToString(), tuan); DateTime lastDay = GetLastDayOfWeek(DateTime.Now.Year.ToString(), tuan); DateTime now = DateTime.Now; DateTime fd = new DateTime(now.Year, now.Month, 1); DateTime ld = fd.AddMonths(1).AddDays(-1); string[] user; //categories.Tuan1 = "Tuần " + (tuan - 3); //categories.Tuan2 = "Tuần " + (tuan - 2); //categories.Tuan3 = "Tuần " + (tuan - 1); //categories.Tuan4 = "Tuần " + (tuan); //categoryStr = ConvertObjectToJson(categories); string url = Tandan.Utilities.Utility.GetAbsoluteSiteUrl(this.SiteUrl); using (SPSite site = new SPSite(url)) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists["CongViec"]; SPQuery query = new SPQuery(); query.Query = string.Concat("<Where>", "<Or>", "<IsNull>", "<FieldRef Name='HanHoanThanh'/>", "</IsNull>", "<And>", "<IsNotNull>", "<FieldRef Name='HanHoanThanh'/>", "</IsNotNull>", "<Geq>", "<FieldRef Name='HanHoanThanh'/>", "<Value IncludeTimeValue='FALSE' Type='DateTime'>" + fd.ToString("yyyy-MM-ddThh:mm:ssZ") + "</Value>", "</Geq>", "</And>", "</Or>", "</Where>", "<OrderBy><FieldRef Name='ID' Ascending='TRUE' /></OrderBy>"); query.ViewFields = string.Concat("<FieldRef Name='ID'/>", "<FieldRef Name='NgayBatDau'/>", "<FieldRef Name='NguoiThucHien'/>", "<FieldRef Name='DaKetThuc'/>", "<FieldRef Name='HanHoanThanh'/>", "<FieldRef Name='NgayKetThuc'/>", "<FieldRef Name='NgayChuyenXuLy'/>", "<FieldRef Name='NguoiChuyenXuLy'/>", "<FieldRef Name='NguoiDaThucHien'/>"); query.ViewFieldsOnly = true; getUser = GetUser(web.CurrentUser.ToString()); //category = getUser.HoVaTen; category = ConvertObjectToJson(getUser.HoVaTen); SPListItemCollection items = list.GetItems(query); if (items != null && items.Count != 0) { DataTable dtGetData = items.GetDataTable(); user = getUser.User; DangXuLy = GetDataByLinQ(tuan, "Đang xử lý", dtGetData, user); ChuyenXuLy = GetDataByLinQ(tuan, "Đã chuyển xử lý", dtGetData, user); DaXuLy = GetDataByLinQ(tuan, "Đã xử lý", dtGetData, user); DangXuLyStr = ConvertObjectToJson(DangXuLy); ChuyenXuLyStr = ConvertObjectToJson(ChuyenXuLy); DaXuLyStr = ConvertObjectToJson(DaXuLy); } } } } catch (Exception ex) { //TextBox1.Text = ex.ToString(); } }