Beispiel #1
0
        private async void OnSave()
        {
            var cd = new CodeDocument();

            if (UpdateDocumentId > 0)
            {
                cd.Id = UpdateDocumentId;
            }
            cd.Title    = this._title;
            cd.Datas    = this._document.Text;
            cd.Deleted  = false;
            cd.KeyWords = this._keyWords;
            if (UpdateDocumentId <= 0)
            {
                cd.CreatedUtc = DateTime.UtcNow;
            }
            cd.LastUpdatedUtc        = DateTime.UtcNow;
            cd.OtherTechniques       = string.Empty;
            cd.ProgrammingLanguageId = this._programmingLanguageId;
            cd.ProgrammingTypeId     = this._programmingTypeId;
            if (UpdateDocumentId <= 0)
            {
                await CodeDocumentService.InsertCodeDocument(cd);
            }
            else
            {
                await CodeDocumentService.UpdateCodeDocument(cd);

                UpdateDocumentId = 0;
            }

            this.Title    = string.Empty;
            this.Document = new TextDocument(new StringTextSource(""));
            this.KeyWords = string.Empty;
        }
Beispiel #2
0
        private async void GetTreeData()
        {
            var list = await CodeDocumentService.GetCodeDocumentTitlesByTitle("");

            string _root     = "";
            var    rootChild = new ItemTreeData();
            var    _list     = new List <ItemTreeData>();

            foreach (var s in list)
            {
                var ss = EnumHelper.GetEnumName <ProgrammingLanguage>(s.ProgrammingLanguageId);
                if (_root != ss)
                {
                    rootChild           = new ItemTreeData();
                    rootChild.titleName = ss;
                    rootChild.itemId    = 0;
                    _list.Add(rootChild);
                    _root = ss;
                }
                var child = new ItemTreeData();
                child.titleName = s.Title;
                child.itemId    = s.Id;
                rootChild.Children.Add(child);
            }
            //itemTreeDataList.Clear();
            //ItemTreeDataList.Clear();
            try
            {
                ItemTreeDataList = new ObservableCollection <ItemTreeData>(_list);
            }
            catch (Exception e)
            {
            }
        }
Beispiel #3
0
        private async void OnDelete()
        {
            if (SelectedCodeId <= 0)
            {
                return;
            }
            var cd = await CodeDocumentService.GetCodeDocumentById(SelectedCodeId);

            await CodeDocumentService.DeleteCodeDocument(cd);

            OnRefresh();
        }
Beispiel #4
0
        private async void GetCodeDocumentById(int id)
        {
            var currentCodeDocument = await CodeDocumentService.GetCodeDocumentById(id);

            if (currentCodeDocument != null)
            {
                updateDocument = currentCodeDocument;
                Title          = currentCodeDocument.Title;
                //Data = currentCodeDocument.Datas;
                Document = new TextDocument(new StringTextSource(currentCodeDocument.Datas));
                ProgrammingLanguageId = currentCodeDocument.ProgrammingLanguageId;
                ProgrammingTypeId     = currentCodeDocument.ProgrammingTypeId;
                KeyWords         = currentCodeDocument.KeyWords;
                UpdateDocumentId = currentCodeDocument.Id;
            }
        }
        private async void GetCodeInfo(int id)
        {
            var dc = await CodeDocumentService.GetCodeDocumentById(id);

            CodeTitle = dc.Title;
            //CodeInfo = dc.KeyWords;
            string spl = EnumHelper.GetEnumName <ProgrammingLanguage>(dc.ProgrammingLanguageId);
            string spt = EnumHelper.GetEnumName <ProgrammingType>(dc.ProgrammingTypeId);

            CodeInfo = $"语言: {spl}   框架: {spt}     关键字: {dc.KeyWords}";
            //Data = dc.Datas;
            if (dc.Datas != null)
            {
                Document = new TextDocument(new StringTextSource(dc.Datas));
            }
        }
Beispiel #6
0
        public async void GetDocumentCount()
        {
            var count = await CodeDocumentService.GetCodeDocumentCount();

            CountDoc = count;
        }