コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        private void Keyword_dialog_ApplyingChanges(object sender, CancelRoutedEventArgs e)
        {
            // Validate keyword field
            if (_keywordValueField.Text.Trim().Length < 1)
            {
                Visual.GetDescendant <TabControl>(Keyword_dialog).SelectedIndex = 0;
                _keywordValueField.Focus();

                MessageBoxError("Please enter a valid keyword", null);
                e.Cancel = true;                 // No significance since we are not calling dialog.EndApplyChanges()
                return;
            }

            int    currentAccountID      = this.Window.CurrentAccount.ID;
            string keywordValueFieldText = _keywordValueField.Text;

            Oltp.KeywordDataTable tbl = null;

            Window.AsyncOperation(delegate()
            {
                // When adding a new keyword, make sure it is unique
                if ((Keyword_dialog.Content as Oltp.KeywordRow).RowState == DataRowState.Added)
                {
                    using (OltpProxy proxy = new OltpProxy())
                    {
                        tbl = proxy.Service.Keyword_Get(currentAccountID, false, keywordValueFieldText, true);
                    }

                    if (tbl.Rows.Count > 0)
                    {
                        MessageBoxError("Keyword already exists.", null);
                        e.Cancel = true;
                        return;
                    }
                }
            },
                                  delegate()
            {
                if (tbl.Rows.Count > 0)
                {
                    MessageBoxError("Keyword already exists.", null);
                    e.Cancel = true;
                    return;
                }

                Dialog_ApplyingChanges <Oltp.KeywordDataTable, Oltp.KeywordRow>(
                    _keywords,
                    Keyword_dialog,
                    typeof(IOltpLogic).GetMethod("Keyword_Save"),
                    e, null, true, null);
            });
        }
        private string GetReferenceData(Oltp.GatewayRow tracker, OltpLogicClient client)
        {
            string referenceData = "";

            if (tracker.AdgroupGK < 1)
            {
                return("");
            }

            Oltp.AdgroupDataTable adg = client.Service.Adgroup_GetSingle(tracker.AdgroupGK);
            if (adg.Rows.Count < 1)
            {
                return("");
            }

            Oltp.AdgroupRow adgroup = adg[0];

            Oltp.CampaignDataTable cmpn = client.Service.Campaign_GetSingle(adgroup.CampaignGK);
            if (cmpn.Rows.Count > 0)
            {
                referenceData += "<span>" + (cmpn.Rows[0] as Oltp.CampaignRow).Name + "</span> > ";
            }
            referenceData += "<span>" + adgroup.Name + "</span> > ";


            if (!tracker.IsReferenceTypeNull())
            {
                if (tracker.ReferenceType == Oltp.GatewayReferenceType.Creative)
                {
                    Oltp.CreativeDataTable c = client.Service.Creative_GetSingle(tracker.ReferenceID);
                    if (c.Rows.Count > 0)
                    {
                        referenceData += "Creative: <span>" + (c[0] as Oltp.CreativeRow).Title + "</span>";
                    }
                }
                else
                {
                    Oltp.KeywordDataTable k = client.Service.Keyword_GetSingle(tracker.ReferenceID);
                    if (k.Rows.Count > 0)
                    {
                        referenceData += "Keyword: <span>" + (k[0] as Oltp.KeywordRow).Keyword + "</span>";
                    }
                }
            }

            return(referenceData);
        }
        public PartialViewResult FindKeywords(string searchText)
        {
            List <Oltp.KeywordRow> L = new List <Oltp.KeywordRow>();

            using (var client = new OltpLogicClient(session_id))
            {
                string str = searchText.Trim().Length > 0 ? searchText.Trim() + "%" : null;
                Oltp.KeywordDataTable keywords = client.Service.Keyword_Get(acc_id, true, str, true);

                foreach (Oltp.KeywordRow keyword in keywords)
                {
                    L.Add(keyword);
                }
            }

            return(PartialView("Table", L));
        }
コード例 #4
0
        public PartialViewResult FindKeywords(string searchText)
        {
            List <Oltp.KeywordRow> L = new List <Oltp.KeywordRow>();

            using (OltpLogicClient client = OltpLogicClient.Open(session_id))
            {
                if (client == null)
                {
                    return(PartialView("~/Views/Shared/_SessionExpiredView.cshtml"));
                }

                string str = searchText.Trim().Length > 0 ? searchText.Trim() + "*" : null;
                Oltp.KeywordDataTable keywords = client.Service.Keyword_Get(acc_id, true, str, true);

                foreach (Oltp.KeywordRow keyword in keywords)
                {
                    L.Add(keyword);
                }
            }

            return(PartialView("Table", L));
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="include"></param>
        private void GetKeywords(Oltp.AccountRow account, string filter, bool include)
        {
            Oltp.AccountRow currentAccount = account == null ? this.Window.CurrentAccount : account;

            if (currentAccount == null)
            {
                return;
            }

            Window.AsyncOperation(delegate()
            {
                using (OltpProxy proxy = new OltpProxy())
                {
                    _keywords = proxy.Service.Keyword_Get(currentAccount.ID, false, filter, include);
                }
            },
                                  delegate()
            {
                // Get an empty new list
                if (_items == null)
                {
                    _items = new ObservableCollection <DataRow>();
                }
                else
                {
                    _items.Clear();
                }

                // Add all items
                foreach (DataRow r in _keywords.Rows)
                {
                    _items.Add(r);
                }

                _listTable.ListView.ItemsSource = _items;
            });
        }