Exemple #1
0
        protected override void ImplementBusinessLogic()
        {
            var info = Info;


            Data.Token = this.PostData.Token;
            Data.Items = new List <AuthItem>();
            Data.Token = this.PostData.Token;


            var user = new Soway.Model.SqlServer.ObjectContext <SOWAY.ORM.AUTH.User>(new bean.ConHelper().GetSysCon(), this).GetDetail(info.User.UserId);

            if (user != null)
            {
                var authuser = new SOWAY.ORM.AUTH.AuthoriezedFactory(new Model.App.Application()
                {
                    SysCon = info.AppSqlCon
                }, this).GetAuthrizedUser(user);
                List <SOWAY.ORM.AUTH.MenuItem> auths = new List <SOWAY.ORM.AUTH.MenuItem>();
                if (String.IsNullOrEmpty(this.Option.ParentAuthCode))
                {
                    auths = new SOWAY.ORM.AUTH.MenuItemFactory(info.CurrentSqlCon, this).GetTopMenus(authuser);
                }
                else
                {
                    auths = new SOWAY.ORM.AUTH.MenuItemFactory(info.CurrentSqlCon, this).GetMenus(authuser, System.Convert.ToInt64(this.Option.ParentAuthCode));
                }
                foreach (var menu in auths.OrderBy(p => p.Index))
                {
                    var item = new Login.V2.AuthItem()
                    {
                        Text     = menu.Text,
                        AuthType = AuthType.ListView,
                        ImageUrl = menu.Image,
                        Note     = menu.Text,
                        ViewId   = menu.ViewID,
                        ViewType = Soway.Service.Login.V1.ViewType.List,
                        Index    = menu.Index,

                        AuthNo = menu.ID.ToString()
                    };
                    Data.Items.Add(item);
                }
            }
            else
            {
                this.Result.Error = new ErrorInfo()
                {
                    Code    = ErrorDescription.TOKEN_INVALIDAT,
                    Message = ErrorDescription.TOKEN_INVALIDAT_MSG
                }
                ;
            }
        }
Exemple #2
0
        protected override void ImplementBusinessLogic()
        {
            var info = new CacheStore().Get(this.PostData.Token);

            if (info != null && info.User != null)
            {
                var user = new Soway.Model.SqlServer.ObjectContext <SOWAY.ORM.AUTH.User>(new bean.ConHelper().GetSysCon(), this).GetDetail(info.User.UserId);
                if (user != null)
                {
                    var authuser = new SOWAY.ORM.AUTH.AuthoriezedFactory(new Model.App.Application()
                    {
                        SysCon = info.AppSqlCon
                    }, this).GetAuthrizedUser(user);
                    List <SOWAY.ORM.AUTH.MenuItem> auths = new List <SOWAY.ORM.AUTH.MenuItem>();

                    auths = new SOWAY.ORM.AUTH.MenuItemFactory(info.CurrentSqlCon, this).GetTopMenus(authuser);
                    foreach (var menu in auths)
                    {
                        var item = new Login.V2.AuthItem()
                        {
                            Text     = menu.Text,
                            AuthType = AuthType.ListView,
                            ImageUrl = menu.Image,
                            Note     = menu.Text,
                            ViewId   = menu.ViewID,
                            ViewType = Login.V1.ViewType.List,
                            Index    = 0,

                            AuthNo = menu.ID.ToString()
                        };
                        Data.Items.Add(item);
                    }
                    //Data.UserID = user.ID;
                    //Data.UserShowName = user.Name;
                    //Data.UserAvtar = user.Str5;
                    //Data.IsLogin = true;


                    info.User.UserId       = user.UserID;
                    info.User.UserName     = user.FirstName + user.LastName;
                    info.User.UserAvtarUrl = user.Avtar;
                }
                else
                {
                    //Data.IsLogin = false;
                    Data.Error = new ErrorInfo(ErrorDescription.CODE_AUTHENTICATE_FAIL,
                                               ErrorDescription.MESSAGE_AUTHENTICATE_FAIL);
                }
            }
        }
Exemple #3
0
        protected override void ImplementBusinessLogic()
        {
            var info = this.Info;

            result.User    = info.User;
            result.Token   = this.PostData.Token;
            result.App     = info.App;
            result.TopMenu = new List <Login.V2.AuthItem>();


            var user = new Soway.Model.SqlServer.SqlContext <SOWAY.ORM.AUTH.User>(new bean.ConHelper().GetSysCon(), this).GetDetail(info.User.UserId);

            if (user != null)
            {
                var authuser = new SOWAY.ORM.AUTH.AuthoriezedFactory(new Model.App.Application()
                {
                    SysCon = info.AppSqlCon
                }, this).GetAuthrizedUser(user);
                List <SOWAY.ORM.AUTH.MenuItem> auths = new SOWAY.ORM.AUTH.MenuItemFactory(info.CurrentSqlCon, this).GetTopMenus(authuser);
                foreach (var menu in auths)
                {
                    var item = new Login.V2.AuthItem()
                    {
                        Text     = menu.Text,
                        AuthType = AuthType.ListView,
                        ImageUrl = menu.Image,
                        Note     = menu.Text,
                        ViewId   = menu.ViewID,
                        ViewType = Soway.Service.Login.V1.ViewType.List,
                        Index    = 1,
                        AuthNo   = menu.ID.ToString()
                    };
                    result.TopMenu.Add(item);
                }
            }
        }
Exemple #4
0
        protected override void ImplementBusinessLogic()
        {
            HandlerCheckCode checkcodeHandler = new HandlerCheckCode();
            bool             isCodeValid      = checkcodeHandler.Check(new bean.CheckCode()
            {
                Key = Option.CheckCodeKey, Code = Option.CheckCode
            });

            if (!isCodeValid)
            {
                Data.Error = new ErrorInfo(ErrorDescription.CHECK_CODE_ERROR,
                                           ErrorDescription.CHECK_CODE_ERROR_MSG);
                return;
            }
            global::Soway.Model.App.AppFac fac = new global::Soway.Model.App.AppFac(new bean.ConHelper().GetSysCon(), this);
            var app = fac.GetApp(Option.AppId, Option.AppKey);

            if (app != null)
            {
                var datacurrentCon = app.DataBase.FirstOrDefault(p => p.StoreBaseId.ToString().Trim().ToLower() == Option.DbId.Trim());
                if (datacurrentCon == null)
                {
                    Data.Error = new ErrorInfo(ErrorDescription.DB_SELECT_ERROR, ErrorDescription.DB_SELECT_ERROR_MSG);
                    return;
                }
                var user = new global::SOWAY.ORM.AUTH.LoginFactory(
                    new bean.ConHelper().GetSysCon(), this).Login(Option.UserId, Option.PassWord);
                if (user != null)
                {
                    var       authuser = new SOWAY.ORM.AUTH.AuthoriezedFactory(app, this).GetAuthrizedUser(user);
                    CacheInfo info     = new CacheInfo();
                    info.AppSqlCon           = app.SysCon;
                    info.CurrentDataBaseName = datacurrentCon.Name;
                    info.CurrentSqlCon       = datacurrentCon.Conection;
                    info.App = new AppInfo()
                    {
                        AppLogoUrl    = app.Avatar,
                        AppName       = app.Name,
                        AppNote       = app.Note,
                        AppPowerBy    = app.Company,
                        AppPowerUrl   = app.Url,
                        AppVer        = app.Version,
                        AppId         = app.APPID.ToString(),
                        DefaultViewId = app.DefaultView
                    };
                    info.User = new User.UserInfo()
                    {
                        UserId         = user.UserID,
                        UserName       = user.FirstName,
                        LoginName      = user.LoginName,
                        UserAvtarUrl   = user.Avtar,
                        CompanyName    = "",
                        DepartmentName = ""
                    };



                    try
                    {
                        ITokenAoStub stub = new LocaTokenAoStub();

                        Data.Token       = stub.getToken(3000, new TokenKeyGenerator().GetTokenKey(info.User, info.App));
                        Data.LoginSucess = true;
                    }
                    catch (Exception e)
                    {
                        //SowayLog.Log.Error("get token fail.", e);
                        Data.Error = new ErrorInfo(ErrorDescription.CODE_SYSTEM_ERROR, ErrorDescription.MESSAGE_SYSTEM_ERROR);
                    }

                    try
                    {
                        new CacheStore().Store(Data.Token, info);
                    }
                    catch (Exception sessionex)
                    {
                        //SowayLog.Log.Error("store session fail.", sessionex);
                        Data.Error = new ErrorInfo(ErrorDescription.SET_SESSION_FAIL,
                                                   ErrorDescription.SET_SESSION_FAIL_MSG);
                        return;
                    }
                }
                else
                {
                    Data.Error = new ErrorInfo(ErrorDescription.CODE_AUTHENTICATE_FAIL,
                                               ErrorDescription.MESSAGE_AUTHENTICATE_FAIL);
                }
            }
        }