public async Task<Person> GetPersonByName(string personName, CancellationToken cancellationToken)
		{
			Person person = null;
			if (_singlePerson == null)
			{
				_singlePerson = new XCollection<Person>();
			}
			person = _singlePerson.FirstOrDefault( bk => bk.Title.Main.Equals( personName ) );
			if (person != null)
			{
				//move to first
				_singlePerson.Remove(person);
				_singlePerson.Insert(0, person);
			}
			if (person == null)
			{
				var parameters = new Dictionary<string, object>
				{							
					{"search_person", personName}								
				};
				var persons = await _client.GetPerson(parameters, cancellationToken);
				if (persons?.Persons != null && persons.Persons.Count > 0)
				{
					_singlePerson.Insert(0, persons.Persons[0]);
					if (_singlePerson.Count > SinglePersonsCount)
					{
						_singlePerson.RemoveAt(SinglePersonsCount);
					}
					return persons.Persons[0];
				}
			}
			return person;
		}
Example #2
0
        public XCollection<Book.CollectionsInfo> GetCollection()
        {
            var sequences = new XCollection<Book.CollectionsInfo>();
            if (collections != null)
            {
                foreach (var collection in collections)
                {
                    try
                    {
                        var imageUrl = string.Format("{0}{1}", "http://win10-ebook.litres.ru", collection.img);

                        sequences.Add(new Book.CollectionsInfo
                        {
                            Id = int.Parse(collection.id),
                            Number = int.Parse(collection.arts_count),
                            Name = collection.name,
                            ImgUrl = imageUrl
                        });
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }
            return sequences;
        }
Example #3
0
        public XCollection<Book.SequenceInfo> GetSequences()
        {
            var sequences = new XCollection<Book.SequenceInfo>();
            if (series != null)
            {
                foreach (var seria in series)
                {
                    try
                    {
                        var imageUrl = string.Format("{0}{1}", "http://win10-ebook.litres.ru", seria.img);

                        sequences.Add(new Book.SequenceInfo
                        {
                            Id = int.Parse(seria.id),
                            Number = int.Parse(seria.total_arts),
                            Name = seria.name,
                            ImgUrl = imageUrl
                        });
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }
            return sequences;
        }
Example #4
0
        public BannerControl(GridView bannerCanv, XCollection<Banner> banners, Frame frame)
        {
            _frame = frame;         
            bannerCanv.Items?.Clear();
            var deviceWidth = Window.Current.CoreWindow.Bounds.Width;
            foreach (var banner in banners)
            {
                var bannerBitmap = new BitmapImage {UriSource = new Uri(banner.Image, UriKind.RelativeOrAbsolute)};

                var bannerImage = SystemInfoHelper.IsMobile() || deviceWidth < 800 ? new Image
                {
                    Source = bannerBitmap,
                    Stretch = Stretch.Fill,
                    MaxWidth = deviceWidth + 5
                } : new Image
                {
                    Source = bannerBitmap,
                    Stretch = Stretch.Fill,
                    MaxHeight = bannerCanv.MaxHeight                    
                };
                bannerImage.Tapped += OnBannerTap;                
                bannerImage.Tag = banner;
                bannerCanv.Visibility = Visibility.Visible;
                bannerImage.Visibility = Visibility.Visible;
                bannerCanv.Items?.Add(bannerImage);
            }
            if (SystemInfoHelper.IsMobile() || deviceWidth < 800)
                bannerCanv.MaxHeight = deviceWidth / 2.46;
        }
		public async Task<XCollection<Notification>> GetNotifications( CancellationToken cancellationToken )
		{
			if (_notifications == null)
			{
				_notifications = _dataCacheService.GetItem<XCollection<Notification>>(CacheItemName);
			}

			return _notifications ?? new XCollection<Notification>();
		}
		public async Task<XCollection<SearchQuery>> GetHistory(CancellationToken cancellationToken)
		{
			if (_searchQueries == null)
			{
				_searchQueries =  _dataCacheService.GetItem<XCollection<SearchQuery>>(CacheItemName);
			}

			return _searchQueries ?? (_searchQueries = new XCollection<SearchQuery>());
		}
		public CollectionsViewModel( ICollectionsProvider collectionsProvider, INavigationService navigationService )
		{
			_collectionsProvider = collectionsProvider;
			_navigationService = navigationService;

			Collections = new XCollection<Collection>();

			RegisterPart( MainPart, ( session, part ) => LoadCollections( session ), ( session, part ) => !_loaded );
		}
		public async void DeleteNotificationsCalled( XCollection<Notification> notifications )
		{
			PreserveSessions( true );

			if( notifications != null )
			{
				var session = new Session( DeleteNotificationPart );
				session.AddParameter( "delete", notifications );
				await Load( session );
			}
		}
Example #9
0
 public XCollection<Person> GetPersons()
 {
     var persons = new XCollection<Person>();
     if (authors != null)
     {
         foreach (var author in authors)
         {
             var person = author.ToPerson();
             persons.Add(person);
         }
     }
     return persons;
 }
Example #10
0
 public XCollection<Book> GetBooks()
 {
     var artsCollection = new XCollection<Book>();
     if (arts != null)
     {
         foreach (var art in arts)
         {
             var book = art.ToBook();
             artsCollection.Add(book);
         }
     }
     return artsCollection;
 }
		public SearchHistoryViewModel( ISearchHistoryProvider searchHistoryProvider, ICatalogProvider catalogProvider, INavigationService navigationService )
		{
			_searchHistoryProvider = searchHistoryProvider;
			_catalogProvider = catalogProvider;
			_navigationService = navigationService;

            RegisterAction(LoadHistoryPart).AddPart((session) => LoadHistory(session), (session) => true);
            RegisterAction(LoadBooksPart).AddPart((session) => SearchBooks(session), (session) => true);
            RegisterAction(AddToHistoryPart).AddPart((session) => AddToHistory(session), (session) => true);
            RegisterAction(RemoveFromHistoryPart).AddPart((session) => RemoveFromHistory(session), (session) => true);
            
            SearchQueries = new XCollection<SearchQuery>();
		}
		public async Task<XCollection<Collection>> ProvideMyCollections( CancellationToken cancellationToken )
		{
			if (_collections == null)
			{
				Dictionary<string, object> parameters = new Dictionary<string, object>
						{									
							{"my_active", "1"},							
						};
				var collections = await _client.ProvideMyCollections(parameters, cancellationToken);
				_collections = collections.Collections;
			}

			return _collections;
		}
		public BookmarksViewModel(IBookmarksProvider bookmarksProvider, ICatalogProvider catalogProvider, INavigationService navigationService)
		{
			_bookmarksProvider = bookmarksProvider;
			_catalogProvider = catalogProvider;
			_navigationService = navigationService;

			RegisterPart( MainPart, ( session, part ) => LoadBookmarks( session ), ( session, part ) => true );
			//RegisterPart( DeletePart, ( session, part ) => DeleteBookmarks( session ), ( session, part ) => true, false );


			Bookmarks = new XCollection<Bookmark>();
			BookmarkedBooks = new XCollection<Book>();

			BookSelected = new RelayCommand<Book>( book => _navigationService.Navigate( "BookBookmarks", Parameters.From( "id", book.Id )), book => book != null );
		}
		public NotificationsViewModel( INotificationsProvider notificationsProvider, INavigationService navigationService )
		{
			_notificationsProvider = notificationsProvider;
			_navigationService = navigationService;

            RegisterAction(DeleteNotificationPart).AddPart(session => DeleteNotificationsProceed(session), session => true);
            RegisterAction(MainPart).AddPart(session => LoadNotifications(session), session => true);

			Notifications = new XCollection<Notification>();

			ShowNotificationsEdit = new RelayCommand( () => _navigationService.Navigate( "NotificationsEdit" ) );
			//CancelEdit = new RelayCommand( () => _navigationService.GoBack() );
			NotificationSelected = new RelayCommand<Notification>( NavigateToObject, notification => notification != null );
			DeleteNotifications = new RelayCommand<XCollection<Notification>>( DeleteNotificationsCalled, notifications => notifications != null );
		}
Example #15
0
        public void ShowInformation()
        {
            #region 3rd party connection
            this.textBoxProvider.Text = DBconfig.ConnectionParameter.Provider;
            this.txtServer.Text       = DBconfig.ConnectionParameter.Server;
            this.txtDB.Text           = DBconfig.ConnectionParameter.Database;
            this.txtUser.Text         = DBconfig.ConnectionParameter.User;
            this.txtPassword.Text     = DBconfig.ConnectionParameter.Password;
            this.connectionStr        = DBconfig.ConnectionParameter.ConnectionStr;
            string head = Regex.Match(connectionStr, pattern).Value;
            this.otherParameters = connectionStr.Substring(head.Length);
            if (DBconfig.TimerInterval < this.numericUpDown.Minimum)
            {
                this.numericUpDown.Value = this.numericUpDown.Minimum;
            }
            else if (DBconfig.TimerInterval > this.numericUpDown.Maximum)
            {
                this.numericUpDown.Value = this.numericUpDown.Maximum;
            }
            else
            {
                this.numericUpDown.Value = DBconfig.TimerInterval;
            }
            this.chkOracleDriver.Checked = DBconfig.OracleDriver;
            #endregion

            #region ChannelInfo
            DBconfig.TimerInterval = (int)numericUpDown.Value;

            if (channelSet != null)
            {
                if (channelSet.Count != 0)
                {
                    ShowChannelSetInformation();
                }
                channelIndex = -1;     //It sign that there is no channel in the channelset
            }
            else
            {
                //Never occur as SQLOutAdapterConfigMgt.SQLOutAdapterConfig was be constuctured
                channelSet = new XCollection <SQLOutboundChanel>();
            }
            #endregion

            LoadFileConnection();
        }
Example #16
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);
            }
        }
Example #17
0
        private XCollection <GWDataDBField> ParseTemplate()
        {
            XCollection <GWDataDBField> fields = new XCollection <GWDataDBField>();

            string s, sub;

            s = tbTemplate.Text;
            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Index))
            {
                sub = "[%" + f.GetFullFieldName().Replace(".", "_") + "%]";
                if (s.IndexOf(sub) >= 0)
                {
                    fields.Add(f);
                }
            }

            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Patient))
            {
                sub = "[%" + f.GetFullFieldName().Replace(".", "_") + "%]";
                if (s.IndexOf(sub) >= 0)
                {
                    fields.Add(f);
                }
            }

            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Order))
            {
                sub = "[%" + f.GetFullFieldName().Replace(".", "_") + "%]";
                if (s.IndexOf(sub) >= 0)
                {
                    fields.Add(f);
                }
            }

            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Report))
            {
                sub = "[%" + f.GetFullFieldName().Replace(".", "_") + "%]";
                if (s.IndexOf(sub) >= 0)
                {
                    fields.Add(f);
                }
            }

            return(fields);
        }
Example #18
0
        public FormElement(StorageItem item, XCollection <StorageItem> itemList)
        {
            InitializeComponent();

            _storageItem = item;
            _itemList    = itemList;

            _tagControler = new TagControler(false, this.groupBoxDicom,
                                             this.comboBoxVR, this.comboBoxTag, this.textBoxGroupNum, this.textBoxElementNum);
            _tagControler.OnValueChanged += new EventHandler(_tagControler_OnValueChanged);

            _fieldControler = new FieldControler(false, this.groupBoxGateway,
                                                 this.comboBoxTable, this.comboBoxField, this.checkBoxFixValue,
                                                 this.textBoxFixValue, this.checkBoxLUT, this.comboBoxLUT, true);
            _fieldControler.OnValueChanged += new EventHandler(_fieldControler_OnValueChanged);

            _tagControler.Enabled = false;
        }
Example #19
0
 public static XCollection <RegularExpressionItem> GetRegExpressions()
 {
     if (_list == null)
     {
         IMCfgMgt mgt = new IMCfgMgt();
         mgt.FileName = Application.StartupPath + "\\..\\..\\" + mgt.FileName;
         if (mgt.Load())
         {
             _list = mgt.Config.RegularExpressions;
             Program.Log.Write("Load IM configuration (for regular expressions) succeeded.");
         }
         else
         {
             Program.Log.Write(LogType.Warning, "Load IM configuration (for regular expressions) failed.");
         }
     }
     return(_list);
 }
Example #20
0
        /// <summary>
        /// User for copy!
        /// </summary>
        /// <param name="channels"></param>
        /// <param name="ft"></param>
        public StorageProcedure(XCollection <SQLOutboundChanel> channels, SQLOutboundChanel ch)
        {
            InitializeComponent();
            channelSet          = channels;
            channel             = ch.Clone();
            channel.Rule.RuleID = ch.Rule.RuleID;
            type      = "Edit";
            this.Text = "Edit Storage Procedure";

            parameterPage = new ParameterPage(channel);
            statementPage = new StatementPage(channel);
            GetSPNameSet(channels);
            channel.SPName += "_Copy";

            InitializationCopy();

            //ShowInformation();
        }
Example #21
0
        private void RefreshList()
        {
            this.listViewList.Items.Clear();
            XCollection <RegularExpressionItem> list = GetRegExpressions();

            if (list == null)
            {
                return;
            }

            foreach (RegularExpressionItem i in list)
            {
                ListViewItem item = new ListViewItem(i.Expression);
                item.SubItems.Add(i.Replacement);
                item.SubItems.Add(i.Description);
                item.Tag = i;
                this.listViewList.Items.Add(item);
            }
        }
Example #22
0
        public void UpdatePrivateTagList()
        {
            Dictionary <string, PrivateTag> dic = new Dictionary <string, PrivateTag>();

            foreach (MWLQueryCriteriaItem qcItem in Rule.QueryCriteria.MappingList)
            {
                if (qcItem.DPath.Type != DPathType.Normal)
                {
                    continue;
                }
                int tag = qcItem.DPath.GetTag();
                if (PrivateTagHelper.IsPrivateTag(tag))
                {
                    string strTag = DHelper.Int2HexString(tag);
                    if (!dic.ContainsKey(strTag))
                    {
                        dic.Add(strTag, new PrivateTag(strTag, qcItem.DPath.VR));
                    }
                }
            }

            // do not keep manually added item, refresh the whole private tag list

            //if (PrivateTagList != null)
            //{
            //    foreach (PrivateTag tag in PrivateTagList)
            //    {
            //        string strTag = tag.Tag;
            //        if (!dic.ContainsKey(strTag))
            //        {
            //            dic.Add(strTag, tag);
            //        }
            //    }
            //}

            XCollection <PrivateTag> xlist = new XCollection <PrivateTag>();

            foreach (KeyValuePair <string, PrivateTag> p in dic)
            {
                xlist.Add(p.Value);
            }
            PrivateTagList = xlist;
        }
Example #23
0
        private bool MatchMessage(Message msg, IRoutingRule rule)
        {
            bool res = false;

            if (msg == null || rule == null)
            {
                return(res);
            }

            switch (rule.Type)
            {
            default:
            case RoutingRuleType.MessageType:
            {
                if (msg.Header == null || msg.Header.Type == null)
                {
                    return(res);
                }
                XCollection <MessageType> mtlist = rule.MessageTypeList;
                if (mtlist == null)
                {
                    return(res);
                }
                foreach (MessageType mt in mtlist)
                {
                    if (msg.Header.Type.EqualsTo(mt))
                    {
                        res = true;
                        break;
                    }
                }
                break;
            }

            case RoutingRuleType.ContentBased:
            {
                return(MatchMessageContent(msg, rule.ContentCriteria));
            }
            }

            return(res);
        }
Example #24
0
        private void SelectMessageTypes(XCollection <MessageTypePair> list)
        {
            List <MessageTypePair> slist = new List <MessageTypePair>();

            foreach (MessageTypePair t in this.checkedListBoxMessageType.Items)
            {
                foreach (MessageTypePair mt in list)
                {
                    if (mt.EqualsTo(t))
                    {
                        slist.Add(t);
                    }
                }
            }
            foreach (MessageTypePair s in slist)
            {
                this.checkedListBoxMessageType.SetItemChecked
                    (this.checkedListBoxMessageType.Items.IndexOf(s), true);
            }
        }
Example #25
0
        public static void Run()
        {
            XCollection coll = new XCollection();

            coll.Add("A");
            coll.Add("B");
            coll.Add("C");
            coll.Add("D");
            coll.Add("E");

            IXIterator it = coll.GetIterator();
            object     o;

            while ((o = it.Next()) != null)
            {
                Console.WriteLine(o);
            }

            // 출력 : A C E  (0, 2, 4 등 짝수만 출력함)
        }
Example #26
0
        public FormPullChannel(PullChannelConfig cfg, ActionType actionType, XCollection <PullChannelConfig> cfgList)
        {
            InitializeComponent();

            _cfgList       = cfgList;
            _channelConfig = cfg;
            _actionType    = actionType;

            if (_channelConfig == null)
            {
                _channelConfig = new PullChannelConfig();
            }

            _routTypeCtrl           = new RoutingTypeControler(this.comboBoxRoutingType);
            _routTypeCtrl.Selected += new RoutingTypeSelectedHanlder(_routTypeCtrl_Selected);
            _routTypeCtrl.Initialize();

            _protocolTypeCtrl = new ProtocolTypeControler(this.comboBoxProtocolType);
            _protocolTypeCtrl.Initialize();
        }
Example #27
0
        private void btSelPreGWDBField_Click(object sender, EventArgs e)
        {
            FSelFields frm = new FSelFields();

            XCollection <GWDataDBField> fields = FileOutboundAdapterConfigMgt.FileOutAdapterConfig.OutGeneralParams.PreGWDataDBFields;

            if (frm.ShowDialog(null, fields) != DialogResult.OK)
            {
                return;
            }

            StringBuilder sb = new StringBuilder();

            foreach (GWDataDBField f in fields)
            {
                sb.Append("[%" + f.GetFullFieldName().Replace(".", "_") + "%]" + "_");
            }

            this.tbFilePrefix.Text = sb.ToString();
        }
Example #28
0
        public T Edit <T>(Form parentForm, XCollection <T> list)
            where T : MappingItem, IDicomMappingItem, new()
        {
            T selitem = GetSelectedItem() as T;

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

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

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

            return(selitem);
        }
Example #29
0
        public Channel(ActiveMode frm, XCollection <SQLOutboundChanel> channels)
        {
            InitializeComponent();

            parentForm       = frm;
            channelSet       = channels;
            type             = "Add";
            this.Text        = "Add Channel";
            channel          = new SQLOutboundChanel();
            criteriaItemList = new XCollection <SQLOutQueryCriteriaItem>();
            resultItemList   = new XCollection <SQLOutQueryResultItem>();

            GetChannelNameSet(channels);

            if (parentForm.DBconfig.ConnectionParameter.FileConnection)
            {
                this.enumCmbbxOperationType.SelectedIndex = 1;
                this.enumCmbbxOperationType.Enabled       = false;
                this.txtModeName.Enabled = false;
            }
        }
		public async Task AddToHistory(SearchQuery query, CancellationToken cancellationToken)
		{
			//if any call add to history without initialization
			await GetHistory(cancellationToken);

			//move to top
			var exits = _searchQueries.FirstOrDefault( x => x.SearchString.ToLower().Equals( query.SearchString.ToLower() ) );
			if (exits != null)
			{
				_searchQueries.Remove( exits );
			}

			_searchQueries.Insert(0, query);

			if (_searchQueries.Count > HistoryCount)
			{
				_searchQueries = new XCollection<SearchQuery>(_searchQueries.Take(HistoryCount));
			}

			_dataCacheService.PutItem(_searchQueries, CacheItemName, cancellationToken);
		}
Example #31
0
        public static void SaveXSLFiles(XCollection <XIMOutboundMessage> messages, SocketConfig config)
        {
            if (messages == null)
            {
                return;
            }

            string path = Application.StartupPath + "\\" + XIMTransformHelper.XSLFolder;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            string tmpFileName = path + "\\" + XIMTransformHelper.TemplateFileNameOut;

            if (!File.Exists(tmpFileName))
            {
                using (StreamWriter sw = File.CreateText(tmpFileName))
                {
                    string tmpString = XIMTransformHelper.GenerateOutboundTemplate();
                    sw.Write(tmpString);
                }
            }

            foreach (XIMOutboundMessage msg in messages)
            {
                string fileName  = path + "\\" + msg.XSLFileName;
                string xslString = XIMTransformHelper.GenerateXSL(msg, config);
                if (xslString == null)
                {
                    continue;
                }

                using (StreamWriter sw = File.CreateText(fileName))
                {
                    sw.Write(xslString);
                }
            }
        }
Example #32
0
        public FormMessage(T message, XCollection <T> messageList, string dbConnection, Logging log, bool copyItem)
        {
            InitializeComponent();

            _isInbound = (typeof(T) == typeof(XIMInboundMessage));

            InitializeEventType();

            _log          = log;
            _isCopyItem   = copyItem;
            _messageList  = messageList;
            _dbConnection = dbConnection;

            _hl7EventCtrl = new HL7EventTypeControler(this.comboBoxHL7);
            _gwEventCtrl  = new GWEventTypeControler(this.comboBoxGCGateway);
            _listViewCtrl = new XmlListViewControler <XIMMappingItem>(this.listViewMain, _isInbound);

            _listViewCtrl.DoubleClick          += new EventHandler(_listViewCtrl_DoubleClick);
            _listViewCtrl.SelectedIndexChanged += new EventHandler(_listViewCtrl_SelectedIndexChanged);

            _message = message;

            if (_message == null)
            {
                this.Text = "Add Message Mapping";
                _message  = new T();
                Reset();
            }
            else
            {
                if (_isCopyItem)
                {
                    this.Text = "Add Message Mapping";
                }
                else
                {
                    this.Text = "Edit Message Mapping";
                }
            }
        }
Example #33
0
        public static DElementListWrapper[] CreateQRElementList <TR>(XCollection <TR> qrList, DataSet dsQR)
            where TR : QueryResultItem, IDicomMappingItem
        {
            if (dsQR == null || qrList == null)
            {
                return(null);
            }

            List <DElementListWrapper> dcmResult = new List <DElementListWrapper>();

            if (dsQR.Tables.Count > 0)
            {
                foreach (DataRow dr in dsQR.Tables[0].Rows)
                {
                    DicomDataset dcmEleList = new DicomDataset();

                    int count = qrList.Count;
                    for (int index = 0; index < count; index++)
                    {
                        IDicomMappingItem qr = qrList[index] as IDicomMappingItem;
                        if (!qr.DPath.Enable)
                        {
                            continue;
                        }
                        List <string> tagList  = qr.DPath.GetTagGE(0);
                        ushort        uGroup   = DHelper.HexString2ushort(tagList[0]);
                        ushort        uElement = DHelper.HexString2ushort(tagList[1]);
                        DicomTag      tag      = new DicomTag(uGroup, uElement);
                        FillElement <TR>(dcmEleList, tag, qr.DPath.VR, ref index, 0, qrList, dr);
                    }

                    DElementListWrapper w = new DElementListWrapper(dcmEleList);
                    w.GUIDs.Add(DicomMappingHelper.GetGUID(dr));
                    dcmResult.Add(w);
                }
            }

            return(dcmResult.ToArray());
        }
Example #34
0
        public override void Refresh()
        {
            base.SetStatus("Refreshing interface list.");

            Program.ConfigMgt.Config.RefreshConfigInfo();
            XCollection <HL7InterfaceConfig> interfaceList = Program.ConfigMgt.Config.InterfaceList;

            _interfaceView.RefreshList(interfaceList);

            if (interfaceList != null)
            {
                Program.Log.Write("{Interface} Refresh interface list succeed : " + interfaceList.Count.ToString() + " items.");
            }
            else
            {
                Program.LogWapper.Write(LogType.Warning, "{Interface} Refresh interface list failed.");

                MessageBox.Show(frmMain, "Refresh interface list failed.\r\n\r\n",
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            base.ClearStatus();
        }
Example #35
0
		private Genre GetGenreInCollectionById(XCollection<Genre> genres, int genreId)
		{
			Genre found = null;

			if (genres != null)
			{
				found = genres.FirstOrDefault(x => x.Id == genreId);

				if (found == null)
				{
					foreach (var genre in genres)
					{
						found = GetGenreInCollectionById(genre.Children, genreId);

						if (found != null)
						{
							break;
						}
					}
				}
			}
			return found;
		}
        //public RelayCommand LoadMoreCalled { get; private set; }

		#region Constructors/Disposer
        public FreeBooksByCategoryViewModel(ICatalogProvider catalogProvider, INavigationService navigationService)
		{
			_catalogProvider = catalogProvider;
			_navigationService = navigationService;

            PopularBooks = new XCollection<Book>();
            NoveltyBooks = new XCollection<Book>();

            RegisterPart(MainPart, (session, part) => LoadBooks(session), (session, part) => !_loadedPopular && !_loadedNovelty, true);
            //RegisterPart( LoadMorePart, ( session, part ) => LoadBooks( session ), ( session, part ) => !_isEndOfList, false );

            RegisterPart(LoadMoreNoveltyBooksPart, (session, part) => LoadNoveltyBooks(session), (session, part) => !_isEndOfListNoveltyBooks, false);
            RegisterPart(LoadMorePopularBooksPart, (session, part) => LoadPopularBooks(session), (session, part) => !_isEndOfListPopularBooks, false);

			//Books = new XCollection<Book>();

			BookSelected = new RelayCommand<Book>(book => _navigationService.Navigate("Book", Parameters.From("id", book.Id)), book => book != null);

            LoadMoreNoveltyBooks = new RelayCommand(LoadMoreNoveltyBooksProceed, () => true);
            LoadMorePopularBooks = new RelayCommand(LoadMorePopularBooksProceed, () => true);

			//LoadMoreCalled = new RelayCommand(() => LoadMore(), () => true);
		}
Example #37
0
        private void btSelFileFields_Click(object sender, EventArgs e)
        {
            XCollection <GWDataDBField> Fields = new XCollection <GWDataDBField>();

            try
            {
                Fields = ParseTemplate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            FSelFields F = new FSelFields();

            if (F.ShowDialog(this, Fields) == DialogResult.OK)
            {
                foreach (GWDataDBField f in Fields)
                {
                    this.tbTemplate.Text += "[%" + f.GetFullFieldName().Replace(".", "_") + "%]\r\n\r\n";
                }
            }
        }
Example #38
0
        public FormElement2(T item, XCollection <T> itemList, T baseItem, bool addChild, string gwDataDBConnection, Logging log, bool isQueryResult, bool isInbound)
        {
            InitializeComponent();

            _mappingItem = item;
            _itemList    = itemList;
            _baseItem    = baseItem;
            _addChild    = addChild;

            _isInbound     = isInbound;
            _isQueryResult = isQueryResult;

            _log = log;
            _gwDataDBConnection = gwDataDBConnection;

            if (_mappingItem == null)
            {
                _mappingItem = new T();
                this.Text    = "Add Element Mapping";
            }
            else
            {
                this.Text = "Edit Element Mapping";
            }

            _tagControler = new TagControler2(this.groupBoxDicom,
                                              this.comboBoxVR, this.comboBoxTag, this.textBoxGroupNum, this.textBoxElementNum);
            _tagControler.OnValueChanged += new EventHandler(_tagControler_OnValueChanged);

            //_fieldControler = new FieldControler2(false, this.groupBoxGateway,
            //    this.comboBoxTable, this.comboBoxField, this.checkBoxFixValue,
            //    this.textBoxFixValue, this.checkBoxLUT, this.comboBoxLUT, true);
            _fieldControler = new FieldControler2(isQueryResult, this.groupBoxGateway,
                                                  this.comboBoxTable, this.comboBoxField, this.checkBoxFixValue,
                                                  this.textBoxFixValue, this.checkBoxLUT, this.comboBoxLUT, isInbound);
            _fieldControler.OnValueChanged += new EventHandler(_fieldControler_OnValueChanged);
        }
Example #39
0
        private void LoadDefaultConfiguration()
        {
            // Identity

            EntityID    = Guid.NewGuid();
            Description = "CS Broker Inbound Adapter";
            DeviceName  = DEVICE_NAME;
            Name        = Program.Context.AppName;

            // Default Transferring(routing) Contract

            Interaction = InteractionTypes.Publisher;
            Direction   = DirectionTypes.Inbound;
            PublishConfig.Publication.MessageTypeList.Add(MessageRegistry.GENERIC_NotificationMessageType);
            SubscribeConfig = null;
            ResponseConfig  = null;

            // Other Default Configuration
            CSBrokerConnectionString = "Provider=SQLNCLI;Server=(local)\\SQLExpress;Database=GWDataDB;UID=sa;Password=123456;";
            CSBrokerSQLOutboundName  = "SQL_OUT";
            TimerInterval            = 3000;
            EnaleKanJiReplacement    = false;
            KanJiReplacementChar     = ".";

            EnableValueReplacement = false;
            _valueReplacement      = new XCollection <ValueReplacementRule>();
            _valueReplacement.Add(new ValueReplacementRule()
            {
                FieldName         = "ORDER_SCHEDULED_DT",
                MatchExpression   = @"\b(?<year>\d{2,4})(?<month>\d{1,2})(?<day>\d{1,2})(?<hour>\d{1,2})(?<minute>\d{1,2})(?<second>\d{1,2}).(?<fractal>\d{1,3})\b",
                ReplaceExpression = @"${year}-${month}-${day} ${hour}:${minute}:${second}"
            });

            MessageDispatchConfig.Model     = MessageDispatchModel.Request;
            MessageDispatchConfig.TableName = GWDataDBTable.None.ToString();
            MessageDispatchConfig.FieldName = string.Empty;
        }
Example #40
0
        public Channel(ActiveMode frm, XCollection <SQLOutboundChanel> channels, int index)
        {
            InitializeComponent();
            parentForm       = frm;
            channelSet       = channels;
            type             = "Edit";
            this.Text        = "Edit Channel";
            channel          = channelSet[index];
            criteriaItemList = channelSet[index].Rule.QueryCriteria.MappingList;
            resultItemList   = channelSet[index].Rule.QueryResult.MappingList;

            channelIndex = index;

            GetChannelNameSet(channels);
            ShowChannel(channel);
            enumCmbbxOperationType.Enabled = false;

            if (parentForm.DBconfig.ConnectionParameter.FileConnection)
            {
                this.enumCmbbxOperationType.SelectedIndex = 1;
                this.enumCmbbxOperationType.Enabled       = false;
                this.txtModeName.Enabled = false;
            }
        }
Example #41
0
        public static DataSet CreateQCDataSet <TC>(XCollection <TC> qcList, DicomDataset dcmQC)
            where TC : MappingItem, IDicomMappingItem
        {
            if (dcmQC == null || qcList == null)
            {
                return(null);
            }

            int       count = qcList.Count;
            Hashtable table = new Hashtable();

            for (int index = 0; index < count; index++)
            {
                FillDataSet(table, ref index, 0, qcList, dcmQC);
            }

            DataSet   ds = new DataSet();
            DataTable dt = ds.Tables.Add();

            foreach (DictionaryEntry de in table)
            {
                string key = de.Key as string;
                dt.Columns.Add(new DataColumn(key, typeof(string)));
            }
            DataRow dr = dt.NewRow();

            foreach (DictionaryEntry de in table)
            {
                string key   = de.Key as string;
                string value = de.Value as string;
                dr[key] = value;
            }
            dt.Rows.Add(dr);

            return(ds);
        }
Example #42
0
 public SuiteInfo()
 {
     Name        = "";
     Description = "";
     Devices     = new XCollection <DeviceInfo>();
 }
        private DateTime NextExpireDateTime(XCollection<Book> books)
        {
            var nextBookTime = DateTime.MaxValue;

            books.ForEach(book =>
            {
                if (!string.IsNullOrEmpty(book.ExpiredDateStr) && !book.IsExpiredBook && book.ExpiredDate < nextBookTime)
                {
                    nextBookTime = book.ExpiredDate;
                }
            });

            return nextBookTime;
        }
Example #44
0
 public ActiveMode()
 {
     InitializeComponent();
     DBconfig   = SQLInAdapterConfigMgt.SQLInAdapterConfig.ThirdPartyInteractConfig;
     channelSet = SQLInAdapterConfigMgt.SQLInAdapterConfig.InboundChanels;
 }
	    public async Task<XCollection<Book>> GetBooksByTag(int fromPosition, int tagId, CancellationToken cancellationToken)
	    {
            if (_booksByTag == null || _booksByTagId != tagId)
            {
                string limit = string.Format("{0},{1}", fromPosition, BooksInPage);

                var parameters = new Dictionary<string, object>
                        {
                            {"tag", tagId},
                            {"limit", limit},
                        };

                var books = await _client.SearchCatalog(parameters, cancellationToken);

                CheckMyBooks(books.Books);

                _booksByTagId = tagId;

                _booksByTag = books.Books;
            }
            else
            {
                int lastIndex = fromPosition + BooksInPage;

                var collection = new XCollection<Book>(_booksByTag.Take(lastIndex));

                if (collection.Count() + BooksInPageShift < lastIndex)
                {
                    lastIndex = collection.Count();

                    string limit = string.Format("{0},{1}", lastIndex, BooksInPage);

                    var parameters = new Dictionary<string, object>
                        {
                            {"genre", tagId},
                            {"limit", limit},
                        };

                    var books = await _client.SearchCatalog(parameters, cancellationToken);

                    if (books != null && books.Books != null && books.Books.Any())
                    {
                        CheckMyBooks(books.Books);

                        foreach (var book in books.Books)
                        {
                            if (!collection.ContainsKey(book.GetKey()))
                            {
                                collection.Add(book);
                            }
                        }
                    }

                    _booksByTag = collection;
                }

                return collection;
            }
            return _booksByTag;
        }
Example #46
0
        private static void FillDataSet <TC>(Hashtable dr, ref int index, int depth, XCollection <TC> qcList, DicomDataset eleList)
            where TC : MappingItem, IDicomMappingItem
        {
            int count = qcList.Count;

            for (; index < count; index++)
            {
                TC qc = qcList[index] as TC;
                if (qc.Translating.Type == TranslatingType.FixValue)
                {
                    continue;
                }
                if (qc.DPath.Type == DPathType.BeginItem)
                {
                    continue;
                }
                if (qc.DPath.Type == DPathType.EndItem && depth > 0)
                {
                    break;
                }
                if (!qc.DPath.Enable)
                {
                    continue;
                }

                //int tag = qc.DPath.GetTag(depth);
                //DicomItem ele = eleList(tag);
                List <string> tagList = qc.DPath.GetTagGE(depth);
                if (tagList == null)
                {
                    continue;
                }

                ushort    uGroup   = DHelper.HexString2ushort(tagList[0]);
                ushort    uElement = DHelper.HexString2ushort(tagList[1]);
                DicomItem ele      = eleList.Get <DicomItem>(new DicomTag(uGroup, uElement));
                if (ele == null || ConvertDicomVRToDVR(ele.ValueRepresentation) != qc.DPath.VR)
                {
                    if (qc.DPath.VR == DVR.SQ)
                    {
                        continue;
                    }
                    dr[qc.SourceField] = GetSQLString <TC>(qc, (ele == null) ? "" : eleList.Get <string>(new DicomTag(uGroup, uElement)));
                    continue;
                }

                if (qc.DPath.VR == DVR.SQ)
                {
                    int           d             = depth + 1;
                    DicomDataset  sqList        = null;
                    DicomSequence dicomSequence = (DicomSequence)ele;
                    if (dicomSequence.Items.Count > 0)     //support one sequence item only
                    {
                        sqList = dicomSequence.Items[0];
                    }
                    index++;
                    if (sqList == null)
                    {
                        sqList = new DicomDataset();
                    }
                    FillDataSet <TC>(dr, ref index, d, qcList, sqList);
                    break;
                }
                else
                {
                    string value = eleList.Get <string>(new DicomTag(uGroup, uElement));
                    if (DHelper.IsDateTime(qc.DPath.VR))
                    {
                        DVR realVR = qc.DPath.VR;

                        // ------ merge TM to DT ------
                        if (uGroup == DicomTag.ScheduledProcedureStepStartDate.Group && uElement == DicomTag.ScheduledProcedureStepStartDate.Element)
                        {
                            string eleTM = eleList.Get <string>(DicomTag.ScheduledProcedureStepStartTime);
                            if (eleTM != null)
                            {
                                string   strTM     = eleTM;
                                string[] strTMList = strTM.Split('-');
                                string[] strDAList = value.Split('-');
                                if (strTMList.Length > 0 && strDAList.Length > 0)
                                {
                                    if (strDAList.Length == 1 && strDAList[0].Length > 0)
                                    {
                                        if (strTMList.Length == 1 && strTMList[0].Length > 0)
                                        {
                                            realVR = DVR.DT;
                                            if (strTM.Length > 6)
                                            {
                                                strTM = strTM.Substring(0, 6);
                                            }
                                            value += strTM;
                                        }
                                        else if (strTMList.Length == 2)
                                        {
                                            realVR = DVR.DT;
                                            string beginTM = strTMList[0];
                                            string endTM   = strTMList[1];
                                            if (beginTM.Length < 1)
                                            {
                                                beginTM = "000000";
                                            }
                                            if (endTM.Length < 1)
                                            {
                                                endTM = "235959";
                                            }
                                            if (beginTM.Length > 6)
                                            {
                                                beginTM = beginTM.Substring(0, 6);
                                            }
                                            if (endTM.Length > 6)
                                            {
                                                endTM = endTM.Substring(0, 6);
                                            }
                                            value = strDAList[0] + beginTM + "-" + strDAList[0] + endTM;
                                        }
                                    }
                                    else if (strDAList.Length == 2)
                                    {
                                        if (strTMList.Length == 1 && strTMList[0].Length > 0)
                                        {
                                            realVR = DVR.DT;
                                            if (strTM.Length > 6)
                                            {
                                                strTM = strTM.Substring(0, 6);
                                            }
                                            value = strDAList[0] + strTM + "-" + strDAList[1] + strTM;
                                        }
                                        else if (strTMList.Length == 2)
                                        {
                                            realVR = DVR.DT;
                                            string beginTM = strTMList[0];
                                            string endTM   = strTMList[1];
                                            if (beginTM.Length < 1)
                                            {
                                                beginTM = "000000";
                                            }
                                            if (endTM.Length < 1)
                                            {
                                                endTM = "235959";
                                            }
                                            if (beginTM.Length > 6)
                                            {
                                                beginTM = beginTM.Substring(0, 6);
                                            }
                                            if (endTM.Length > 6)
                                            {
                                                endTM = endTM.Substring(0, 6);
                                            }
                                            value = strDAList[0] + beginTM + "-" + strDAList[1] + endTM;
                                        }
                                    }
                                }
                            }
                        }
                        // ----------------------------

                        if (qc.DPath.Range == DRangeType.None)
                        {
                            DDateTime2 singleddt = DDateTime2.FromDateTime(realVR, value);
                            object     singledt  = (singleddt != null) ? singleddt.GetDateTime() : null;
                            //value = (singledt != null) ? ((DateTime)singledt).ToString(GWDataDB.DateTimeFormat) : "";
                            value = GetGWDTStartString(singledt, realVR);
                            dr[qc.SourceField] = GetSQLString <TC>(qc, value);
                            continue;
                        }

                        TC qcStart = qc;
                        if (qcStart.DPath.Range != DRangeType.Begin)
                        {
                            continue;
                        }

                        TC qcEnd = qcList[index + 1];
                        if (qcEnd == null || qcEnd.DPath.Range != DRangeType.End)
                        {
                            continue;
                        }

                        index++;

                        object     dtStart = null, dtEnd = null;
                        DDateTime2 ddt = DDateTime2.FromDateTime(realVR, value);
                        if (ddt != null)
                        {
                            switch (ddt.Type)
                            {
                            case DDateTimeType.SINGLE:
                            {
                                dtStart = dtEnd = ddt.GetDateTime();
                                break;
                            }

                            case DDateTimeType.START_ONLY:
                            {
                                dtStart = ddt.GetStartDateTime();
                                break;
                            }

                            case DDateTimeType.END_ONLY:
                            {
                                dtEnd = ddt.GetEndDateTime();
                                break;
                            }

                            case DDateTimeType.RANGE:
                            {
                                dtStart = ddt.GetStartDateTime();
                                dtEnd   = ddt.GetEndDateTime();
                                break;
                            }
                            }
                        }

                        string strStart = "", strEnd = "";
                        strStart = GetGWDTStartString(dtStart, realVR);
                        strEnd   = GetGWDTEndString(dtEnd, realVR);
                        dr[qcStart.SourceField] = strStart;
                        dr[qcEnd.SourceField]   = strEnd;
                    }
                    else if (qc.DPath.VR == DVR.PN)
                    {
                        value = PersonNameRule.Parse(value);
                        dr[qc.SourceField] = GetSQLString <TC>(qc, value);
                    }
                    else
                    {
                        dr[qc.SourceField] = GetSQLString <TC>(qc, value);
                    }
                    break;
                }
            }
        }
Example #47
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;
                    }
                }
            }
        }
        public async Task<XCollection<Book>> GetNoveltyBooks(int fromPosition, CancellationToken cancellationToken, int customBooksOnPage = 0)
		{
            int booksOnPage = customBooksOnPage > 0 ? customBooksOnPage : BooksInPage;
			if (_interestingBooks == null)
			{
                string limit = string.Format("{0},{1}", fromPosition, booksOnPage);

				var parameters = new Dictionary<string, object>
						{						
							{"sort", "time_desc"},									
							{"min_person_rating", "6"},								
							{"limit", limit},
						};

				var books = await _client.SearchCatalog(parameters, cancellationToken);

				CheckMyBooks( books.Books );

				_interestingBooks = books.Books;
			}
			else
			{
                int lastIndex = fromPosition + booksOnPage;

				var collection = new XCollection<Book>( _interestingBooks.Take( lastIndex ) );

				if (collection.Count() + BooksInPageShift < lastIndex)
				{
					lastIndex = collection.Count();

                    string limit = string.Format("{0},{1}", lastIndex, booksOnPage);

					var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif									
							{"rating", "authors"},								
							{"limit", limit},
						};

					var books = await _client.SearchCatalog(parameters, cancellationToken);

					if (books != null && books.Books != null && books.Books.Any())
					{
						CheckMyBooks( books.Books );

						foreach (var book in books.Books)
						{
							if (!collection.ContainsKey( book.GetKey() ))
							{
								collection.Add( book );
							}
						}
					}

					_interestingBooks = collection;
				}
                _dataCacheService.PutItem(_interestingBooks, InterestingBooksCacheItemName, cancellationToken);
                return collection;
			}
            _dataCacheService.PutItem(_interestingBooks, InterestingBooksCacheItemName, cancellationToken);
            return _interestingBooks;
		}
Example #49
0
        private static void FillElement <TR>(DicomDataset ds, DicomTag tagIn, DVR vrIn, ref int index, int depth, XCollection <TR> qrList, DataRow dr)
            where TR : QueryResultItem, IDicomMappingItem
        {
            TR qr = qrList[index] as TR;

            if (!qr.DPath.Enable)
            {
                return;
            }

            switch (qr.DPath.VR)
            {
            case DVR.Unknown: return;

            case DVR.SQ:
            {
                index++;
                int          count   = qrList.Count;
                DicomDataset eleList = null;
                for (; index < count; index++)
                {
                    qr = qrList[index] as TR;
                    switch (qr.DPath.Type)
                    {
                    case DPathType.BeginItem:
                    {
                        eleList = new DicomDataset();
                        continue;
                    }

                    case DPathType.EndItem:
                    {
                        DicomSequence dicomSequence = new DicomSequence(tagIn);
                        if (eleList != null)
                        {
                            dicomSequence.Items.Add(eleList);
                        }
                        TR qrNext = ((index + 1) < qrList.Count) ? qrList[index + 1] : null;
                        if (qrNext == null || qrNext.DPath.Type != DPathType.BeginItem)
                        {
                            return;
                        }
                        continue;
                    }

                    default:
                    {
                        if (eleList == null)
                        {
                            continue;
                        }
                        if (!qr.DPath.Enable)
                        {
                            continue;
                        }
                        //int tag = qr.DPath.GetTag(depth + 1);
                        List <string> tagList  = qr.DPath.GetTagGE(depth + 1);
                        ushort        uGroup   = DHelper.HexString2ushort(tagList[0]);
                        ushort        uElement = DHelper.HexString2ushort(tagList[1]);
                        DicomTag      tag      = new DicomTag(uGroup, uElement);

                        //DElement ele = new DElement(tag, qr.DPath.VR);
                        FillElement <TR>(eleList, tag, qr.DPath.VR, ref index, depth + 1, qrList, dr);
                        //eleList.Add(ele);
                        break;
                    }
                    }
                }
                break;
            }

            default:
            {
                string value = null;
                object obj   = dr[qr.TargetField];
                if (obj != null)
                {
                    value = obj.ToString();
                }
                if (value == null)
                {
                    value = "";
                }

                if (DHelper.IsDateTime(qr.DPath.VR))
                {
                    try
                    {
                        if (value.Length > 0)
                        {
                            DateTime dt = DateTime.Parse(value);
                            //DDateTime ddt = DDateTime.FromDateTime(qr.DPath.VR, dt);
                            DicomDateTime ddt = new DicomDateTime(tagIn, dt);
                            //rootSQElement.Value = ddt.ToDicomString();
                            ds.Add(ddt);
                        }
                        else
                        {
                            //rootSQElement.Value = value;
                            ds.Add <string>(tagIn, value);
                        }
                    }
                    catch (Exception err)
                    {
                        //SetError(err);
                        //rootSQElement.Value = value;
                        ds.Add <string>(tagIn, value);
                    }
                }
                else
                {
                    //rootSQElement.Value = value;
                    ds.Add <string>(tagIn, value);
                }


                break;
            }
            }
        }
        public SearchViewModel(ICatalogProvider catalogProvider, INavigationService navigationService, ILitresPurchaseService litresPurchaseService, ICredentialsProvider credentialsProvider, IProfileProvider profileProvider)
        {
            _catalogProvider = catalogProvider;
            _navigationService = navigationService;
            _litresPurchaseService = litresPurchaseService;
            _credentialsProvider = credentialsProvider;
            _profileProvider = profileProvider;

            FoundBooks = new XCollection<Book>();
            FoundPersons = new XCollection<Person>();
            FoundSequeses = new XCollection<Book.SequenceInfo>();
           
            FirstBooks = new XSubRangeCollection<Book>(FoundBooks, 0, 3);
            FirstPersons = new XSubRangeCollection<Person>(FoundPersons, 0, 3);
            FirstSequeces = new XSubRangeCollection<Book.SequenceInfo>(FoundSequeses, 0, 3);
            //FoundCollections = new XCollection<Book.CollectionsInfo>();
            //FirstCollections = new XSubRangeCollection<Book.CollectionsInfo>(FoundCollections, 0, 3);

            TagsAndGenresCollection = new List<object>(6);
            BestResult = new List<object>();

            RegisterAction(LoadAllDataPart).AddPart(SearchAll, session => true);
            RegisterAction(BuyBookLitresPart).AddPart((session) => BuyBookFromLitres(session, Book), (session) => true);
            RegisterAction(CreditCardInfoPart).AddPart(session => CreditCardInfoAsync(session), (session) => true);
            RegisterAction(BuyBookPart).AddPart((session) => BuyBookAsync(session, Book), (session) => true);

            BuyBook = new RelayCommand<Book>(book => BuyBookFromLitresAsync(book));
            RunCreditCardPaymentProcess = new RelayCommand(CreditCardInfo);
            ShowCreditCardView = new RelayCommand<Book>(book => _navigationService.Navigate("CreditCardPurchase", XParameters.Create("BookEntity", book)), book => book != null);
            BuyBookFromMicrosoft = new RelayCommand(BuyBookFromMicrosoftAsync);

            BookSelected = new RelayCommand<Book>(book => _navigationService.Navigate("Book", XParameters.Create("BookEntity", book)), book => book != null);
            PersonSelected = new RelayCommand<Person>(person => _navigationService.Navigate("Person", XParameters.Create("Id", person.Id)), person => person != null);
            GenreSelected = new RelayCommand<Genre>(genre => _navigationService.Navigate("BooksByCategory", XParameters.Empty.ToBuilder()
                .AddValue("category", 6)
                .AddValue("id", int.Parse(genre.id))
                .AddValue("title", genre.name)
                .ToImmutable()), genre => genre != null);
            TagSelected = new RelayCommand<Tag>(tag => _navigationService.Navigate("BooksByCategory", XParameters.Empty.ToBuilder()
                .AddValue("category", 5)
                .AddValue("id", int.Parse(tag.id))
                .AddValue("title", tag.name)
                .ToImmutable()), tag => tag != null);
            SequenceSelected = new RelayCommand<Book.SequenceInfo>(sequence => _navigationService.Navigate("BooksByCategory", XParameters.Empty.ToBuilder()
                .AddValue("category", 7)
                .AddValue("id", sequence.Id)
                .AddValue("title", sequence.Name)
                .ToImmutable()), sequence => sequence != null);
            Read = new RelayCommand<Book>(book =>
            {
                if (!book.IsExpiredBook)
                    _navigationService.Navigate("Reader", XParameters.Create("BookEntity", book), false);
                else new MessageDialog("Истёк срок выдачи.").ShowAsync();
            });

            //CollectionSelected = new RelayCommand<Book.SequenceInfo>(sequence => _navigationService.Navigate("BooksByCategory", XParameters.Empty.ToBuilder()
            //    .AddValue("category", 8)
            //    .AddValue("id", sequence.Id)
            //    .AddValue("title", sequence.Name)
            //    .ToImmutable()), sequence => sequence != null);

            LoadMoreFoundBooks = new RelayCommand(() => Load(new Session()));
        }
        private async void CheckExpiration(XCollection<Book> booksToExpire)
        {
            if(Debugger.IsAttached) Debug.WriteLine("CheckExpirationDoing");
            var messageStr = new StringBuilder();

            foreach (var book in booksToExpire)
            {
                Notify(book);
             
                await _bookProvider.RemoveFullBookInLocalStorage(book);
                book.IsExpiredBook = true;
                
                messageStr.AppendLine(book.Description.Hidden.TitleInfo.BookTitle);
            }
            
            await _catalogProvider.ExpireBooks(booksToExpire);

            var books = await _catalogProvider.GetMyBooksFromCache(CancellationToken.None);
            if (books == null) books = booksToExpire;            
            else
            {
                booksToExpire.ForEach(expiredBook =>
                {
                    try
                    {
                        var bk = books.First(book => book.Id == expiredBook.Id);
                        bk.IsExpiredBook = true;
                    }
                    catch (Exception){}
                });
            }            

            _catalogProvider.SaveMyBooksToCache(books, CancellationToken.None);
            _catalogProvider.CheckBooks();

            if (messageStr.Length > 0) { 
                //Deployment.Current.Dispatcher.BeginInvoke(() =>
                //{
                //    MessageBox.Show(messageStr.ToString(), "Книги истекли", MessageBoxButton.OK);
                //});

                await new MessageDialog(messageStr.ToString(), "Книги истекли").ShowAsync();
            }
            var purchaseService = ((Digillect.Mvvm.UI.WindowsRTApplication)Application.Current).Scope.Resolve<IPurchaseServiceDecorator>();
            foreach (var bk in booksToExpire)
            {
                await purchaseService.RefreshPages(bk);
            }

            if(NextExpireDateTime(books) != DateTime.MaxValue) StartGuardian();
        }
Example #52
0
 public PassiveMode()
 {
     InitializeComponent();
     DBconfig   = SQLOutAdapterConfigMgt.SQLOutAdapterConfig.ThirdPartyInteractConfig;
     channelSet = SQLOutAdapterConfigMgt.SQLOutAdapterConfig.OutboundPassiveChanels;
 }
        public async Task<XCollection<Book>> GetPopularBooks(int fromPosition, CancellationToken cancellationToken, int customBooksOnPage = 0)
        {
            int booksOnPage = customBooksOnPage > 0 ? customBooksOnPage : BooksInPage;
            if (_popularBooks == null)
            {
                string limit = string.Format("{0},{1}", fromPosition, booksOnPage);

                var parameters = new Dictionary<string, object>
                {
                    {"sort", "pop_desc"},
                    {"limit", limit},
                };

                var books = await _client.SearchCatalog(parameters, cancellationToken);

                CheckMyBooks(books.Books);

                _popularBooks = books.Books;
            }
            else
            {
                int lastIndex = fromPosition + booksOnPage;

                var collection = new XCollection<Book>(_popularBooks.Take(lastIndex));

                if (collection.Count() + BooksInPageShift < lastIndex)
                {
                    lastIndex = collection.Count();

                    string limit = string.Format("{0},{1}", lastIndex, booksOnPage);

                    var parameters = new Dictionary<string, object>
                    {
                        {"sort", "pop_desc"},
                        {"limit", limit},
                    };

                    var books = await _client.SearchCatalog(parameters, cancellationToken);

                    if (books != null && books.Books != null && books.Books.Any())
                    {
                        CheckMyBooks(books.Books);

                        foreach (var book in books.Books)
                        {
                            if (!collection.ContainsKey(book.GetKey()))
                            {
                                collection.Add(book);
                            }
                        }
                    }

                    _popularBooks = collection;
                }
                _dataCacheService.PutItem(_popularBooks, PopularBooksCacheItemName, cancellationToken);
                return collection;
            }
            _dataCacheService.PutItem(_popularBooks, PopularBooksCacheItemName, cancellationToken);
            return _popularBooks;
        }
		public async Task<XCollection<Book>> GetNoveltyBooksByGenre(int fromPosition, int genreId, CancellationToken cancellationToken)
		{
			if (_noveltyBooksByGenre == null || _noveltyBooksByGenreId != genreId)
			{
				string limit = string.Format( "{0},{1}", fromPosition, BooksInPage );

				var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif								
							{"genre", genreId},														
							{"limit", limit},									
							{"sort", "time_desc"},
						};

				var books = await _client.SearchCatalog(parameters, cancellationToken);

				CheckMyBooks( books.Books );

				_noveltyBooksByGenreId = genreId;

				_noveltyBooksByGenre = books.Books;
			}
			else
			{
				int lastIndex = fromPosition + BooksInPage;

				XCollection<Book> collection = new XCollection<Book>( _noveltyBooksByGenre.Take( lastIndex ) );

				if (collection.Count() + BooksInPageShift < lastIndex)
				{
					lastIndex = collection.Count();

					string limit = string.Format( "{0},{1}", lastIndex, BooksInPage );

					var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif
                        {"genre", genreId},													
							{"limit", limit},										
							{"sort", "time_desc"},		
						};

					var books = await _client.SearchCatalog(parameters, cancellationToken);

					if (books != null && books.Books != null && books.Books.Any())
					{
						CheckMyBooks( books.Books );

						foreach (var book in books.Books)
						{
							if (!collection.ContainsKey( book.GetKey() ))
							{
								collection.Add( book );
							}
						}
					}

					_noveltyBooksByGenre = collection;
				}

				return collection;
			}
			return _noveltyBooksByGenre;
		}
		public async Task<XCollection<Book>> GetPopularBooksByGenres(int fromPosition, List<int> genreId, CancellationToken cancellationToken)
		{
			if( _popularBooksByGenres == null || _popularBooksByGenresIds == null || !_popularBooksByGenresIds.SequenceEqual( genreId ) )
			{
				string limit = string.Format( "{0},{1}", fromPosition, BooksInPage );

				var parameters = new Dictionary<string, object>
						{																	
							{"genre", genreId},							
							{"limit", limit},																
							{"sort", "pop_desc"},								
						};

				var books = await _client.SearchCatalog(parameters, cancellationToken);

				CheckMyBooks( books.Books );

				_popularBooksByGenresIds = genreId;

				_popularBooksByGenres = books.Books;
			}
			else
			{
				int lastIndex = fromPosition + BooksInPage;

				var collection = new XCollection<Book>( _popularBooksByGenres.Take( lastIndex ) );

				if (collection.Count() + BooksInPageShift < lastIndex)
				{
					lastIndex = collection.Count();

					string limit = string.Format( "{0},{1}", lastIndex, BooksInPage );

					var parameters = new Dictionary<string, object>
						{															
							{"genre", genreId},							
							{"limit", limit},															
							{"sort", "pop_desc"},		
						};

					var books = await _client.SearchCatalog(parameters, cancellationToken);

					if (books != null && books.Books != null && books.Books.Any())
					{
						CheckMyBooks( books.Books );

						foreach (var book in books.Books)
						{
							if (!collection.ContainsKey( book.GetKey() ))
							{
								collection.Add( book );
							}
						}
					}

					_popularBooksByGenres = collection;
				}

				return collection;
			}
			return _popularBooksByGenres;
		}
		public async Task<XCollection<Book>> GetAllMyBooks(CancellationToken cancellationToken)
		{
		    XCollection<Book> _Fragments = null; 
			if (_myBooks == null)
			{
				_myBooks = new XCollection<Book>();
			}
			else
			{
                _Fragments = _myBooks.Derive(bk => bk.isFragment);
				_myBooks.Clear();
			}
            if (_Fragments == null && _myBooksByTime != null) _Fragments = _myBooksByTime.Derive(bk => bk.isFragment);

			while (true)
			{
				string limit = string.Format("{0},{1}", _myBooks.Count, BooksInPage);
				var parameters = new Dictionary<string, object>
						{
							{ "my", 1 },
#if PDF_ENABLED	
                        {"search_types", "0,4"},	
#else
                        {"search_types", "0"},	
#endif
							{ "limit", limit }
						};

				var books = await _client.GetMyBooks(parameters, CancellationToken.None);

			    if (books != null && books.Books != null)
			    {
			        books.Books.ForEach(x => x.IsMyBook = true);


			        _myBooks.BeginUpdate();
			        _myBooks.AddRange(books.Books);
			        _myBooks.EndUpdate();

			        if (books.Books.Count >= BooksInPage || books.Books.Count == 0)
			        {
			            break;
			        }
			    }
			    else
			    {
			        break;
			    }
			}

            if (_Fragments != null)
		    {
                _Fragments.AddRange(_myBooks);
                _myBooks.BeginUpdate();
                _myBooks.Clear();
                _myBooks.AddRange(_Fragments);
                _myBooks.EndUpdate();
		        _Fragments = null;
		    }

			_dataCacheService.PutItem( _myBooks, AllMyBooksCacheItemName, CancellationToken.None );
			_dataCacheService.PutItem( GetTileBooksFromBookCollection( _myBooks ), AllMyBooksTileCacheItemName, CancellationToken.None );

			//cache images
			foreach( var myBook in _myBooks )
			{
				_fileDownloadService.DownloadFileAsynchronously( myBook.CoverPreviewSized );
			}
			
			//Update id
			if( _myBooksIds == null )
			{
				_myBooksIds = new List<int>();
			}
			else
			{
				_myBooksIds.Clear();
			}

			_myBooksIds.AddRange( _myBooks.Select( x => x.Id ) );

			_dataCacheService.PutItem( _myBooksIds, AllMyBooksIdCacheItemName, CancellationToken.None );

			//check exits books
			if( _myBooksByTime != null )
			{
				for( int i = _myBooksByTime.Count - 1; i >= 0; i-- )
				{
				    var mBook = _myBooks.FirstOrDefault(x => x.Id == _myBooksByTime[i].Id);
				    if (mBook == null)
				    {
				        _myBooksByTime.Remove(_myBooksByTime[i]);
				    }
				    else
				    {
				        _myBooksByTime[i].Update(mBook);
				    }
				}
			}

			_dataCacheService.PutItem( _myBooksByTime, ReadingBooksCacheItemName, CancellationToken.None );

			CheckBooks();

			return _myBooks;
		}
		public PersonViewModel(ICredentialsProvider credentialsProvider, IPersonsProvider personsProvider, ICatalogProvider catalogProvider, INavigationService navigationService, IRecensesProvider recensesProvider, INotificationsProvider notificationsProvider, ILitresPurchaseService litresPurchaseService, IProfileProvider profileProvider)
		{
			_credentialsProvider = credentialsProvider;
			_personsProvider = personsProvider;
			_catalogProvider = catalogProvider;
			_navigationService = navigationService;
			_recensesProvider = recensesProvider;
			_notificationsProvider = notificationsProvider;
		    _litresPurchaseService = litresPurchaseService;
		    _profileProvider = profileProvider;

		    PersonBooks = new XCollection<Book>();
			PersonRecenses = new XCollection<Recense>();

            RegisterAction(LoadMorePart).AddPart(session => LoadPersonBooks(session, Entity), session => true);
            RegisterAction(ChangeNotificationStatusPart).AddPart(session => ChangeNotificationStatus(session), session => true);
            RegisterAction(LoadMainPart).AddPart(session => LoadPerson(session), session => true);
            RegisterAction(AddPersonRecensePart).AddPart((session) => AddPersonRecense(session), (session) => true);
            RegisterAction(BuyBookLitresPart).AddPart((session) => BuyBookFromLitres(session, Book), (session) => true);
            RegisterAction(CreditCardInfoPart).AddPart(session => CreditCardInfoAsync(session), (session) => true);
            RegisterAction(BuyBookPart).AddPart((session) => BuyBookAsync(session, Book), (session) => true);

            LoadMoreCalled = new RelayCommand( () => LoadMore(), () => true );
			BookSelected = new RelayCommand<Book>( NavigateToBook, book => book != null );
			WriteRecenseSelected = new RelayCommand( () => _navigationService.Navigate( "AddRecense", XParameters.Create( "personId", Entity.Id ) ), () => Entity != null );
            BuyBook = new RelayCommand<Book>(book => BuyBookFromLitresAsync(book));
            RunCreditCardPaymentProcess = new RelayCommand(CreditCardInfo);
            ShowCreditCardView = new RelayCommand<Book>(book => _navigationService.Navigate("CreditCardPurchase", XParameters.Create("BookEntity", book)), book => book != null);
            BuyBookFromMicrosoft = new RelayCommand(BuyBookFromMicrosoftAsync);
            Read = new RelayCommand<Book>(book =>
            {
                if (!book.IsExpiredBook)
                    _navigationService.Navigate("Reader", XParameters.Create("BookEntity", book), false);
                else new MessageDialog("Истёк срок выдачи.").ShowAsync();
            });
        }
Example #58
0
        public MainViewModel(
         //   IExpirationGuardian expirationGuardian, 
            IProfileProvider profileProvider, 
            IGenresProvider genresProvider, 
            ICatalogProvider catalogProvider, 
            ICredentialsProvider credentialsProvider,
            IBookProvider bookProvider,
            INavigationService navigationService, 
            INetworkAvailabilityService networkAvailability,
            IDeviceInfoService deviceInfoService, ILitresPurchaseService litresPurchaseService)
        {            
            _genresProvider = genresProvider;
			_catalogProvider = catalogProvider;
			_credentialsProvider = credentialsProvider;
			_profileProvider = profileProvider;
			_bookProvider = bookProvider;
			_navigationService = navigationService;
		//    _expirationGuardian = expirationGuardian;
		    _networkAvailability = networkAvailability;
            _deviceInfoService = deviceInfoService;
            _litresPurchaseService = litresPurchaseService;

            var deviceFamily = _deviceInfoService.DeviceFamily;
            if (!string.IsNullOrEmpty(deviceFamily) && deviceFamily.Equals("Windows.Desktop"))
            {
                _booksPerPage = 30;
            }
            ////MyBooks reload allways, may change account information
            RegisterAction(BuyBookPart).AddPart((session) => BuyBookAsync(session, Book), (session) => true);
            RegisterAction(GiftBookPart).AddPart((session) => GetGiftAsync(session, Book), (session) => true);
            RegisterAction(MyBooksPart).AddPart( LoadMyBooks, session => true);
            RegisterAction(BuyBookLitresPart).AddPart((session) => BuyBookFromLitres(session, Book), (session) => true);
            RegisterAction(CreditCardInfoPart).AddPart(session => CreditCardInfoAsync(session), (session) => true);
            RegisterAction(LoadMoreNoveltyBooksPart).AddPart(session => LoadNoveltyBooks(session), session => true);
            RegisterAction(LoadMorePopularBooksPart).AddPart(session => LoadPopularBooks(session), session => true);
            RegisterAction(LoadMoreInterestingBooksPart).AddPart(session => LoadInterestingBooks(session), session => true);
            RegisterAction(MyOffersPart).AddPart(LoadOffers, session => true);
            //RegisterPart(MyBooksPart, (session, part) => LoadMyBooks(session), (session, part) => true, false);
            ////RegisterPart(NewBooksPart, (session, part) => LoadNewBooks(session), (session, part) => true, false);

            MyBooksViewState = MyBooksViewStateEnum.Loading;

			Genres = new XCollection<Genre>();
			Banners = new XCollection<Banner>();

			_myBooks = new XCollection<Book>();
			_noveltyBooks = new XCollection<Book>();
			_popularBooks = new XCollection<Book>();
			_interestingBooks = new XCollection<Book>();

			MyBooks = new XSubRangeCollection<Book>(_myBooks, 0, 10);
            
            NoveltyBooks = new XCollection<Book>();
			PopularBooks = new XCollection<Book>();
			InterestingBooks = new XCollection<Book>();
			ShowMyBooks = new RelayCommand( ToMyBooks );
            BookSelected = new RelayCommand<Book>(book =>  _navigationService.Navigate("Book", XParameters.Create("BookEntity", book)), book => book != null);
            BuyBook = new RelayCommand<Book>(BuyBookFromLitresAsync);
            GiftBook = new RelayCommand<Book>(GiftBookFromLitresAsync);
            ShowInterestingBooks = new RelayCommand(() => _navigationService.Navigate("BooksByCategory", XParameters.Create("category", (int) BooksByCategoryViewModel.BooksViewModelTypeEnum.Interesting)));
			ShowPopularBooks = new RelayCommand(() => _navigationService.Navigate("BooksByCategory", XParameters.Create("category", (int) BooksByCategoryViewModel.BooksViewModelTypeEnum.Popular)));
			ShowNewBooks = new RelayCommand(() => _navigationService.Navigate("BooksByCategory", XParameters.Create("category", (int) BooksByCategoryViewModel.BooksViewModelTypeEnum.Novelty)));
            LoadMoreNoveltyBooks = new RelayCommand(LoadMoreNoveltyBooksProceed, () => true);
            LoadMorePopularBooks = new RelayCommand(LoadMorePopularBooksProceed, () => true);
            LoadMoreInterestingBooks = new RelayCommand(LoadMoreInterestingBooksProceed, () => true);
            GenreSelected = new RelayCommand<int>(ChooseGenre);
			ShowSearchHistory = new RelayCommand(() => _navigationService.Navigate("Search"));
            BuyBookFromMicrosoft = new RelayCommand(BuyBookFromMicrosoftAsync);
            Read = new RelayCommand<Book>(book =>
            {
                if (!book.IsExpiredBook)
                    _navigationService.Navigate("Reader", XParameters.Create("BookEntity", book), false);
                else new MessageDialog("Истёк срок выдачи.").ShowAsync();
            });

            ShowAuthorization = new RelayCommand(() => _navigationService.Navigate("Authorization"));
            ShowRegistration = new RelayCommand(() => _navigationService.Navigate("Registration"));
			ShowUserInfo = new RelayCommand( ToUserInfo );
            RunCreditCardPaymentProcess = new RelayCommand(CreditCardInfo);
           
            ShowAccountInfo = new RelayCommand(ToAccountInfo);
			ShowSettings = new RelayCommand(() => _navigationService.Navigate("Settings"));
			ShowBookmarks = new RelayCommand( () => _navigationService.Navigate( "Bookmarks" ) );
			ShowAbout = new RelayCommand( () => _navigationService.Navigate( "About" ) );
			ShowNotifications = new RelayCommand(() => _navigationService.Navigate("NotificationsEdit"));
            ShowCreditCardView = new RelayCommand<Book>(book => _navigationService.Navigate("CreditCardPurchase", XParameters.Create("BookEntity", book)), book => book != null);

            ShowAppSettings = new RelayCommand(ToAppSettings);

            //_expirationGuardian.StartGuardian();		    
        }
Example #59
0
 public async Task LoadOffers(Session session)
 {
     GiftInfo.GiftAvailable = false;
     var result = await _profileProvider.GetOffers(session.Token);
     var offers = result.Offers;
     Offers = new XCollection<Offer>();
     foreach (var offer in offers.Where(offer => offer.Campaign == 2))
     {
         Offers.Add(offer);
     }
     PresentValidTime = DateTime.MinValue;
     foreach (var time in Offers.Select(offer => DateTime.ParseExact(offer.ValidTill, "yyyy-MM-dd HH:mm:ss", new CultureInfo("ru-RU"), DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)).Where(time => time > PresentValidTime))
     {
         PresentValidTime = time;
     }
     var count = Offers.Count(of => of.Class == 2);
     if (count <= 0) return;
     GiftInfo.GiftAvailable = true;
     var giftPrice = (from offer in Offers where offer.Xml.Hidden.Present.Price > 0 select offer.Xml.Hidden.Present.Price).Concat(new double[] {99999}).Min();
     GiftInfo.MinGiftPrice = giftPrice;
 }
 private XCollection<Book> getExpireBooks(XCollection<Book> books, DateTime nextBookTime)
 {
     var booksToExpire = new XCollection<Book>();
     books.ForEach(book =>
     {
         if (!string.IsNullOrEmpty(book.ExpiredDateStr) &&
             !book.IsExpiredBook &&
             book.ExpiredDate == nextBookTime)
         {
             booksToExpire.Add(book);
         }
     });
     return booksToExpire;
 }