Ejemplo n.º 1
0
        public string SalonInfo([FromBody] SUID model)
        {
            string value = CodeHelp.GetResults(0, "失败", "");

            try
            {
                if (string.IsNullOrEmpty(model.suid.ToString()))
                {
                    value = CodeHelp.GetResults(0, "失败", "沙龙ID不能为空");
                }
                else
                {
                    SalonSimple     salon = new SalonSimple();
                    List <AllSalon> list  = new List <AllSalon>();
                    SalonService    sa    = new SalonService();
                    INoticeService  nots  = new INoticeService();
                    //取沙龙的基本信息和环境图
                    list = sa.GetSalonInfo(model.suid, 3);
                    if (list != null && list.Count > 0)
                    {
                        if (list[0].Status != 4)
                        {
                            value = CodeHelp.GetResults(0, "无法找到页面,该沙龙暂时不提供此服务。", "沙龙未开通");
                        }
                        else
                        {
                            if (list[0].Opendate < DateTime.Now)
                            {
                                value = CodeHelp.GetResults(0, "无法找到页面,该沙龙暂时不提供此服务。", "沙龙未开通");
                            }
                            else
                            {
                                list.First().Address = list.First().Address.Replace("|", "");
                                Tnotice noice        = new Tnotice();
                                noice = nots.GetNotice(model.suid);
                                if (noice != null)
                                {
                                    list.First().noticecontent = noice.content;
                                }
                                else
                                {
                                    list.First().noticecontent = "暂无公告";
                                }
                                value = CodeHelp.GetResults(1, "成功", list).ToLower();
                            }
                        }
                    }
                    else
                    {
                        value = CodeHelp.GetResults(0, "失败", "未取到数据");
                    }
                }
            }
            catch (Exception ex)
            {
                value = CodeHelp.GetResults(0, "失败", ex.Message);
            }
            return(value);
        }
Ejemplo n.º 2
0
 public void AddSUID(SUID card)
 {
     if (SUIDs.ContainsKey(card.id))
     {
         SUIDs.Remove(card.id);
     }
     SUIDs.Add(card.id, card);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// The pipe reads from a given readmethod and evaluates it. This is done so threaded. It waits for all threads to complete
        /// </summary>
        /// <param name="rm">A readmethod e.g JSON or .CSV</param>
        /// <param name="filename">Where to read from</param>
        /// <param name="evalr">An IEvaluator</param>
        /// <returns>A dictionary that maps identifiers to their predicted result</returns>

        public static IDictionary <IIdentifier, Result> ThreadedSentenceLevelPipe(IOReadMethod rm, string filename, IEvaluator evalr)
        {
            // idea from https://stackoverflow.com/questions/3720111/threadpool-queueuserworkitem-with-list
            var cBag = new ConcurrentDictionary <IIdentifier, Result>();

            using (var finished = new CountdownEvent(1))
            {
                foreach (string sentence in rm(Program.src_dir + "\\" + filename))
                {
                    var original = sentence;

                    finished.AddCount();
                    ThreadPool.QueueUserWorkItem(
                        (state) =>
                    {
                        try
                        {
                            var ts   = evalr.EvaluateSentence(sentence.ToString());
                            var suid = new SUID(Thread.CurrentThread.ManagedThreadId + DateTime.Today.Millisecond, original);
                            var r    = new Result(suid, ts.Item1, ts.Item2);
                            if (!cBag.TryAdd(suid, r))
                            {
                                FileWriter.WriteErrorLog("[ThreadedPipe_Dictionary] failed at adding '" + suid + "' and it's result" + Environment.NewLine);
                            }
                        }
                        finally
                        {
                            finished.Signal();
                        }
                    }, null);
                }
                finished.Signal();
                finished.Wait();
            }
            return(cBag);
        }
Ejemplo n.º 4
0
 public TSentence(IEnumerable <Token> tokenizedSentence, SUID identifier)
 {
     this.identifier = identifier;
     tokens          = tokenizedSentence;
 }