Пример #1
0
        public List <UrlList> GetMenuList(int i, string filter)
        {
            List <UrlList> list   = new List <UrlList>();
            var            result = bll.Find().FindAll(n => n.Status == i);

            if (!string.IsNullOrEmpty(filter))
            {
                result = result.FindAll(n => n.Url.Contains(filter) || n.Id.Contains(filter) || n.Name.Contains(filter) || n.Types.Contains(filter));
            }
            foreach (var item in result)
            {
                UrlList e = new UrlList();
                e.Id     = item.Id;
                e.Name   = string.Format("<div class=\"input-group\"><input type=\"text\" value=\"{0}\" class=\"form-control\" placeholder=\"名称……\" id=\"txtName_{1}\"><span class=\"input-group-btn\"><button class=\"btn btn-default\" type=\"button\" onclick=\"UrlNameUpdateSave('{1}')\">Go</button></span></div>", item.Name, item.Id);
                e.Url    = string.Format("<div class=\"input-group\"><input type=\"text\" value=\"{0}\" class=\"form-control\" placeholder=\"网址……\" id=\"txtUrl_{1}\"><span class=\"input-group-btn\"><button class=\"btn btn-default\" type=\"button\" onclick=\"UrlUpdateSave('{1}')\">Go</button></span></div>", item.Url, item.Id);
                e.Source = string.Format("<div class=\"input-group\"><input type=\"text\" value=\"{0}\" class=\"form-control\" placeholder=\"网址描述……\" id=\"txtSource_{1}\"><span class=\"input-group-btn\"><button class=\"btn btn-default\" type=\"button\" onclick=\"UrlSourceUpdateSave('{1}')\">Go</button></span></div>", item.Source, item.Id);
                //e.Title = string.Format("<div class=\"input-group\"><input type=\"text\" value=\"{0}\" class=\"form-control\" placeholder=\"Title……\" id=\"txtTitle_{1}\"><span class=\"input-group-btn\"><button class=\"btn btn-default\" type=\"button\" onclick=\"UrlTitleUpdateSave('{1}')\">Go</button></span></div>", item.Title, item.Id);
                e.Types     = string.Format("<a onclick=\"myModalModify('{0}')\">{1}</a>", item.Id, item.Types);
                e.SortDesc  = string.Format("<div class=\"input-group\"><input type=\"text\" value=\"{0}\" class=\"form-control\" placeholder=\"降序排列……\" id=\"txtSort_{1}\"><span class=\"input-group-btn\"><button class=\"btn btn-default\" type=\"button\" onclick=\"btnSortSave('{1}')\">Go</button></span></div>", item.SortDesc.ToString(), item.Id);
                e.Status    = string.Format("<button class=\"{2}\" id='btnStatus{0}' onclick=\"myStatusEdit('{0}');\">{1}</button>", item.Id, item.Status.ToEnumDiscription <EnumUrlStatus>(), GetStatusCss(item.Status));
                e.Operation = string.Format("<a class=\"btn btn-info btn-circle\" href=\"{0}\" target=\"_blank\" title=\"{1}\" id=\"txtfwxtest_{2}\" onclick=\"BtnClearClass('{2}')\"> <i class=\"glyphicon glyphicon-ok\"></i></a>", item.Url, item.Title, item.Id);
                list.Add(e);
            }
            return(list);
        }
        public HttpResponseMessage AddUrl([FromBody] U_Url_List p)
        {
            U_Url_ListBLL bll_UrlList = new U_Url_ListBLL();
            U_Url_TypeBLL bllType     = new U_Url_TypeBLL();
            string        returnInfo  = string.Empty;

            #region 添加网站
            try
            {
                if (!string.IsNullOrEmpty(p.Url) && !string.IsNullOrEmpty(p.Name))
                {
                    if (p.Url.IsUrlFormat())
                    {
                        if (bllType.Find(string.Format("AND ID='{0}'", p.Types)) != null)
                        {
                            if (bll_UrlList.Find(string.Format("AND Url='{0}'", p.Url)) == null)
                            {
                                if (!string.IsNullOrEmpty(p.IconImg))
                                {
                                    if (!p.IconImg.IsUrlFormat())
                                    {
                                        returnInfo = "网址LOG错误,不是Url地址,请检查";
                                    }
                                }
                                if (string.IsNullOrEmpty(returnInfo))
                                {
                                    p.Id = GetStr.GetGuid;
                                    bll_UrlList.Add(new List <U_Url_List> {
                                        p
                                    });
                                    returnInfo = "添加成功";
                                }
                            }
                            else
                            {
                                returnInfo = "网址已存在,请确认";
                            }
                        }
                        else
                        {
                            returnInfo = "添加的类型不存,请确认";
                        }
                    }
                    else
                    {
                        returnInfo = "网址地址,错误,请检查";
                    }
                }
                else
                {
                    returnInfo = "网址地址或名称为空,请检查";
                }
            }
            catch
            {
                returnInfo = "发生错误";
            }
            #endregion
            return(JsonConvert.SerializeObject(returnInfo).ToHttpResponseMessage());
        }
        private void _urlcheckresult(string userId)
        {
            U_Url_ListBLL bll_UrlList = new U_Url_ListBLL();
            var           list        = bll_UrlList.Find().FindAll(n => n.Status == EnumUrlStatus.Normal.GetHashCode());

            #region foreach
            foreach (var item in list)
            {
                try
                {
                    if (!item.Url.UrlVerification())
                    {
                        bll_UrlList.UpdateStatus(item.Id, EnumUrlStatus.NotDefined.GetHashCode(), userId);
                    }
                    if (item.IconImg.IsNotNull() &&
                        !System.IO.File.Exists(string.Format("{0}\\{1}", Images.GenerateIconsPath, item.IconImg)) &&
                        !item.IcomStream.IsNotNull() &&
                        !item.IconImg.UrlVerification())
                    {
                        item.IconImg       = "";
                        item.LastUpdate_Id = userId;
                        bll_UrlList.Update(item);
                    }
                }
                catch { }
            }
            #endregion
        }
        public ActionResult AddUrl(string Url, string Name, string IconImg, string Title, string Types)
        {
            string returnInfo = string.Empty;

            #region 添加网站
            try
            {
                U_Url_List t = new U_Url_List();
                t.Url         = Url;
                t.Name        = Ext.FilterMark(Name);
                t.IconImg     = IconImg;
                t.Title       = Ext.FilterMark(Title);
                t.Types       = Ext.FilterMark(Types);
                t.Status      = EnumUrlStatus.New.GetHashCode();
                t.Source      = "用户添加";
                t.Create_Time = GetStr.GetCurrentDate;
                if (!string.IsNullOrEmpty(t.Url) && !string.IsNullOrEmpty(t.Name))
                {
                    if (t.Url.IsUrlFormat())
                    {
                        if (bllType.Find(string.Format("AND ID='{0}'", t.Types)) != null)
                        {
                            if (bll_UrlList.Find(string.Format("AND Url='{0}'", t.Url)) == null)
                            {
                                if (!string.IsNullOrEmpty(t.IconImg))
                                {
                                    if (!t.IconImg.IsUrlFormat())
                                    {
                                        returnInfo = "网址LOG错误,不是Url地址,请检查";
                                    }
                                }
                                if (string.IsNullOrEmpty(returnInfo))
                                {
                                    t.Id = GetStr.GetGuid;
                                    bll_UrlList.Add(new List <U_Url_List> {
                                        t
                                    });
                                    returnInfo = "添加成功";
                                }
                            }
                            else
                            {
                                returnInfo = "网址已存在,请确认";
                            }
                        }
                        else
                        {
                            returnInfo = "添加的类型不存,请确认";
                        }
                    }
                    else
                    {
                        returnInfo = "网址地址,错误,请检查";
                    }
                }
                else
                {
                    returnInfo = "网址地址或名称为空,请检查";
                }
            }
            catch
            {
                returnInfo = "发生错误";
            }
            #endregion
            return(this.Json(returnInfo, JsonRequestBehavior.AllowGet));
        }
        private HttpResponseMessage _processrequest(string method, string parameter, string parameter2)
        {
            string returnInfo = string.Empty;

            if (method.IsNotNull())
            {
                U_Url_ClickRateBLL clickRateBll = new U_Url_ClickRateBLL();
                U_Url_TypeBLL      bllType      = new U_Url_TypeBLL();
                U_Url_ListBLL      bllMenuList  = new U_Url_ListBLL();
                U_Url_ListBLL      bll          = new U_Url_ListBLL();
                switch (method)
                {
                case "geturlalldata":
                    returnInfo = JsonConvert.SerializeObject(_geturlalldata(parameter, parameter2));
                    break;

                case "getcurrentobj":
                    if (!string.IsNullOrEmpty(parameter))
                    {
                        returnInfo = JsonConvert.SerializeObject(bll.Find(string.Format("AND ID='{0}'", parameter)));
                    }
                    break;

                case "gettypedata":
                    returnInfo = JsonConvert.SerializeObject(UrlTypeBLL.UrlTypeListManager.OrderByDescending(n => n.SortDesc));
                    break;

                case "geturlentity":
                    if (!string.IsNullOrEmpty(parameter))
                    {
                        returnInfo = JsonConvert.SerializeObject(bll.FindList(string.Format("AND Types='{0}'", parameter)).OrderBy(n => n.SortDesc));
                    }
                    break;

                case "addclickrate":
                    U_Url_ClickRate rate = new U_Url_ClickRate();
                    //rate.Id = GetStr.GetGuid;
                    //rate.UserAgents = context.Request.QueryString["b"];
                    //rate.UrlId = context.Request.QueryString["a"];
                    //rate.Ip = context.Request.QueryString["c"];
                    //rate.Msg = context.Request.QueryString["d"];
                    //rate.ClickDate = GetStr.GetCurrentDate;
                    //if (!string.IsNullOrEmpty(rate.UserAgents) && !string.IsNullOrEmpty(rate.UrlId))
                    //{
                    //    clickRateBll.Add(rate);
                    //}
                    break;

                case "geturlmodify":
                    returnInfo = JsonConvert.SerializeObject(new U_Url_ListBLL().QuerySql(string.Format(SqlStr.GetmyModalModify, parameter)).FirstOrDefault());
                    break;

                case "getclickrateday":
                    if (string.IsNullOrEmpty(parameter))
                    {
                        DateTime now = DateTime.Now;
                        parameter = new DateTime(now.Year, now.Month, 1).ToString(GetStr.yyyyMMddmmHHss);
                    }
                    if (string.IsNullOrEmpty(parameter2))
                    {
                        parameter2 = GetStr.GetCurrentDate;
                    }
                    returnInfo = JsonConvert.SerializeObject(clickRateBll.FinList <_ClickRate>(string.Format(SqlStr.GetClickRateDay, parameter, parameter2)));
                    break;

                case "getclickratemonth":
                    if (string.IsNullOrEmpty(parameter))
                    {
                        parameter = DateTime.Now.AddYears(-1).ToString(GetStr.yyyyMMddmmHHss);
                    }
                    if (string.IsNullOrEmpty(parameter2))
                    {
                        parameter2 = GetStr.GetCurrentDate;
                    }
                    returnInfo = JsonConvert.SerializeObject(clickRateBll.FinList <_ClickRate>(string.Format(SqlStr.GetClickRateMonth, parameter, parameter2)));
                    break;

                case "getcheckresult":
                    if (string.IsNullOrEmpty(parameter))
                    {
                        DateTime now = DateTime.Now;
                        parameter = new DateTime(now.Year, now.Month, 1).ToString(GetStr.yyyyMMddmmHHss);
                    }
                    if (string.IsNullOrEmpty(parameter2))
                    {
                        parameter2 = GetStr.GetCurrentDate;
                    }
                    returnInfo = JsonConvert.SerializeObject(clickRateBll.FinList <U_Url_Check>(string.Format(SqlStr.GetCheckResult, parameter, parameter2)));
                    break;

                case "leaveamessage":
                    if (string.IsNullOrEmpty(parameter))
                    {
                        DateTime now = DateTime.Now;
                        parameter = new DateTime(now.Year, now.Month, 1).ToString(GetStr.yyyyMMddmmHHss);
                    }
                    if (string.IsNullOrEmpty(parameter2))
                    {
                        parameter2 = GetStr.GetCurrentDate;
                    }
                    returnInfo = JsonConvert.SerializeObject(clickRateBll.FinList <LeaveAMessage>(string.Format(SqlStr.LeaveAMessage, parameter, parameter2)));
                    break;

                case "log":
                    if (string.IsNullOrEmpty(parameter))
                    {
                        DateTime now = DateTime.Now;
                        parameter = new DateTime(now.Year, now.Month, 1).ToString(GetStr.yyyyMMddmmHHss);
                    }
                    if (string.IsNullOrEmpty(parameter2))
                    {
                        parameter2 = GetStr.GetCurrentDate;
                    }
                    returnInfo = JsonConvert.SerializeObject(clickRateBll.FinList <S_Log>(string.Format(SqlStr.LogSql, parameter, parameter2)));
                    break;
                }
            }
            return(JsonConvert.SerializeObject(returnInfo).ToHttpResponseMessage());
        }