Exemplo n.º 1
0
 public override List<Answer> GetAnswer(BasePage basePage)
 {
     base.ranker = basePage.Ranker;
     // checking for query terms that contain noun forms and adjectives (as they talk about nouns)
     string nnQuery = string.Join(" ", ranker.queryWords.Where((w, i) => Ranker.NNTags.Contains(ranker.queryTags.ElementAt(i))));
     nnQuery = HttpUtility.UrlPathEncode(nnQuery);
     string queryUrl = String.Format(queryTemplate, nnQuery);
     List<Answer> answers = new List<Answer>();
     if (ranker.queryTags.Exists(tag => Ranker.WHTags.Contains(tag.ToString())))
     {
         // there is a valid postag in the query. hence triggering this answer
         Stream responseHtml = Util.MakeWebRequestStream(queryUrl);
         Answer answer = new Answer();
         ParseResponse(responseHtml, answer);
         if (answer != null && !string.IsNullOrEmpty(answer.topAnswer))
         {
             answer.isStarred = true;
             answer.type = AnswerType.Text;
             answer.url = queryUrl;
             answer.source = AnswerSource.Wikipedia;
             ranker.GetFeatures(answer);
             answers.Add(answer);
         }
     }
     BasePage.SqlLogger.InsertAnswer(basePage.SessionID, ranker.query, AnswerSource.Wikipedia.ToString(), AnswerType.Text.ToString(), answers.Count);
     return answers;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session != null)
            {
                // Store essential session information temporarily
                string culture = Session["culture"] as string ?? "nl-NL";

                Session["culture"] = null;

                // Restore the essential session information
                Session["culture"] = culture;
            }
            if (Request.Params["id"] == null)
            {
                if (HttpContext.Current != null &&
                    HttpContext.Current.User != null &&
                    HttpContext.Current.User.Identity.IsAuthenticated == true &&
                    HttpContext.Current.Session["userid"] == null)
                {
                    // We got here in a strange way, user is unknown (Session cleared) but
                    // not properly signed out. We try to sign out again and redirect back
                    // here.
                    FormsAuthentication.SignOut();
                    Response.Redirect("~/Default.aspx", false);
                }
            }

            BasePage obj = new BasePage();
            obj.IncludePage(FooterLiteral, Resources.Resource.FooterSection);
        }
        public static void DataUserSelectorListView(BasePage page, String ObjId, Dictionary<Guid, String> SelectedUsers, List<GroupInfo> SelectedGroups, bool DisabledGroupSelector)
        {
            var ids = SelectedUsers != null && SelectedUsers.Count > 0 ? SelectedUsers.Select(i => i.Key).ToArray() : new List<Guid>().ToArray();
            var names = SelectedUsers != null && SelectedUsers.Count > 0 ? SelectedUsers.Select(i => i.Value).ToArray() : new List<string>().ToArray();

            page.RegisterInlineScript(String.Format(" SelectedUsers{0} = {1}; ",
                                                        ObjId,
                                                        JsonConvert.SerializeObject(
                                                            new
                                                            {
                                                                IDs = ids,
                                                                Names = names,
                                                                PeopleImgSrc = WebImageSupplier.GetAbsoluteWebPath("people_icon.png", ProductEntryPoint.ID),
                                                                DeleteImgSrc = WebImageSupplier.GetAbsoluteWebPath("trash_12.png"),
                                                                DeleteImgTitle = CRMCommonResource.DeleteUser,
                                                                CurrentUserID = SecurityContext.CurrentAccount.ID
                                                            })), onReady: false);
            if (!DisabledGroupSelector)
            {
                ids = SelectedGroups != null && SelectedGroups.Count > 0 ? SelectedGroups.Select(i => i.ID).ToArray() : new List<Guid>().ToArray();
                names = SelectedGroups != null && SelectedGroups.Count > 0 ? SelectedGroups.Select(i => i.Name.HtmlEncode()).ToArray() : new List<string>().ToArray();

                page.RegisterInlineScript(String.Format(" SelectedGroups{0} = {1}; ",
                                                            ObjId,
                                                            JsonConvert.SerializeObject(
                                                                    new
                                                                    {
                                                                        IDs = ids,
                                                                        Names = names,
                                                                        GroupImgSrc = WebImageSupplier.GetAbsoluteWebPath("group_12.png"),
                                                                        TrashImgSrc = WebImageSupplier.GetAbsoluteWebPath("trash_12.png"),
                                                                        TrashImgTitle = CRMCommonResource.Delete
                                                                    })), onReady: false);
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if(!string.IsNullOrEmpty(Request.Params["picked"]))
     {
         var picked = int.Parse(Request.Params["picked"]);
         var basePage = new BasePage();
         var moods = basePage.getMoods();
         var canvas = string.Format("http://apps.facebook.com/{0}/mysmiles.apsx", suffix);
         var moodList = JSONHelper.ConvertFromJSONArray(this.Api.Data.GetUserPreference(0));
         moodList.Insert(0, picked.ToString());
         this.Api.Data.SetUserPreference(0, JSONHelper.ConvertToJSONArray(moodList));
         var oldCount =  0;
         if(!string.IsNullOrEmpty(this.Api.Data.GetUserPreference(2)))
         {
             oldCount = int.Parse(this.Api.Data.GetUserPreference(2));
         }
         this.Api.Data.SetUserPreference(2, (oldCount+1).ToString());
         var image = string.Format("{0}images/smile{1}.jpg",callback,picked);
         var images = JSONHelper.ConvertToJSONAssociativeArray(new Dictionary<string, string> { { "src", image }, { "href", canvas } });
         var templateData = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "mood", moods.ElementAt(picked).Value }, { "emote", moods.ElementAt(picked).Key}, { "images", images }, { "mood_src", image } });
         var feed = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string,string>{ {"template_id",basePage.FeedTemplate1.ToString()},{"template_data",templateData}});
         var content = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string,string>{ {"feed",feed},{"next",canvas}});
         var data = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string,string>{ {"method","feedStory"},{"content",content}});
         json = data;
     }
     else
     {
         throw new Exception("no smile picked");
     }
 }
Exemplo n.º 5
0
 //NLog.Logger logger = LogManager.GetCurrentClassLogger();
 public override List<Answer> GetAnswer(BasePage basePage)
 {
     base.ranker = basePage.Ranker;
     List<Answer> answers = new List<Answer>();
     string webResponse = SendRequest(ranker.query);
     answers = ParseResponse(webResponse);
     BasePage.SqlLogger.InsertAnswer(basePage.SessionID, ranker.query, AnswerSource.MSDN.ToString(), AnswerType.Text.ToString(), answers.Count);
     return answers;
 }
Exemplo n.º 6
0
        private void MapearAplicacaoUsuario()
        {
            //Instância do Usuário conectado
            var mUsuarioAtivo = (FuncionarioVO)Session["UsuarioAtivo"];

            //Caso encontre o Usuário conectado
            if (mUsuarioAtivo != null)
            {
                var basePage = new BasePage();
                lblUsuario.Text = mUsuarioAtivo.Apelido;
                lblData.Text = DateTime.Now.ToString();
                lblVersion.Text = VersionInfo;
                string xmlMenu = string.Empty;
                if (Session["xmlMenu"] != null)
                    xmlMenu = (string)Session["xmlMenu"];
                else
                {
                    if (mUsuarioAtivo.CodFuncionario != null)
                        xmlMenu = Business.Usuario.ListarMenuUsuario(mUsuarioAtivo.CodFuncionario.Value);
                    //Armazenar XML do Menu na Sessão
                    Session.Add("xmlMenu", xmlMenu);
                }
                var xmldoc = new XmlDocument();
                xmldoc.LoadXml(xmlMenu);
                //Carregar Menu conforme Perfil de Acesso);
                menuPrincipal.DataSource = xmldoc;
                menuPrincipal.Layout = skmMenu.MenuLayout.Horizontal;
                menuPrincipal.DefaultCssClass = "Menu";
                menuPrincipal.SubMenuCssClass = "Menu";
                menuPrincipal.SelectedMenuItemStyle.CssClass = "MenuItemSelecionado";

                //Definir permissão de Acesso via Menu
                /*foreach (PerfilAcessoVO identPerfil in mUsuarioAtivo.Perfils)
                {
                    switch (identPerfil.CodPerfilAcesso)
                    {
                        case BasePage.perfilAdmForum:
                            menuPrincipal.UserRoles.Add("perfilAdmForum");
                            break;
                        case BasePage.perfilAdmSis:
                            menuPrincipal.UserRoles.Add("perfilAdmSis");
                            break;
                        case BasePage.perfilSTI:
                            menuPrincipal.UserRoles.Add("perfilSTI");
                            break;
                    }
                }
                */
                menuPrincipal.zIndex = 9999;
                menuPrincipal.DataBind();
            }
        }
Exemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack) {
         var LoginModel = new BasePage().LoginCheck();
         if (LoginModel == null)
         {
             //this.ltrLoginInfo.Text = "<p><span><a href=\"/login.aspx\">登录</a></span><span><a href=\"/register.aspx\">注册</a></span></p>";
         }
         else {
             //this.ltrLoginInfo.Text = "<p><span><a href=\"/member/member_info.aspx\">" + LoginModel.nickname + "</a></span><span><a href=\"/Logout.aspx\">退出</a></span></p>";
         }
     }
 }
Exemplo n.º 8
0
 //NLog.Logger logger = LogManager.GetCurrentClassLogger();
 public override List<Answer> GetAnswer(BasePage basePage)
 {
     base.ranker = basePage.Ranker;
     IEnumerable<WebResultsWebResult> bingResults = Util.GetBingWebResults(ranker.query, siteName);
     if (bingResults == null)
     {
         //logger.Error("encountered in valid bing response for query:{0}", ranker.query);
         return new List<Answer>();
     }
     List<Answer> answers = ParseSearchResult(bingResults, ranker.query);
     BasePage.SqlLogger.InsertAnswer(basePage.SessionID, ranker.query, AnswerSource.WikiHow.ToString(), AnswerType.Text.ToString(), answers.Count);
     return answers;
 }
Exemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            string Remark = context.Request.QueryString["trk"];
            string talkid = Utils.GetQueryStringValue("talkid");
            int CommentType = Utils.GetInt(context.Request.QueryString["CommentType"]);
            string HotspotId = context.Request.QueryString["HotspotId"];
            context.Response.ContentType = "text/plain";
            context.Response.Expires = 0;
            context.Response.CacheControl = "no-cache";
            context.Response.Cache.SetNoStore();
            if (!String.IsNullOrEmpty(Remark))
            {
                string Uid = "";
                string name = "匿名";
                MbmemberDTO model = new BasePage().LoginCheck();
                if (model != null)
                {
                    Uid = model.id;
                    name = model.nickname;
                }
                TywcommentDTO m = new TywcommentDTO();
                m.id = System.Guid.NewGuid().ToString();
                m.uid = Uid;
                m.name = name;
                m.content = Remark;
                m.commenttime = DateTime.Now;
                m.objecttype = CommentType;
                m.objectid = HotspotId;
                if (!String.IsNullOrWhiteSpace(talkid))
                    m.replyid = talkid;
                else
                    m.replyid = "0";
                m.datasource = BasePage.Target;
                var Result = BComment.Add(m);
                if (Result)
                {
                    Utils.RCWE(UtilsCommons.AjaxReturnJson("1", "评论成功!"));
                    return;
                }
                else
                {
                    Utils.RCWE(UtilsCommons.AjaxReturnJson("0", "评论失败!"));
                    return;
                }

            }
            else
            {
                Utils.RCWE(UtilsCommons.AjaxReturnJson("0", "评论失败!"));
            }
        }
Exemplo n.º 10
0
 //NLog.Logger logger = LogManager.GetCurrentClassLogger();
 public override List<Answer> GetAnswer(BasePage basePage)
 {
     base.ranker = basePage.Ranker;
     List<Answer> answers = new List<Answer>();
     // check if it is a what query;
     List<string> WrbQuery = ranker.queryWords.Where((w, i) => Ranker.WHTags.Contains(ranker.queryTags.ElementAt(i))).ToList<string>();
     if (!WrbQuery.Contains("how"))
         return null;
     Stream webResponse = SendRequest(ranker.query);
     if (webResponse != null)
     {
         answers = ParseResponse(webResponse);
     }
     BasePage.SqlLogger.InsertAnswer(basePage.SessionID, ranker.query, AnswerSource.YouTube.ToString(), AnswerType.Video.ToString(), answers.Count);
     return answers;
 }
Exemplo n.º 11
0
 public override List<Answer> GetAnswer(BasePage basePage)
 {
     //List<Answer> answers = new List<Answer>();
     base.ranker = basePage.Ranker;
     nnQuery = string.Join(" ", ranker.queryWords.Where((w, i) => Ranker.NNTags.Contains(ranker.queryTags.ElementAt(i))));
     IEnumerable<WebResultsWebResult> bingResults = Util.GetBingWebResults(nnQuery, siteName).Take(resultsSize);
     if (bingResults == null)
     {
         //logger.Error("Encountered invalid bing response for query:{0}", ranker.query);
         return new List<Answer>();
     }
     //answers = ParseSearchResult(bingResults, ranker.query);
     ParseSearchResult(bingResults, ranker.query);
     //return answers;
     return Answers;
 }
Exemplo n.º 12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack) {
         MbmemberDTO model = new BasePage().LoginCheck();
         if (model != null)
         {
             this.phLogin.Visible = false;
             this.ltrLoginInfo.Text = "<img src=\"" + Common.NoPhotoDefault(model.head) + "\" width=\"70\" height=\"68\"><p>" + model.nickname + "<br/>" + DateTime.Now.ToString("yyyy-MM-dd") + "</p>";
         }
         else
         {
             this.phLogin.Visible = true;
             this.ltrLoginInfo.Text = "<img src=\"../images/travel_raiders_tx_img1.jpg\"><p>游客<br/>" + DateTime.Now.ToString("yyyy-MM-dd") + "</p>";
         }
     }
 }
Exemplo n.º 13
0
        protected override void OnInit(EventArgs e)
        {
            // Creating some objects
            _hostPage = (BasePage)this.Page;
            Publication pub = _hostPage.CMS.Context.Publication;

            // Get the XSL
            if (XslFile.Equals(string.Empty))
                throw new Exception("XslFile attribute is empty");
            else
                _XslCompiledTransform = Templates.GetXslCompiledTransform(_hostPage.CMS.Context.PublicationID, Page.ResolveUrl(XslFile));

            _XslParams = new XsltArgumentList();

            // Adding NodeID as parameter
            try
            {
                _XslParams.AddParam("NodeID", "", _hostPage.CMS.Context.NodeID);
            }
            catch { }

            // Adding some more parameters:
            _XslParams.AddParam("TemplatePath", "", pub.TemplateUrl);
            _XslParams.AddParam("ApplicationPath", "", HttpContext.Current.Request.ApplicationPath);
            _XslParams.AddParam("CurrentPageData", "", _hostPage.CMS.Context.PageData.ToXmlNode());
            _XslParams.AddParam("PubID", "", pub.PubID);
            _XslParams.AddParam("PublishedUrl", "", pub.PublishedPrimaryUrl);
            _XslParams.AddParam("PageType", "", _hostPage.CMS.Context.PageData.PageType.Name);

            // Adding Custom Publication Properties
            XmlDocument siteProperties = SitePropertyHelper.GetSitePropertyPage(pub.PubID).XmlContentNode();
            foreach (XmlNode property in siteProperties.ChildNodes)
            {
                string customPropValue = property.InnerXml;
                _XslParams.AddParam(property.Name, "", customPropValue);
            }

            // Adding CMS API
            CMSAPI cms = new CMSAPI();
            cms.LiveMode = Globals.IsLiveMode();
            cms.UrlProvider = _hostPage.CMS.Context.UrlProvider;
            _XslParams.AddExtensionObject("urn:CMS", cms);

            SetXml();

            base.OnInit(e);
        }
        public static void DataUserSelectorListView(BasePage page, String ObjId, Dictionary<Guid, String> SelectedUsers)
        {
            var ids = SelectedUsers != null && SelectedUsers.Count > 0 ? SelectedUsers.Select(i => i.Key).ToArray() : new List<Guid>().ToArray();
            var names = SelectedUsers != null && SelectedUsers.Count > 0 ? SelectedUsers.Select(i => i.Value).ToArray() : new List<string>().ToArray();

            page.RegisterInlineScript(String.Format(" SelectedUsers{0} = {1}; ",
                                                        ObjId,
                                                        JsonConvert.SerializeObject(
                                                            new
                                                            {
                                                                IDs = ids,
                                                                Names = names,
                                                                DeleteImgSrc = WebImageSupplier.GetAbsoluteWebPath("remove_12.png", ProductEntryPoint.ID),
                                                                DeleteImgTitle = CRMCommonResource.DeleteUser,
                                                                CurrentUserID = SecurityContext.CurrentAccount.ID
                                                            })), onReady: false);
        }
Exemplo n.º 15
0
 //NLog.Logger logger = LogManager.GetCurrentClassLogger();
 public override List<Answer> GetAnswer(BasePage basePage)
 {
     base.ranker = basePage.Ranker;
     string nnQuery = string.Join(" ", ranker.queryWords.Where((w, i) => Ranker.NNTags.Contains(ranker.queryTags.ElementAt(i))));
     // check if it is a what query;
     List<string> WrbQuery = ranker.queryWords.Where((w, i) => Ranker.WHTags.Contains(ranker.queryTags.ElementAt(i))).ToList<string>();
     if (!WrbQuery.Contains("what") && !WrbQuery.Contains("who"))
         return null;
     SearchResponse bingResults = Util.SendBingSearchRequest(nnQuery, siteFilter, "image");
     if (bingResults == null||bingResults.Image == null || bingResults.Image.Results == null)
     {
         //logger.Error("encountered in valid bing response for query:{0}", nnQuery);
         return new List<Answer>();
     }
     List<Answer> finalAnswers = ParseSearchResult(bingResults.Image.Results.Take(5), nnQuery);
     BasePage.SqlLogger.InsertAnswer(basePage.SessionID, ranker.query, AnswerSource.BingImages.ToString(), AnswerType.Image.ToString(), finalAnswers.Count);
     return finalAnswers;
 }
Exemplo n.º 16
0
 public override List<Answer> GetAnswer(BasePage basePage)
 {
     url = "http://query.chacha.com/answer/search.json?query=How+Old+is+Brad+Pitt&pageSize=10";
     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
     request.Method = "GET";
     request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.120 Safari/535.2";
     request.Headers.Add("apikey", "jvwj5ttfhjqych42gm34xxyu");
     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
     XmlDocument xdoc = new XmlDocument();
     using (StreamReader responseReader = new StreamReader(response.GetResponseStream()))
     {
         responseReader.ReadToEnd();
         xdoc.Load(responseReader);
     }
     Answer answer = new Answer();
     List<Answer> answers = new List<Answer>();
     answers.Add(answer);
     return answers;
 }
Exemplo n.º 17
0
 //NLog.Logger logger = LogManager.GetCurrentClassLogger();
 public override List<Answer> GetAnswer(BasePage basePage)
 {
     List<Thread> workers = new List<Thread>();
     List<Answer> answers = new List<Answer>();
     base.ranker = basePage.Ranker;
     Stream webResponse = sendQuestionSearchRequest(ranker.query);
     answers = ParseQuestionResponse(webResponse);
     // the below extra calls are only to get votes information which is not reliable and hence not worth making.
     //List<Answer> yahooAnswers = new List<Answer>();
     //int resultcount = 0;
     //foreach (Answer ans in answers)
     //{
     //    Thread worker = new Thread(() => ParseAnswerResponse(ans, sendAnswerSearchRequst(ans.metaData)));
     //    worker.Start();
     //    workers.Add(worker);
     //    yahooAnswers.Add(ans);
     //    //webResponse = sendAnswerSearchRequst(ans.metaData);
     //    //ParseAnswerResponse(ans, webResponse);
     //    if (resultcount > resultsSize)
     //        break;
     //    resultcount += 1;
     //}
     //while (workers.Count > 0)
     //{
     //    List<Thread>  remThreads = new List<Thread>();
     //    foreach (Thread worker in workers)
     //        if (worker.IsAlive)
     //            remThreads.Add(worker);
     //    workers = remThreads;
     //}
     //return yahooAnswers;
     if (answers == null)
     {
         //logger.Info("YahooAnswers Result Count: no results");
     }
     else
     {
         //logger.Info("YahooAnswers Result Count:{0}", answers.Count);
     }
     BasePage.SqlLogger.InsertAnswer(basePage.SessionID, ranker.query, AnswerSource.YahooAnswers.ToString(), AnswerType.Text.ToString(), answers.Count);
     return answers;
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     var basePage = new BasePage();
     var moods = basePage.getMoods();
     if (!string.IsNullOrEmpty(Request.Params["method"]) && Request.Params["method"] == "publisher_getFeedStory")
     {
         //TODO: need to figure out how to pull picked out of this
         var picked = 0; //int.Parse(Request.Params["app_params"]);
         var canvas = string.Format("http://apps.facebook.com/{0}/mysmiles.aspx", suffix);
         var image = string.Format("{0}images/smile{1}.jpg", callback, picked);
         var images = JSONHelper.ConvertToJSONAssociativeArray(new Dictionary<string, string> { { "src", image }, { "href", canvas } });
         var templateData = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "mood", moods.ElementAt(picked).Value }, { "emote", moods.ElementAt(picked).Key }, { "images", images }, { "mood_src", image } });
         var feed = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "template_id", basePage.FeedTemplate1.ToString() }, { "template_data", templateData } });
         var content = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "feed", feed } });
         var data = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "method", "publisher_getFeedStory" }, { "content", content } });
         json = data;
     }
     else if (!string.IsNullOrEmpty(Request.Params["method"]) && Request.Params["method"] == "publisher_getInterface")
     {
         //TODO: need to figure out how to pull picked out of this
         var fbml = FBMLControlRenderer.RenderFBML<string>(string.Format("~/controls/PublisherHeader.ascx"), callback).Replace("\n","");
         //var fbml = @"<style>
         //</style>";
         //fbml += "test";
         fbml += string.Format("<form>{0}<input type=\"hidden\" id=\"picked\" name=\"picked\" value=\"-1\"></form>", basePage.BuildEmoticonGrid(moods, callback, suffix, false));
         var content = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "fbml", fbml }, { "publishEnabled", "true" }, { "commentEnabled", "true" } });
         var data = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "content", content }, { "method", "publisher_getInterface" } });
         json = data;
     }
     else
     {
         throw new Exception("no smile picked");
     }
 }
Exemplo n.º 19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack) {
         //Response.Write(Request.CurrentExecutionFilePath);
         if (Request.CurrentExecutionFilePath.ToLower() == "/default.aspx" || Request.CurrentExecutionFilePath.ToLower() == "default.aspx")
             this.phLanguage.Visible = true;
         var LoginModel = new BasePage().LoginCheck();
         if (LoginModel == null)
         {
             this.ltrLoginInfo.Text = "<p><a href=\"/login.aspx\">登录</a><a href=\"/register.aspx\">注册</a></p>";
         }
         else {
             if (BMemberSign.IsSign(LoginModel.id) == false)
             {
                 this.ltrLoginInfo.Text = "<p><a href=\"/RegistrationIt.aspx\" class=\"qd-btn\">签到</a><a href=\"/member/member_info.aspx\">" + LoginModel.nickname + "</a><a href=\"/Logout.aspx\">退出</a></p>";
             }
             else
             {
                 this.ltrLoginInfo.Text = "<p><a href=\"/RegistrationIt.aspx\" class=\"qd-btn\">今日已签</a><a href=\"/member/member_info.aspx\">" + LoginModel.nickname + "</a><a href=\"/Logout.aspx\">退出</a></p>";
             }
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Request.Params["picked"]))
     {
         var picked = int.Parse(Request.Params["picked"]);
         var basePage = new BasePage();
         var moods = basePage.getOtherMoods();
         var canvas = string.Format("http://apps.facebook.com/{0}/mysmiles.aspx", suffix);
         var templateData = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "emote", moods.ElementAt(picked).Value }, { "emoteaction", moods.ElementAt(picked).Key } });
         var feed = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "template_id", basePage.FeedTemplate2.ToString() }, { "template_data", templateData } });
         var content = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "feed", feed }, { "next", canvas } });
         var data = JSONHelper.ConvertToJSONAssociativeArray(
             new Dictionary<string, string> { { "method", "multiFeedStory" }, { "content", content } });
         json = data;
     }
     else
     {
         throw new Exception("no smile picked");
     }
 }
Exemplo n.º 21
0
        //NLog.Logger logger = LogManager.GetCurrentClassLogger();
        public override List<Answer> GetAnswer(BasePage basePage)
        {
            base.ranker = basePage.Ranker;

            string nnQuery = string.Join(" ", ranker.queryWords.Where((w, i) => Ranker.NNTags.Contains(ranker.queryTags.ElementAt(i))));
            IEnumerable<WebResultsWebResult> bingResults = Util.GetBingWebResults(nnQuery, siteName).Take(resultsSize);
            if (bingResults == null)
            {
                //logger.Error("Encountered invalid bing response for query:{0}", ranker.query);
                return Answers;
            }
            ParseSearchResult(bingResults, ranker.query);
            BasePage.SqlLogger.InsertAnswer(basePage.SessionID, ranker.query, AnswerSource.Wikipedia.ToString(), AnswerType.Text.ToString(), Answers.Count);
            BasePage.SqlLogger.InsertAnswer(basePage.SessionID, ranker.query, AnswerSource.WikipediaInfoBox.ToString(), AnswerType.Text.ToString(), InfoAnswers.Count);

            List<Answer> finalAnswers = new List<Answer>();
            // adding description wiki answer only if query is what / Who and there is no answer from info box
            if ((ranker.queryWords.Contains("what") || ranker.queryWords.Contains("who")) && InfoAnswers.Count == 0)
                finalAnswers.AddRange(Answers.Take(resultsSize));
            // adding info box answers
            finalAnswers.AddRange(InfoAnswers.Take(resultsSize));

            return finalAnswers;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session != null)
            {
                // Store essential session information temporarily
                string culture = Session["culture"] as string ?? "nl-NL";

                Session["culture"] = null;

                // Restore the essential session information
                Session["culture"] = culture;
            }

            if (!Request.IsAuthenticated)
            {
                if (Request.Params["pid"] != null || Request.Params["tid"] != null)
                {
                    Response.Redirect(string.Format("~/Account/Login.aspx?tid={0}&pid={1}",
                                    Request.Params["tid"],
                                    Request.Params["pid"]), false);
                }
                else
                {
                    Response.Redirect("~/Default.aspx", false);
                }
            }

            Literal name = HeadLoginView.FindControl("HeadLoginName") as Literal;
            if (name != null)
            {
                if (Session["userid"] != null)
                {
                    long userId = Util.UserId;
                    using (Database db = new MySqlDatabase())
                    {
                        ClientInfo ci = db.GetClientInfo(userId);
                        name.Text = string.Format(" {0}", ci.FirstName); // ci.GetFullName());
                    }
                }
            }
            if (!IsPostBack)
            {
                BasePage obj = new BasePage();
                obj.IncludePage(FooterLiteral, Resources.Resource.FooterSection);
            }
        }
 void LoadDocumentGrid()
 {
     BasePage bp = new BasePage();
     int userId = bp.UserInfo.ByID;
     List<BuilderPropertyDocuments> lstBuilderPropertyDocuments = (BuilderPropertyDocuments.GetBuilderPortalDocuments(_unitID, userId)).ToList();
     gridDocuments.DataSource = lstBuilderPropertyDocuments;
     gridDocuments.DataBind();
 }
        public static void DataContactDetailsViewForTaskAction(BasePage page, Contact TargetContact)
        {
            var isPrivate = !CRMSecurity.CanAccessTo(TargetContact);
            var contactAccessList = new List<Guid>();
            if (isPrivate)
            {
                contactAccessList = CRMSecurity.GetAccessSubjectTo(TargetContact).Keys.ToList<Guid>();
            }

            page.RegisterInlineScript(String.Format(" var contactForInitTaskActionPanel = {0}; ",
                                                    JsonConvert.SerializeObject(new
                                                    {
                                                        id = TargetContact.ID,
                                                        displayName = TargetContact.GetTitle().HtmlEncode().ReplaceSingleQuote(),
                                                        smallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(TargetContact.ID, TargetContact is Company),
                                                        isPrivate = isPrivate,
                                                        accessList = contactAccessList.ConvertAll(n => new { id = n })
                                                    })), onReady: false);
        }
        public static void DataCasesActionView(BasePage page, ASC.CRM.Core.Entities.Cases targetCase)
        {
            var customFieldList = targetCase != null
                ? Global.DaoFactory.GetCustomFieldDao().GetEnityFields(EntityType.Case, targetCase.ID, true)
                : Global.DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Case);
            var tags = targetCase != null ? Global.DaoFactory.GetTagDao().GetEntityTags(EntityType.Case, targetCase.ID) : new string[] { };
            var availableTags = Global.DaoFactory.GetTagDao().GetAllTags(EntityType.Case).Where(item => !tags.Contains(item));


            var presetContactsJson = "";
            var selectedContacts = new List<Contact>();
            if (targetCase != null)
            {
                selectedContacts = Global.DaoFactory.GetContactDao().GetContacts(Global.DaoFactory.GetCasesDao().GetMembers(targetCase.ID));
            }
            else
            {
                var URLContactID = UrlParameters.ContactID;
                if (URLContactID != 0)
                {
                    var target = Global.DaoFactory.GetContactDao().GetByID(URLContactID);
                    if (target != null)
                    {
                        selectedContacts.Add(target);
                    }
                }
            }

            if (selectedContacts.Count > 0)
            {
                presetContactsJson = JsonConvert.SerializeObject(selectedContacts.ConvertAll(item => new
                                {
                                    id = item.ID,
                                    displayName = item.GetTitle().HtmlEncode().ReplaceSingleQuote().Replace(@"\", @"\\"),
                                    smallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(item.ID, item is Company)
                                }));
            }

            var script = String.Format(@"
                                        var casesActionTags = {0};
                                        var casesActionAvailableTags = {1};
                                        var casesActionSelectedContacts = '{2}'; ",
                                    JsonConvert.SerializeObject(tags),
                                    JsonConvert.SerializeObject(availableTags),
                                    presetContactsJson
                                    );

            page.RegisterInlineScript(script, onReady: false);
            page.JsonPublisher(customFieldList, "casesEditCustomFieldList");
        }
        public static void DataDealFullCardView(BasePage page, Deal targetDeal)
        {
            var customFieldList = Global.DaoFactory.GetCustomFieldDao().GetEnityFields(EntityType.Opportunity, targetDeal.ID, false);
            var tags = Global.DaoFactory.GetTagDao().GetEntityTags(EntityType.Opportunity, targetDeal.ID);
            var availableTags = Global.DaoFactory.GetTagDao().GetAllTags(EntityType.Opportunity).Where(item => !tags.Contains(item));

            var responsibleIDs = new List<Guid>();
            if (CRMSecurity.IsPrivate(targetDeal)) {
                responsibleIDs = CRMSecurity.GetAccessSubjectGuidsTo(targetDeal);
            }

            var script = String.Format(@"
                                            var dealTags = {0};
                                            var dealAvailableTags = {1};
                                            var dealResponsibleIDs = {2}; ",
                                        JsonConvert.SerializeObject(tags),
                                        JsonConvert.SerializeObject(availableTags),
                                        JsonConvert.SerializeObject(responsibleIDs)
                                        );

            page.RegisterInlineScript(script, onReady: false);
            page.JsonPublisher(customFieldList, "customFieldList");
        }
        public static void DataDealActionView(BasePage page, Deal targetDeal)
        {
             var customFieldList = targetDeal != null
                ? Global.DaoFactory.GetCustomFieldDao().GetEnityFields(EntityType.Opportunity, targetDeal.ID, true)
                : Global.DaoFactory.GetCustomFieldDao().GetFieldsDescription(EntityType.Opportunity);
           
            var dealExcludedIDs = new List<Int32>();
            var dealClientIDs = new List<Int32>();
            var dealMembersIDs = new List<Int32>();
            
            if (targetDeal != null)
            {
                dealExcludedIDs = Global.DaoFactory.GetDealDao().GetMembers(targetDeal.ID).ToList();
                dealMembersIDs = new List<int>(dealExcludedIDs);
                if (targetDeal.ContactID != 0) {
                    dealMembersIDs.Remove(targetDeal.ContactID);
                    dealClientIDs.Add(targetDeal.ContactID);
                }
            }


            var presetClientContactsJson = "";
            var presetMemberContactsJson = "";
            var showMembersPanel = false;
            var selectedContacts = new List<Contact>();
            var hasTargetClient = false;

            if (targetDeal != null && targetDeal.ContactID != 0)
            {
                var contact = Global.DaoFactory.GetContactDao().GetByID(targetDeal.ContactID);
                if(contact != null)
                {
                    selectedContacts.Add(contact);
                }
            }
            else
            {
                var URLContactID = UrlParameters.ContactID;
                if (URLContactID != 0)
                {
                    var target = Global.DaoFactory.GetContactDao().GetByID(URLContactID);
                    if (target != null)
                    {
                        selectedContacts.Add(target);
                        hasTargetClient = true;
                    }
                }
            }
            if (selectedContacts.Count > 0)
            {
                presetClientContactsJson = JsonConvert.SerializeObject(selectedContacts.ConvertAll(item => new
                                {
                                    id = item.ID,
                                    displayName = item.GetTitle().HtmlEncode().ReplaceSingleQuote().Replace(@"\", @"\\"),
                                    smallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(item.ID, item is Company)
                                }));
            }


            selectedContacts = new List<Contact>();
            selectedContacts.AddRange(Global.DaoFactory.GetContactDao().GetContacts(dealMembersIDs.ToArray()));
            if (selectedContacts.Count > 0)
            {
                showMembersPanel = true;
                presetMemberContactsJson = JsonConvert.SerializeObject(selectedContacts.ConvertAll(item => new
                                {
                                    id = item.ID,
                                    displayName = item.GetTitle().HtmlEncode().ReplaceSingleQuote().Replace(@"\", @"\\"),
                                    smallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(item.ID, item is Company)
                                }));
            }

            var ResponsibleSelectedUserId = targetDeal == null ?
                                                SecurityContext.CurrentAccount.ID :
                                                (targetDeal.ResponsibleID != Guid.Empty ? targetDeal.ResponsibleID : Guid.Empty);

            var script = String.Format(@"
                                            var presetClientContactsJson = '{0}';
                                            var presetMemberContactsJson = '{1}';
                                            var hasDealTargetClient = {2};
                                            var showMembersPanel = {3};
                                            var dealClientIDs = {4};
                                            var dealMembersIDs = {5};
                                            var responsibleId = '{6}'; ",
                                        presetClientContactsJson,
                                        presetMemberContactsJson,
                                        hasTargetClient.ToString().ToLower(),
                                        showMembersPanel.ToString().ToLower(),
                                        JsonConvert.SerializeObject(dealClientIDs),
                                        JsonConvert.SerializeObject(dealMembersIDs),
                                        ResponsibleSelectedUserId
                                    );

            page.RegisterInlineScript(script, onReady: false);
            page.JsonPublisher(customFieldList, "customFieldList");
            page.JsonPublisher(Global.DaoFactory.GetDealMilestoneDao().GetAll(), "dealMilestones");

            if (targetDeal != null) {
                page.JsonPublisher(targetDeal, "targetDeal");
            }
        }
        public static void DataHistoryView(BasePage page, List<Guid> UserList)
        {
            page.RegisterInlineScript(String.Format(" var historyView_dateTimeNowShortDateString = '{0}'; ",TenantUtil.DateTimeNow().ToShortDateString()), onReady: false);

            if (UserList != null)
            {
                page.RegisterInlineScript(String.Format(" UserList_HistoryUserSelector = {0}; ", JsonConvert.SerializeObject(UserList)), onReady: false);
            }

            RegisterClientScriptHelper.DataUserSelectorListView(page, "_HistoryUserSelector", null);
        }
        public static void DataInvoicesActionView(BasePage page, Invoice targetInvoice)
        {
            var invoiceItems = Global.DaoFactory.GetInvoiceItemDao().GetAll();
            var invoiceItemsJson = JsonConvert.SerializeObject(invoiceItems.ConvertAll(item => new
                {
                    id = item.ID,
                    title = item.Title,
                    stockKeepingUnit = item.StockKeepingUnit,
                    description = item.Description,
                    price = item.Price,
                    quantity = item.Quantity,
                    stockQuantity = item.StockQuantity,
                    trackInventory = item.TrackInventory,
                    invoiceTax1ID = item.InvoiceTax1ID,
                    invoiceTax2ID = item.InvoiceTax2ID
                }));

            var invoiceTaxes = Global.DaoFactory.GetInvoiceTaxDao().GetAll();
            var invoiceTaxesJson = JsonConvert.SerializeObject(invoiceTaxes.ConvertAll(item => new
                {
                    id = item.ID,
                    name = item.Name,
                    rate = item.Rate,
                    description = item.Description
                }));

            var invoiceSettings = Global.TenantSettings.InvoiceSetting ?? InvoiceSetting.DefaultSettings;
            var invoiceSettingsJson = JsonConvert.SerializeObject(new
                {
                    autogenerated = invoiceSettings.Autogenerated,
                    prefix = invoiceSettings.Prefix,
                    number = invoiceSettings.Number,
                    terms = invoiceSettings.Terms
                });

            var presetContactsJson = string.Empty;
            var presetContactID = UrlParameters.ContactID;
            if (targetInvoice == null && presetContactID != 0)
            {
                var targetContact = Global.DaoFactory.GetContactDao().GetByID(presetContactID);
                if (targetContact != null)
                {
                    presetContactsJson = JsonConvert.SerializeObject(new
                    {
                        id = targetContact.ID,
                        displayName = targetContact.GetTitle().HtmlEncode().ReplaceSingleQuote(),
                        smallFotoUrl = ContactPhotoManager.GetSmallSizePhoto(targetContact.ID, targetContact is Company),
                        currencyAbbreviation = targetContact.Currency
                    });
                }
            }

            var currencyRates = Global.DaoFactory.GetCurrencyRateDao().GetAll();
            var currencyRatesJson = JsonConvert.SerializeObject(currencyRates.ConvertAll(item => new
            {
                id = item.ID,
                fromCurrency = item.FromCurrency,
                toCurrency = item.ToCurrency,
                rate = item.Rate
            }));

            var apiServer = new Api.ApiServer();
            const string apiUrlFormat = "{0}crm/contact/{1}/data.json";

            var contactInfoData = string.Empty;
            var consigneeInfoData = string.Empty;
            
            if(targetInvoice != null)
            {
                if (targetInvoice.ContactID > 0)
                {
                    contactInfoData = apiServer.GetApiResponse(String.Format(apiUrlFormat, SetupInfo.WebApiBaseUrl, targetInvoice.ContactID), "GET");
                }
                if (targetInvoice.ConsigneeID > 0)
                {
                    consigneeInfoData = apiServer.GetApiResponse(String.Format(apiUrlFormat, SetupInfo.WebApiBaseUrl, targetInvoice.ConsigneeID), "GET");
                }
            } else if (presetContactID != 0)
            {
                contactInfoData = apiServer.GetApiResponse(String.Format(apiUrlFormat, SetupInfo.WebApiBaseUrl, presetContactID), "GET");
            }

            var apiUrl = String.Format("{0}crm/invoice/{1}.json",
                                       SetupInfo.WebApiBaseUrl,
                                       targetInvoice != null ? targetInvoice.ID.ToString(CultureInfo.InvariantCulture) : "sample");
            var invoiceData = apiServer.GetApiResponse(apiUrl, "GET");

            var script = String.Format(@"
                                        var invoiceItems = '{0}';
                                        var invoiceTaxes = '{1}';
                                        var invoiceSettings = '{2}';
                                        var invoicePresetContact = '{3}';
                                        var currencyRates = '{4}';
                                        var invoiceJsonData = '{5}'; ",
                                       Global.EncodeTo64(invoiceItemsJson),
                                       Global.EncodeTo64(invoiceTaxesJson),
                                       Global.EncodeTo64(invoiceSettingsJson),
                                       Global.EncodeTo64(presetContactsJson),
                                       Global.EncodeTo64(currencyRatesJson),
                                       targetInvoice != null ? Global.EncodeTo64(targetInvoice.JsonData) : ""
                );

            page.RegisterInlineScript(script, onReady: false);
            page.JsonPublisher(contactInfoData, "invoiceContactInfo");
            page.JsonPublisher(consigneeInfoData, "invoiceConsigneeInfo");
            page.JsonPublisher(invoiceData, "invoice");
        }
        public static void DataInvoicesDetailsView(BasePage page, Invoice targetInvoice)
        {
            if(targetInvoice == null)
                return;

            var script = String.Format(@"var invoiceData = '{0}';", Global.EncodeTo64(targetInvoice.JsonData));

            var apiServer = new Api.ApiServer();
            var apiUrl = String.Format("{0}crm/invoice/{1}.json",SetupInfo.WebApiBaseUrl, targetInvoice.ID);
            var invoice = apiServer.GetApiResponse(apiUrl, "GET");

            page.RegisterInlineScript(script, onReady: false);
            page.JsonPublisher(invoice, "invoice");
        }