Exemplo n.º 1
0
        public ActionResult AirportSearch(string searchTerm, int pageSize, int pageNum)
        {
            var ca_o  = HttpRuntime.Cache["airports-data"];
            var sel_o = new Select2Result[] { new Select2Result {
                                                  id = "", text = "none"
                                              } };

            Suggest sg = new Suggest();

            Select2PagedResult aps_o = new Select2PagedResult
            {
                Total   = 1,
                Results = sel_o
            };

            try
            {
                if (ca_o != null)
                {
                    Airports[] all_airports = (Airports[])ca_o;

                    aps_o.Results = sg.Airports(searchTerm, all_airports);
                }
            } catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            }


            return(new JsonResult
            {
                Data = aps_o,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            settings.loadSettings(Environment.CurrentDirectory + "/server.properties");   // Load settings from file
            settings.settings.Populate();                                                 // Populate loaded settings into program

            console.BeginLog();                                                           // Enable logging

            console.WriteLine("Settings loaded from ./server.properties", LogLevel.Info); //TODO: Make load path changable from args
            console.WriteLine("", LogLevel.Info);

            pluginManager.LoadPlugins();

            while (keepAlive)
            {
                console.Write("@console:~$ ", LogLevel.Info, false);

                List <Suggest> suggestions = new List <Suggest>();

                Suggest s = new Suggest("settings", new string[] { "get", "set", "delete" });
                suggestions.Add(s);

                string command = console.ReadLine(suggestions);

                CommandManagers.MasterConsole.HandleCommand(command, console);
            }

            Program.settings.SaveSettings(Environment.CurrentDirectory + "/server.properties");
            console.WriteLine("Settings saved to ./server.properties", LogLevel.Info);
            //TODO: Make load path changable from Program->Main->args

            Program.console.StopLog();
            Environment.Exit(0);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 临时保存征询
 /// </summary>
 /// <param name="suggest"></param>
 /// <returns></returns>
 public bool saveSuggest(Suggest suggest)
 {
     using (SqliteContext context = new SqliteContext())
     {
         var old = context.Suggest.FirstOrDefault(s => s.Id == suggest.Id);
         try
         {
             if (old == null)
             {
                 context.Suggest.Add(suggest);
             }
             else
             {
                 //old = suggest;
                 old.suggest_content = suggest.suggest_content;
                 old.remark          = suggest.remark;
             }
             context.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
Exemplo n.º 4
0
        public void Delete(Suggest item)
        {
            var prsUser = Convert(item);

            prsUser.DeleteAsync().Wait();
            LogFactory.Log.InfoFormat("Suggest #{0} successfuly deleted", item.UniqueID);
        }
Exemplo n.º 5
0
 public void Aliases()
 {
     Suggest.Aliases(new Feed
     {
         Name        = "My App/",
         EntryPoints =
         {
             new EntryPoint {
                 Command = Command.NameRun, NeedsTerminal = true
             },
             new EntryPoint {
                 Command = Command.NameRunGui
             },
             new EntryPoint {
                 Command = "cli1/", NeedsTerminal = true
             },
             new EntryPoint {
                 Command = "cli2/", NeedsTerminal = true, BinaryName = "custom"
             }
         }
     }).Should().Equal(
         new AppAlias {
         Name = "my-app-", Command = Command.NameRun
     },
         new AppAlias {
         Name = "cli1-", Command = "cli1/"
     },
         new AppAlias {
         Name = "custom", Command = "cli2/"
     });
 }
        public void RestrictedSuggestFailsWithoutCertificate()
        {
            var Suggest2 = new Suggest(new Settings("authoring-hss.cp-access.com", "https://searchg2-restricted.crownpeak.net/", null));
            var result   = Suggest2.Execute("a");

            Assert.AreEqual(0, result.Count, "Expected 0 results, found " + result.Count);
        }
        public static string[] GetCompletionList(string prefixText, int count)
        {
            List <string> results = new List <string>();

            var autocompleter = new Suggest(new Settings(COLLECTION));
            var searchResults = autocompleter.Execute(prefixText);

            foreach (var suggestion in (IEnumerable <Suggestion>)searchResults)
            {
                foreach (var option in suggestion.Options)
                {
                    results.Add(option);
                    if (results.Count >= count)
                    {
                        break;
                    }
                }
                if (results.Count >= count)
                {
                    break;
                }
            }

            return(results.ToArray());
        }
Exemplo n.º 8
0
 public Suggest Save(Suggest suggest, int authorId)
 {
     suggest.Author = _sqlContext._users.Where(u => u.Id == authorId).SingleOrDefault();
     _sqlContext.Suggests.Add(suggest);
     _sqlContext.SaveChanges();
     return(suggest);
 }
Exemplo n.º 9
0
        public string AddSuggest(int category, string content, string method)
        {
            string userName    = "******";
            string userAccount = string.Empty;

            if (HttpContext.Current.Session[BasePage.EmployeeSessionKey] != null)
            {
                var CurrentUser = HttpContext.Current.Session[BasePage.EmployeeSessionKey] as DataTransferObject.Organization.EmployeeDetailInfo;
                userName    = CurrentUser.Name;
                userAccount = CurrentUser.UserName;
            }
            var suggest = new Suggest
            {
                SuggestCategory     = (SuggestCategory)category,
                SuggestContent      = HtmlFilter.Replace(content, string.Empty),
                ContractInformation = HtmlFilter.Replace(method, string.Empty),
                CreateTime          = DateTime.Now,
                Creator             = userAccount,
                CreatorName         = userName,
                Id      = Guid.NewGuid(),
                Readed  = false,
                Handled = false
            };

            SuggestService.AddSuggest(suggest);
            return("OK");
        }
Exemplo n.º 10
0
        private void btn_submit_Click(object sender, EventArgs e)
        {
            if (suggest == null)
            {
                suggest              = new Entity.Suggest();
                suggest.Id           = Guid.NewGuid().ToString();
                suggest.isLocal      = "1";
                suggest.lawId        = lawId;
                suggest.nodeId       = nodeId;
                suggest.suggest_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                suggest.userId       = Global.user.Id;
            }
            suggest.remark          = rtb_remark.Text.Trim();
            suggest.suggest_content = rtb_suggest.Text.Trim();
            bool commitResult;

            if (Global.online)                            //联网状态下直接提交,提交失败时保存在本地数据库
            {
                commitResult = saveSuggestLocal(suggest); //todo 待确认
            }
            else//断网状态下直接保存在本地数据库
            {
                commitResult = saveSuggestLocal(suggest);
            }
            if (commitResult)
            {
                MessageBox.Show("提交成功");
                this.Close();
            }
            else
            {
                MessageBox.Show("提交失败");
            }
        }
        public void RestrictedSuggestWorksWithCertificate()
        {
            var Suggest2 = new Suggest(new Settings("authoring-hss.cp-access.com", "https://searchg2-restricted.crownpeak.net/", CertificateCreator.LoadCertificate("E63D2DCEB03E981968F373F5C419E043D9394AF9")));
            var result   = Suggest2.Execute("a");

            Assert.AreEqual(1, result.Count, "Expected 4 results, found " + result.Count);
            Assert.AreEqual(4, result[0].Options.Length, "Expecting 4 options, got " + result[0].Options.Length);
        }
Exemplo n.º 12
0
        public ActionResult Delete(int id)
        {
            Suggest s = suggestContext.suggestLists.Find(id);

            suggestContext.suggestLists.Remove(s);
            suggestContext.SaveChanges();
            return(Content("删除成功"));
        }
Exemplo n.º 13
0
        public static Argument WithSuggestionSource(
            this Argument argument,
            Suggest suggest)
        {
            argument.AddSuggestionSource(suggest);

            return(argument);
        }
Exemplo n.º 14
0
        public ActionResult FollowSuggest()
        {
            var currentUser = GetUser();
            var suggest     = new Suggest();
            var viewModel   = suggest.FollowSuggest(currentUser.Id, _db);

            return(PartialView("rightside", viewModel));
        }
Exemplo n.º 15
0
        public void Save(Suggest item)
        {
            var prsSuggest = Convert(item);

            prsSuggest.SaveAsync().Wait();

            item.UniqueID = prsSuggest.ObjectId;
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            //Node x = new Node();
            //Node y = new Node();
            //Node z = new Node();

            //Box box = new Box();

            ////case-1: box.Fisrt == x;
            //box.Add(x);
            ////Console.WriteLine(box.Last == x);

            //box.Add(y);
            ////Console.WriteLine(box.Last == y);

            //box.Add(z);
            ////case-2: box.Last == z;
            //Console.WriteLine(box.Last == z);


            //Beauty beauty = new Beauty();


            Article ate = new Article();              //文章

            ate.Author   = "xr->";
            ate.Tite     = $"{ate.Author}发布了一篇文章 ";
            ate.Body     = "文章内容..............";
            ate.Agree    = 0;
            ate.Disagree = 0;

            Comment cmt = new Comment();   //评论

            cmt.Author   = "xxx";
            cmt.Tite     = $"来自{cmt.Author}的评论:";
            cmt.Body     = "评论内容..............";
            cmt.Agree    = 0;
            cmt.Disagree = 0;

            Suggest sgt = new Suggest();          //意见

            sgt.Author   = "xxx";
            sgt.Tite     = $"这是一条来自{sgt.Author}的建议: ";
            sgt.Body     = "意见内容..............";
            sgt.Agree    = 0;
            sgt.Disagree = 0;

            Problem pbm = new Problem();       //求助

            pbm.Author = "xxx";
            pbm.Tite   = $"这是一条来自{sgt.Author}的求助: ";
            pbm.Body   = "求助内容..............";

            //ate.Publish();      //发布一篇文章
            // cmt.Publish();  //发一条评论
            //sgt.Publish();   //提一个建议
            //pbm.Publish();//发布一个求助
        }
Exemplo n.º 17
0
 private void AddNewSuggest_Load(object sender, EventArgs e)
 {
     suggest = db.getLocalSuggest(lawId, nodeId);
     if (suggest != null)
     {
         rtb_suggest.Text = suggest.suggest_content;
         rtb_remark.Text  = suggest.remark;
     }
 }
Exemplo n.º 18
0
        public static TOption WithSuggestionSource <TOption>(
            this TOption option,
            Suggest suggest)
            where TOption : Option
        {
            option.Argument.AddSuggestionSource(suggest);

            return(option);
        }
Exemplo n.º 19
0
        public static void Do()
        {
            //内容(Content)发布(Publish)的时候检查其作者(Author)是否为空,如果为空抛出“参数为空”异常
            User    user    = new User("哈哈", "asd*6j");
            Content content = new Suggest(user);

            content.Author = null;
            ContentService.Publish(content);
        }
Exemplo n.º 20
0
 public static bool AddSuggest(Suggest suggest)
 {
     using (var command = Factory.CreateCommand())
     {
         var db = Factory.CreateSuggestRepository(command);
         db.Insert(suggest);
     }
     return(true);
 }
Exemplo n.º 21
0
        public static TArgument WithSuggestionSource <TArgument>(
            this TArgument argument,
            Suggest suggest)
            where TArgument : Argument
        {
            argument.AddSuggestionSource(suggest);

            return(argument);
        }
Exemplo n.º 22
0
        protected internal Option(
            string[] aliases,
            string help,
            ArgumentsRule arguments = null,
            Option[] options        = null,
            Func <AppliedOption, object> materialize = null)
        {
            if (aliases == null)
            {
                throw new ArgumentNullException(nameof(aliases));
            }

            if (!aliases.Any())
            {
                throw new ArgumentException("An option must have at least one alias.");
            }

            if (aliases.Any(string.IsNullOrWhiteSpace))
            {
                throw new ArgumentException("An option alias cannot be null, empty, or consist entirely of whitespace.");
            }

            foreach (var alias in aliases)
            {
                this.aliases.Add(alias.RemovePrefix());
            }

            HelpText = help;

            Name = aliases
                   .Select(a => a.RemovePrefix())
                   .OrderBy(a => a.Length)
                   .Last();

            this.materialize = materialize;

            if (options != null && options.Any())
            {
                foreach (var option in options)
                {
                    option.Parent = this;
                    DefinedOptions.Add(option);
                }
            }

            ArgumentsRule = arguments ?? Accept.NoArguments;

            if (options != null)
            {
                ArgumentsRule = Accept.ZeroOrMoreOf(options).And(ArgumentsRule);
            }

            AllowedValues = ArgumentsRule.AllowedValues;

            suggest = ArgumentsRule.Suggest;
        }
Exemplo n.º 23
0
        public JsonResult Autocomplete(string query)
        {
            var search   = new Suggest(new Settings("www.crownpeak.com"));
            var searcher = search.Execute(query);

            if (searcher.Count > 0)
            {
                return(Json(searcher[0].Options.Select(o => new { Value = o, Label = o }), JsonRequestBehavior.AllowGet));
            }
            return(null);
        }
Exemplo n.º 24
0
        static void ShowSuggests(IPostService postService, string tag)
        {
            Suggest suggest = postService.GetSuggest(tag);

            System.Console.WriteLine("[Popular]");
            suggest.Popular.ForEach(System.Console.WriteLine);
            System.Console.WriteLine("[Recommended]");
            suggest.Recommended.ForEach(System.Console.WriteLine);
            System.Console.WriteLine("[Network]");
            suggest.Network.ForEach(System.Console.WriteLine);
        }
Exemplo n.º 25
0
        private static EventResult SuggestionHandler(SocketMessage msg)
        {
            if (Clubby.Program.config.DiscordChannels.ContainsKey("suggestions") && msg.Channel.Id == Clubby.Program.config.DiscordChannels["suggestions"])
            {
                msg.DeleteAsync().Wait();
                Suggest.MakeRawSuggestion(msg, msg.Content, msg.Channel as SocketTextChannel).Wait();

                return(EventResult.Stop);
            }
            return(EventResult.Continue);
        }
Exemplo n.º 26
0
        public Suggest Convert(ParseObject item)
        {
            var suggestionResult = new Suggest
            {
                UniqueID  = item.ObjectId,
                Username  = item.Get <string>("Username"),
                ConcertId = item.Get <string>("ConcertId")
            };

            return(suggestionResult);
        }
Exemplo n.º 27
0
        public bool IsExisted(Suggest item)
        {
            var query = from suggestionResult in ParseObject.GetQuery("Suggest")
                        where suggestionResult.Get <string>("Username") == item.Username &&
                        suggestionResult.Get <string>("ConcertId") == item.ConcertId
                        select suggestionResult;

            var result = query.FindAsync().Result;

            return(result.Any());
        }
Exemplo n.º 28
0
        public ParseObject Convert(Suggest item)
        {
            var suggest = new ParseObject("Suggest")
            {
                ObjectId = item.UniqueID
            };

            suggest["Username"]  = item.Username.ToCustomLower();
            suggest["ConcertId"] = item.ConcertId;

            return(suggest);
        }
Exemplo n.º 29
0
        public Suggest publish(string title, string body, int authorId)
        {
            Suggest suggest = new Suggest
            {
                //Author = new UserRepository().GetById(authorId),
                Body  = body,
                Title = title,
            };

            suggest.Publish();
            return(_suggestRepository.Save(suggest));
        }
Exemplo n.º 30
0
        /// <summary>
        /// 添加建议
        /// </summary>
        /// <param name="model">建议模型</param>
        public void CreateSuggest(SuggestModel model)
        {
            IRepository <Suggest> rep = Factory.Factory <IRepository <Suggest> > .GetConcrete <Suggest>();

            Suggest s = new Suggest(model.Body, model.UserID, model.UserName, model.Reply, model.Type);

            try
            {
                rep.Add(s);
                rep.PersistAll();
            }
            catch { }
        }