示例#1
0
 public SimpleProperty(T value, string displayName, string description, bool readOnly, bool visible,
                       ESortDirection sortOrder)
 {
     _value        = value;
     _valueInitial = value;
     _displayName  = displayName;
     _readOnly     = readOnly;
     _visible      = visible;
     _description  = description;
     _sortOrder    = sortOrder;
 }
示例#2
0
 public SimpleProperty(T value, string displayName, string description, bool readOnly, bool visible,
                       object sortCriteria, ESortDirection sortOrder, IGroupCriteria groupCriteria)
 {
     _value         = value;
     _valueInitial  = value;
     _displayName   = displayName;
     _readOnly      = readOnly;
     _visible       = visible;
     _description   = description;
     _sortOrder     = sortOrder;
     _sortCriteria  = sortCriteria;
     _groupCriteria = groupCriteria;
 }
示例#3
0
        public static WorkReportViewModel GetAllUserWorkReports(int year, int month, string sortField = null, ESortDirection sortDirection = ESortDirection.Ascending, string filterUser = null)
        {
            List <WorkReport> workReports = null;

            using (MyDbContext db = new MyDbContext())
            {
                var query = db.WorkReports.Include("User").Where(r => r.AsOfDate.Year == year && r.AsOfDate.Month == month);
                if (!string.IsNullOrWhiteSpace(filterUser))
                {
                    query = query.Where(r => r.User.ChineseName.Contains(filterUser) || r.User.EnglishName.Contains(filterUser) || r.User.FullName.Contains(filterUser));
                }
                workReports = query.ToList();
            }
            var       workReportsNormal = workReports.Where(r => !r.User.IsWorkingAtHome);
            var       workReportsAtHome = workReports.Where(r => r.User.IsWorkingAtHome);
            DataTable dtNormal          = BuildWorkReportDataTable(workReportsNormal, year, month);
            DataTable dtAtHome          = BuildWorkReportDataTable(workReportsAtHome, year, month);
            DataView  dvNormal          = dtNormal.DefaultView;

            if (!string.IsNullOrWhiteSpace(sortField))
            {
                dvNormal.Sort = sortField + " " + sortDirection.GetDescription();
            }
            return(new WorkReportViewModel
            {
                Month = new DateTime(year, month, 1).ToString("MM/yyyy"),
                SortField = sortField,
                SortDirection = sortDirection,
                Filter = filterUser,
                WorkReportDataView = dvNormal,
                WorkReportAtHomeDataView = dtAtHome.DefaultView,
                UploadProperty = WorkReportPropertyService.GetWorkReportProperty(year, month),
                UserAutoCompletionSource = UserService.GetUserAutoCompletionSourceData()
            });
        }
示例#4
0
 /// <summary>
 /// 建構函式。
 /// </summary>
 /// <param name="fieldName">欄位名稱。</param>
 /// <param name="sortDirection">排序方式。</param>
 public GSortField(string fieldName, ESortDirection sortDirection)
 {
     this.FieldName     = fieldName;
     this.SortDirection = sortDirection;
 }
示例#5
0
        public List <IDynamicProperty> GetPropertiesSorted(bool nullValues, ESortBy sortBy, ESortDirection sortDirection)
        {
            //copy and return property list
            var properties = new List <IDynamicProperty>();

            properties = GetProperties(nullValues);

            switch (sortBy)
            {
            case ESortBy.None:
                break;

            case ESortBy.Key:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyKeyComparer());
                }
                else
                {
                    properties.Sort(new PropertyKeyComparerDesc());
                }
                break;

            case ESortBy.Value:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyValueAsStringComparer());
                }
                else
                {
                    properties.Sort(new PropertyValueAsStringComparerDesc());
                }
                break;

            case ESortBy.ValueAsString:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyValueAsStringComparer());
                }
                else
                {
                    properties.Sort(new PropertyValueAsStringComparerDesc());
                }
                break;

            case ESortBy.DisplayName:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyDisplayNameComparer());
                }
                else
                {
                    properties.Sort(new PropertyDisplayNameComparerDesc());
                }
                break;

            case ESortBy.Description:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyDescriptionComparer());
                }
                else
                {
                    properties.Sort(new PropertyDescriptionComparerDesc());
                }
                break;

            case ESortBy.SortCriteria:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertySortCriteriaComparer());
                }
                else
                {
                    properties.Sort(new PropertySortCriteriaComparerDesc());
                }
                break;

            case ESortBy.Custom:
                Debug.Assert(false,
                             "For custom sorting use GetPropertiesSorted(bool nullValues, IComparer<IDynamicProperty> comparer) function");
                break;

            default:
                break;
            }

            return(properties);
        }
示例#6
0
 public static void AddDynamicColumns(ColumnView gridView, IDynamicPropertyList propertyList, ESortBy sortBy,
                                      ESortDirection sortDir, string nullText)
 {
     AddDynamicColumns(gridView, propertyList, sortBy, sortDir, nullText, null, true);
 }
示例#7
0
        private static void AddDynamicColumns(ColumnView gridView, IDynamicPropertyList propertyList, ESortBy sortBy,
                                              ESortDirection sortDir, string nullText, IComparer <IDynamicProperty> comparer, bool allowFilter)
        {
            RepositoryItemTextEdit riteCol = null;

            gridView.BeginDataUpdate();
            int visibleIndexValue = 0;

            foreach (GridColumn column in gridView.Columns)
            {
                if (column.VisibleIndex > visibleIndexValue)
                {
                    visibleIndexValue = column.VisibleIndex;
                }
            }

            if (!string.IsNullOrEmpty(nullText))
            {
                riteCol          = new RepositoryItemTextEdit();
                riteCol.NullText = nullText;
            }

            List <IDynamicProperty> propertyListSorted;

            if (comparer == null)
            {
                propertyListSorted = propertyList.GetPropertiesSorted(true, sortBy, sortDir);
            }
            else
            {
                propertyListSorted = propertyList.GetPropertiesSorted(true, comparer);
            }

            foreach (IDynamicProperty property in propertyListSorted)
            {
                var newColumn = new GridColumn();

                newColumn.Caption   = property.DisplayName;
                newColumn.FieldName = property.Key;
                newColumn.Name      = "col" + property.Key;
                newColumn.OptionsColumn.ReadOnly = property.ReadOnly;
                newColumn.Visible = property.Visible;
                newColumn.ToolTip = property.Description;
                newColumn.OptionsFilter.AllowFilter = allowFilter;
                if (riteCol != null)
                {
                    newColumn.ColumnEdit = riteCol;
                }

                if (property.Visible)
                {
                    visibleIndexValue++;
                    newColumn.VisibleIndex = visibleIndexValue;
                }
                else
                {
                    newColumn.VisibleIndex = -1;
                }

                newColumn.Tag         = property.Key;
                newColumn.UnboundType = GetUnboundType(property);

                //check if column exists
                foreach (GridColumn column in gridView.Columns)
                {
                    Debug.Assert(column.Name != newColumn.Name, "Column with this name exists already");
                }

                gridView.Columns.Add(newColumn);
            }
            gridView.EndDataUpdate();
        }
示例#8
0
 public List <JiraWorkLogDetail> GetJiraWorkLogsByUsers(string startDate, string lastDate, ESortDirection sortDirection)
 {
     using (var db = new JiraDbContext())
     {
         DateTime sd       = DateTime.Parse(startDate);
         DateTime ldTemp   = DateTime.Parse(lastDate);
         DateTime ld       = ldTemp.AddDays(1);
         var      workLogs = from cwd_user cu in db.cwd_user
                             join app_user au in db.app_user
                             on cu.lower_user_name equals au.lower_user_name
                             join worklog wl in db.worklogs
                             on au.user_key equals wl.AUTHOR
                             join jiraissue jissue in db.jiraissues
                             on wl.issueid equals jissue.ID
                             join project pro in db.projects
                             on jissue.PROJECT equals pro.ID
                             where wl.UPDATED >= sd && wl.UPDATED <= ld && cu.active == 1
                             orderby wl.UPDATED.Value.Day + sortDirection, pro.pname, cu.display_name
                  select new JiraWorkLogDetail {
             UpdateTime = wl.UPDATED.Value.Year.ToString() + "-" + wl.UPDATED.Value.Month.ToString() + "-" + wl.UPDATED.Value.Day.ToString(), Project = pro.pname, DisplayName = cu.display_name, WorkLogBody = wl.worklogbody, TimeWorked = wl.timeworked / 3600
         };
         return(workLogs.ToList());
     }
 }