public virtual void Edit(long id)
        {
            AuthConnectConfig x = AuthConnectConfig.GetById(id);

            bind("x", x);
            target(Update, id);
        }
        public virtual void SaveSort()
        {
            long   id  = ctx.PostLong("id");
            String cmd = ctx.Post("cmd");

            AuthConnectConfig data      = AuthConnectConfig.GetById(id);
            String            condition = (ctx.app == null ? "" : "AppId=" + ctx.app.Id);

            List <AuthConnectConfig> list = AuthConnectConfig.GetAll();

            if (cmd == "up")
            {
                new SortUtil <AuthConnectConfig>(data, list).MoveUp();
                echoRedirect("ok");
            }
            else if (cmd == "down")
            {
                new SortUtil <AuthConnectConfig>(data, list).MoveDown();
                echoRedirect("ok");
            }
            else
            {
                echoError(lang("exUnknowCmd"));
            }
        }
Beispiel #3
0
        public String getConnectLinks()
        {
            List <AuthConnectConfig> xlist = AuthConnectConfig.GetEnabledList();
            String lnk = Link.To(Site.Instance, new ConnectController().Login) + "?connectType=";

            StringBuilder sb = new StringBuilder();

            sb.Append("[");

            for (int i = 0; i < xlist.Count; i++)
            {
                sb.Append("{");
                sb.AppendFormat("\"name\":\"{0}\",", xlist[i].Name);
                sb.AppendFormat("\"lname\":\"{0}\",", strUtil.HasText(xlist[i].LoginName) ? xlist[i].LoginName : xlist[i].Name);
                sb.AppendFormat("\"link\":\"{0}\",", lnk + xlist[i].TypeFullName);
                sb.AppendFormat("\"logos\":\"{0}\",", xlist[i].LogoS);
                sb.AppendFormat("\"pick\":\"{0}\"", xlist[i].IsPick);
                sb.Append("}");

                if (i < xlist.Count - 1)
                {
                    sb.AppendFormat(",");
                }
            }

            sb.Append("]");
            return(sb.ToString());
        }
        public virtual void Delete(long id)
        {
            AuthConnectConfig x = AuthConnectConfig.GetById(id);

            x.delete();
            echoResult(null);
        }
Beispiel #5
0
        public void Edit(int id)
        {
            AuthConnectConfig x = AuthConnectConfig.GetById(id);

            bind("x", x);
            target(Update, id);
        }
Beispiel #6
0
        public void Delete(int id)
        {
            AuthConnectConfig x = AuthConnectConfig.GetById(id);

            x.delete();
            echoResult(null);
        }
        public virtual void Create()
        {
            AuthConnectConfig x = ctx.PostValue <AuthConnectConfig>("x");

            validatePost(x);

            if (ctx.HasErrors)
            {
                echoError();
                return;
            }

            x.insert();

            echoToParentPart(lang("opok"));
        }
        public virtual void Update(long id)
        {
            AuthConnectConfig x = AuthConnectConfig.GetById(id);

            x = ctx.PostValue(x, "x") as AuthConnectConfig;
            validatePost(x);

            if (ctx.HasErrors)
            {
                echoError();
                return;
            }

            x.update();

            echoToParentPart(lang("opok"));
        }
        public virtual void Pick(long id)
        {
            AuthConnectConfig x = AuthConnectConfig.GetById(id);

            if (x.IsPick == 1)
            {
                x.IsPick = 0;
            }
            else
            {
                x.IsPick = 1;
            }

            x.update();

            echoResult(null);
        }
Beispiel #10
0
        public virtual void connectLogin()
        {
            IBlock block = getBlock("connectWrap");
            List <AuthConnectConfig> xlist = AuthConnectConfig.GetEnabledList();

            if (xlist.Count == 0)
            {
                return;
            }

            String lnk = Link.To(Site.Instance, new ConnectController().Login) + "?connectType=";

            xlist.ForEach(x => x.data.show = lnk + x.TypeFullName);
            block.BindList("connects", "x", xlist);

            block.Next();
        }
Beispiel #11
0
        public void Stop(int id)
        {
            AuthConnectConfig x = AuthConnectConfig.GetById(id);

            if (x.IsStop == 1)
            {
                x.IsStop = 0;
            }
            else
            {
                x.IsStop = 1;
            }

            x.update();

            echoResult(null);
        }
 private void validatePost(AuthConnectConfig x)
 {
     if (strUtil.IsNullOrEmpty(x.Name))
     {
         errors.Add("请填写名称");
     }
     if (strUtil.IsNullOrEmpty(x.TypeFullName))
     {
         errors.Add("请填写TypeFullName");
     }
     if (strUtil.IsNullOrEmpty(x.ConsumerKey))
     {
         errors.Add("请填写ConsumerKey");
     }
     if (strUtil.IsNullOrEmpty(x.ConsumerSecret))
     {
         errors.Add("请填写ConsumerSecret");
     }
 }
        public void BindAccount()
        {
            List <AuthConnectConfig> list = AuthConnectConfig.GetAll();

            IBlock block = getBlock("list");

            foreach (AuthConnectConfig x in list)
            {
                if (x.IsStop == 1)
                {
                    continue;
                }

                block.Set("connect.Logo", x.LogoM);
                block.Set("connect.Name", x.Name);

                IBlock yBlock = block.GetBlock("bind");
                IBlock xBlock = block.GetBlock("unbind");

                String q = "?connectType=" + x.TypeFullName;

                UserConnect c = connectService.GetConnectInfo(ctx.viewer.Id, x.TypeFullName);
                if (c != null)
                {
                    yBlock.Set("connect.Uid", c.Uid);
                    yBlock.Set("connect.Name", c.Name);
                    yBlock.Set("connect.UnBindLink", to(new ConnectController().UnBind) + q);
                    yBlock.Set("connect.SyncLink", to(new ConnectController().Sync) + q);
                    yBlock.Set("connect.CheckSync", c.NoSync == 0 ? "checked=\"checked\"" : "");
                    yBlock.Next();
                }
                else
                {
                    xBlock.Set("connect.BindLink", to(new ConnectController().Bind) + q);
                    xBlock.Next();
                }

                block.Next();
            }
        }
        public virtual void Index()
        {
            List <AuthConnectConfig> list = AuthConnectConfig.GetAll();

            list.ForEach(x => {
                x.data["StatusStr"] = (x.IsStop == 1 ? "已停用" : "");
                x.data["StopCmd"]   = (x.IsStop == 1 ? "启用" : "停用");
                x.data["stop"]      = to(Stop, x.Id);

                x.data["PickStr"] = (x.IsPick == 1 ? "★" : "");
                x.data["PickCmd"] = (x.IsPick == 1 ? "取消前置" : "前置");
                x.data["pick"]    = to(Pick, x.Id);

                x.data["LoginName"] = strUtil.HasText(x.LoginName) ? "<span class=\"note\">(" + x.LoginName + ")</span>" : "";

                x.data.edit   = to(Edit, x.Id);
                x.data.delete = to(Delete, x.Id);
            });

            set("addLink", to(Add));
            set("sortAction", to(SaveSort));
            bindList("list", "x", list);
            set("totalCount", list.Count);
        }
Beispiel #15
0
        private string getConnectName(string connectType)
        {
            AuthConnectConfig x = AuthConnectConfig.GetByType(connectType);

            return(x == null ? "" : x.Name);
        }