protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.article_detail); article = JsonConvert.DeserializeObject <KbArticle>(Intent.GetStringExtra("current")); bindControls(); }
/// <summary> /// Creates any entity records that this sample requires. /// </summary> public void CreateRequiredRecords() { #region create kb articles Console.WriteLine(" Creating KB Articles"); _subjectId = ( from subject in _context.SubjectSet where subject.Title == "Default Subject" select subject.Id ).First(); var kbArticleTemplateId = ( from articleTemplate in _context.KbArticleTemplateSet where articleTemplate.Title == "Standard KB Article" select articleTemplate.Id ).FirstOrDefault(); if (kbArticleTemplateId != Guid.Empty) { // create a KB article _articles[0] = new KbArticle() { // set the article properties Title = "Searching the knowledge base", ArticleXml = @" <articledata> <section id='0'> <content><![CDATA[This is a sample article about searching the knowledge base.]]></content> </section> <section id='1'> <content><![CDATA[Knowledge bases contain information useful for various people.]]></content> </section> </articledata>", // use the built-in "Standard KB Article" template KbArticleTemplateId = new EntityReference(KbArticleTemplate.EntityLogicalName, kbArticleTemplateId), // use the default subject SubjectId = new EntityReference(Subject.EntityLogicalName, _subjectId), KeyWords = "Searching Knowledge base" }; _context.AddObject(_articles[0]); _articles[1] = new KbArticle() { Title = "What's in a knowledge base", ArticleXml = @" <articledata> <section id='0'> <content><![CDATA[This is a sample article about what would be in a knowledge base.]]></content> </section> <section id='1'> <content><![CDATA[This section contains more information.]]></content> </section> </articledata>", KbArticleTemplateId = new EntityReference(KbArticleTemplate.EntityLogicalName, kbArticleTemplateId), SubjectId = new EntityReference(Subject.EntityLogicalName, _subjectId), KeyWords = "Knowledge base" }; _context.AddObject(_articles[1]); _articles[2] = new KbArticle() { Title = "Searching the knowledge base from code", ArticleXml = @" <articledata> <section id='0'> <content><![CDATA[This article covers searching the knowledge base from code.]]></content> </section> <section id='1'> <content><![CDATA[This section contains more information.]]></content> </section> </articledata>", KbArticleTemplateId = new EntityReference(KbArticleTemplate.EntityLogicalName, kbArticleTemplateId), SubjectId = new EntityReference(Subject.EntityLogicalName, _subjectId), KeyWords = "Knowledge base code" }; _context.AddObject(_articles[2]); _context.SaveChanges(); } else { throw new ArgumentException("Standard Article Templates are missing"); } #endregion #region Submit the articles Console.WriteLine(" Submitting the articles"); foreach (var article in _articles) { _context.Execute(new SetStateRequest { EntityMoniker = article.ToEntityReference(), State = new OptionSetValue((int)KbArticleState.Unapproved), Status = new OptionSetValue((int)kbarticle_statuscode.Unapproved) }); } #endregion #region Approve and Publish the article Console.WriteLine(" Publishing articles"); foreach (var article in _articles) { _context.Execute(new SetStateRequest { EntityMoniker = article.ToEntityReference(), State = new OptionSetValue((int)KbArticleState.Published), Status = new OptionSetValue((int)kbarticle_statuscode.Published) }); } #endregion #region Waiting for publishing to finish // Wait 20 seconds to ensure that data will be available // Full-text indexing Console.WriteLine(" Waiting 20 seconds to ensure indexing has completed on the new records."); System.Threading.Thread.Sleep(20000); Console.WriteLine(); #endregion #region Add cases to KbArticles // Create UoM _uomSchedule = new UoMSchedule() { Name = "Sample unit group", BaseUoMName = "Sample base unit" }; _context.AddObject(_uomSchedule); _context.SaveChanges(); _uom = (from uom in _context.UoMSet where uom.Name == _uomSchedule.BaseUoMName select uom).First(); Console.WriteLine(" Creating an account and incidents for the KB articles"); var whoami = (WhoAmIResponse)_context.Execute(new WhoAmIRequest()); _account = new Account() { Name = "Coho Winery", }; _context.AddObject(_account); _context.SaveChanges(); _product = new Product() { Name = "Sample Product", ProductNumber = "0", ProductStructure = new OptionSetValue(1), DefaultUoMScheduleId = _uomSchedule.ToEntityReference(), DefaultUoMId = _uom.ToEntityReference() }; _context.AddObject(_product); _context.SaveChanges(); // Publish Product SetStateRequest publishRequest = new SetStateRequest { EntityMoniker = new EntityReference(Product.EntityLogicalName, _product.Id), State = new OptionSetValue((int)ProductState.Active), Status = new OptionSetValue(1) }; _context.Execute(publishRequest); _incident = new Incident() { Title = "A sample incident", OwnerId = new EntityReference(SystemUser.EntityLogicalName, whoami.UserId), KbArticleId = _articles[0].ToEntityReference(), CustomerId = _account.ToEntityReference(), SubjectId = new EntityReference(Subject.EntityLogicalName, _subjectId), ProductId = _product.ToEntityReference() }; _context.AddObject(_incident); _context.SaveChanges(); #endregion }
public View comAdapter_OnGetView(int position, View convertView, ViewGroup parent, KbArticle item, ViewHolder viewHolder) { viewHolder.GetView <TextView>(Resource.Id.text_title).Text = item.Title; viewHolder.GetView <TextView>(Resource.Id.text_summary).Text = item.Summary; viewHolder.GetView <TextView>(Resource.Id.text_good_count).Text = item.DiggCount.ToString(); viewHolder.GetView <TextView>(Resource.Id.text_author).Text = "作者 " + item.Author; viewHolder.GetView <TextView>(Resource.Id.text_watch_count).Text = item.ViewCount.ToString(); return(viewHolder.GetConvertView()); }
/// <summary> /// Creates any entity records that this sample requires. /// </summary> public void CreateRequiredRecords() { #region Create KB records // Use a built-in CRM KB Article Template (required field) // Template Standard KB Article: C3F93721-91B6-475A-ACD0-0A68AA1CB842 // Get the Guid for the Default Subject (required field) var query = new QueryExpression("subject") { ColumnSet = new ColumnSet("title"), EntityName = Subject.EntityLogicalName }; Entity defaultSubject = _serviceProxy.RetrieveMultiple(query).Entities.Where (x => String.Equals((string)x["title"], "Default Subject", StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); if (defaultSubject == null) { Console.WriteLine ("There is no a Default Subject record. Cannot create KB article."); return; } // Create kbarticle1 KbArticle article1 = new KbArticle(); article1.SubjectId = new EntityReference (Subject.EntityLogicalName, defaultSubject.Id); article1.Title = "Raining"; // ArticleXml field is required to be able to Publish an article article1.ArticleXml = @"<articledata> <section id='0'> <content> <![CDATA[This is the Summary for Test1]]> </content> </section> <section id='1'> <content> <![CDATA[This is the Additional Comments for Test1]]> </content> </section> </articledata>"; article1.KbArticleTemplateId = new EntityReference (KbArticleTemplate.EntityLogicalName, _articleTemplate); _article1Id = _serviceProxy.Create(article1); Console.WriteLine("KB article 1 has been Created. Title: " + article1.Title + ". Id: " + _article1Id); // Create kbarticle2 KbArticle article2 = new KbArticle(); article2.SubjectId = new EntityReference (Subject.EntityLogicalName, defaultSubject.Id); article2.Title = "Snowing"; article2.ArticleXml = @"<articledata> <section id='0'> <content> <![CDATA[This is the Summary for Test2]]> </content> </section> <section id='1'> <content> <![CDATA[This is the Additional Comments for Test2]]> </content> </section> </articledata>"; article2.KbArticleTemplateId = new EntityReference (KbArticleTemplate.EntityLogicalName, _articleTemplate); _article2Id = _serviceProxy.Create(article2); Console.WriteLine("KB article 2 has been Created. Title: " + article2.Title + ". Id: " + _article2Id); // Create kbarticle3 KbArticle article3 = new KbArticle(); article3.SubjectId = new EntityReference (Subject.EntityLogicalName, defaultSubject.Id); article3.Title = "Thundering"; // ArticleXml field is required to be able to Publish an article article3.ArticleXml = @"<articledata> <section id='0'> <content> <![CDATA[This is the Summary for Test3]]> </content> </section> <section id='1'> <content> <![CDATA[This is the Additional Comments for Test3]]> </content> </section> </articledata>"; article3.KbArticleTemplateId = new EntityReference (KbArticleTemplate.EntityLogicalName, _articleTemplate); _article3Id = _serviceProxy.Create(article3); Console.WriteLine("KB article 3 has been Created. Title: " + article3.Title + ". Id: " + _article3Id); Console.WriteLine(); #endregion #region Submit KB records // Change state from Draft to Unapproved (Submit) // to be able to Publish _serviceProxy.Execute(new SetStateRequest { EntityMoniker = new EntityReference (KbArticle.EntityLogicalName, _article1Id), State = new OptionSetValue((int)KbArticleState.Unapproved), Status = new OptionSetValue((int)kbarticle_statuscode.Unapproved) }); Console.WriteLine("KB Article 1 has been Submitted."); _serviceProxy.Execute(new SetStateRequest { EntityMoniker = new EntityReference (KbArticle.EntityLogicalName, _article2Id), State = new OptionSetValue((int)KbArticleState.Unapproved), Status = new OptionSetValue((int)kbarticle_statuscode.Unapproved) }); Console.WriteLine("KB Article 2 has been Submitted."); _serviceProxy.Execute(new SetStateRequest { EntityMoniker = new EntityReference (KbArticle.EntityLogicalName, _article3Id), State = new OptionSetValue((int)KbArticleState.Unapproved), Status = new OptionSetValue((int)kbarticle_statuscode.Unapproved) }); Console.WriteLine("KB Article 3 has been Submitted."); Console.WriteLine(); #endregion #region Publish KB records // Publish KB Article records _serviceProxy.Execute(new SetStateRequest { EntityMoniker = new EntityReference (KbArticle.EntityLogicalName, _article1Id), State = new OptionSetValue((int)KbArticleState.Published), Status = new OptionSetValue((int)kbarticle_statuscode.Published) }); Console.WriteLine("KB Article 1 has been Published."); _serviceProxy.Execute(new SetStateRequest { EntityMoniker = new EntityReference (KbArticle.EntityLogicalName, _article2Id), State = new OptionSetValue((int)KbArticleState.Published), Status = new OptionSetValue((int)kbarticle_statuscode.Published) }); Console.WriteLine("KB Article 2 has been Published."); _serviceProxy.Execute(new SetStateRequest { EntityMoniker = new EntityReference (KbArticle.EntityLogicalName, _article3Id), State = new OptionSetValue((int)KbArticleState.Published), Status = new OptionSetValue((int)kbarticle_statuscode.Published) }); Console.WriteLine("KB Article 3 has been Published."); Console.WriteLine(); #endregion #region Ensure availability of the data // Wait 10 seconds to ensure that data will be available // Full-text indexing Console.WriteLine("Waiting 10 seconds to ensure indexing has completed on the new records."); Console.WriteLine(); System.Threading.Thread.Sleep(10000); #endregion }