public ActionResult submitSoapQuery()
        {
            try
            {
                String            json    = new StreamReader(this.Request.InputStream).ReadToEnd();
                TTLAPIRequestForm wrapper = (TTLAPIRequestForm)JsonConvert.DeserializeObject(json, typeof(TTLAPIRequestForm));
                TTLAPIRequest     form    = wrapper.form;

                // validate form OTP here
                var disable = ConstantDbContext.getInstance().findActiveByKeyNoTracking("INSTRUCTION_FORM_OTP_DISABLE");
                if (disable == null || disable.Value != "1")
                {
                    if (form.otp != null && form.otp != "")
                    {
                        BaseControllerSession session = getSession();

                        string email = session.email;

                        if (!(new UserCodeController().VerifyEmailCodeCombination(email, form.otp)))
                        {
                            return(this.Json(BaseResponse.MakeResponse("F002", null, null, "OTP Incorrect")));
                        }
                    }
                }
                var res = new APIController().callSoapQuery <object>(form);
                return(this.Json(BaseResponse.MakeResponse(res)));
            }
            catch (Exception e)
            {
                return(this.Json(BaseResponse.MakeResponse("F001", e)));
            }
        }
예제 #2
0
        BaseControllerSession MakeBaseControllerSession(TTLITradeWSDEV.clientLoginResponseLoginResp resp)
        {
            BaseControllerSession session = new BaseControllerSession();

            session.fullname         = resp.fullname;
            session.clientID         = resp.clientId;
            session.sessionID        = resp.sessionID;
            session.accountSeq       = resp.accountSeq;
            session.accountType      = resp.accountType;
            session.tradingAccSeq    = resp.tradingAccSeq;
            session.tradingAccStatus = resp.tradingAccStatus;
            session.tradingAccList   = Newtonsoft.Json.JsonConvert.SerializeObject(resp.tradingAccList);
            if (resp.tradingAccList != null && resp.tradingAccList.Length > 0)
            {
                var acc = resp.tradingAccList[0];
                if (acc != null)
                {
                    session.hasTradingAcc              = true;
                    session.ttL_accountSeqField        = acc.accountSeq;
                    session.ttL_accountTypeField       = acc.accountType;
                    session.ttL_defaultSubAccountField = acc.defaultSubAccount;
                    session.ttL_investorTypeIDField    = acc.investorTypeID;
                    session.ttL_tradingAccSeqField     = acc.tradingAccSeq;
                    session.ttL_tradingAccStatusField  = acc.tradingAccStatus;
                }
            }
            return(session);
        }
예제 #3
0
        public BaseControllerSession getSession(bool excludePostLogin = false)
        {
            BaseControllerSession session = new BaseControllerSession();

            session.isLoggedIn = false;

            if (!excludePostLogin)
            {
                if (Session["TTLClient"] != null)
                {
                    TTLITradeWSDEV.clientLoginResponseLoginResp resp = (TTLITradeWSDEV.clientLoginResponseLoginResp)(Session["TTLClient"]);
                    session            = MakeBaseControllerSession(resp);
                    session.isLoggedIn = true;

                    if (Session["TTLAccount"] != null)
                    {
                        TTLITradeWSDEV.queryAccountDetailsResponseQueryAccountDetailsResp resp2 = (TTLITradeWSDEV.queryAccountDetailsResponseQueryAccountDetailsResp)(Session["TTLAccount"]);
                        session.email = resp2.email;
                    }

                    if (Session["jsessionID"] != null)
                    {
                        string jsessionID = (string)Session["jsessionID"];
                        session.jsessionID = jsessionID;
                    }
                }
            }

            if (excludePostLogin || !session.isLoggedIn)
            {
                Session["isKeptAlive"] = false;
            }

            session.fontSize = SessionLogin.getFontSizeNormal();
            if (Session["fontSize"] != null)
            {
                session.fontSize = (int)Session["fontSize"];
            }

            if (Session["isKeptAlive"] != null)
            {
                session.isKeptAlive = (bool)Session["isKeptAlive"];
            }
            else
            {
                session.isKeptAlive = false;
            }

            return(session);
        }
        public ActionResult RegisterFromSession()
        {
            // register email and code combination into ip address controller
            // will expire within 15 minutes
            // will not register new code within 5 minute after register, but will refresh existing code's expiry time
            // will register & override with new code after 5 minute after register has passed
            // will also send email to the user

            try
            {
                BaseControllerSession session = getSession();

                string email = session.email;

                var res = RegisterEmailCodeCombination(email);

                return(this.Json(BaseResponse.MakeResponse(res)));
            }
            catch (Exception e)
            {
                return(this.Json(BaseResponse.MakeResponse("F001", e)));
            }
        }
        public ActionResult get_qpi_login_params()
        {
            /* QPI (Client side) */
            BaseControllerSession session = getSession();

            if (session == null)
            {
                return(this.Json(BaseResponse.MakeResponse(new Dictionary <string, string>
                {
                })));
            }

            string login_url      = "";
            string keep_alive_url = "";
            var    qpisession     = getSession();
            string jsessionid     = null;

            if (qpisession != null)
            {
                jsessionid = qpisession.jsessionID;
            }

            login_url = "http://uat.quotepower.com/web/geminis/login.jsp";
            var _constant = ConstantDbContext.getInstance().findActiveByKeyNoTracking("IFRAME_QPI_URL");

            if (_constant != null)
            {
                login_url = _constant.Value + "login.jsp";
            }


            keep_alive_url = "http://uat.quotepower.com/web/luso/json/heartbeat.jsp";
            _constant      = ConstantDbContext.getInstance().findActiveByKeyNoTracking("IFRAME_QPI_LUSO");
            if (_constant != null)
            {
                keep_alive_url = _constant.Value + "json/heartbeat.jsp";
            }

            string domain   = "GEMINIS";
            string uid      = session.clientID;
            string ts       = DateTime.Now.ToString("yyyyMMddHHmmss");
            string env_key  = "UAT";
            string password = "******";

            var enqstr = "";

            enqstr += "domain=" + domain;
            enqstr += "&uid=" + uid;
            enqstr += "&password="******"&ts=" + ts;
            enqstr += "&env_key=" + env_key;

            System.Security.Cryptography.SHA256Managed crypt = new System.Security.Cryptography.SHA256Managed();
            System.Text.StringBuilder hash = new System.Text.StringBuilder();
            byte[] crypto = crypt.ComputeHash(Encoding.UTF8.GetBytes(enqstr), 0, Encoding.UTF8.GetByteCount(enqstr));
            foreach (byte theByte in crypto)
            {
                hash.Append(theByte.ToString("x2"));
            }
            string hashstr = hash.ToString();

            return(this.Json(BaseResponse.MakeResponse(new Dictionary <string, string> {
                ["domain"] = domain,
                ["uid"] = uid,
                ["ts"] = ts,
                ["env_key"] = env_key,
                ["token"] = hashstr,
                ["password"] = password,
                ["login_url"] = login_url,
                ["keep_alive_url"] = keep_alive_url,
                ["jsessionid"] = jsessionid
            })));
        }
        public ActionResult login(string username, string password)
        {
            try
            {
                var res = new APIController().callSoapQuery <TTLITradeWSDEV.clientLoginResponseLoginResp>(
                    new TTLAPIRequest(
                        "clientLogin",
                        new Dictionary <string, object>
                {
                    ["ChannelID"]     = "INT",
                    ["ClientID"]      = username,
                    ["Password"]      = password,
                    ["TradingAccSeq"] = "-1",
                    ["Encrypt"]       = "Y",
                })
                    );

                //TTLITradeWSDEV.ItradeWebServicesClient soap = new TTLITradeWSDEV.ItradeWebServicesClient();
                var resp = (TTLITradeWSDEV.clientLoginResponseLoginResp)res;

                if (resp.errorCode != null || resp.errorMessage != null)
                {
                    return(this.Json(BaseResponse.MakeResponse("F001", resp.errorCode, null, resp.errorMessage)));
                }



                setSession(resp);


                BaseControllerSession session = getSession();


                if (session != null)
                {
                    try
                    {
                        var isNonTradingAccField = "1";
                        if (session.hasTradingAcc)
                        {
                            isNonTradingAccField = "-1";
                        }

                        var res2 = new APIController().callSoapQuery <TTLITradeWSDEV.queryAccountDetailsResponseQueryAccountDetailsResp>(
                            new TTLAPIRequest(
                                "queryAccountDetails",
                                new Dictionary <string, object>
                        {
                            ["ClientID"]             = session.clientID,
                            ["SessionID"]            = session.sessionID,
                            ["isNonTradingAccField"] = isNonTradingAccField,
                            ["version"]   = "1",
                            ["deviceID"]  = "",
                            ["osVersion"] = "1",
                        })
                            );

                        if (res2 != null)
                        {
                            setAccSession(res2);
                        }
                    }
                    catch (Exception e)
                    {
                        AuditLogDbContext.getInstance().createAuditLog(new AuditLog
                        {
                            action  = "queryAccountDetails",
                            remarks = "failed",
                        });
                    }
                }


                /*
                 * var jsession = loginQPI(username, password, resp);
                 *
                 * if (jsession.Result != null)
                 * {
                 *  setJSession(jsession.Result);
                 * }
                 */

                var is_sso_enabled = false;
                var sso_enabled    = ConstantDbContext.getInstance().findActiveByKeyNoTracking("SSO_enabled");
                if (sso_enabled != null &&
                    sso_enabled.Value != null)
                {
                    is_sso_enabled = sso_enabled.Value == "1";
                }

                SSO_UpsertUser(is_sso_enabled);

                return(this.Json(BaseResponse.MakeResponse(resp)));
            }
            catch (Exception e)
            {
                return(this.Json(BaseResponse.MakeResponse("F001", e)));
            }
        }
        public static SessionLogin UpsertSessionLogin(string sessionID, string userID, BaseControllerSession ttlsession, string jsessionID)
        {
            foreach (var sessionLogin in SessionLoginMap)
            {
                if (sessionLogin.sessionID == sessionID &&
                    sessionLogin.userID == userID)
                {
                    sessionLogin.keepaliveDate  = DateTime.Now;
                    sessionLogin.heartbeatDate  = DateTime.Now;
                    sessionLogin.isForcedExpire = false;
                    sessionLogin.ttlsession     = ttlsession;
                    sessionLogin.jsessionID     = jsessionID;
                    return(sessionLogin);
                }
            }

            SessionLogin sl = new SessionLogin();

            sl.sessionID      = sessionID;
            sl.userID         = userID;
            sl.keepaliveDate  = DateTime.Now;
            sl.heartbeatDate  = DateTime.Now;
            sl.isForcedExpire = false;
            sl.ttlsession     = ttlsession;
            sl.jsessionID     = jsessionID;
            SessionLoginMap.Add(sl);
            return(sl);
        }
예제 #8
0
        public static BaseViewModel make(string locale, string category, string id, HttpRequestBase request, BaseControllerSession session)
        {
            // locale

            if (locale == null)
            {
                locale = "zh-HK";
            }

            string language = "zh";
            string culture  = "HK";

            try
            {
                language = locale.Split('-')[0];
                culture  = locale.Split('-')[1];
            }
            catch (Exception e)
            {
            }

            if (culture != null && culture == "CN")
            {
                language = "cn";
            }

            if (culture != null && culture == "HK")
            {
                language = "zh";
            }

            if (culture != null && culture == "TW")
            {
                language = "zh";
            }


            GlobalData globalData = new GlobalData();

            globalData.implement_lbls(language);


            BaseViewModel vm = new BaseViewModel();

            vm.lang         = new Lang();
            vm.lang.locale  = locale;
            vm.lang.lang    = language;
            vm.lang.culture = culture;

            vm.globalData = globalData;

            vm.currentYear = DateTime.Now.Year.ToString();

            // sessions
            vm.current = new Current(session, null, null);



            // top warning

            vm.topWarningMessages = new List <string>();
            var systemMaintenanceNotifications = SystemMaintenanceNotificationDbContext.getInstance().findAllActivatedNotifications();

            foreach (var item in systemMaintenanceNotifications)
            {
                vm.topWarningMessages.Add(item.GetDesc(language));
            }

            // constants


            vm.constants = new List <Constant>();
            var constants = WebApplication2.Context.ConstantDbContext.getInstance().findActiveNoTracking();

            foreach (var constant in constants)
            {
                vm.constants.Add(constant);
            }


            // queries

            vm.queries = new List <Constant>();
            var keys = request.QueryString.Keys;

            for (var i = 0; i < keys.Count; i++)
            {
                var      val      = request.QueryString[keys[i]];
                Constant constant = new Constant();
                constant.Key      = keys[i];
                constant.Value    = val;
                constant.isActive = true;
                vm.queries.Add(constant);
            }

            if (vm.GetQuery("stock_code") == null)
            {
                Constant constant = new Constant();
                constant.Key      = "stock_code";
                constant.Value    = "00001";
                constant.isActive = true;
                vm.queries.Add(constant);
            }


            int articlelist_page = 1;
            int articlelist_size = 10;

            foreach (Constant constant in vm.queries)
            {
                if (constant.Key == "page")
                {
                    articlelist_page = int.Parse(constant.Value);
                }
                if (constant.Key == "size")
                {
                    articlelist_size = int.Parse(constant.Value);
                }
            }



            // category

            var db = WebApplication2.Context.InfrastructureCategoryDbContext.getInstance();

            WebApplication2.Models.Infrastructure.Category cat = null;


            // header data

            vm.headerData       = new ViewCategory(null, null);
            vm.headerData.title = "Geminis";


            // header menu

            vm.headerMenu = createHeaderMenu(0, vm.lang);

            vm.headerMenuRight = createHeaderMenuRight(0, vm.lang);

            // footer menu

            vm.footerMenu = createFooterMenu(0, vm.lang);


            // bottom menu

            vm.bottomMenu = createBottomMenu(0, vm.lang);


            // shortcut menu

            vm.shortcutMenu = createShortcutMenu(0, vm.lang);


            // jumbotron menu

            vm.jumbotronMenu = createJumbotronMenu(0, vm.lang);



            if (category != null && locale != null)
            {
                cat = db.findCategoryByURL(category);

                vm.category = new ViewCategory(cat, vm.lang);



                // breadcrumb data

                vm.breadcrumbData = createBreadcrumbData(vm.category.categoryItemID, vm.lang);


                // top bar menu

                if (cat != null && cat.pageShouldShowTopbarmenu && cat.parentItemID.HasValue)
                {
                    vm.topbarMenu = createSubmenu(cat.parentItemID.Value, vm.lang, false, false, false, false, false);
                }

                if (vm.topbarMenu != null && vm.topbarMenu.Count <= 0)
                {
                    vm.topbarMenu = null;
                }
                else if (vm.topbarMenu != null)
                {
                    foreach (Menu menuItem in vm.topbarMenu)
                    {
                        if (menuItem.category.categoryItemID == cat.ItemID)
                        {
                            menuItem.is_highlighted = true;
                        }
                        else
                        {
                            menuItem.is_highlighted = false;
                        }
                    }
                }
            }


            // content

            vm.content = null;

            if (cat != null)
            {
                if (cat.isArticleList)
                {
                    vm.category.type = "ArticleList";

                    WebApplication2.Models.ArticlePublished articlePublished = null;

                    if (id != null)
                    {
                        articlePublished = WebApplication2.Context.ArticlePublishedDbContext.getInstance().getArticlePublishedBySlugAndCategoryID(cat.ItemID, id, vm.lang.lang);
                    }

                    if (articlePublished != null)
                    {
                        vm.content                         = new ViewContent();
                        vm.content.name                    = articlePublished.Name;
                        vm.content.desc                    = articlePublished.Desc;
                        vm.content.slug                    = articlePublished.Slug;
                        vm.content.link                    = new Link(vm.lang.locale, cat.getUrl(), null, articlePublished.Slug);
                        vm.content.link.is_absolute        = false;
                        vm.content.link.is_external        = false;
                        vm.content.type                    = "Article";
                        vm.content.datetime                = articlePublished.datePublished;
                        vm.content.datetime_representation = articlePublished.getDatePublished();

                        var nextArticlePublished = WebApplication2.Context.ArticlePublishedDbContext.getInstance().getNextArticlePublishedBySlugAndCategoryID(cat.ItemID, id, vm.lang.lang);
                        var prevArticlePublished = WebApplication2.Context.ArticlePublishedDbContext.getInstance().getPrevArticlePublishedBySlugAndCategoryID(cat.ItemID, id, vm.lang.lang);

                        if (nextArticlePublished != null)
                        {
                            vm.nextContent      = new ViewContent();
                            vm.nextContent.name = nextArticlePublished.Name;
                            vm.nextContent.slug = nextArticlePublished.Slug;
                        }

                        if (prevArticlePublished != null)
                        {
                            vm.prevContent      = new ViewContent();
                            vm.prevContent.name = prevArticlePublished.Name;
                            vm.prevContent.slug = prevArticlePublished.Slug;
                        }
                    }
                    else
                    {
                        vm.content             = new ViewContent();
                        vm.content.articleList = new List <Listitem>();
                        var articleList = WebApplication2.Context.ArticlePublishedDbContext.getInstance().getArticlesPublishedByCategoryPaginated(cat, articlelist_size, articlelist_page, vm.lang.lang);
                        foreach (var article in articleList)
                        {
                            Listitem item = new Listitem();
                            item.name             = article.Name;
                            item.summary          = article.Excerpt;
                            item.link             = new Link(vm.lang.locale, cat.getUrl(), null, article.Slug);
                            item.link.is_absolute = false;
                            item.link.is_external = false;
                            vm.content.articleList.Add(item);
                        }
                        vm.content.articleListTotal       = WebApplication2.Context.ArticlePublishedDbContext.getInstance().getArticlesPublishedByCategoryTotalCount(cat, vm.lang.lang);
                        vm.content.articleListTotalPages  = vm.content.articleListTotal / articlelist_size;
                        vm.content.articleListPageSize    = articlelist_size;
                        vm.content.articleListCurrentPage = articlelist_page;
                        vm.content.articleListHasPrevPage = articlelist_page <= 1;
                        vm.content.articleListHasNextPage = articlelist_page >= vm.content.articleListTotalPages;
                        vm.content.type = "ArticleList";
                    }
                }

                else if (cat.isContentPage)
                {
                    vm.category.type = "ContentPage";

                    WebApplication2.Models.ArticlePublished contentPage = null;
                    var contentPages = WebApplication2.Context.ArticlePublishedDbContext.getInstance().getArticlesPublishedByCategory(cat, vm.lang.lang);
                    if (contentPages.Count > 0)
                    {
                        contentPage = contentPages[0];
                    }

                    if (contentPage != null)
                    {
                        vm.content                         = new ViewContent();
                        vm.content.name                    = contentPage.Name;
                        vm.content.desc                    = contentPage.Desc;
                        vm.content.slug                    = contentPage.Slug;
                        vm.content.link                    = new Link(vm.lang.locale, cat.getUrl(), contentPage.BaseArticleID + "", null);
                        vm.content.link.is_absolute        = false;
                        vm.content.link.is_external        = false;
                        vm.content.type                    = "ContentPage";
                        vm.content.datetime                = contentPage.datePublished;
                        vm.content.datetime_representation = contentPage.getDatePublished();
                    }
                }

                else

                {
                    vm.content = null;
                }
            }


            if (vm.content == null)
            {
                var error404cat = db.findCategoryByURL("page-not-found");

                if (error404cat != null)
                {
                    WebApplication2.Models.ArticlePublished contentPage = null;
                    var contentPages = WebApplication2.Context.ArticlePublishedDbContext.getInstance().getArticlesPublishedByCategory(error404cat, vm.lang.lang);
                    if (contentPages.Count > 0)
                    {
                        contentPage = contentPages[0];
                    }

                    if (contentPage != null)
                    {
                        vm.category.type = "ContentPage";

                        vm.content                         = new ViewContent();
                        vm.content.name                    = contentPage.Name;
                        vm.content.desc                    = contentPage.Desc;
                        vm.content.slug                    = contentPage.Slug;
                        vm.content.link                    = new Link(vm.lang.locale, cat.getUrl(), contentPage.BaseArticleID + "", null);
                        vm.content.link.is_absolute        = false;
                        vm.content.link.is_external        = false;
                        vm.content.type                    = "ContentPage";
                        vm.content.datetime                = contentPage.datePublished;
                        vm.content.datetime_representation = contentPage.getDatePublished();
                    }
                }
            }


            if (vm.content == null)
            {
                if (vm.category == null)
                {
                    vm.category = new ViewCategory();
                }

                vm.category.isNoContent = true;
                vm.isError      = true;
                vm.errorCode    = 404;
                vm.errorMessage = "Error: Page not found";
            }
            else
            {
                if (vm.category == null)
                {
                    vm.category = new ViewCategory();
                }

                vm.category.isNoContent = false;

                if (cat.pageClassName != null)
                {
                    vm.content.pageClassName = cat.pageClassName;
                }

                if (cat.isUseNewsArticleDetailsTemplate)
                {
                    vm.content.showArticleDetailsTemplate = true;
                }
                else
                {
                    vm.content.showArticleDetailsTemplate = false;
                }
            }


            return(vm);
        }
예제 #9
0
 public Current(BaseControllerSession session, Account me, ViewCategory page)
 {
     this.session = session;
     this.me      = me;
     this.page    = page;
 }