Пример #1
0
        public T AddChild <T>(Form parentForm, XCollection <T> list)
            where T : MappingItem, IDicomMappingItem, new()
        {
            T selitem = GetSelectedItem() as T;

            if (selitem == null || selitem.DPath.VR != DVR.SQ)
            {
                return(null);
            }

            FormElement2 <T> frm = new FormElement2 <T>(null, list, selitem, true, _gwDataDBConnection, _log, _asQueryResult, _isInbound);

            BeforeShowFormElement(ButtonType.AddChild, frm, selitem);
            if (frm.ShowDialog(parentForm) != DialogResult.OK)
            {
                return(null);
            }
            AfterShowFormElement(ButtonType.AddChild, frm, selitem);

            T newitem = frm.MappingItem;

            if (newitem == null)
            {
                return(null);
            }

            int  index    = list.IndexOf(selitem);
            bool hasChild = DicomMappingHelper.HasSequence <T>(index, list);

            if (hasChild == false)
            {
                T iBegin = new T();
                DPath.SetItemGroupPathBegin(iBegin.DPath, 0);
                T iEnd = new T();
                DPath.SetItemGroupPathEnd(iEnd.DPath, 0);

                int sqIndex = index + 1;
                list.Insert(sqIndex++, iBegin);
                list.Insert(sqIndex, iEnd);
            }

            if (DicomMappingHelper.FindEndDPathIndex <T>(ref index, list))
            {
                newitem.DPath.Catagory = selitem.DPath.Catagory;
                list.Insert(index, newitem);
            }

            return(newitem);
        }
Пример #2
0
        public T Add <T>(Form parentForm, XCollection <T> list)
            where T : MappingItem, IDicomMappingItem, new()
        {
            T selitem = GetSelectedItem() as T;

            FormElement2 <T> frm = new FormElement2 <T>(null, list, selitem, false, _gwDataDBConnection, _log, _asQueryResult, _isInbound);

            BeforeShowFormElement(ButtonType.Add, frm, selitem);
            if (frm.ShowDialog(parentForm) != DialogResult.OK)
            {
                return(null);
            }
            AfterShowFormElement(ButtonType.Add, frm, selitem);

            T newitem = frm.MappingItem;

            if (newitem == null)
            {
                return(null);
            }

            if (selitem == null)
            {
                list.Add(newitem);
            }
            else
            {
                newitem.DPath.Catagory = selitem.DPath.Catagory;
                int index = list.IndexOf(selitem);
                list.Insert(index, newitem);
            }

            return(newitem);
        }
Пример #3
0
        public static void SetAdditionalQueryCriteria <TC>(XCollection <TC> qcList, XCollection <TC> additionalQCList, QueryCriteriaType additionalQCJoinType)
            where TC : QueryCriteriaItem, IDicomMappingItem, new()
        {
            if (qcList == null || additionalQCList == null)
            {
                return;
            }

            if (qcList.Count < 1)
            {
                foreach (TC qcItem in additionalQCList)
                {
                    qcList.Add(qcItem);
                }
            }
            else if (additionalQCList.Count > 0)
            {
                qcList[0].Type           = QueryCriteriaType.None;
                additionalQCList[0].Type = QueryCriteriaType.None;

                TC qcLeft = new TC();
                qcLeft.Singal = QueryCriteriaSignal.LeftBracket;
                qcLeft.Type   = QueryCriteriaType.None;
                qcList.Insert(0, qcLeft);

                TC qcRight = new TC();
                qcRight.Singal = QueryCriteriaSignal.RightBracket;
                qcRight.Type   = QueryCriteriaType.None;
                qcList.Add(qcRight);

                TC qcAddLeft = new TC();
                qcAddLeft.Singal = QueryCriteriaSignal.LeftBracket;
                qcAddLeft.Type   = additionalQCJoinType;
                qcList.Add(qcAddLeft);

                foreach (TC qcItem in additionalQCList)
                {
                    qcList.Add(qcItem);
                }

                TC qcAddRight = new TC();
                qcAddRight.Singal = QueryCriteriaSignal.RightBracket;
                qcAddRight.Type   = QueryCriteriaType.None;
                qcList.Add(qcAddRight);
            }
        }
Пример #4
0
        public static void ModifyQCMappingList_DateTime <TC>(XCollection <TC> qcList, bool withBracket)
            where TC : QueryCriteriaItem, IDicomMappingItem, new()
        {
            if (qcList == null)
            {
                return;
            }
            bool found = true;

            while (found)
            {
                found = false;
                int count = qcList.Count;
                for (int index = 0; index < count; index++)
                {
                    TC item = qcList[index];

                    IDicomMappingItem dcmItem = item as IDicomMappingItem;
                    if (dcmItem == null)
                    {
                        continue;
                    }

                    if (dcmItem.DPath != null &&
                        dcmItem.DPath.Range == DRangeType.None &&
                        DHelper.IsDateTime(dcmItem.DPath.VR))
                    {
                        qcList.Remove(item);

                        QueryCriteriaItem itemB = dcmItem.Clone() as QueryCriteriaItem;
                        ((IDicomMappingItem)itemB).DPath.Range = DRangeType.Begin;
                        itemB.Operator    = QueryCriteriaOperator.EqualLargerThan;
                        itemB.SourceField = itemB.SourceField + "_BEGIN";

                        QueryCriteriaItem itemE = dcmItem.Clone() as QueryCriteriaItem;
                        ((IDicomMappingItem)itemE).DPath.Range = DRangeType.End;
                        itemE.Operator    = QueryCriteriaOperator.EqualSmallerThan;
                        itemE.SourceField = itemE.SourceField + "_END";

                        if (withBracket)    // for GetRule()
                        {
                            qcList.Insert(index, GetRightBracket <TC>());
                            qcList.Insert(index, GetRightBracket <TC>());

                            TC itemEE = GetFreeText <TC>("@" + itemE.SourceField + "=''");
                            itemEE.Type = QueryCriteriaType.And;
                            qcList.Insert(index, itemEE);

                            TC itemBB = GetFreeText <TC>("@" + itemB.SourceField + "=''");
                            itemBB.Type = QueryCriteriaType.None;
                            qcList.Insert(index, itemBB);

                            TC itemOr = GetLeftBracket <TC>();
                            itemOr.Type = QueryCriteriaType.Or;
                            qcList.Insert(index, itemOr);

                            qcList.Insert(index, GetRightBracket <TC>());

                            itemE.Type = QueryCriteriaType.And;
                            qcList.Insert(index, itemE);

                            itemB.Type = QueryCriteriaType.None;
                            qcList.Insert(index, itemB);

                            qcList.Insert(index, GetLeftBracket <TC>());

                            TC itemAnd = GetLeftBracket <TC>();
                            itemAnd.Type = QueryCriteriaType.And;
                            qcList.Insert(index, itemAnd);
                        }
                        else                // for NT Service to create QC DataSet
                        {
                            qcList.Insert(index, itemE);
                            qcList.Insert(index, itemB);
                        }

                        found = true;
                        break;
                    }
                }
            }
        }
Пример #5
0
		private async Task LoadBookmarks( Session session )
		{
			XCollection<Bookmark> bookmarks = null;
			try
			{
				bookmarks = await _bookmarksProvider.GetBookmarks( session.Token );
			}
			catch (CatalitNoCredentialException)
			{
				//ToDo: Do something? Message?
			}

			XCollection<Book> books = new XCollection<Book>();

			foreach (var bookmark in bookmarks)
			{
				if( bookmark.Group != "0" )
				{
					var exits = books.FirstOrDefault( x => x.Description.Hidden.DocumentInfo.Id == bookmark.ArtId );

					if( exits != null )
					{
						exits.BookmarksCount++;
					}
					else
					{
						var book = await _catalogProvider.GetBookByDocumentId( bookmark.ArtId, session.Token );
						if( book != null )
						{
							book.BookmarksCount = 1;
							books.Add( book );
						}
					}
				}
			}

			//sort books by last opened
			int top = 0;
			var myBooksHistory = await _catalogProvider.GetBooksIdsFromHistory( session.Token );

			foreach( var mybook in myBooksHistory )
			{
				var inbookmarked = books.FirstOrDefault(x => x.Id == mybook );

				if( inbookmarked != null )
				{
					books.Remove( inbookmarked );
					books.Insert( top, inbookmarked );
					top++;
				}
			}

			BookmarkedBooks.Update( books );

			BookmarkedBooksEmpty = BookmarkedBooks.Count == 0;

			if (bookmarks != null)
			{
				Bookmarks.Update(bookmarks);
			}
		}
Пример #6
0
        public static void ModifyQCMappingList_CS <TC>(XCollection <TC> qcList, bool withBracket)
            where TC : QueryCriteriaItem, IDicomMappingItem, new()
        {
            if (qcList == null)
            {
                return;
            }
            bool found = true;

            while (found)
            {
                found = false;
                int count = qcList.Count;
                for (int index = 0; index < count; index++)
                {
                    TC item = qcList[index];

                    IDicomMappingItem dcmItem = item as IDicomMappingItem;
                    if (dcmItem == null)
                    {
                        continue;
                    }

                    if (dcmItem.DPath != null &&
                        dcmItem.DPath.VR == DVR.CS &&
                        dcmItem.DPath.Path == DicomMappingHelper.DataColumnName2DPath(item.SourceField))
                    {
                        qcList.Remove(item);

                        if (withBracket)    // for GetRule()
                        {
                            qcList.Insert(index, DicomMappingHelper.GetRightBracket <TC>());
                        }

                        for (int i = Program.ConfigMgt.Config.CSDivisionMAXCount - 1; i >= 0; i--)  // for GetRule() and for NT Service to create QC DataSet
                        {
                            QueryCriteriaItem itemSub = dcmItem.Clone() as QueryCriteriaItem;
                            itemSub.SourceField = itemSub.SourceField + "_" + i.ToString();
                            itemSub.Operator    = QueryCriteriaOperator.Like;
                            if (i == 0)
                            {
                                itemSub.Type = QueryCriteriaType.None;
                            }
                            else
                            {
                                itemSub.Type = QueryCriteriaType.Or;
                            }
                            qcList.Insert(index, itemSub);
                        }

                        if (withBracket)    // for GetRule()
                        {
                            TC itemAnd = DicomMappingHelper.GetLeftBracket <TC>();
                            itemAnd.Type = QueryCriteriaType.And;
                            qcList.Insert(index, itemAnd);
                        }

                        found = true;
                        break;
                    }
                }
            }
        }