Exemplo n.º 1
0
        public List <Application> GetApplications(ISurfaceUnitOfWork surfaceUnitOfWork)
        {
            List <Application> queryApplications = new List <Application>();

            try {
                queryApplications = (from application in surfaceUnitOfWork.SURF_ApplicationRepository.Table()
                                     select new Application {
                    Id = application.Id,
                    ApplicationCode = application.ApplicationCode,
                    RedirectKey = application.RedirectValue,
                    RedirectValue = application.RedirectValue,
                    UrlTag = application.UrlTag,
                    LastUpdateDate = application.LastUpdateDate,
                    LastUpdateUserCode = application.LastUpdateUserCode,
                    RecordStatus = application.RecordStatus,
                    GatewayUrl = application.GatewayUrl,
                    ApplicationName = application.ApplicationCode,
                    EsbApplicationCode = application.EsbApplicationCode,
                    Port = application.Port
                }).ToList();

                log.InfoFormat("Applications get from SurfaceDb");
            }
            catch (Exception ex) {
                log.ErrorFormat("{0}-{1}-{2}", "ApplicationData was get from SurfaceDb", "MenuService-GetApplications", "Error: " + ex);
            }

            return(queryApplications);
        }
Exemplo n.º 2
0
        public List <dynamic> GetMenus(ISurfaceUnitOfWork surfaceUnitOfWork)
        {
            string   tenantCode    = EsbContextOperation.GetTenantCode();
            string   status        = "fail";
            DateTime startDateTime = DateTime.Now;

            try {
                log.InfoFormat("{0}-{1}", "GetMenusStart", menuGuid);
                List <dynamic> menus   = new List <object>();
                var            results = (from menuItem in surfaceUnitOfWork.SURF_MenuRepository.Table()
                                          join menuHierarcy in surfaceUnitOfWork.SURF_MenuHierarcyRepository.Table() on menuItem.Id equals menuHierarcy.MenuId
                                          join application in surfaceUnitOfWork.SURF_ApplicationRepository.Table() on menuItem.ApplicationCode equals application.ApplicationCode
                                          where menuItem.RecordStatus == true && application.RecordStatus == true && menuItem.TenantCode == tenantCode
                                          select new {
                    menuItem.Id,
                    Text = menuItem.StringKey,
                    menuItem.ScreenCode,
                    ParentId = menuHierarcy.ParentMenuId,
                    Icon = menuItem.IconCode,
                    menuItem.TenantCode,
                    Application = application.ApplicationCode,
                    application.GatewayUrl,
                    menuItem.IsVisible,
                    menuHierarcy.MenuOrder,
                    menuItem.TranCode
                }).ToList();

                foreach (var item in results)
                {
                    menus.Add(item);
                }

                TimeSpan timeSpan = DateTime.Now - startDateTime;
                status = "ok";
                log.InfoFormat("{0}-{1}-{2}-{3}", "GetMenusSuccess", menuGuid, timeSpan.TotalMilliseconds, status);
                return(menus);
            }
            catch (Exception ex) {
                log.ErrorFormat("{0}-{1}-{2}", "GetMenus", menuGuid, ex);
                throw;
            }
            finally {
                TimeSpan timeSpan = DateTime.Now - startDateTime;
                log.InfoFormat("{0}-{1}-{2}-{3}", "GetMenusFinally", menuGuid, timeSpan, status);
            }
        }