/// <summary>
        /// 当软件的[语言]改变时
        /// </summary>
        /// <param name="_languageType">是中文的性格?还是英文的性格?</param>
        public void OnLanguageChange(LanguageType _languageType)
        {
            //修改每一个数据
            for (int i = 0; i < LatelyProjectDatas.Count; i++)
            {
                LatelyProjectData _data = LatelyProjectDatas[i];

                if (_data != null)
                {
                    _data.OpenTimeString = DateTimeTool.DateTimeToString(_data.OpenTime.ToLocalTime(), TimeFormatType.YearMonthDayHourMinute);
                    if (_data.Mode == ModeType.Collaboration)
                    {
                        _data.ModeString = AppManager.Systems.LanguageSystem.CollaborativeModeString;
                    }
                    else
                    {
                        _data.ModeString = "";
                    }
                }
            }

            //修改[最近项目]的右键菜单
            if (AppManager.Uis.LatelyProjectUi.UiControl != null && AppManager.Uis.LatelyProjectUi.UiControl.Items != null)
            {
                //获取所有的Item
                List <LatelyProjectListItemControl> _items = AppManager.Uis.LatelyProjectUi.UiControl.Items;

                //遍历所有的Item
                for (int i = 0; i < _items.Count; i++)
                {
                    _items[i].OpenFolderTextBlock.Text = AppManager.Systems.LanguageSystem.LatelyProjectItemOpenFolderString;
                    _items[i].RemoveTextBlock.Text     = AppManager.Systems.LanguageSystem.LatelyProjectItemRemoveString;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 备份[工程]
        ///(备份[project.bugs]文件)
        /// </summary>
        public void BackupProject()
        {
            /* 格式:Backup/Project/年月日时分秒.bugs*/

            try
            {
                /*创建[Backup]文件夹(_projectFolderPath/Backup/)*/
                DirectoryInfo _projectBackupDirectoryInfo = new DirectoryInfo(ProjectBackupFolderPath);
                //如果没有文件夹,就创建文件夹
                if (_projectBackupDirectoryInfo.Exists == false)
                {
                    _projectBackupDirectoryInfo.Create();
                }


                /*获取【工程】文件的个数(如果文件超过10个,就删除最早创建的那个文件)*/
                FileInfo[] _projectBackupFileInfos = _projectBackupDirectoryInfo.GetFiles();
                if (_projectBackupFileInfos.Length > 10)
                {
                    //找到Project备份文件中,最早创建的那个文件
                    FileInfo _firstFileInfo = FindFirstBackupFile(_projectBackupFileInfos);

                    //删除最早的1个文件
                    if (_firstFileInfo != null)
                    {
                        File.Delete(_firstFileInfo.FullName);
                    }
                }



                /* 获取要备份的文件的路径 */
                //当前的时间(年月日时分秒)
                string _nowDateTimeString = DateTimeTool.DateTimeToString(DateTime.UtcNow, TimeFormatType.YearMonthDayHourMinuteSecondMillisecond);

                //文件的备份路径
                string _projectFilePath = ProjectBackupFolderPath + "/"
                                          + _nowDateTimeString + AppManager.Systems.ProjectSystem.ProjectFileSuffix;


                /* 进行备份 */
                //获取Bug文件和Project文件的内容
                string _projectText = File.ReadAllText(AppManager.Systems.ProjectSystem.ProjectFilePath);

                //把Bug文件和Project文件的内容,复制到备份文件中
                File.WriteAllText(_projectFilePath, _projectText, Encoding.Default);
            }
            catch (Exception e)
            {
            }
        }
Exemple #3
0
        /// <summary>
        /// 添加Bug
        /// </summary>
        /// <param name="_name">Bug的名字</param>
        /// <param name="_priority">Bug的优先级</param>
        public void AddBug(string _name, PriorityType _priority)
        {
            //创建一个Bug
            BugData _bugData = new BugData();

            _bugData.Id   = DateTimeTool.DateTimeToLong(DateTime.UtcNow, TimeFormatType.YearMonthDayHourMinuteSecondMillisecond);
            _bugData.Name = new HighlightText()
            {
                Text = _name
            };
            _bugData.Progress      = ProgressType.Undone;
            _bugData.Priority      = _priority;
            _bugData.CreateTime    = DateTime.UtcNow;
            _bugData.UpdateTime    = DateTime.UtcNow;
            _bugData.TemperamentId = 0;

            //把Bug添加到BugDatas中
            BugDatas.Add(_bugData);

            //重新获取Bug的个数+页数
            AppManager.Systems.BugSystem.CalculatedBugsNumber();
            AppManager.Systems.PageSytem.CalculatedPagesNumber();

            //重新排序
            AppManager.Systems.SortSystem.Sort();

            //重新过滤
            AppManager.Systems.SearchSystem.Filter();

            //重新计算页数
            AppManager.Systems.PageSytem.CalculatedPagesNumber();

            //显示Bug到当前页面
            AppManager.Systems.PageSytem.Insert(_bugData);

            //显示ListBug的Tip
            AppManager.Uis.ListUi.UiControl.OpenOrCloseListTip(true, true, _bugData);

            //保存Bug文件
            this.SaveBug(AppManager.Datas.ProjectData.ModeType, _bugData.Id);
        }
Exemple #4
0
        /// <summary>
        /// 当点击[浏览]按钮时
        /// </summary>
        public void ClickBrowseButton()
        {
            /* FolderBrowserDialog类,用于打开文件夹对话框 */
            FolderBrowserDialog _folderBrowserDialog = new FolderBrowserDialog();

            /* 调用OpenFileDialog.ShowDialog()方法,显示[打开文件对话框]
             * 这个方法有一个bool?类型的返回值
             * 返回值为Ok,代表用户选择了文件;否则就代表用户没有选择文件 */
            DialogResult _dialogResult = _folderBrowserDialog.ShowDialog();

            /* 获取用户打开的文件 的路径 */
            if (_dialogResult == DialogResult.OK)
            {
                //把用户选择的文件夹,赋值给ExportLocation属性
                string _folderPath = _folderBrowserDialog.SelectedPath + "/"
                                     + AppManager.Systems.ProjectSystem.ProjectData.FileName
                                     + " - "
                                     + DateTimeTool.DateTimeToString(DateTime.Now, TimeFormatType.YearMonthDayHourMinuteSecondMillisecond)
                                     + ".xlsx";
                UiControl.ExportLocation = _folderPath;
            }
        }
Exemple #5
0
        /// <summary>
        /// 添加记录
        /// (往Bug中,添加1条记录)
        /// </summary>
        /// <param name="_bugData">对哪个BugData进行操作?</param>
        /// <param name="_content">记录的内容</param>
        /// <param name="_images">图片的路径</param>
        public void AddRecord(BugData _bugData, string _content, ObservableCollection <string> _images = null)
        {
            /* 创建记录 */
            //创建记录数据
            RecordData _recordData = new RecordData();

            _recordData.Id      = DateTimeTool.DateTimeToLong(DateTime.UtcNow, TimeFormatType.YearMonthDayHourMinuteSecondMillisecond);
            _recordData.BugId   = _bugData.Id;
            _recordData.Content = _content;
            _recordData.Time    = DateTime.UtcNow;

            //添加到Record数据中
            AppManager.Datas.ProjectData.RecordDatas.Add(_recordData);

            //保存图片
            if (_images != null)
            {
                //遍历所有的图片
                for (int i = 0; i < _images.Count; i++)
                {
                    //保存图片(赋值图片)
                    AppManager.Systems.ImageSystem.AddImageFile(_recordData.Id, _images[i]);
                }
            }

            //赋值Bug里的ShowRecords属性
            AppManager.Systems.RecordSystem.SetShowRecords(_bugData, AppManager.Datas.OtherData.IsShowBugReply);



            /* 回复记录 (当Bear说话后,Bug需要回复一句话) */
            _recordData.ReplyId = AppManager.Systems.TemperamentSystem.RandomReply(_bugData.TemperamentId);//随机1个回复



            /* 保存记录 */
            SaveRecord(AppManager.Systems.CollaborationSystem.ModeType, _recordData.Id);
        }
        /// <summary>
        /// 将项目导出为Excel文件
        /// </summary>
        /// <param name="_path">路径(文件夹+文件名+文件后缀)</param>
        /// <returns>是否导出成功?</returns>
        public bool ExportExcel(string _path)
        {
            try
            {
                //获取Excel文件的信息(因为文件可能不存在,所以可能暂时取不到Excel文件的信息)
                FileInfo _fileInfo = new FileInfo(_path);

                //通过Excel文件的信息,打开Excel文件(如果Excel文件不存在,这个也不会报错)
                using (ExcelPackage _excelPackage = new ExcelPackage(_fileInfo))
                {
                    /* 获取要操作的表 */
                    //如果Excel文件中,没有任何表格(或者Excel文件不存在)
                    if (_excelPackage.Workbook.Worksheets.Count <= 0)
                    {
                        //创建一张表格(创建Excel文件)
                        _excelPackage.Workbook.Worksheets.Add("Sheet1");
                    }

                    //获取我们要操作的Excel表格(获取第1张表)
                    ExcelWorksheet _worksheet = _excelPackage.Workbook.Worksheets[1];



                    /* 清空表格 */
                    _worksheet.Cells.Clear();


                    /* 写入数据:表头 */
                    _worksheet.Cells[1, 1].Value = "Progress";   //往[第1行 第1列]中写入[完成度]数据
                    _worksheet.Cells[1, 2].Value = "Priority";   //往[第1行 第2列]中写入[优先级]数据
                    _worksheet.Cells[1, 3].Value = "Title";      //往[第1行 第3列]中写入[标题]数据
                    _worksheet.Cells[1, 4].Value = "CreateTime"; //往[第1行 第4列]中写入[创建时间]数据
                    _worksheet.Cells[1, 5].Value = "UpdateTime"; //往[第1行 第5列]中写入[更新时间]数据
                    _worksheet.Cells[1, 6].Value = "SolveTime";  //往[第1行 第6列]中写入[完成时间]数据


                    /* 写入数据:Bug数据 */
                    //获取BugData
                    ObservableCollection <BugData> _allBugDatas = AppManager.Systems.BugSystem.BugDatas; //所有的Bug数据
                    List <BugData> _sortBugDatas = new List <BugData>();                                 //排序后的Bug数据
                    for (int i = 0; i < _allBugDatas.Count; i++)
                    {
                        //Bug数据
                        BugData _bugData = _allBugDatas[i];

                        //判断这个Bug是否没有被删除
                        if (_bugData != null && _bugData.IsDelete != true)
                        {
                            _sortBugDatas.Add(_bugData);
                        }
                    }

                    //排序数据(按照创建时间,从前往后排序)
                    _sortBugDatas.Sort((bug1, bug2) =>
                    {
                        /* 这个Lamba表达式的返回值为int类型,意思是bug1和bug2比较的大小。(大的排后面)
                         * 如果不能理解这段代码,可以搜索"C# List 多权重排序" */

                        int _index = 0;

                        //对[创建时间]进行排序(从低到高)
                        _index += DateTime.Compare(bug1.CreateTime, bug2.CreateTime);

                        return(_index);
                    });


                    //写入数据
                    for (int i = 0; i < _sortBugDatas.Count; i++)
                    {
                        BugData _bugData = _sortBugDatas[i];                                                                                                             //Bug数据

                        int _row = i + 2;                                                                                                                                //行数(从第2行开始)

                        _worksheet.Cells[_row, 1].Value = _bugData.Progress.ToString();                                                                                  //往[第_currentRow行 第1列]中写入[完成度]数据
                        _worksheet.Cells[_row, 2].Value = _bugData.Priority.ToString();                                                                                  //往[第_currentRow行 第2列]中写入[优先级]数据
                        _worksheet.Cells[_row, 3].Value = _bugData.Name.Text;                                                                                            //往[第_currentRow行 第3列]中写入[标题]数据
                        _worksheet.Cells[_row, 4].Value = DateTimeTool.DateTimeToString(_bugData.CreateTime.ToLocalTime(), TimeFormatType.YearMonthDayHourMinuteSecond); //往[第_currentRow行 第4列]中写入[创建时间]数据
                        _worksheet.Cells[_row, 5].Value = DateTimeTool.DateTimeToString(_bugData.UpdateTime.ToLocalTime(), TimeFormatType.YearMonthDayHourMinuteSecond); //往[第_currentRow行 第5列]中写入[更新时间]数据
                        if (_bugData.Progress == ProgressType.Solved)
                        {
                            _worksheet.Cells[_row, 6].Value = DateTimeTool.DateTimeToString(_bugData.SolveTime.ToLocalTime(), TimeFormatType.YearMonthDayHourMinuteSecond);//往[第_currentRow行 第6列]中写入[完成时间]数据
                        }
                    }


                    /* 保存表格 */
                    _excelPackage.Save();
                }//关闭Excel文件


                return(true);
            }
            catch (Exception e)
            {
                //输出错误
                AppManager.Uis.ErrorUi.UiControl.TipContent = e.ToString();
                AppManager.Uis.ErrorUi.OpenOrClose(true);

                return(false);
            }
        }
Exemple #7
0
        /// <summary>
        /// 备份[Record]
        ///(备份[Record/Records.json]文件)
        /// </summary>
        public void BackupRecord()
        {
            /* 格式:Backup/Record/年月日时分秒.json */
            try
            {
                /*创建[Backup/Record]文件夹(_projectFolderPath/Backup/Record/)*/
                DirectoryInfo _recordBackupDirectoryInfo = new DirectoryInfo(RecordBackupFolderPath);
                //如果没有文件夹,就创建文件夹
                if (_recordBackupDirectoryInfo.Exists == false)
                {
                    _recordBackupDirectoryInfo.Create();
                }

                /*获取【Record】文件的个数(如果文件超过10个,就删除最早创建的那个文件)*/
                FileInfo[] _recordBackupFileInfos = _recordBackupDirectoryInfo.GetFiles();
                if (_recordBackupFileInfos != null && _recordBackupFileInfos.Length > 10)
                {
                    //找到Record备份文件中,最早创建的那个文件
                    FileInfo _firstFileInfo = FindFirstBackupFile(_recordBackupFileInfos);

                    //删除最早的1个文件
                    if (_firstFileInfo != null)
                    {
                        File.Delete(_firstFileInfo.FullName);
                    }
                }



                /* 获取要备份的文件的路径 */
                //当前的时间(年月日时分秒)
                string _nowDateTimeString = DateTimeTool.DateTimeToString(DateTime.UtcNow, TimeFormatType.YearMonthDayHourMinuteSecondMillisecond);

                //文件的备份路径
                string _recordFilePath = RecordBackupFolderPath + "/"
                                         + _nowDateTimeString + AppManager.Systems.ProjectSystem.OtherFileSuffix;



                /* 进行备份 */
                //取到所有的Record数据
                ObservableCollection <RecordData> _recordDatas = AppManager.Systems.RecordSystem.RecordDatas;

                //把RecordData转换为RecordBaseData
                List <RecordBaseData> _recordBaseDatas = new List <RecordBaseData>();
                for (int i = 0; i < _recordDatas.Count; i++)
                {
                    RecordBaseData _recordBaseData = RecordBaseData.DataToBaseData(_recordDatas[i]);
                    if (_recordBaseData != null)
                    {
                        _recordBaseDatas.Add(_recordBaseData);
                    }
                }

                //把RecordBaseData转换为json
                string _recordsJsonText = JsonMapper.ToJson(_recordBaseDatas);

                //把json文件保存到[Records.json]文件里
                File.WriteAllText(_recordFilePath, _recordsJsonText, Encoding.Default);
            }
            catch (Exception e)
            {
            }
        }
Exemple #8
0
        /// <summary>
        /// 创建项目
        /// </summary>
        /// <param name="_chooseFolderPath">用户选择的路径</param>
        /// <param name="_projectName">项目的名字</param>
        /// <param name="_modeType">项目的模式</param>
        /// <returns>是否创建成功?</returns>
        public bool CreateProject(string _chooseFolderPath, string _projectName, ModeType _modeType)
        {
            try
            {
                /* 判断文件夹是否存在 */
                DirectoryInfo _directoryInfo = new DirectoryInfo(_chooseFolderPath);//文件夹的信息
                if (_directoryInfo.Exists == false)
                {
                    return(false);
                }



                /* 去除ProjectName中的非法字符:
                 *  文件夹和文件的 名字中,不能包含:? * : " < > \ / |
                 *  并且,不能以空格开头*/
                string _projectFileName = StringTool.RemoveInvaildChat(_projectName);

                /* 如果项目名为空格,或者是去除了违规字符后为空 */
                if (_projectFileName == null || _projectFileName == "")
                {
                    //设置新的文件名字
                    _projectFileName = "New Bugs";
                }

                /*判断是否有相同的文件夹*/
                //判断是否有相同的文件夹(返回值是一个唯一的文件夹【xxxx/文件夹 (1)/】)
                string _onlyFolderPath = FolderTool.AvoidSameFolder(_chooseFolderPath + "/" + _projectFileName);
                //取到文件夹的名字(这个文件夹不会和任何文件夹重名)
                DirectoryInfo _onlyFolderInfo = new DirectoryInfo(_onlyFolderPath);
                _projectFileName = _onlyFolderInfo.Name;



                /* Project数据 */
                //创建ProjectData对象
                ProjectData _projectData = new ProjectData();
                _projectData.Id       = DateTimeTool.DateTimeToLong(DateTime.UtcNow, TimeFormatType.YearMonthDayHourMinuteSecondMillisecond);
                _projectData.Name     = _projectName;
                _projectData.FileName = _projectFileName;
                _projectData.ModeType = _modeType;

                //修改ProjectData属性
                ProjectData = _projectData;

                //工程文件夹的路径
                ProjectFolderPath = _chooseFolderPath + "\\" + _projectFileName;



                /* 创建文件和文件夹 */
                //创建:[项目文件夹]、[Bug文件夹]、[记录文件夹]、[图片文件夹]、[备份文件夹]
                CreateFolders();
                //创建:[项目文件]、[Bug文件]
                CreateFiles();



                /* 保存Project数据 */
                bool _isSave = SaveProject();
                if (_isSave == false)
                {
                    return(false);
                }


                /* 打开协同合作功能 */
                AppManager.Systems.CollaborationSystem.Handle(true);


                return(true);
            }
            catch (Exception e)
            {
                //输出错误
                AppManager.Uis.ErrorUi.UiControl.TipContent = e.ToString();
                AppManager.Uis.ErrorUi.OpenOrClose(true);
                return(false);
            }
        }
Exemple #9
0
        /// <summary>
        /// 同步
        /// (当有文件更改时,3秒后,把已经修改的文件,进行同步)
        /// </summary>
        /// <returns>是否有新的数据被同步?(true代表,有数据被同步了;false代表,这次的修改没有数据被同步)</returns>
        public bool Sync()
        {
            if (ModeType != ModeType.Collaboration)
            {
                return(false);
            }


            /* 获取数据 */
            List <long> _syncBugIds    = SyncBugIds;
            List <long> _syncRecordIds = SyncRecordIds;

            /* 清除数据 */
            SyncBugIds    = new List <long>();
            SyncRecordIds = new List <long>();

            /* 数据容器 */
            List <string> _bugLogs;                           //Bug的日志
            List <string> _recordLogs;                        //记录的日志
            Dictionary <long, ChangeType> _bugChangeTypes;    //Bug的改变
            Dictionary <long, ChangeType> _recordChangeTypes; //记录的改变



            /*同步*/
            SyncBug(_syncBugIds, out _bugChangeTypes, out _bugLogs);
            SyncRecord(_syncRecordIds, out _recordChangeTypes, out _recordLogs);



            /*更新Ui:Bug*/
            if (_bugLogs.Count > 0)
            {
                /* 重新排列 */
                //重新获取Bug的个数+页数
                AppManager.Systems.BugSystem.CalculatedBugsNumber();
                AppManager.Systems.PageSytem.CalculatedPagesNumber();

                //重新排序
                AppManager.Systems.SortSystem.Sort();

                //重新过滤
                AppManager.Systems.SearchSystem.Filter();

                //重新计算页数
                AppManager.Systems.PageSytem.CalculatedPagesNumber();



                /*更新Ui*/
                foreach (long _bugId in _bugChangeTypes.Keys)//遍历所有的改变
                {
                    //获取Bug数据
                    BugData _bugData = AppManager.Systems.BugSystem.GetBugData(_bugId);

                    //获取改变
                    ChangeType _changeType = ChangeType.None;
                    _bugChangeTypes.TryGetValue(_bugId, out _changeType);

                    //判断Bug的改变
                    if (_bugData != null)
                    {
                        switch (_changeType)
                        {
                        //如果是[添加Bug]
                        case ChangeType.Add:
                            //把Bug插入到当前的页面中
                            AppManager.Systems.PageSytem.Insert(_bugData);
                            break;

                        //如果是[删除Bug]
                        case ChangeType.Delete:
                            //并且正在显示这个Bug的话
                            if (AppManager.Uis.BugUi.UiControl.Visibility == Visibility.Visible &&
                                AppManager.Datas.OtherData.ShowBugItemData != null &&
                                AppManager.Datas.OtherData.ShowBugItemData.Data.Id == _bugId &&
                                _bugId > -1)
                            {
                                //关闭修改Bug的界面
                                if (AppManager.Uis.ChangeBugUi.UiControl.Visibility == Visibility.Visible)
                                {
                                    AppManager.Uis.ChangeBugUi.OpenOrClose(false);
                                }

                                //关闭Bug的界面
                                AppManager.Uis.BugUi.OpenOrClose(false);

                                //如果MainUi没有打开
                                if (AppManager.Uis.MainUi.UiControl.Visibility == Visibility.Collapsed)
                                {
                                    //就打开ListUi
                                    AppManager.Uis.ListUi.OpenOrClose(true);
                                }
                            }
                            break;

                        //如果是[修改Bug]
                        case ChangeType.Change:
                            //显示BugItem的GoToPage按钮
                            int _pageNumber = AppManager.Systems.PageSytem.GetPageNumber(_bugData); //获取到Bug的新页码
                            _bugData.ItemData.GoToPageNumber = _pageNumber;                         //显示跳转的页码
                            break;
                        }
                    }
                }
            }

            /*更新Ui:Record*/
            if (_recordLogs.Count > 0)
            {
                /*更新Ui*/
                foreach (long _recordId in _recordChangeTypes.Keys)
                {
                    //获取Record数据
                    RecordData _recordData = AppManager.Systems.RecordSystem.GetRecordData(_recordId);

                    //获取Bug数据
                    BugData _bugData = AppManager.Systems.BugSystem.GetBugData(_recordData);

                    //如果Bug是正在显示的Bug,那么就刷新BugUi的记录
                    if (AppManager.Datas.OtherData.ShowBugItemData != null &&
                        _bugData != null &&
                        AppManager.Datas.OtherData.ShowBugItemData.Data.Id == _bugData.Id)
                    {
                        //刷新记录
                        AppManager.Systems.RecordSystem.SetShowRecords(_bugData, AppManager.Datas.OtherData.IsShowBugReply);
                    }
                }
            }



            /*日志*/
            if (_bugLogs.Count > 0 || _recordLogs.Count > 0)
            {
                //这次的日志
                string _syncLogText = "";

                //时间
                _syncLogText += "【" + DateTimeTool.DateTimeToString(DateTime.Now, TimeFormatType.YearMonthDayHourMinuteSecond) + "】";

                //Bug的日志
                for (int i = 0; i < _bugLogs.Count; i++)
                {
                    _syncLogText += "\n" + "    " + "(" + (i + 1) + ") " + _bugLogs[i];
                }
                //Record的日志
                for (int i = 0; i < _recordLogs.Count; i++)
                {
                    _syncLogText += "\n" + "    " + "(" + (i + 1) + ") " + _recordLogs[i];
                }

                //提行
                _syncLogText += "\n\n\n";

                //刷新Ui
                SyncLogText = _syncLogText + SyncLogText;
            }


            /*时间和次数*/
            if (_bugLogs.Count > 0 || _recordLogs.Count > 0)
            {
                SyncNumber      += 1;
                LastSyncDateTime = DateTime.UtcNow;
            }


            /* 返回值 */
            if (_bugLogs.Count > 0 || _recordLogs.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }