/// <summary>
        /// 把[Data对象]转换为[BaseData对象]
        /// </summary>
        /// <param name="_data">要转换的Data对象</param>
        /// <returns>转换后的BaseData对象</returns>
        public static RecordBaseData DataToBaseData(RecordData _data)
        {
            if (_data != null)
            {
                RecordBaseData _baseData = new RecordBaseData();


                _baseData.Id      = _data.Id;
                _baseData.BugId   = _data.BugId;
                _baseData.ReplyId = _data.ReplyId;
                _baseData.Content = _data.Content;
                _baseData.Time    = new List <int>()
                {
                    _data.Time.Year, _data.Time.Month, _data.Time.Day, _data.Time.Hour, _data.Time.Minute, _data.Time.Second
                };
                _baseData.Images   = ObservableCollectionTool.ObservableCollectionToList(_data.Images);
                _baseData.IsDelete = _data.IsDelete;


                return(_baseData);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 把[BaseData对象]转换为[Data对象]
        /// </summary>
        /// <param name="_baseData">要转换的BaseData对象</param>
        /// <returns>转换后的Data对象</returns>
        public static RecordData BaseDataToData(RecordBaseData _baseData)
        {
            if (_baseData != null)
            {
                RecordData _data = new RecordData();


                _data.Id       = _baseData.Id;
                _data.BugId    = _baseData.BugId;
                _data.ReplyId  = _baseData.ReplyId;
                _data.Content  = _baseData.Content;
                _data.Time     = new DateTime(_baseData.Time[0], _baseData.Time[1], _baseData.Time[2], _baseData.Time[3], _baseData.Time[4], _baseData.Time[5]);
                _data.Images   = ObservableCollectionTool.ListToObservableCollection(_baseData.Images);
                _data.IsDelete = _baseData.IsDelete;


                return(_data);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 设置ShowRecords属性
        /// (设置OtherData.ShowRecords属性)
        /// </summary>
        /// <param name="_bugData">要显示哪个Bug中的记录?</param>
        /// <param name="_showBugRecordType">[显示Bug记录]的类型</param>
        private void SetShowRecords(BugData _bugData, ShowBugRecordType _showBugRecordType)
        {
            if (_bugData == null || RecordDatas == null)
            {
                return;
            }



            /*容器:所有要显示的Record数据*/
            ObservableCollection <RecordItemData> _showrRecordItemDatas = new ObservableCollection <RecordItemData>();

            /*取到这个Bug中的Record*/
            List <RecordData> _recordDatas = ObservableCollectionTool.ObservableCollectionToList <RecordData>(GetRecordDatas(_bugData.Id));

            /* 进行排序:自定义排序方法 */
            _recordDatas.Sort((record1, record2) =>
            {
                /* 这个Lamba表达式的返回值为int类型,意思是record1和record2比较的大小。(大的排后面)*/
                return(DateTime.Compare(record1.Time, record2.Time));
            });



            /*赋值ShowRecords属性
             * (-1是[Bug创建时说的话])*/
            for (int i = -1; i < _recordDatas.Count; i++)//遍历Records集合
            {
                //Bug创建时说的话
                if (i <= -1)
                {
                    switch (_showBugRecordType)
                    {
                    //如果显示[所有][Bug说的话]
                    case ShowBugRecordType.All:
                        _showrRecordItemDatas.Add(new RecordItemData()
                        {
                            Type    = RecordType.Bug,
                            Content = AppManager.Systems.TemperamentSystem.GetCreateString(_bugData.TemperamentId, 0),
                        });
                        break;

                    //如果显示[1条][Bug说的话]
                    case ShowBugRecordType.One:
                        //Bug创建时说的话
                        if (_recordDatas.Count <= 0)
                        {
                            _showrRecordItemDatas.Add(new RecordItemData()
                            {
                                Type    = RecordType.Bug,
                                Content = AppManager.Systems.TemperamentSystem.GetCreateString(_bugData.TemperamentId, 0),
                            });
                        }
                        break;

                    //如果显示[0条][Bug说的话]
                    case ShowBugRecordType.Zero:
                        break;
                    }
                }

                //Bear说的话,以及 Bug回复时说的话
                else if (_recordDatas[i].IsDelete != true)
                {
                    switch (_showBugRecordType)
                    {
                    //如果显示[所有][Bug说的话]
                    case ShowBugRecordType.All:
                        //Bear的话
                        _showrRecordItemDatas.Add(_recordDatas[i].BearRecordItemData);

                        //Bug的话
                        if (_recordDatas[i].ReplyId >= 0)
                        {
                            _recordDatas[i].BugRecordItemData.Content = AppManager.Systems.TemperamentSystem.GetReplyString(_bugData.TemperamentId, _recordDatas[i].ReplyId);
                            _showrRecordItemDatas.Add(_recordDatas[i].BugRecordItemData);
                        }
                        break;

                    //如果显示[1条][Bug说的话]
                    case ShowBugRecordType.One:
                        //把Bear说的话,直接加入到列表中
                        _showrRecordItemDatas.Add(_recordDatas[i].BearRecordItemData);

                        //如果是最后一条记录数据,才加入到列表中
                        if (i == (_recordDatas.Count - 1) && _recordDatas[i].ReplyId >= 0)
                        {
                            _recordDatas[i].BugRecordItemData.Content = AppManager.Systems.TemperamentSystem.GetReplyString(_bugData.TemperamentId, _recordDatas[i].ReplyId);
                            _showrRecordItemDatas.Add(_recordDatas[i].BugRecordItemData);
                        }
                        break;

                    //如果显示[0条][Bug说的话]
                    case ShowBugRecordType.Zero:
                        //把Bear说的话,直接加入到列表中
                        _showrRecordItemDatas.Add(_recordDatas[i].BearRecordItemData);
                        break;
                    }
                }
            }

            //在集合中,多添加一个元素。这个最后1个元素的Type属性为None
            _showrRecordItemDatas.Add(new RecordItemData()
            {
                Type = RecordType.None
            });

            //显示
            ShowRecordItemDatas = _showrRecordItemDatas;
        }