public TopicWorker(Factories.TopicFactory factory, Map map, Topic parentTopic, ITopicConnection connectionType) { _topic = factory.CreateTopic(map, parentTopic); _topicPointer = factory.CreateTopicPointer(connectionType); _topic.Pointer = _topicPointer; }
public static IReadOnlyCollection<Address> To(this IMessageRouter router, Topic topic) { return new ReadOnlyCollection<Address>(new List<Address> { topic }); }
public ActionResult Create(TopicModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageTopics)) return AccessDeniedView(); if (ModelState.IsValid) { if (!model.IsPasswordProtected) { model.Password = null; } var topic = new Topic() { Body = model.Body, IncludeInSitemap = model.IncludeInSitemap, IsPasswordProtected = model.IsPasswordProtected, MetaDescription = model.MetaDescription, MetaKeywords = model.MetaKeywords, MetaTitle = model.MetaTitle, Password = model.Password, SystemName = model.SystemName, Title = model.Title }; _topicService.InsertTopic(topic); //locales UpdateLocales(topic, model); SuccessNotification("Chủ đề đã được tạo."); return continueEditing ? RedirectToAction("Edit", new { id = topic.Id }) : RedirectToAction("List"); } //If we got this far, something failed, redisplay form return View(model); }
void ITopicOwned.SetOwner(Topic owner) { if (_owner != owner) { if (_owner != null) { _owner.Unsubscribe("+", _owner_changed); Change_A(null); Change_B(null); _parent = null; } _owner = owner as DVar<PiWire>; if (_owner != null) { _owner.saved = true; var dc = _owner.Get<string>("_declarer"); dc.saved = true; dc.value = "Wire"; if (_owner.parent != null && _owner.parent.valueType == typeof(PiLogram)) { _parent = (_owner.parent as DVar<PiLogram>).value; } _owner.Subscribe("+", _owner_changed); if (exec) { Change_A(_a); Change_B(_b); } } } }
private static void DeclarerChanged(Topic sender, TopicChanged param) { DVar<string> dec=sender as DVar<string>; Topic infoT; DVar<string> infoD; if(dec==null) { return; } StatementDescription stR=null; if(param.Art==TopicChanged.ChangeArt.Remove) { stR=_statements.FirstOrDefault(z => z.name==dec.name); if(stR!=null) { _statements.Remove(stR); } } else { if(param.Art==TopicChanged.ChangeArt.Value) { stR=_statements.FirstOrDefault(z => z.name==dec.name); } if(stR==null) { stR=new StatementDescription() { name=dec.name }; _statements.Add(stR); } stR.image=dec.value; if(dec.Exist("_description", out infoT) && (infoD=(infoT as DVar<string>))!=null && !string.IsNullOrEmpty(infoD.value)) { stR.sortKey=infoD.value.Substring(0, 2); stR.info=infoD.value.Substring(2); } } }
public async Task<DataFeed[]> GetFeedsAsync(Topic topic, int maxResults, DateTime queryStartTime) { if (!topicTranslator.ContainsKey(topic) || maxResults < 0 || queryStartTime >= DateTime.Now) { return null; } int periodInHours = (int) Math.Ceiling((DateTime.Now - queryStartTime).TotalHours); string url = string.Format(urlTemplate, topicTranslator[topic], periodInHours, maxResults); string response = (await ApiHandler.GetResponseAsync(domain,url)); if (response == null) { return null; } JObject jsonResponse; int resultsFeedNumber; try { jsonResponse = JObject.Parse(response); resultsFeedNumber = (int) jsonResponse["num_results"]; } catch (Exception e) { return null; } return GetDataFeedsFromResponse(jsonResponse, resultsFeedNumber,maxResults); }
private void CfgChanged(Topic sender, TopicChanged arg) { DVar<string> dv=sender as DVar<string>; if(dv==null || sender==_verbose) { return; } if(arg.Art==TopicChanged.ChangeArt.Remove) { foreach(var i in _items.Where(z => z.name==dv.name).ToArray()) { i.Dispose(); _items.Remove(i); } } else if(!string.IsNullOrWhiteSpace(dv.value)) { Uri u; try { u=new Uri(dv.value); } catch(UriFormatException ex) { Log.Warning("{0}=\"{1}\" - {2}", dv.path, dv.value, ex.Message); return; } if(string.IsNullOrEmpty(u.AbsolutePath)) { return; } WsSyncItem it=_items.FirstOrDefault(z => z.name==dv.name); if(it==null) { it=new WsSyncItem(dv.name, u); _items.Add(it); } else { it.ChangeUri(u); } } }
public void Calculate(DVar<PiStatement> model, Topic source) { if(source==_csv) { Import(); Rebuild(); } else if((source==_yRef || source==_match) && _match.value) { double y2=_cubSpl.Func(_x.value); double yo=_yRef.value-y2; if(double.IsNaN(y2) || Math.Abs(yo)>_ye.value) { double xo=Math.Round(_x.value/_xe.value)*_xe.value; double y1; if(_data.TryGetValue(xo, out y1) && !double.IsNaN(y2)) { y1+=yo/10; } else { y1=_yRef.value; } if(!double.IsNaN(y1)) { _data[xo]=y1; } //Log.Debug("{2}({0}, {1})", xo, y1, model.path); _upd++; Rebuild(); _y.value=_cubSpl.Func(_x.value); } } else if(source==_x) { _y.value=_cubSpl.Func(_x.value); if(_upd>2) { Export(); _upd=0; } } }
/// <summary> /// Return all notifications for a specified topic /// </summary> /// <param name="topic"></param> /// <returns></returns> public IList<TopicNotification> GetByTopic(Topic topic) { return _context.TopicNotification .Where(x => x.Topic.Id == topic.Id) .AsNoTracking() .ToList(); }
public void Init() { _sign=Topic.root.Get("/etc/PersistentStorage"); _verbose=_sign.Get("verbose"); _verbose.config=true; if(!Directory.Exists("../data")) { Directory.CreateDirectory("../data"); } _file=new FileStream("../data/persist.xdb", FileMode.OpenOrCreate, FileAccess.ReadWrite); if(_file.Length<=0x40) { _file.Write(new byte[0x40], 0, 0x40); _file.Flush(true); _nextBak=DateTime.Now.AddHours(1); } else { Load(); } _fileLength=_file.Length; _work=new AutoResetEvent(false); _thread=new Thread(new ThreadStart(PrThread)); _thread.Priority=ThreadPriority.BelowNormal; _now=DateTime.Now; if(_nextBak<_now) { Backup(); } _thread.Start(); Topic.root.all.changed+=MqChanged; }
public MessageSender(String broker, String topicName) { //Create connection try { sonicSender = new SonicCommunicator(topicName, broker); cf = sonicSender.GetConnectionFactory(); conn = cf.createConnection(); session = (Session)conn.createSession(false, Sonic.Jms.SessionMode.AUTO_ACKNOWLEDGE); } catch (JMSException jmse) { throw new Exception("Unable to establish connection to MQ." + jmse.Message + " / " + jmse.InnerException); } Console.WriteLine("Create Session: " + session.ToString()); //create the topic try { topic = session.createTopic(topicName); publisher = session.createProducer(topic); tempTopic = session.createTemporaryTopic(); subscriber = session.createConsumer(tempTopic); conn.start(); } catch (JMSException jmse) { throw new Exception("Unable to create topic." + jmse.Message + " / " + jmse.InnerException); } }
internal static byte[] Serialize(Topic t) { List<byte> ret=new List<byte>(); switch(Type.GetTypeCode(t.valueType)) { case TypeCode.Boolean: ret.Add((byte)((t as DVar<bool>).value?1:0)); break; case TypeCode.Int64: { long vo=(t as DVar<long>).value; long v=vo; do { ret.Add((byte)v); v=v>>8; } while(vo<0?(v<-1 || (ret[ret.Count-1]&0x80)==0):(v>0 || (ret[ret.Count-1]&0x80)!=0)); } break; //case TypeCode.Double: case TypeCode.String: { string v=(string)t.GetValue(); if(!string.IsNullOrEmpty(v)) { ret.AddRange(Encoding.Default.GetBytes(v)); } } break; case TypeCode.Object: if(t.valueType==typeof(PLC.ByteArray) && t.GetValue()!=null) { ret.AddRange(((PLC.ByteArray)t.GetValue()).GetBytes()); } break; } return ret.ToArray(); }
protected override object ConnectData(Topic topic, IList<string> topicInfo, ref bool newValues) { TestArrayTopic testArrayTopic = (TestArrayTopic)topic; _topics.Add(testArrayTopic); Debug.Print("ConnectData - Prefix {0}", testArrayTopic.Prefix); return ExcelErrorUtil.ToComError(ExcelError.ExcelErrorNA); }
public void Initialize() { tr=Topic.root.Get("/test"); cbData=new List<Topic>(); //Topic.RequestContext=ReqCtx; //Topic.root.Get("test/req").all.ToArray(); //Topic.RequestContext=null; }
public void StartConversation( Topic[] topics ) { // Verify topics we gave us aren't bunk // need to have a start topic // and the start topic needs to have options Topic start = null; foreach ( Topic topic in topics ) { if ( topic._topicName == TopicName.START ) { start = topic; break; } } if ( start == null ) { Debug.LogError("Topics don't contain a START topic!"); return; } _state = new ConversationState { _topics = topics, _currentTopicName = TopicName.START, _currentTopic = start }; OnConversationStart(); }
public void Add(Topic topic, string ip) { DbCommand comm = this.GetCommand("SPTopicsInsert"); comm.AddParameter<string>(this.Factory, "TopicTitle", topic.Title); comm.AddParameter<string>(this.Factory, "TopicShortName", topic.ShortName); comm.AddParameter<string>(this.Factory, "TopicDescription", topic.Description); comm.AddParameter<int>(this.Factory, "UserId", topic.User.Id); comm.AddParameter<string>(this.Factory, "TopicTags", topic.Tags.ToString()); comm.AddParameter<string>(this.Factory, "Forum", topic.Forum.ShortName); comm.AddParameter(this.Factory, "TopicOrder", DbType.Int32, topic.IsSticky ? 1 : (int?)null); comm.AddParameter<string>(this.Factory, "Ip", ip); comm.AddParameter(this.Factory, "ReadAccessGroupId", DbType.Int16, topic.ReadAccessRole); comm.AddParameter(this.Factory, "PostAccessGroupId", DbType.Int16, topic.PostAccessRole); DbParameter idParameter = comm.AddParameter(this.Factory, "TopicId", DbType.Int32, null); idParameter.Direction = ParameterDirection.Output; this.SafeExecuteNonQuery(comm); if (idParameter.Value != DBNull.Value) { topic.Id = Convert.ToInt32(idParameter.Value); } else { throw new DataException("No value for the output parameter: " + idParameter.ParameterName); } }
public void Should_Have_List_Of_Topics_With_Name_And_Color() { var topic = new Topic {Id = 1, Color = Color.Red, Name = "Work"}; var model = ((ViewResult) new TopicController().Index()).ViewData.Model; Assert.AreEqual(topic, ( (List<Topic>) model)[0]); }
public ActionResult _DisplayListTopic(Topic topic) { var notifications = db.PushNotifications.Where(pn => pn.TopicID == topic.ID) .ToDictionary(pn => pn.User, pn => pn.Confirmed); return PartialView("_DisplayListTopic", notifications); }
public DomainParticipantTransportSource(DomainParticipant participant, string senderTopic, string receiverTopic) { _participant = participant; var senderTopicQos = new TopicQos(); participant.get_default_topic_qos(senderTopicQos); var receiverTopicQos = new TopicQos(); participant.get_default_topic_qos(receiverTopicQos); _sender = participant.create_topic(senderTopic, BytesTypeSupport.TYPENAME, senderTopicQos, null, StatusMask.STATUS_MASK_NONE); _receiver = participant.create_topic(receiverTopic, BytesTypeSupport.TYPENAME, receiverTopicQos, null, StatusMask.STATUS_MASK_NONE); var writerQos = new DataWriterQos(); //writerQos.publish_mode.kind = PublishModeQosPolicyKind.ASYNCHRONOUS_PUBLISH_MODE_QOS; writerQos.publish_mode.flow_controller_name = FlowController.FIXED_RATE_FLOW_CONTROLLER_NAME; participant.get_default_datawriter_qos(writerQos); var readerQos = new DataReaderQos(); participant.get_default_datareader_qos(readerQos); _writer = participant.create_datawriter(_sender, writerQos, null, StatusMask.STATUS_MASK_NONE); _reader = participant.create_datareader(_receiver, readerQos, this, StatusMask.STATUS_MASK_ALL); }
public void Init() { b1 = new Blog("blabla", "blabla"); b2 = new Blog("blbal", "ujbghu"); t1 = new Topic("blb"); t2 = new Topic("blabla"); }
public static void MyClassInitialize(TestContext testContext) { r=new Random((int)DateTime.Now.Ticks); root=Topic.root; //root.SetJson("{\"$type\":\"X13.Engine_UT.TestObj, Engine_UT\",\"A\":315,\"B\":0.41}"); //PLC.instance.Tick(); //root.ToJson(); }
/// <summary> /// Deletes a topic /// </summary> /// <param name="topic">Topic</param> public virtual void DeleteTopic(Topic topic) { if (topic == null) throw new ArgumentNullException("topic"); _topicRepository.Delete(topic); }
public void SetOwner(Topic owner) { if(_owner!=null) { if(Topic.brokerMode) { _owner.Unsubscribe("+", STVarChanged); } } if(_dev!=null) { _dev.Pool+=_dev_Pool; } _owner=owner; if(_owner!=null) { name=owner.name; if(Topic.brokerMode) { if(_owner.parent!=null && _owner.parent.valueType==typeof(MsDevice)) { _dev=(_owner.parent as DVar<MsDevice>).value; } _owner.Get<string>("_declarer", _owner).value="TWI"; _owner.Subscribe("+", STVarChanged); if(_dev!=null) { _dev.Pool+=_dev_Pool; Reset(); } } } }
/* ================================ */ /* Load メソッド */ /* ================================ */ public void AddTopic(Topic t){ if(t.Id == 0) throw new Exception("トピックの番号がありません : " + t.ToString()); Object[] data = new Object[]{t.Id, t.Date.Ticks, t.Created.Ticks, t}; DataRow row = this.NewRow(); row.ItemArray = data; this.Rows.Add(row); }
////////////////////////////////////////////////////////////////////////// private void GenerateContentsHtml(Topic RootTopic, string HtmlPath, string BasePath) { using(StreamWriter sw = new StreamWriter(HtmlPath, false, Encoding.UTF8)) { sw.WriteLine(@"<html>"); sw.WriteLine(@" <head>"); sw.WriteLine(@" <META http-equiv='Content-Type' content='text/html; charset=utf-8'>"); sw.WriteLine(@" <title>Contents</title>"); sw.WriteLine(@" <meta name='GENERATOR' content='hhc2html'>"); sw.WriteLine(@" <link rel='stylesheet' type='text/css' href='tree.css'>"); sw.WriteLine(@" <script src='tree.js' language='javascript' type='text/javascript'>"); sw.WriteLine(@" </script>"); sw.WriteLine(@" </head>"); sw.WriteLine(@" <body id='docBody' style='background-color: #f1f1f1; color: White; margin: 0px 0px 0px 0px;' onload='resizeTree()' onresize='resizeTree()' onselectstart='return false;'>"); //sw.WriteLine(@" <div id='synctoc'><div style='font-family: verdana; font-size: 8pt; cursor: pointer; margin: 6 4 8 2; text-align: right' onmouseover='this.style.textDecoration='underline'' onmouseout='this.style.textDecoration='none'' onclick='syncTree(window.parent.frames[1].document.URL)'>sync toc</div></div>"); sw.WriteLine(@" <div id=""synctoc""><div style=""font-family: verdana; font-size: 8pt; cursor: pointer; text-align: right"" onmouseover=""this.style.textDecoration='underline'"" onmouseout=""this.style.textDecoration='none'"" onclick=""syncTree(window.parent.frames[1].document.URL)"">sync toc</div></div>"); sw.WriteLine(@" <div id='tree' style='top: 35px; left: 0px;' class='treeDiv'>"); sw.WriteLine(@" <div id='treeRoot' onselectstart='return false' ondragstart='return false'>"); foreach(Topic SubTopic in RootTopic.SubTopics) { GenerateNode(sw, SubTopic, BasePath, 8); } sw.WriteLine(@" </div>"); sw.WriteLine(@" </div>"); sw.WriteLine(@" </body>"); sw.WriteLine(@"</html>"); } }
private void CreatChanOKbutton_Click(object sender, EventArgs e) { Topic newtopic = new Topic(); string topicname = nameTextBox.Text; string topicdesc = DesptextBox.Text; string topicurl = URLtextBox.Text; if (topicname != null && topicname.Trim().Length > 0) { newtopic.TopicName = topicname; newtopic.TopicDesc = topicdesc; newtopic.Url = topicurl; newtopic.CreateTime = DateTime.Now; newtopic.UnreadCount = 0; newtopic.TopType = 0; newtopic.AccountId = InfoSource.curuser.UserId; DataOperation InsertNewTopic = new DataOperation(); if(InsertNewTopic.InsertNewTopic(newtopic)) { MessageBox.Show("新的栏目添加成功.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); InfoSource.AddTopic(newtopic); } else { MessageBox.Show("新的栏目添加失败!囧…….", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("组名不能为空格或空字符.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Init() { Topic.paused=true; _sign=Topic.root.Get("/local/cfg/PersistentStorage"); _verbose=Topic.root.Get<bool>("/local/cfg/PersistentStorage/verbose"); if(!Directory.Exists("../data")) { Directory.CreateDirectory("../data"); } _file=new FileStream("../data/persist.xdb", FileMode.OpenOrCreate, FileAccess.ReadWrite); if(_file.Length<0x40) { _file.Write(new byte[0x40], 0, 0x40); _file.Flush(true); _nextBak=DateTime.Now.AddHours(1); } else { Load(); } _fileLength=_file.Length; _work=new AutoResetEvent(false); _thread=new Thread(new ThreadStart(PrThread)); _thread.Priority=ThreadPriority.Lowest; _now=DateTime.Now; if(_nextBak<_now) { Backup(); } _thread.Start(); Topic.root.Subscribe("/#", MqChanged); }
public DetailPageVM() : this(null, "", 0) { if (IsInDesignMode) { currentResource = new Forum() { title = "Design Forum" }; Topic t1 = new Topic() { Forum = currentResource as Forum, PosterFirstname = "John", PosterLastname = "Doe", title = "Design Topic 1", Views = 15 }; Topic t2 = new Topic() { Forum = currentResource as Forum, PosterFirstname = "Jane", PosterLastname = "Doe", title = "Design Topic 2", Views = 15 }; (currentResource as Forum).Topics.AddRange(new Topic[] { t1, t2 }); t1.Posts.Add(new Post() { PosterFirstname = "John", PosterLastname = "Doe", Topic = t1, Text = "Design Text 1 Design Text 1 Design Text 1 " + "Design Text 1 Design Text 1 Design Text 1 " + "Design Text 1 Design Text 1 Design Text 1 " + "Design Text 1 Design Text 1 Design Text 1 " + "Design Text 1 Design Text 1 Design Text 1 " }); t1.Posts.Add(new Post() { PosterFirstname = "John", PosterLastname = "Doe", Topic = t1, Text = "Design Text 2 Design Text 2 Design Text 2 " + "Design Text 2 Design Text 2 Design Text 2 " + "Design Text 2 Design Text 2 Design Text 2 " + "Design Text 2 Design Text 2 Design Text 2 " + "Design Text 2 Design Text 2 Design Text 2 " }); t1.Posts.Add(new Post() { PosterFirstname = "Jane", PosterLastname = "Doe", Topic = t1, Text = "Design Text 3 Design Text 3 Design Text 3 " + "Design Text 3 Design Text 3 Design Text 3 " + "Design Text 3 Design Text 3 Design Text 3 " + "Design Text 3 Design Text 3 Design Text 3 " + "Design Text 3 Design Text 3 Design Text 3 " }); t2.Posts.Add(new Post() { PosterFirstname = "Jane", PosterLastname = "Doe", Topic = t1, Text = "Design Text 1 Design Text 1 Design Text 1 " + "Design Text 1 Design Text 1 Design Text 1 " + "Design Text 1 Design Text 1 Design Text 1 " + "Design Text 1 Design Text 1 Design Text 1 " + "Design Text 1 Design Text 1 Design Text 1 " }); } }
public Producer(IMessageProducer nmsProducer, SimulationParams simulationParams, Topic topic) { _nmsProducer = nmsProducer; _simulationParams = simulationParams; _topic = topic; MinSendTime = TimeSpan.MaxValue; MaxSendTime = TimeSpan.MinValue; }
public void nsm_mf_and_topic() { var tp = TestConfigFactory.CreateTokenProvider(); var mf = TestConfigFactory.CreateMessagingFactory(tp); var nm = TestConfigFactory.CreateNamespaceManager(mf, tp); topic = nm.TryCreateTopic(mf, "non-existing").Result; topic.ShouldNotBeNull(); }
private string[] GetImageFolder(Topic topic) { return(FileContainer.CreateDirectory("images", new[] { topic.FolderPath })); }
public ActionResult Create(CreateEditTopicViewModel viewModel) { using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork()) { var cats = _categoryService.GetAllowedEditCategories(UsersRole); if (cats.Count > 0) { if (ModelState.IsValid) { if (CheckCats(viewModel.Category, cats)) { var topic = new Topic(); var post = new Post(); topic.Name = viewModel.Name; topic.Category_Id = viewModel.Category; topic.IsLocked = viewModel.IsLocked; topic.IsSticky = viewModel.IsSticky; topic.MembershipUser_Id = LoggedOnReadOnlyUser.Id; topic.Id = post.Id; post.PostContent = viewModel.Content; post.MembershipUser_Id = LoggedOnReadOnlyUser.Id; post.Topic_Id = topic.Id; post.IsTopicStarter = true; try { _topicServic.Add(topic); _postSevice.Add(post); unitOfWork.Commit(); } catch (Exception ex) { LoggingService.Error(ex.Message); unitOfWork.Rollback(); } } else { //viewModel.Category = null; //No permission to create a Poll so show a message but create the topic //TempData[AppConstants.MessageViewBagName] = new GenericMessageViewModel //{ // Message = LocalizationService.GetResourceString("Errors.NoPermissionCatergory"), // MessageType = GenericMessages.info //}; ModelState.AddModelError(string.Empty, LocalizationService.GetResourceString("Errors.CatergoryMessage")); } } viewModel.Categories = _categoryService.GetBaseSelectListCategories(cats); return(View(viewModel)); } return(ErrorToHomePage(LocalizationService.GetResourceString("Errors.NoPermission"))); } }
public void DrinkTopicFactory_Create_DrinkTopic() { Topic expected = _topicFactory.Create(A.Dummy <SimpleDrink>(), A.Dummy <TopicInfo>()); Assert.NotNull(expected); }
public ActionResult GetSubjectTopicsAndLessons(int SubjectId) { // var SubjectTopics = db.AspnetSubjectTopics.Where(x => x.SubjectId == SubjectId).ToList(); //var AllSubjectTopicsLessons = from SubjectTopic in db.AspnetSubjectTopics // join Lesson in db.AspnetLessons on SubjectTopic.Id equals Lesson.TopicId // where SubjectTopic.SubjectId == SubjectId // select new // { // TopicId = SubjectTopic.Id, // TopicName = SubjectTopic.Name, // LessonId = Lesson.Id, // LessonName = Lesson.Name, // Lesson.Duration, // Lesson.Description // }; var SubjectsTopics = db.AspnetSubjectTopics.Where(x => x.SubjectId == SubjectId).ToList(); List <Topic> TopicListObj = new List <Topic>(); int Count = 0; foreach (var a in SubjectsTopics) { int count1 = 0; Topic TopicObj = new Topic(); var list = db.AspnetLessons.Where(x => x.TopicId == a.Id).ToList(); TopicObj.TopicId = a.Id; TopicObj.TopicName = a.Name; List <Lesson> LessonsList = new List <Lesson>(); foreach (var lesson in list) { Lesson lessonobj = new Lesson(); lessonobj.LessonId = lesson.Id; lessonobj.LessonName = lesson.Name; lessonobj.LessonDuration = lesson.Duration; LessonsList.Add(lessonobj); Count++; count1++; } List <Lesson> OrderByLessons = LessonsList.OrderBy(x => x.LessonName).ToList(); TopicObj.LessonList = OrderByLessons; TopicObj.TotalLessons = Count; TopicObj.TotalLessons1 = count1; TopicListObj.Add(TopicObj); } // return Json(TopicListObj, JsonRequestBehavior.AllowGet); return(Json(TopicListObj.OrderBy(x => x.TopicName).ToList(), JsonRequestBehavior.AllowGet)); }
public async Task UpdateTopicAsync(string tenant, string product, string component, Topic topic) { foreach (var storage in _storageHubRepository.GetStorages()) { int index = new Random().Next(storage.Value.Agents.Count); if (!storage.Value.Agents.IsEmpty) { await _hub.Clients.Client(storage.Value.Agents.Keys.ElementAt(index)).TopicUpdated(new Model.Storages.Events.Topics.TopicUpdatedDetails() { Id = topic.Id, Name = topic.Name, Tenant = tenant, Product = product, Component = component, TopicSettings = topic.TopicSettings }); } } }
public static TopicModel ToModel(this Topic entity) { return(entity.MapTo <Topic, TopicModel>()); }
public Publish(Topic topic, MessageBody message) { _message = message; _topic = topic; }
public override NSObject GetObjectValue(NSTableView tableView, NSTableColumn tableColumn, int row) { Topic topic = doc.current_entry [row]; return(new NSString(RenderTopicMatch(topic))); }
public static Topic ToEntity(this TopicModel model, Topic destination) { return(model.MapTo(destination)); }
public async Task Add(Topic newTopic) { _dbContext.Topics.Add(newTopic); await _dbContext.SaveChangesAsync(); }
public async Task Delete(Topic topic) { _dbContext.Topics.Remove(topic); await _dbContext.SaveChangesAsync(); }
public static IEnumerable <Person> Participants(Topic topic, Session session) { var topId = topic.Id; return(session.Person.Where(p => p.Topic.Any(t => t.Id == topId))); }
/// <summary> /// Get paths of all images (only with valid extension). /// </summary> /// <param name="topic">The topic</param> /// <returns>Paths to all images of topic</returns> private IEnumerable <string> GetImagePaths(Topic topic) { // get image path string[] imageFolderPath = GetImageFolder(topic); return(ImagePathUtil.GetValidImagePaths(FileContainer.GetFiles(imageFolderPath))); }
public void Remove(Topic entity) { context.Topics.Remove(entity); context.SaveChanges(); }
public abstract bool IsSubTopic(Topic anotherTopic);
public void Add(Topic entity) { context.Topics.Add(entity); context.SaveChanges(); }
public static IEnumerable <ArgPoint> ArgPointsOf(Person pers, Discussion d, Topic t) { return(pers.ArgPoint.Where(ap => ap.Topic != null && ap.Topic.Id == t.Id)); }
public Question(Topic topic) { this.topic = topic; }
/// <summary> /// Topic has been created /// </summary> /// <param name="topic"></param> public void TopicCreated(Topic topic) { var topicCreatedActivity = TopicCreatedActivity.GenerateMappedRecord(topic, DateTime.UtcNow); Add(topicCreatedActivity); }
private void RunExample( int domainId = 0, uint lotsToProcess = 10) { // Exercise #1.1: Add QoS provider // A DomainParticipant allows an application to begin communicating in // a DDS domain. Typically there is one DomainParticipant per application. // Exercise #1.2: Load DomainParticipant QoS profile DomainParticipant participant = DomainParticipantFactory.Instance .CreateParticipant(domainId); // A Topic has a name and a datatype. Create a Topic named // "ChocolateLotState" with type ChocolateLotState. Topic <ChocolateLotState> lotStateTopic = participant.CreateTopic <ChocolateLotState>( CHOCOLATE_LOT_STATE_TOPIC.Value); // Add a Topic for Temperature to this application Topic <Temperature> temperatureTopic = participant.CreateTopic <Temperature>( CHOCOLATE_TEMPERATURE_TOPIC.Value); // A Publisher allows an application to create one or more DataWriters // Publisher QoS is configured in USER_QOS_PROFILES.xml Publisher publisher = participant.CreatePublisher(); // This DataWriter writes data on Topic "ChocolateLotState" // Exercise #4.1: Load ChocolateLotState DataWriter QoS profile after // debugging incompatible QoS DataWriter <ChocolateLotState> lotStateWriter = publisher.CreateDataWriter(lotStateTopic); // A Subscriber allows an application to create one or more DataReaders // Subscriber QoS is configured in USER_QOS_PROFILES.xml Subscriber subscriber = participant.CreateSubscriber(); // Create DataReader of Topic "ChocolateLotState". // Exercise #1.3: Update the lotStateReader and temperatureReader // to use correct QoS DataReader <ChocolateLotState> lotStateReader = subscriber.CreateDataReader(lotStateTopic); // Add a DataReader for Temperature to this application DataReader <Temperature> temperatureReader = subscriber.CreateDataReader(temperatureTopic); // Obtain the DataReader's Status Condition StatusCondition temperatureStatusCondition = temperatureReader.StatusCondition; temperatureStatusCondition.EnabledStatuses = StatusMask.DataAvailable; // Associate a handler with the status condition. This will run when the // condition is triggered, in the context of the dispatch call (see below) temperatureStatusCondition.Triggered += _ => MonitorTemperature(temperatureReader); // Do the same with the lotStateReader's StatusCondition StatusCondition lotStateStatusCondition = lotStateReader.StatusCondition; lotStateStatusCondition.EnabledStatuses = StatusMask.DataAvailable; int lotsProcessed = 0; lotStateStatusCondition.Triggered += _ => lotsProcessed += MonitorLotState(lotStateReader); // Create a WaitSet and attach the StatusCondition var waitset = new WaitSet(); waitset.AttachCondition(lotStateStatusCondition); // Add the new DataReader's StatusCondition to the Waitset waitset.AttachCondition(temperatureStatusCondition); // Start publishing in a separate thread var startLotTask = Task.Run(() => PublishStartLot(lotStateWriter, lotsToProcess)); while (!shutdownRequested && lotsProcessed < lotsToProcess) { waitset.Dispatch(Duration.FromSeconds(4)); } startLotTask.Wait(); }
protected static bool TryGetTopic(RegionEndpoint regionEndpoint, string topicName, out Topic topic) { topic = GetAllTopics(regionEndpoint, topicName).SingleOrDefault(); return(topic != null); }
public static ArgPoint clonePoint(DiscCtx ctx, ArgPoint ap, Topic topic, Person owner, String name) { var top = ctx.Topic.FirstOrDefault(t0 => t0.Id == topic.Id); if (top == null) { return(null); } var ownPoints = top.ArgPoint.Where(p0 => p0.Person.Id == owner.Id); int orderNr = 1; foreach (var pt in ownPoints) { if (pt.OrderNumber > orderNr) { orderNr = pt.OrderNumber; } } var pointCopy = DaoUtils.NewPoint(top, orderNr + 1); pointCopy.Point = name; pointCopy.Description.Text = ap.Description.Text; foreach (var src in ap.Description.Source) { var newSrc = new Source { Text = src.Text }; pointCopy.Description.Source.Add(newSrc); } foreach (var cmt in ap.Comment) { if (cmt.Person == null) { continue; } var comment = new Comment(); comment.Text = cmt.Text; var commentPersonId = cmt.Person.Id; comment.Person = ctx.Person.FirstOrDefault(p0 => p0.Id == commentPersonId); pointCopy.Comment.Add(comment); } var ownId = SessionInfo.Get().person.Id; var self = ctx.Person.FirstOrDefault(p0 => p0.Id == ownId); foreach (var media in ap.Attachment) { var attach = new Attachment(); attach.ArgPoint = pointCopy; attach.Format = media.Format; attach.Link = media.Link; attach.Name = media.Name; attach.Title = media.Title; attach.VideoEmbedURL = media.VideoEmbedURL; attach.VideoLinkURL = media.VideoLinkURL; attach.VideoThumbURL = media.VideoThumbURL; attach.OrderNumber = media.OrderNumber; if (media.Thumb != null) { attach.Thumb = (byte[])media.Thumb.Clone(); } if (media.MediaData != null && media.MediaData.Data != null) { var mediaClone = new MediaData(); mediaClone.Data = (byte[])media.MediaData.Data.Clone(); attach.MediaData = mediaClone; } attach.Person = self; } pointCopy.Person = self; pointCopy.Topic = top; return(pointCopy); }
/// <summary> /// Updates the topic /// </summary> /// <param name="topic">Topic</param> public void UpdateTopic([FromBody] Topic topic) { _topicService.UpdateTopic(topic); }
/// <summary> /// Deletes a topic /// </summary> /// <param name="topic">Topic</param> public void DeleteTopic([FromBody] Topic topic) { _topicService.DeleteTopic(topic); }
/// <summary> /// Inserts a topic /// </summary> /// <param name="topic">Topic</param> public void InsertTopic([FromBody] Topic topic) { _topicService.InsertTopic(topic); }
protected void UpdateTopic() { Topic originalTopic = new Topic(EditingTopicId); StringBuilder sql = new StringBuilder(2500); int StoreID = 0; bool bTopicNameExist = IsTopicNameExist(out StoreID); int ExistingTopicId = Topic.GetTopicID(TopicName, LocaleSetting, originalTopic.StoreID); if (TopicName != originalTopic.TopicName && ExistingTopicId != originalTopic.TopicID && ExistingTopicId > 0) { resetError("The topic name entered already exists. Please choose a unique topic name.", true); return; } sql.Append("update Topic set "); sql.Append("Published=" + (CommonLogic.IIF(chkPublished.Checked, 1, 0)).ToString() + ","); sql.Append("Name=" + DB.SQuote(AppLogic.FormLocaleXml("Name", TopicName, LocaleSetting, "topic", Convert.ToInt32(EditingTopicId))) + ","); sql.Append("SkinID=" + Localization.ParseUSInt(txtSkin.Text) + ","); sql.Append("DisplayOrder=" + Localization.ParseUSInt(txtDspOrdr.Text) + ","); sql.Append("ContentsBGColor=" + DB.SQuote(txtContentsBG.Text) + ","); sql.Append("PageBGColor=" + DB.SQuote(txtPageBG.Text) + ","); sql.Append("GraphicsColor=" + DB.SQuote(txtSkinColor.Text) + ","); sql.Append("Title=" + DB.SQuote(AppLogic.FormLocaleXml("Title", ltTitle.Text, LocaleSetting, "topic", Convert.ToInt32(EditingTopicId))) + ","); sql.Append("IsFrequent=" + (CommonLogic.IIF(chkIsFrequent.Checked, 1, 0)).ToString() + ","); String desc = String.Empty; if (bUseHtmlEditor) { desc = AppLogic.FormLocaleXml("Description", radDescription.Content, LocaleSetting, "topic", Convert.ToInt32(EditingTopicId)); } else { desc = AppLogic.FormLocaleXmlEditor("Description", "Description", LocaleSetting, "topic", Convert.ToInt32(EditingTopicId)); } if (desc.Length != 0) { sql.Append("Description=" + DB.SQuote(desc) + ","); } else { sql.Append("Description=NULL,"); } if (txtPassword.Text.Trim().Length != 0) { sql.Append("Password="******","); } else { sql.Append("Password=NULL,"); } sql.Append("RequiresSubscription=" + rbSubscription.SelectedValue.ToString() + ","); sql.Append("HTMLOk=" + rbHTML.SelectedValue.ToString() + ","); sql.Append("RequiresDisclaimer=" + rbDisclaimer.SelectedValue.ToString() + ","); sql.Append("ShowInSiteMap=" + rbPublish.SelectedValue.ToString() + ","); if (AppLogic.FormLocaleXml("SEKeywords", ltSEKeywords.Text, LocaleSetting, "topic", Convert.ToInt32(EditingTopicId)).Length != 0) { sql.Append("SEKeywords=" + DB.SQuote(AppLogic.FormLocaleXml("SEKeywords", ltSEKeywords.Text, LocaleSetting, "topic", Convert.ToInt32(EditingTopicId))) + ","); } else { sql.Append("SEKeywords=NULL,"); } if (AppLogic.FormLocaleXml("SEDescription", ltSEDescription.Text, LocaleSetting, "topic", Convert.ToInt32(EditingTopicId)).Length != 0) { sql.Append("SEDescription=" + DB.SQuote(AppLogic.FormLocaleXml("SEDescription", ltSEDescription.Text, LocaleSetting, "topic", Convert.ToInt32(EditingTopicId))) + ","); } else { sql.Append("SEDescription=NULL,"); } if (AppLogic.FormLocaleXml("SETitle", ltSETitle.Text, LocaleSetting, "topic", Convert.ToInt32(EditingTopicId)).Length != 0) { sql.Append("SETitle=" + DB.SQuote(AppLogic.FormLocaleXml("SETitle", ltSETitle.Text, LocaleSetting, "topic", Convert.ToInt32(EditingTopicId)))); } else { sql.Append("SETitle=NULL"); } sql.Append(" where TopicID=" + EditingTopicId.ToString()); DB.ExecuteSQL(sql.ToString()); resetError("Topic updated.", false); int EditedTopic = EditingTopicId; UnloadTopic(); if (TopicSaved != null) { TopicSaved(this, new TopicEditEventArgs(EditedTopic, originalTopic.TopicName != TopicName)); } }
public CustomSortCommand(Topic parent, int[] newIndices) { Parent = parent; NewIndices = newIndices; }
private Topic GetNestedTopics(BsonDocument document, Topic parent = null, int index = 1) { Topic instance = new Topic { Index = index }; if (parent != null) { instance.ParentTopic = parent; } instance.Children = new List <Topic>(); instance.LabelGroup = new LabelGroup(); instance.LabelGroup.Labels = new List <Label>(); for (int i = 0; i < document.Elements.Count(); i++) { var element = document.GetElement(i); switch (element.Name) { case "name": instance.Name = element.Value.AsString; break; case "category": instance.Name = element.Value.AsString; instance.LabelGroup.Labels.Add(new Label { LanguageId = (int)LanguageTypes.English, Text = element.Value.AsString }); break; case "heCategory": instance.LabelGroup.Labels.Add(new Label { LanguageId = (int)LanguageTypes.Hebrew, Text = element.Value.AsString }); break; case "title": instance.Name = element.Value.AsString; instance.LabelGroup.Labels.Add(new Label { LanguageId = (int)LanguageTypes.English, Text = element.Value.AsString }); break; case "heTitle": instance.LabelGroup.Labels.Add(new Label { LanguageId = (int)LanguageTypes.Hebrew, Text = element.Value.AsString }); break; case "contents": var array = element.Value.AsBsonArray; instance.Children = new List <Topic>(); for (int j = 0; j < array.Count; j++) { var item = array[j]; if (item.IsBsonDocument) { instance.Children.Add(GetNestedTopics(item.AsBsonDocument, instance, j + 1)); } } break; } } return(instance); }
/// <summary> /// Topic settings were found but no content layout file. In such cases, this is called to create a /// default content layout file based on the settings alone. /// </summary> private void CreateDefaultContentLayoutFile() { string filename = Path.Combine(base.ProjectFolder, "ContentLayout.content"); Topic commonSettings, t; if(!topicSettings.TryGetValue("*", out commonSettings)) commonSettings = new Topic(); else topicSettings.Remove("*"); if(topicSettings.Count == 0) return; XmlWriterSettings settings = new XmlWriterSettings(); XmlWriter writer = null; try { settings.Indent = true; settings.CloseOutput = true; writer = XmlWriter.Create(filename, settings); writer.WriteStartDocument(); writer.WriteStartElement("Topics"); foreach(string key in topicSettings.Keys) { t = topicSettings[key]; foreach(MSHelpKeyword kw in commonSettings.Keywords) t.Keywords.Add(kw); writer.WriteStartElement("Topic"); writer.WriteAttributeString("id", key); writer.WriteAttributeString("visible", "true"); if(!String.IsNullOrEmpty(t.Title)) writer.WriteAttributeString("title", t.Title); if(!String.IsNullOrEmpty(t.TocTitle) && t.TocTitle != t.Title) writer.WriteAttributeString("tocTitle", t.TocTitle); if(!String.IsNullOrEmpty(t.LinkText)) writer.WriteAttributeString("linkText", t.LinkText); if(t.HelpAttributes.Count != 0) t.HelpAttributes.WriteXml(writer, true); if(t.Keywords.Count != 0) t.Keywords.WriteXml(writer); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); } finally { if(writer != null) writer.Close(); } project.AddFileToProject(filename, filename); }
public TopicSubscriptionConfigurator(Topic topic) : base(topic) { }