Example #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            _context.Credentials = CredentialCache.DefaultNetworkCredentials;
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.AddToContractCompany(ContractCompany);
            _context.BeginSaveChanges(adoSave_RLMember, ContractCompany);

            var company = _context.ContractCompany;

            DataServiceQuery <ContractCompany> query = company;

            TaskFactory <IEnumerable <ContractCompany> > taskFactory = new TaskFactory <IEnumerable <ContractCompany> >();
            var kompany = await taskFactory.FromAsync(query.BeginExecute(null, null), iar => query.EndExecute(iar));

            ContractCompany2 = kompany.FirstOrDefault();

            _context.DeleteObject(ContractCompany2);
            _context.BeginSaveChanges(adoSave_RLMember, ContractCompany2);

            return(RedirectToPage("./Index"));
        }
Example #2
0
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
        public async Task <IActionResult> OnPostAsync()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
        {
            _context.Credentials = CredentialCache.DefaultNetworkCredentials;
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var contract = _context.Contract;

            DataServiceQuery <Contract> query = contract;

            TaskFactory <IEnumerable <Contract> > taskFactory = new TaskFactory <IEnumerable <Contract> >();
            var kontrakt = await taskFactory.FromAsync(query.BeginExecute(null, null), iar => query.EndExecute(iar));

            Contract2 = kontrakt.FirstOrDefault();

            _context.DeleteObject(Contract2);
            _context.BeginSaveChanges(adoSave_RLMember, Contract2);

            _context.AddToContract(Contract);
            _context.BeginSaveChanges(adoSave_RLMember, Contract);
            return(RedirectToPage("./Index"));
        }
Example #3
0
        public void EditItem(string id, object itemValue)
        {
            DataServiceQuery <Item> query = GetQuery(id);
            var tuple = new Tuple <DataServiceQuery <Item>, object>(query, itemValue);

            query.BeginExecute(AsyncEditCallback, tuple);
        }
Example #4
0
        void LoadMoreItems(uint count, int baseIndex)
        {
            BackgroundWorker worker = new BackgroundWorker();

            //worker.RunWorkerAsync ();
            worker.DoWork += (o, ae) =>
            {
                DataServiceQuery <Order> query = northwindEntity.Orders.Expand("Customer");
                query = query.Skip <Order>(baseIndex).Take <Order>(50) as DataServiceQuery <Order>;
                IAsyncResult ar    = query.BeginExecute(null, null);
                var          items = query.EndExecute(ar);
                var          list  = items.ToList();

                Android.OS.Handler mainHandler = new Android.OS.Handler(Android.OS.Looper.MainLooper);
                Java.Lang.Runnable myRunnable  = new Java.Lang.Runnable(() =>
                {
                    GridSource.LoadItems(list);
                });
                mainHandler.Post(myRunnable);
            };

            worker.RunWorkerCompleted += (o, ae) =>
            {
                IsBusy = false;
            };

            IsBusy = true;
            worker.RunWorkerAsync();
        }
Example #5
0
        /// <summary>Asynchronously loads the collection by executing a <see cref="Microsoft.OData.Client.DataServiceQuery{TElement}" />.Supported only by the WCF Data Services 5.0 client for Silverlight.</summary>
        /// <param name="query">The <see cref="Microsoft.OData.Client.DataServiceQuery{TElement}" /> that, when executed, returns the entities to load into the collection.</param>
        /// <exception cref="System.ArgumentException">When query is null or not a <see cref="Microsoft.OData.Client.DataServiceQuery{TElement}" />.</exception>
        /// <exception cref="System.InvalidOperationException">When a previous call to <see cref="Microsoft.OData.Client.DataServiceCollection{T}.LoadAsync(System.Linq.IQueryable{T})" /> is not yet complete.</exception>
        /// <remarks>This method uses the event-based async pattern.
        /// The method returns immediately without waiting for the query to complete. Then it calls the handler of the
        /// <see cref="LoadCompleted"/> event exactly once on the UI thread. The event will be raised regardless
        /// if the query succeeded or not.
        /// This class only support one asynchronous operation in flight.</remarks>
        public void LoadAsync(System.Linq.IQueryable <T> query)
        {
            Util.CheckArgumentNull(query, "query");
            DataServiceQuery <T> dsq = query as DataServiceQuery <T>;

            if (dsq == null)
            {
                throw new ArgumentException(Strings.DataServiceCollection_LoadAsyncRequiresDataServiceQuery, nameof(query));
            }

            if (this.ongoingAsyncOperation != null)
            {
                throw new InvalidOperationException(Strings.DataServiceCollection_MultipleLoadAsyncOperationsAtTheSameTime);
            }

            if (this.trackingOnLoad)
            {
                this.StartTracking(
                    ((DataServiceQueryProvider)dsq.Provider).Context,
                    null,
                    this.entitySetName,
                    this.entityChangedCallback,
                    this.collectionChangedCallback);
                this.trackingOnLoad = false;
            }

            this.BeginLoadAsyncOperation(
                asyncCallback => dsq.BeginExecute(asyncCallback, null),
                asyncResult =>
            {
                QueryOperationResponse <T> response = (QueryOperationResponse <T>)dsq.EndExecute(asyncResult);
                this.Load(response);
                return(response);
            });
        }
Example #6
0
        /// <summary>
        /// Adds the image button.
        /// </summary>
        /// <param name="lessonId">The lesson identifier.</param>
        /// <param name="parent">The parent.</param>
        private async void AddImageButton(int lessonId, StackPanel parent)
        {
            //System.Diagnostics.Debug.WriteLine("AddImageButton!");
            DataServiceQuery <RESOURCE>           dps = (DataServiceQuery <RESOURCE>)(ctx.RESOURCE.Where(r => r.LESSON_ID == lessonId));
            TaskFactory <IEnumerable <RESOURCE> > tf  = new TaskFactory <IEnumerable <RESOURCE> >();
            IEnumerable <RESOURCE> resources          = (await tf.FromAsync(dps.BeginExecute(null, null), iar => dps.EndExecute(iar)));

            foreach (var r in resources)
            {
                System.Diagnostics.Debug.WriteLine(r.URL);
                Image image = null;
                if (r.TYPE == 2)
                {
                    image = GenerateDocImage(r.URL);
                    parent.Children.Add(image);
                    Img_Lsn.Add(image, lessonId);
                }
                else if (r.TYPE == 1)
                {
                    image = GenerateAudioImage(r.URL);
                    parent.Children.Add(image);
                    Img_Lsn.Add(image, lessonId);
                }
                else if (r.TYPE == 3)
                {
                    image = GenerateAudioImage(r.URL);
                    parent.Children.Add(image);
                    Img_Lsn.Add(image, lessonId);
                }
                image.Tapped += ResImageTapped;
            }
        }
        protected async Task PostAndGetShouldReturnSameEntity(UniverseEntity entity)
        {
            var          uri           = new Uri(this.BaseAddress);
            const string entitySetName = "UniverseEntity";

            await this.ClearRepositoryAsync(entitySetName);

            var ctx = WriterClient(uri, ODataProtocolVersion.V4);

            ctx.AddObject(entitySetName, entity);
            await ctx.SaveChangesAsync();

            // get collection of entities from repository
            ctx = ReaderClient(uri, ODataProtocolVersion.V4);
            DataServiceQuery <UniverseEntity> query = ctx.CreateQuery <UniverseEntity>(entitySetName);
            var entities = await Task.Factory.FromAsync(query.BeginExecute(null, null), (asyncResult) =>
            {
                return(query.EndExecute(asyncResult));
            });

            var beforeUpdate = entities.ToList().First();

            AssertExtension.DeepEqual(entity, beforeUpdate);

            // clear repository
            await this.ClearRepositoryAsync(entitySetName);
        }
Example #8
0
            public void QueryHeadersViaExecuteMethod()
            {
                Uri baseUri = ctx.BaseUri;

                // Accessing headers via DataServiceContext.Execute<> method
                Uri requestUri = new Uri(baseUri.OriginalString + "/Customers('QUICK')");
                var results    = (QueryOperationResponse <northwindClient.Customers>)ctx.Execute <northwindClient.Customers>(requestUri);

                Utils.IsSuccessResponse(results, HttpStatusCode.OK);
                // assert that there is exactly one object
                results.Single <northwindClient.Customers>();

                // Accessing headers via DataServiceContext.BeginExecute/EndExecute method
                IAsyncResult asyncResult = ctx.BeginExecute <northwindClient.Customers>(requestUri, null, null);

                results = (QueryOperationResponse <northwindClient.Customers>)ctx.EndExecute <northwindClient.Customers>(asyncResult);
                Utils.IsSuccessResponse(results, HttpStatusCode.OK);
                // assert that there is exactly one object
                results.Single <northwindClient.Customers>();

                // Accessing headers via DataServiceQuery<>.Execute method
                DataServiceQuery <northwindClient.Customers> query = ctx.CreateQuery <northwindClient.Customers>("Customers");

                results = (QueryOperationResponse <northwindClient.Customers>)query.Execute();
                Utils.IsSuccessResponse(results, HttpStatusCode.OK);
                Assert.IsTrue(results.Count <northwindClient.Customers>() > 0, "expecting atleast one object");

                // Accessing headers via DataServiceQuery<>.BeginExecute/EndExecute method
                asyncResult = query.BeginExecute(null, null);
                results     = (QueryOperationResponse <northwindClient.Customers>)query.EndExecute(asyncResult);
                Utils.IsSuccessResponse(results, HttpStatusCode.OK);
                Assert.IsTrue(results.Count <northwindClient.Customers>() > 0, "expecting atleast one object");
            }
Example #9
0
        public void PostAndGetShouldReturnSameEntity(UniverseEntity entity)
        {
            var          uri           = new Uri(this.BaseAddress);
            const string entitySetName = "UniverseEntity";

            this.ClearRepository(entitySetName);

            var ctx = WriterClient(uri, ODataProtocolVersion.V4);

            ctx.AddObject(entitySetName, entity);
            ctx.SaveChangesAsync().Wait();

            // get collection of entities from repository
            ctx = ReaderClient(uri, ODataProtocolVersion.V4);
            DataServiceQuery <UniverseEntity> query = ctx.CreateQuery <UniverseEntity>(entitySetName);
            IAsyncResult asyncResult = query.BeginExecute(null, null);

            asyncResult.AsyncWaitHandle.WaitOne();

            var entities = query.EndExecute(asyncResult);

            var beforeUpdate = entities.ToList().First();

            AssertExtension.DeepEqual(entity, beforeUpdate);

            // clear repository
            this.ClearRepository(entitySetName);
        }
Example #10
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            course     = e.Parameter as Course;
            globalRate = 0;

            attendDsq = (DataServiceQuery <ATTEND>)(from attend in ctx.ATTEND
                                                    where attend.COURSE_ID == course.ID && attend.CUSTOMER_ID == Constants.User.ID
                                                    select attend);

            try
            {
                TaskFactory <IEnumerable <ATTEND> > tf = new TaskFactory <IEnumerable <ATTEND> >();
                IEnumerable <ATTEND> attends           = await tf.FromAsync(attendDsq.BeginExecute(null, null), iar => attendDsq.EndExecute(iar));

                if (attends.Count() != 0)
                {
                    enterCommentStackPanel.Visibility = Visibility.Visible;
                }
            }
            catch
            {
                ShowMessageDialog();
            }

            commentDsq = (DataServiceQuery <COMMENT_DET>)(from comment in ctx.COMMENT_DET
                                                          where comment.COURSE_ID == course.ID
                                                          orderby comment.TIME ascending
                                                          select comment);
            commentDsq.BeginExecute(OnCommentComplete, null);
        }
Example #11
0
        /// <summary>
        /// Handles the 1 event of the beginButton_Click control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private async void beginButton_Click_1(object sender, RoutedEventArgs e)
        {
            Button bt = sender as Button;

            if (bt.Content.ToString() == "Start Learning!")
            {
                Constants.coursing.NavigateToLecture();
            }
            else if (bt.Content.ToString() == "Edit Course")
            {
                try
                {
                    DataServiceQuery <COURSE> dsq = (DataServiceQuery <COURSE>)(from c in ctx.COURSE
                                                                                where c.ID == course.ID
                                                                                select c);
                    TaskFactory <IEnumerable <COURSE> > tf = new TaskFactory <IEnumerable <COURSE> >();
                    editCourse = (await tf.FromAsync(dsq.BeginExecute(null, null), iar => dsq.EndExecute(iar))).FirstOrDefault();
                }
                catch
                {
                    ShowMessageDialog("Network connection error.31");
                    return;
                }

                courseTitle.Text   = editCourse.TITLE;
                price.Text         = editCourse.PRICE.ToString();
                courseContent.Text = editCourse.INTRO;

                EditCoursePopup.IsOpen = true;
            }
        }
Example #12
0
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。Parameter
        /// 属性通常用于配置页。</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            course = e.Parameter as Course;
            List <object> courseInfo = e.Parameter as List <object>;

            course      = courseInfo[0] as Course;
            DataContext = course;

            if ((courseInfo[1] as string) == "attending")
            {
                beginButton.Content = "Start Learning!";
                getLearnedPercentage();
            }
            else if ((courseInfo[1] as string) == "teaching")
            {
                beginButton.Content = "Edit Course";
            }

            SetStarsStackPanel(course.Rate ?? 0);

            categoryDsq = (DataServiceQuery <CATEGORY>)(from category in ctx.CATEGORY select category);
            categoryDsq.BeginExecute(OnCategoryComplete, null);

            pgDsq = (DataServiceQuery <PARENT_GUIDE>)(from pg in ctx.PARENT_GUIDE select pg);
            pgDsq.BeginExecute(OnPGComplete, null);


            // getLearnedPercentage();
        }
Example #13
0
        private void ShowImage()
        {
            DataServiceQuery <Annotation> NotesQuery = (DataServiceQuery <Annotation>) this.ThisContext
                                                       .AnnotationSet.Where <Annotation>(a => a.FileName == ImageFileName);

            NotesQuery.BeginExecute(ReadNotesCompleted, NotesQuery);
        }
Example #14
0
        /// <summary>
        /// Initializes the popup style.
        /// </summary>
        private void InitializePopupStyle()
        {
            // 样式设置
            var grids = from g in AdvanceSearchStackPanel.Children.OfType <Grid>()
                        where !g.Name.Equals(searchButtonsGrid.Name)
                        select g;

            foreach (var grid in grids)
            {
                grid.Margin = new Thickness(10);
                grid.Height = 70;

                var filterTitles = from c in grid.Children.OfType <TextBlock>()
                                   select c;
                filterTitles.FirstOrDefault().FontSize = 50;

                var filterContent = from c in grid.Children.OfType <TextBox>()
                                    select c;
                if (filterContent != null && filterContent.Count() != 0)
                {
                    filterContent.FirstOrDefault().FontSize = 40;
                    filterContent.FirstOrDefault().Text     = "";
                }
            }

            // Category内容设置
            categoryDsq = (DataServiceQuery <CATEGORY>)(from category in ctx.CATEGORY select category);
            categoryDsq.BeginExecute(OnCategoryComplete, null);

            SearchPopTitleText.KeyDown       += AdvanceSearch_KeyDown;
            SearchPopAuthorText.KeyDown      += AdvanceSearch_KeyDown;
            SearchPopDescriptionText.KeyDown += AdvanceSearch_KeyDown;
        }
Example #15
0
        /// <summary>
        /// Ons the resource complete.
        /// </summary>
        /// <param name="res">The resource.</param>
        private void onResComplete(IAsyncResult res)
        {
            IEnumerable <RESOURCE> resources = resourceDsq.EndExecute(res);
            RESOURCE resource = resources.FirstOrDefault();

            resTypeDsq = (DataServiceQuery <RES_TYPE>)(ctx.RES_TYPE.Where(r => r.ID == resource.TYPE));
            resTypeDsq.BeginExecute(onQueryComplete2, null);
        }
Example #16
0
        private void ReadConfiguration()
        {
            int Value = 100000000; //Aspose.ImageAttach
            DataServiceQuery <aspose_configuration> Configs = (DataServiceQuery <aspose_configuration>) this.ThisContext
                                                              .aspose_configurationSet.Where <aspose_configuration>(a => a.aspose_Type.Value.Value == Value);

            Configs.BeginExecute(ReadConfiguration, Configs);
        }
Example #17
0
 /// <summary>
 /// 在此页将要在 Frame 中显示时进行调用。
 /// </summary>
 /// <param name="e">描述如何访问此页的事件数据。Parameter
 /// 属性通常用于配置页。</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     //!!!!!!!!!!
     Constants.User.SetAttendTeachNumber();
     image.DataContext       = Constants.User;
     biggestGrid.DataContext = Constants.User;
     customerDsq             = (DataServiceQuery <CUSTOMER>)(from user in ctx.CUSTOMER select user);
     customerDsq.BeginExecute(OnCustomerComplete, null);
 }
Example #18
0
 private void EnableLicense()
 {
     if (LicenseWebResourceName != "")
     {
         DataServiceQuery <WebResource> License = (DataServiceQuery <WebResource>) this.ThisContext
                                                  .WebResourceSet.Where <WebResource>(a => a.Name == LicenseWebResourceName);
         License.BeginExecute(RetrieveLicense, License);
     }
 }
Example #19
0
        /// <summary>
        /// In this method we send a REST request to ADO.NET Data Service to request CourseGrade
        /// records. We expand Person and Course so the foreign records will be returned as well
        /// </summary>
        private void LoadData()
        {
            _context = new SchoolLinqToSQLDataContext(new Uri(_schoolLinqToSQLUri));
            DataServiceQuery <CourseGrade> query = (DataServiceQuery <CourseGrade>)(
                from c in _context.CourseGrades.Expand("Person").Expand("Course")
                select c);

            query.BeginExecute(OnCourseGradeQueryComplete, query);
        }
        /// <summary>
        /// 本方法中,发送一个异步的REST请求到ADO.NET Data Service来获得 CourseGrade 数据
        /// 我们扩展了 Person 以及 Course,所以外部记录也会被返回到客户端。
        /// </summary>
        private void LoadData()
        {
            _entities = new SQLServer2005DBEntities(new Uri(_schoolLinqToEntitiesUri));
            DataServiceQuery<CourseGrade> query = (DataServiceQuery<CourseGrade>)(
                from c in _entities.CourseGrade.Expand("Person").Expand("Course")
                select c);

            query.BeginExecute(OnCourseGradeQueryComplete, query);
        }
        /// <summary>
        /// 本方法中,我们向ADO.NET Data Service发送了一个异步的REST请求,来获得Category
        /// 记录。
        /// </summary>
        private void LoadData()
        {
            _context = new SampleProjects(new Uri(_sampleUri));
            DataServiceQuery <Category> query = (DataServiceQuery <Category>)(
                from c in _context.Categories
                select c);

            query.BeginExecute(OnCategoryQueryComplete, query);
        }
Example #22
0
        void FindCustomerByIDAndProcess(string customerID, Action <Customers> action)
        {
            DataServiceQuery <Customers> query = (DataServiceQuery <Customers>)context.Customers.Where <Customers>(customer => customer.CustomerID == customerID);

            try {
                query.BeginExecute(FindCustomerByIDCallback, new QueryAction(query, action));
            } catch (Exception ex) {
                HandleException(ex);
            }
        }
        public static async Task <IEnumerable <TResult> > ExecuteAsync <TResult>(this DataServiceQuery <TResult> query)
        {
            var queryTask = Task.Factory.FromAsync <IEnumerable <TResult> >(query.BeginExecute(null, null), (asResult) =>
            {
                var result = query.EndExecute(asResult).ToList();
                return(result);
            });

            return(await queryTask);
        }
Example #24
0
 /// <summary>
 /// Extension method to perform sync/async version of DataServiceQuery.Execute dynamically
 /// </summary>
 /// <typeparam name="TElement">The element type of the results</typeparam>
 /// <param name="query">The query to execute</param>
 /// <param name="continuation">The asynchronous continuation</param>
 /// <param name="async">A value indicating whether or not to use async API</param>
 /// <param name="onCompletion">A callback for when the call completes</param>
 public static void Execute <TElement>(this DataServiceQuery <TElement> query, IAsyncContinuation continuation, bool async, Action <IEnumerable <TElement> > onCompletion)
 {
     ExceptionUtilities.CheckArgumentNotNull(query, "query");
     AsyncHelpers.InvokeSyncOrAsyncMethodCall <IEnumerable <TElement> >(
         continuation,
         async,
         () => query.Execute(),
         c => query.BeginExecute(c, null),
         r => query.EndExecute(r),
         onCompletion);
 }
Example #25
0
        public async Task OnGetAsync()
        {
            _nav.Credentials = CredentialCache.DefaultNetworkCredentials;
            var contracts = _nav.Customer;

            DataServiceQuery <Customer> query = contracts;

            TaskFactory <IEnumerable <Customer> > taskFactory = new TaskFactory <IEnumerable <Customer> >();

            Customer = await taskFactory.FromAsync(query.BeginExecute(null, null), iar => query.EndExecute(iar));
        }
        private IEnumerable <Order> ProcessOrder(DataServiceQuery <Order> queryOrder)
        {
            IAsyncResult resultOrder = queryOrder.BeginExecute((res) =>
            {
                Console.WriteLine(res);
            }, null);

            IEnumerable <Order> objOrder = queryOrder.EndExecute(resultOrder);

            return(objOrder);
        }
Example #27
0
 public static void ProcessQuery(DataViewModelBase sender, DataServiceQuery query, AsyncCallback callback)
 {
     if (!objectRepository.Value.Keys.Contains(query.ToString()))
     {
         query.BeginExecute(callback, null);
     }
     else
     {
         sender.OnCompleteSource(objectRepository.Value[query.ToString()]);
     }
 }
        public async Task <List <FileSystemItem> > GetFiles()
        {
            DataServiceQuery <MS.FileServices.FileSystemItem> query = (DataServiceQuery <MS.FileServices.FileSystemItem>)
                                                                      from file in apiData.Files
                                                                      select file;

            TaskFactory <IEnumerable <FileSystemItem> > taskFactory = new TaskFactory <IEnumerable <FileSystemItem> >();
            IEnumerable <FileSystemItem> result = await taskFactory.FromAsync(query.BeginExecute(null, null), iar => query.EndExecute(iar));

            return(result.ToList());
        }
Example #29
0
        /// <summary>
        /// Ons the get lesson complete.
        /// </summary>
        /// <param name="iar">The iar.</param>
        private async void onGetLessonComplete(IAsyncResult iar)
        {
            try
            {
                System.Diagnostics.Debug.WriteLine("get lesson complete");
                IEnumerable <LESSON> lessons = dba.lessonDsq.EndExecute(iar);

                foreach (var l in lessons)
                {
                    this.allLessons.Add(l);
                    //coursesData.AddCourse(Constants.CourseAvail2Course(c));
                }
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    foreach (var l in this.allLessons)
                    {
                        System.Diagnostics.Debug.WriteLine(l.TITLE);
                        allLessonsStackPanel.Children.Add(GenerateALessonBox(l));
                    }
                    //dataCategory = coursesData.GetGroupsByCategory();
                    //cvs1.Source = dataCategory;
                    //(SemanticZoom.ZoomedOutView as ListViewBase).ItemsSource = cvs1.View.CollectionGroups;
                    //loadingProgressRing.IsActive = false;
                });
            }
            catch
            {
                //ShowMessageDialog();
                // Network Connection error.
            }
            try
            {
                resourceDic = new Dictionary <string, int>(Constants.ResourceType.Count);
                for (int i = 0; i < Constants.ResourceType.Count; ++i)
                {
                    DataServiceQuery <RES_TYPE> dps = (DataServiceQuery <RES_TYPE>)(from res_type in ctx.RES_TYPE
                                                                                    where res_type.DESCRIPTION.Trim() == Constants.ResourceType[i]
                                                                                    select res_type);
                    TaskFactory <IEnumerable <RES_TYPE> > tf = new TaskFactory <IEnumerable <RES_TYPE> >();
                    RES_TYPE resID = (await tf.FromAsync(dps.BeginExecute(null, null), result => dps.EndExecute(result))).FirstOrDefault();

                    resourceDic.Add(Constants.ResourceType[i], resID.ID);
                }
            }
            catch
            {
                ShowMessageDialog("Network connection error!11");
                return;
            }


            GetLearnedLessons();
        }
        private void GetPartSuppliers()
        {
            if (currentItem != null)
            {
                DataServiceQuery <SuppliersItem> query =
                    (DataServiceQuery <SuppliersItem>)context.PartSuppliers.Where(s => s.PartId == currentItem.Part.Id).Select(s => new SuppliersItem {
                    Title = s.Supplier.Title, DUNS = s.Supplier.DUNS, Rating = s.Supplier.Rating
                });

                query.BeginExecute(DisplaySuppliers, query);
            }
        }