Пример #1
0
 private bool AddToDB(string parentName, string topicName, string longTitle, string description)
 {
     try
     {
         using (var session = FactoryProvider.SessionFactory.OpenSession())
         {
             MeasureService measureSvc = new MeasureService(session);
             if (topicName == string.Empty)
             {
                 // Row is a topic category.
                 measureSvc.AddTopicCategory(parentName, longTitle, description);
             }
             else
             {
                 // Row is a topic.
                 // Find the topic topic field.
                 TopicCategory category = measureSvc.GetTopicCategory(parentName);
                 // Check to make sure we found one.
                 if (category == null)
                 {
                     // Create a new Topic topic.
                     // longTitle and description are related to the topic, not the parent topic, so just reuse the name.
                     measureSvc.AddTopicCategory(parentName, parentName, parentName);
                 }
                 Topic topic = measureSvc.AddTopic(category, topicName, longTitle, description);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         Logger.Write(ex);
         return(false);
     }
 }