Beispiel #1
0
        public static PERSPECTIVE_VIEW LookupView(PSsqmEntities ctx, string perspective, string viewName, decimal viewID, string nlsLanguage)
        {
            PERSPECTIVE_VIEW view = null;

            try
            {
                if (viewID > 0)
                {
                    view = (from v in ctx.PERSPECTIVE_VIEW.Include("PERSPECTIVE_VIEW_ITEM").Include("PERSPECTIVE_VIEW_LANG").Include("PERSPECTIVE_VIEW_ITEM.PERSPECTIVE_VIEW_ITEM_LANG")
                            where (v.VIEW_ID == viewID)
                            select v).SingleOrDefault();
                }
                else
                {
                    view = (from v in ctx.PERSPECTIVE_VIEW.Include("PERSPECTIVE_VIEW_ITEM").Include("PERSPECTIVE_VIEW_LANG").Include("PERSPECTIVE_VIEW_ITEM.PERSPECTIVE_VIEW_ITEM_LANG")
                            where (v.PERSPECTIVE == perspective && v.VIEW_NAME == viewName)
                            select v).SingleOrDefault();
                }


                if (view != null && nlsLanguage.ToLower() != "en")
                {
                    PERSPECTIVE_VIEW_LANG lang = view.PERSPECTIVE_VIEW_LANG.Where(v => v.NLS_LANGUAGE.ToLower() == nlsLanguage.ToLower()).FirstOrDefault();
                    if (lang != null)
                    {
                        view.VIEW_NAME = lang.VIEW_NAME;
                        view.VIEW_DESC = lang.VIEW_DESC;
                        PERSPECTIVE_VIEW_ITEM_LANG langItem = null;
                        foreach (PERSPECTIVE_VIEW_ITEM item in view.PERSPECTIVE_VIEW_ITEM)
                        {
                            if ((langItem = item.PERSPECTIVE_VIEW_ITEM_LANG.Where(i => i.NLS_LANGUAGE.ToLower() == nlsLanguage.ToLower()).FirstOrDefault()) != null)
                            {
                                item.TITLE       = langItem.TITLE;
                                item.SCALE_LABEL = langItem.SCALE_LABEL;
                                item.A_LABEL     = langItem.A_LABEL;
                                if (!string.IsNullOrEmpty(langItem.OPTIONS))
                                {
                                    item.OPTIONS = langItem.OPTIONS;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //SQMLogger.LogException(ex);
            }

            return(view);
        }
Beispiel #2
0
        public static List <PERSPECTIVE_VIEW> SelectFilteredViewList(string perspective, decimal personID, decimal companyID, decimal busOrgID, decimal plantID, bool activeOnly, string nlsLanguage)
        {
            List <PERSPECTIVE_VIEW> viewList = SelectViewList(perspective, companyID);
            List <PERSPECTIVE_VIEW> outList  = new List <PERSPECTIVE_VIEW>();

            foreach (PERSPECTIVE_VIEW view in viewList)
            {
                if (!activeOnly || (activeOnly && view.STATUS != "I"))
                {
                    if (view.AVAILABILTY == 4 || view.OWNER_ID == personID)
                    {
                        outList.Add(view);
                    }
                    else if ((view.AVAILABILTY == 3 && view.BUS_ORG_ID == busOrgID) || (view.AVAILABILTY == 2 && view.PLANT_ID == plantID))
                    {
                        outList.Add(view);
                    }
                    else
                    {
                        ;
                    }
                }
            }

            // get alternate language texts
            if (nlsLanguage != "en")
            {
                PERSPECTIVE_VIEW_LANG langView = null;
                {
                    foreach (PERSPECTIVE_VIEW view in outList)
                    {
                        if ((langView = view.PERSPECTIVE_VIEW_LANG.Where(v => v.NLS_LANGUAGE.ToLower() == nlsLanguage.ToLower()).FirstOrDefault()) != null)
                        {
                            view.VIEW_NAME = langView.VIEW_NAME;
                            view.VIEW_DESC = langView.VIEW_DESC;
                        }
                    }
                }
            }

            return(outList);
        }