Example #1
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);
        }
Example #2
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);
        }
Example #3
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);
            }
        }