Esempio n. 1
0
        public BusinessTripManagementService()
        {
            var webUrl = SPContext.Current.Web.Url;

            _businessTripEmployeeDetailDAL = new BusinessTripEmployeeDetailDAL(webUrl);
            _businessTripManagementDAL     = new BusinessTripManagementDAL(webUrl);
            _businessTripScheduleDAL       = new BusinessTripScheduleDAL(webUrl);
        }
        private XElement BuildViewString(EmployeeInfo employeeInfo, string siteUrl)
        {
            XElement filterElement = null;
            string   filterStr     = "<Eq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Eq>";

            if (employeeInfo == null)
            {
                return(XElement.Parse(filterStr));
            }

            BusinessTripEmployeeDetailDAL _businessTripEmployeeDetailDAL = new BusinessTripEmployeeDetailDAL(siteUrl);
            string taskQueryStr = string.Format(@"<Where>
                                    <Eq>
                                        <FieldRef Name='Employee' LookupId='TRUE' />
                                        <Value Type='Lookup'>{0}</Value>
                                    </Eq>
                                </Where>", employeeInfo.ID);

            List <BusinessTripEmployeeDetail> employeeDetailCollection = _businessTripEmployeeDetailDAL.GetByQuery(taskQueryStr);

            if (employeeDetailCollection.Any())
            {
                List <int> itemIds = employeeDetailCollection.Select(t => t.BusinessTripManagementID.LookupId).Distinct().ToList();

                if (itemIds != null && itemIds.Count > 0)
                {
                    filterStr = "";
                    foreach (var itemId in itemIds)
                    {
                        filterStr += string.Format("<Value Type='Counter'>{0}</Value>", itemId);
                    }
                    if (!string.IsNullOrEmpty(filterStr))
                    {
                        filterStr = string.Format("<In><FieldRef Name='ID'/><Values>{0}</Values></In>", filterStr);
                    }
                }
            }

            filterElement = XElement.Parse(filterStr);

            return(filterElement);
        }