示例#1
0
        /// <summary>
        /// Thread body
        /// </summary>
        /// <param name="state"></param>
        private void StartWork(object state)
        {
            // Busy
            ShopproHelper.ShowBusyIndicator(this);

            if (this.ContentPageCtx.InSearchMode)
            {
                // In search mode now. Get the count first
                EventHandler <searchByTextCount_ItemCompletedEventArgs> h1 = (s, e) =>
                {
                    if (e.Error == null)
                    {
                        this.ContentPageCtx.TotalItemCount = e.Result;
                    }
                    nextOneAutoResetEvent.Set();
                };
                Globals.WSClient.searchByTextCount_ItemCompleted += h1;
                Globals.WSClient.searchByTextCount_ItemAsync(this.ContentPageCtx.SearchText);
                nextOneAutoResetEvent.WaitOne();
                Globals.WSClient.searchByTextCount_ItemCompleted -= h1;

                // Get current page
                Globals.WSClient.searchByText_ItemCompleted += new EventHandler <HappyDog.SL.Beelun.Shoppro.WSEntryManager.searchByText_ItemCompletedEventArgs>(WSClient_searchByText_ItemCompleted);
                Globals.WSClient.searchByText_ItemAsync(this.ContentPageCtx.SearchText, this.ContentPageCtx.FirstResult, this.ContentPageCtx.MaxResult);
            }
            else
            {
                // Get current list count async
                EventHandler <getCountByCondition_ItemCompletedEventArgs> h3 = (s, e) =>
                {
                    if (e.Error == null)
                    {
                        this.ContentPageCtx.TotalItemCount = e.Result;
                    }
                    nextOneAutoResetEvent.Set();
                };
                Globals.WSClient.getCountByCondition_ItemCompleted += h3;
                Globals.WSClient.getCountByCondition_ItemAsync(this.ContentPageCtx.FilterId);
                nextOneAutoResetEvent.WaitOne();
                Globals.WSClient.getCountByCondition_ItemCompleted -= h3;

                // Update current category if necessary
                if (this.NeedUpdateCategoryListData)
                {
                    EventHandler <getAll_CategoryCompletedEventArgs> h5 = (s, e) =>
                    {
                        if (e.Error == null)
                        {
                            ModelProvider.Instance.MDC.allCategories = new List <category>(e.Result);
                        }
                        nextOneAutoResetEvent.Set();
                    };
                    Globals.WSClient.getAll_CategoryCompleted += h5;
                    Globals.WSClient.getAll_CategoryAsync();
                    nextOneAutoResetEvent.WaitOne();
                    Globals.WSClient.getAll_CategoryCompleted -= h5;
                    this.UpdateCategoryListUI();
                }

                // Get the list content of current page
                Globals.WSClient.getByCondition_ItemCompleted += new EventHandler <getByCondition_ItemCompletedEventArgs>(WSClient_getByCondition_ItemCompleted);
                Globals.WSClient.getByCondition_ItemAsync(this.ContentPageCtx.OrderBy, this.ContentPageCtx.Ascending, this.ContentPageCtx.FirstResult, this.ContentPageCtx.MaxResult, this.ContentPageCtx.FilterId);
            }
        }
示例#2
0
 /// <summary>
 /// 'Add' button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Add_Button_Click(object sender, RoutedEventArgs e)
 {
     this.ContentPageCtx.GotoAddNewPage = true;
     ShopproHelper.GoToContentPage(this, PageEnum.ItemDetailsPage);
 }
示例#3
0
 /// <summary>
 /// 'Previous/Next' button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void itemDataForm_CurrentItemChanged(object sender, EventArgs e)
 {
     ShopproHelper.SetWorkSpaceBodyContentPageTitle(this, string.Format("Record {0} of {1} in current page", this.itemDataForm.CurrentIndex + 1, this.CategorysCountInCurrentPage));
 }
示例#4
0
        /// <summary>
        /// Interaction about Item/Category mapping
        /// </summary>
        /// <param name="state"></param>
        private void StartWork_C2IMappingRelated(object state)
        {
            List <long> idList = state as List <long>;

            if (idList != null)
            {
                // Start get current mapping status
                AutoResetEvent     nextOneAutoResetEvent = new AutoResetEvent(false);
                List <MappingView> l = new List <MappingView>();
                EventHandler <getMappingStatus_ItemCompletedEventArgs> h1 = (s, e) =>
                {
                    foreach (mappingStatus m in e.Result)
                    {
                        l.Add(new MappingView(ShopproHelper.ConvertToCheckedValue(m.mappingStatus1.ToString()), m.name, m.id));
                    }
                    nextOneAutoResetEvent.Set();
                };
                Globals.WSClient.getMappingStatus_ItemCompleted += h1;
                Globals.WSClient.getMappingStatus_ItemAsync(idList.ToArray());
                nextOneAutoResetEvent.WaitOne();
                Globals.WSClient.getMappingStatus_ItemCompleted -= h1;

                // Hide busy indicator
                ShopproHelper.HideBusyIndicator(this);

                // Show category picker
                this.Dispatcher.BeginInvoke(delegate()
                {
                    MappingPicker cp = new MappingPicker(l);
                    cp.Title         = "Category mapping";
                    cp.Instruction   = "Add selected items to category or remove them from category:";
                    cp.Closed       += new EventHandler(cp_Closed);
                    cp.Show();
                });
            }
            else
            {
                Dictionary <long, bool> changedMapping = state as Dictionary <long, bool>;
                if (null != changedMapping)
                {
                    // Start get current mapping status
                    AutoResetEvent nextOneAutoResetEvent = new AutoResetEvent(false);

                    // TODO: optimize this?
                    foreach (long cid in changedMapping.Keys)
                    {
                        EventHandler <setMappingStatus_ItemCompletedEventArgs> h2 = (s, e) =>
                        {
                            // TODO: error handling
                            nextOneAutoResetEvent.Set();
                        };
                        Globals.WSClient.setMappingStatus_ItemCompleted += h2;
                        Globals.WSClient.setMappingStatus_ItemAsync(this.selectedItemId.ToArray(), cid, (changedMapping[cid] == true) ? mappingStatusEnum.ALL : mappingStatusEnum.NONE);
                        nextOneAutoResetEvent.WaitOne();
                        Globals.WSClient.setMappingStatus_ItemCompleted -= h2;
                    }
                }

                // Hide busy indicator
                ShopproHelper.HideBusyIndicator(this);
            }
        }
 private void Add_Button_Click(object sender, RoutedEventArgs e)
 {
     this.ContentPageCtx.GotoAddNewPage = true;  // Go to 'New' page directly
     ShopproHelper.GoToContentPage(this, PageEnum.TemplateDetailsPage);
 }
示例#6
0
 /// <summary>
 /// 'Back'button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BackButton_Click(object sender, RoutedEventArgs e)
 {
     ShopproHelper.GoBack(this);
 }
示例#7
0
 /// <summary>
 /// 'Back'button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BackButton_Click(object sender, RoutedEventArgs e)
 {
     // Navigate back to the item list page
     ShopproHelper.GoBack(this);
 }
 /// <summary>
 /// 'Add' button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Add_Button_Click(object sender, RoutedEventArgs e)
 {
     // Navigate to the item details page
     ShopproHelper.GoToContentPage(this, PageEnum.UserDetailsPage);
 }
示例#9
0
 private void brandDataForm_CurrentItemChanged(object sender, EventArgs e)
 {
     ShopproHelper.SetWorkSpaceBodyContentPageTitle(this, string.Format("Record {0} in current page", this.brandDataForm.CurrentIndex + 1));
 }
        /// <summary>
        /// Thread body
        /// </summary>
        /// <param name="state"></param>
        private void StartWork(object state)
        {
            MediaView mediaView  = state as MediaView;
            media     savedMedia = null;
            media     theMedia   = new media();

            mediaView.Merge(theMedia, editMode);

            // Save to backend
            if (this.editMode == DataFormMode.Edit)
            {
                // Edit mode
                AutoResetEvent nextOneAutoResetEvent           = new AutoResetEvent(false);
                EventHandler <save_MediaCompletedEventArgs> h1 = (s, e) =>
                {
                    // TODO: handle error from server side
                    savedMedia = e.Result;
                    nextOneAutoResetEvent.Set();
                };
                Globals.WSClient.save_MediaCompleted += h1;
                Globals.WSClient.save_MediaAsync(theMedia);
                nextOneAutoResetEvent.WaitOne();
                Globals.WSClient.save_MediaCompleted -= h1;
            }
            else
            {
                //
                // Add new mode
                //

                // Get file content
                byte[] content = ShopproHelper.ReadFully(fileInfo.OpenRead());

                // Save to the backend
                AutoResetEvent nextOneAutoResetEvent = new AutoResetEvent(false);
                EventHandler <createNew_MediaCompletedEventArgs> h3 = (s, e) =>
                {
                    // TODO: handle error from server side
                    savedMedia = e.Result;
                    nextOneAutoResetEvent.Set();
                };
                Globals.WSClient.createNew_MediaCompleted += h3;
                Globals.WSClient.createNew_MediaAsync(theMedia, content);
                nextOneAutoResetEvent.WaitOne();
                Globals.WSClient.createNew_MediaCompleted -= h3;
            }

            // Check return result. If failure, savedCategory will be null
            if (savedMedia != null)
            {
                this.Dispatcher.BeginInvoke(delegate()
                {
                    mediaView.Restore(new MediaView(savedMedia));
                });
            }
            else
            {
                // Show error message
                ShopproHelper.ShowMessageWindow(this, "Error", "Fail to save this entry.", false);

                // Back to readonly mode
                this.Dispatcher.BeginInvoke(delegate()
                {
                    // Restore cached UI data
                    mediaView.CancelEdit();
                    this.mediaDataForm.CancelEdit();
                });
            }

            // No unsaved item
            this.editMode = DataFormMode.ReadOnly;
            this.fileInfo = null;

            // Hide busy indicator
            ShopproHelper.HideBusyIndicator(this);

            // Go to original page if necessary
            if (this.ContentPageCtx.GotoAddNewPage)
            {
                ShopproHelper.GoToContentPage(this, PageEnum.MediaListPage);
            }
        }
示例#11
0
 /// <summary>
 /// 'Add' button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Add_Button_Click(object sender, RoutedEventArgs e)
 {
     // Navigate to the item details page
     this.ContentPageCtx.GotoAddNewPage = true;
     ShopproHelper.GoToContentPage(this, PageEnum.ArticleDetailsPage);
 }