Esempio n. 1
0
        private async Task <bool> SetServiceFilter(HttpContext context)
        {
            bool bHasSet = false;
            //if the search is using a serviceid filter, set the service
            string sServiceId
                = DataHelpers.GetFormValue(this.SearchManagerData.SearchResult, SERVICE_ID);

            if (string.IsNullOrEmpty(sServiceId))
            {
                //look in the querystring
                sServiceId = context.Request.Query[SERVICE_ID].ToString();
                //sServiceId = context.Request.QueryString[SERVICE_ID];
            }
            int iServiceId = 0;

            int.TryParse(sServiceId, out iServiceId);
            if (iServiceId != 0)
            {
                ContentService contentService = new ContentService(this.SearchManagerData.SearchResult);
                //app won't change but service filter will be set
                bHasSet = await contentService.SetServiceAndChangeAppAsync(this.SearchManagerData.SearchResult,
                                                                           iServiceId);

                contentService.Dispose();
            }
            return(bHasSet);
        }
Esempio n. 2
0
 private void SetNetworkTypeFromForm(HttpContext context)
 {
     if (context.Request != null)
     {
         string sNetworkType
             = DataHelpers.GetFormValue(this.SearchManagerData.SearchResult, NETWORK_FILTER_TYPE);
         //public searches don't have a network filter type
         this.SearchManagerData.NetworkType
             = DataAppHelpers.Networks.NETWORK_FILTER_TYPES.none;
         if (string.IsNullOrEmpty(sNetworkType))
         {
             if (this.SearchManagerData.SearchResult.URIMember.ClubInUse.PKId
                 != 0)
             {
                 //default search for logged in member is through myagreement
                 this.SearchManagerData.NetworkType
                     = DataAppHelpers.Networks.NETWORK_FILTER_TYPES.myagreement;
             }
         }
         else
         {
             this.SearchManagerData.NetworkType
                 = (DataAppHelpers.Networks.NETWORK_FILTER_TYPES)Enum.Parse(typeof(DataAppHelpers.Networks.NETWORK_FILTER_TYPES), sNetworkType);
             //= DataAppHelpers.Networks.GetNetworkFilter(sNetworkType);
         }
     }
     else
     {
         this.SearchManagerData.NetworkType
             = DataAppHelpers.Networks.NETWORK_FILTER_TYPES.none;
     }
 }
Esempio n. 3
0
        public void GetNewAction(HttpContext context,
                                 ref DataHelpers.SERVER_ACTION_TYPES serverActionType)
        {
            //url started with one action, but the ajax request might be for another ...
            string sNewContentURIPattern = GetRequestParam(context, CONTENT_PATTERN);

            if (string.IsNullOrEmpty(sNewContentURIPattern))
            {
                sNewContentURIPattern = GetRequestParam(context, Helpers.IOHelper.FILE_UPLOAD_URI);
            }
            if (!string.IsNullOrEmpty(sNewContentURIPattern))
            {
                //don't build a ContentURI because networkname uses a db hit
                string controller            = string.Empty;
                string action                = string.Empty;
                string networkName           = string.Empty;
                string nodeName              = string.Empty;
                string name                  = string.Empty;
                string id                    = string.Empty;
                string fileNameExtensionType = string.Empty;
                string subAction             = string.Empty;
                string subActionView         = string.Empty;
                string variable              = string.Empty;
                ContentURI.GetContentURIParams(sNewContentURIPattern,
                                               out controller, out action,
                                               out networkName, out nodeName, out name,
                                               out id, out fileNameExtensionType, out subAction,
                                               out subActionView, out variable);
                if (!string.IsNullOrEmpty(action))
                {
                    serverActionType = DataHelpers.GetServerAction(action);
                }
            }
        }
Esempio n. 4
0
 public static void GetRowArgs(Dictionary <string, string> rowArgs,
                               int pageSize, out int startRow, out string isForward, out int parentStartRow)
 {
     if (rowArgs != null)
     {
         string sOldStartRow = DataHelpers.GetFormValue(rowArgs, StylesheetHelper.START_ROW_TYPES.oldstartrow.ToString());
         int    iOldStartRow = (string.IsNullOrEmpty(sOldStartRow)) ? 0 : DataHelpers.ConvertStringToInt(sOldStartRow);
         string sStartRow    = DataHelpers.GetFormValue(rowArgs, StylesheetHelper.START_ROW_TYPES.startrow.ToString());
         startRow = (string.IsNullOrEmpty(sStartRow)) ? 0 : DataHelpers.ConvertStringToInt(sStartRow);
         //0=back; 1=forward
         isForward = DataHelpers.GetFormValue(rowArgs, StylesheetHelper.START_ROW_TYPES.isforward.ToString());
         isForward = (string.IsNullOrEmpty(isForward)) ? "-1" : isForward;
         //pageSize = 0;
         //do some rules here
         GetStartRow(iOldStartRow, isForward, pageSize, ref startRow);
         if (isForward == "-1")
         {
             //search records will return startrow + pagesize records
             isForward = "1";
         }
         //parent toc clicks return to same starting row and when children were clicked
         string sParentStartRow = DataHelpers.GetFormValue(rowArgs, StylesheetHelper.START_ROW_TYPES.parentstartrow.ToString());
         parentStartRow = (string.IsNullOrEmpty(sParentStartRow)) ? 0 : DataHelpers.ConvertStringToInt(sParentStartRow);
     }
     else
     {
         startRow  = 0;
         isForward = "1";
         //pageSize = 0;
         parentStartRow = 0;
     }
 }
Esempio n. 5
0
        public async Task <bool> SetSearchDataForAllUsers(HttpContext context,
                                                          string controller, ISearchService searchService, bool isAdminSearch)
        {
            bool bHasSet = false;

            //set servicegroup properties
            this.SearchManagerData.ServiceGroups = await searchService.GetServiceGroupsAsync(
                this.SearchManagerData, this.SearchManagerData.SearchResult.URIService.Service.ServiceClassId);

            //set network group properties
            this.SearchManagerData.NetworkGroups = await searchService.GetNetworkGroupsAsync(
                this.SearchManagerData, controller);

            bool bIsAdminApp = DataHelpers.IsAdminApp(this.SearchManagerData.SearchResult.URIDataManager.AppType);

            if (!bIsAdminApp)
            {
                //these apps use the searchtype properties
                int iServiceGroupId = (int)this.SearchManagerData.SearchResult.URIDataManager.SubAppType;
                this.SearchManagerData.SearchTypes
                    = await searchService.GetSearchTypesByNetworkIdAndServiceGroupIdAsync(
                          this.SearchManagerData, this.SearchManagerData.SearchResult.URIDataManager.SubAppType,
                          this.SearchManagerData.TypeId, this.SearchManagerData.SearchResult.URINetwork.PKId,
                          iServiceGroupId);
            }
            bHasSet = true;
            return(bHasSet);
        }
Esempio n. 6
0
        public ContentURI SetInitialModelProperties(
            ContentURI initialURI, HttpContext context,
            string controller, string action, string partialUriPattern)
        {
            //set any params sent in request body
            SetModel(context, controller, action, partialUriPattern);
            //set misc other params sent by client
            SetModelPropsFromForm();
            //set apps, subapps and servicegroups
            DataHelpers.SetApps(_uri);

            //copy appsettings and configs from initialuri to _uri
            DevTreks.Data.Helpers.AppSettings.CopyURIAppSettings(initialURI, _uri);
            //set additional appsettings from request (should be done with context after)
            //absolute web path: comes from ms.aspnet.http.extensions
            //http://localhost/greentreks/search/etc...
            DevTreks.Data.Helpers.AppSettings.SetAbsoluteURLPath(_uri, context.Request.GetDisplayUrl());
            //context.Request.GetEncodedUrl() can also be used, but no difference with these urls

            //NOTE: If Networks are used to store data in separate databases,
            //use _uri.URINetworkPartName or _uri.URINetwork to find the corresponding
            //connection string from usersecrets and instead of storing all content in
            //commontreks, store it the same as resources (i.e. network_ag .., but admin pattern must be changed too)

            return(_uri);
        }
Esempio n. 7
0
        public static double GetDoubleValue(string value)
        {
            double dbValue = (isNumber(value))
                ? DataHelpers.ConvertStringToDouble(value) : 0;

            return(dbValue);
        }
Esempio n. 8
0
        public static int GetIntValue(string value)
        {
            int iValue = (isNumber(value))
                ? DataHelpers.ConvertStringToInt(value) : 0;

            return(iValue);
        }
Esempio n. 9
0
 public static void GetRouteValues(Microsoft.AspNetCore.Routing.RouteData route, out string controller,
                                   out string action, out string partialUriPattern)
 {
     controller = (route.Values[CONTROLLER] != null) ?
                  route.Values[CONTROLLER].ToString() : DataHelpers.GetDefaultNetworkGroupName();
     action = (route.Values[ACTION] != null) ?
              route.Values[ACTION].ToString() : DataHelpers.SERVER_ACTION_TYPES.search.ToString();
     partialUriPattern = (route.Values[CONTENTURIPATTERN] != null) ?
                         route.Values[CONTENTURIPATTERN].ToString() : DataHelpers.MakeURIPatternStart();
 }
Esempio n. 10
0
        //[HttpPost]
        public async Task <ActionResult> LinkedViews(string contenturipattern)
        {
            contenturipattern = (string.IsNullOrEmpty(contenturipattern)) ? DataHelpers.MakeURIPatternStart()
                : contenturipattern;
            DataHelpers.SERVER_ACTION_TYPES eServerActionType
                = DataHelpers.SERVER_ACTION_TYPES.linkedviews;
            ViewDataHelper viewHelper = new ViewDataHelper();

            viewHelper.GetNewAction(this.HttpContext, ref eServerActionType);
            return(await this.GeneralAction(contenturipattern, eServerActionType));
        }
Esempio n. 11
0
 private void SetModelParams()
 {
     //rare, but qry string and form params can change these params
     _uri.URIDataManager.ClientActionType = (!string.IsNullOrEmpty(DataHelpers.GetFormValue(_uri, CLIENT_ACTION)))
             ? (DataHelpers.CLIENTACTION_TYPES)Enum.Parse(typeof(DataHelpers.CLIENTACTION_TYPES),
                                                          DataHelpers.GetFormValue(_uri, CLIENT_ACTION)) : DataHelpers.CLIENTACTION_TYPES.postrequest;
     //this assumes a 1-1 relation between serveractiontype and updatepaneltype
     //in the current mvc pattern, that's true, but if it becomes false
     //add an updatepanel type argument to the ajax client click event
     _uri.URIDataManager.UpdatePanelType = (DataHelpers.UPDATE_PANEL_TYPES)_uri.URIDataManager.ServerActionType;
 }
Esempio n. 12
0
        public async Task <ActionResult> Search(string contenturipattern)
        {
            contenturipattern = (string.IsNullOrEmpty(contenturipattern)) ?
                                DataHelpers.MakeURIPatternStart() : contenturipattern;
            //check for redirections from ajax content requests or subserveractiontypes
            DataHelpers.SERVER_ACTION_TYPES eServerActionType
                = DataHelpers.SERVER_ACTION_TYPES.search;
            ViewDataHelper viewHelper = new ViewDataHelper();

            viewHelper.GetNewAction(this.HttpContext, ref eServerActionType);
            return(await this.GeneralAction(contenturipattern, eServerActionType));
        }
Esempio n. 13
0
        //[ChildActionOnly]
        public async Task <ActionResult> ContentAction(string contenturipattern = "")
        {
            contenturipattern = (string.IsNullOrEmpty(contenturipattern)) ?
                                DataHelpers.MakeURIPatternStart() : contenturipattern;
            string sViewName = ViewDataHelper.CONTENT_VIEW;
            string sTitle    = string.Empty;

            ViewData["NetworkGroup"] = AG_TREKS;
            //construct the viewdata model
            ContentViewModel vwContentViewModel = new ContentViewModel(_uri);

            try
            {
                //agtreks shares the same actions as other networkgroups (i.e. buildtreks),
                //so a contentviewdata class is used by all
                bool bHasSet = await vwContentViewModel.SetViewAsync(this.RouteData, this.Request.HttpContext,
                                                                     _contentService, _memberService, contenturipattern);

                sViewName         = vwContentViewModel.ViewName;
                sTitle            = vwContentViewModel.Title;
                ViewData["Title"] = sTitle;
                ViewData["URI"]   = vwContentViewModel.ContentURIData.URIFull ?? string.Empty;
                //return the model to the view
                if (sViewName == ViewDataHelper.MESSAGE_VIEW)
                {
                    //respond with the message
                    ViewData[ViewDataHelper.MESSAGE_VIEW] = vwContentViewModel.ContentURIData.Message;
                    return(View(sViewName));
                }
                else if (sViewName == ViewDataHelper.ERROR_VIEW)
                {
                    //respond with the error message
                    ViewData[ViewDataHelper.ERROR_VIEW] = vwContentViewModel.ContentURIData.ErrorMessage;
                    return(View(sViewName));
                }
                else if (sViewName == ViewDataHelper.JSON_VIEW)
                {
                    //respond with the javascript
                    return(Json(vwContentViewModel.ContentURIData.Json));
                }
                //respond with the model
                return(View(sViewName, vwContentViewModel));
            }
            catch (Exception x)
            {
                AppHelper.SetErrorMessage(x, vwContentViewModel.ContentURIData);
                _logger.LogError(x.Message);
                return(View(sViewName, vwContentViewModel));
            }
        }
Esempio n. 14
0
        public async Task <bool> SetViewAsync(
            RouteData route, HttpContext context,
            ISearchService searchService, IMemberService memberService,
            string partialUriPattern)
        {
            bool   bHasSet            = false;
            string sViewName          = this.ViewName;
            string sTitle             = this.Title;
            bool   bIsInitView        = false;
            string sController        = string.Empty;
            string sAction            = string.Empty;
            string sContenturipattern = string.Empty;

            ViewDataHelper.GetRouteValues(route, out sController,
                                          out sAction, out sContenturipattern);
            //?? can get and post actions can be differentiated by this parameter
            if (partialUriPattern == string.Empty)
            {
                partialUriPattern = sContenturipattern;
            }
            ViewDataHelper.GetViews(route, context, sController,
                                    out bIsInitView, ref sViewName, ref sTitle);
            this.ViewName = sViewName;
            this.Title    = sTitle;
            bHasSet       = await SetSearchModel(context, sController, sAction, bIsInitView,
                                                 partialUriPattern, searchService, memberService);

            bool bIsNetworkingSearch = IsNetworkingSearch();

            bHasSet = await SetSearchDataForAllUsers(context, sController, searchService,
                                                     bIsNetworkingSearch);

            if (!HtmlMemberExtensions.UserIsLoggedIn(context))
            {
                bHasSet = await SetSearchDataForPublicMember(searchService,
                                                             bIsNetworkingSearch);
            }
            else
            {
                bHasSet = await SetSearchDataForLoggedinMember(searchService,
                                                               bIsNetworkingSearch);
            }
            //set the restful addresses
            DataHelpers.SetFullURIs(this.SearchManagerData.SearchResult);
            //publish error messages
            AppHelper.PublishErrorMessage(this.SearchManagerData.SearchResult);
            return(bHasSet);
        }
Esempio n. 15
0
 public void SetModelPropsFromForm()
 {
     if (_uri.URIDataManager.FormInput != null)
     {
         string sSelectionsNodeNeededName
             = DataHelpers.GetFormValue(_uri,
                                        DevTreks.Data.EditHelpers.AddHelperLinq.SELECT_EXISTING_PARAMS.selectionsnodeneededname.ToString());
         _uri.URIDataManager.SelectionsNodeNeededName
             = (sSelectionsNodeNeededName == null)
             ? string.Empty : sSelectionsNodeNeededName;
     }
     else
     {
         _uri.URIDataManager.SelectionsNodeNeededName = string.Empty;
     }
 }
Esempio n. 16
0
        public static string GetNetworkGroupFromRoute(
            Microsoft.AspNetCore.Routing.RouteData route, HttpContext context)
        {
            string sNetworkGroupName = string.Empty;

            if (route != null)
            {
                sNetworkGroupName = (!string.IsNullOrEmpty(route.Values[CONTROLLER].ToString())) ?
                                    route.Values[CONTROLLER].ToString().ToLower()
                    : DataHelpers.GetDefaultNetworkGroupName();
            }
            else
            {
                sNetworkGroupName = DataHelpers.GetDefaultNetworkGroupName();
            }
            return(sNetworkGroupName);
        }
Esempio n. 17
0
        private void SetSearchType(HttpContext context)
        {
            string sTypeId
                = DataHelpers.GetFormValue(this.SearchManagerData.SearchResult, TYPE_ID);

            if (string.IsNullOrEmpty(sTypeId))
            {
                //look in the querystring
                sTypeId = context.Request.Query[TYPE_ID].ToString();
                //sTypeId = context.Request.QueryString[TYPE_ID];
            }
            //init with all categories
            int iTypeId = 0;

            int.TryParse(sTypeId, out iTypeId);
            this.SearchManagerData.TypeId = iTypeId;
        }
Esempio n. 18
0
        public async Task <bool> AddGoodContentAndMemberToNewURIAsync(HttpContext context,
                                                                      IContentService contentService, IMemberService memberService,
                                                                      ContentURI uri)
        {
            //set uri props needed to get a good filepath
            //set apps, subapps and servicegroups
            GenHelpers.SetApps(uri);
            //set member and club
            bool bIsInitView = true;
            bool bHasSet     = await SetClubAndMemberAsync(context, bIsInitView, memberService, uri);

            //set the service for context app (or file paths will be to agreements not apps)
            bHasSet = await contentService.SetServiceAndChangeAppAsync(uri, uri.URIId);

            //set content model properties
            bHasSet = await contentService.SetContentModelAndAncestorsAsync(memberService, uri, bIsInitView);

            return(bHasSet);
        }
Esempio n. 19
0
 private void SetKeywords(HttpContext context)
 {
     this.SearchManagerData.Keywords
         = DataHelpers.GetFormValue(this.SearchManagerData.SearchResult, KEYWORDS);
     if (string.IsNullOrEmpty(this.SearchManagerData.Keywords))
     {
         if (this.SearchManagerData.SearchResult != null)
         {
             if (!string.IsNullOrEmpty(this.SearchManagerData.SearchResult.URIName))
             {
                 this.SearchManagerData.Keywords = this.SearchManagerData.SearchResult.URIName;
             }
             else
             {
                 this.SearchManagerData.Keywords = DataHelpers.NONE;
             }
         }
     }
 }
Esempio n. 20
0
        public static void SetErrorMessage(Exception x, DevTreks.Data.ContentURI uri)
        {
            //move this to error component and tie in with help file system
            //dynamic help, dynamic messaging
            string sExceptionMessage = x.ToString();
            string sErrorMessage     = string.Empty;

            if (uri.URIDataManager != null)
            {
                //the error was generated by the search page
                if (uri.URIService == null)
                {
                    uri.URIService = new AccountToService();
                }
                if (uri.URIMember == null)
                {
                    uri.URIMember = new AccountToMember();
                }
                if (uri.URIMember.ClubInUse == null)
                {
                    uri.URIMember.ClubInUse = new Account();
                }
                sErrorMessage += (x.InnerException == null) ? string.Empty : x.InnerException.ToString();
                sErrorMessage  = string.Concat(sExceptionMessage, "</ br>", uri.ErrorMessage);
                string[] arrErrorMessage = { uri.URIDataManager.ServerActionType.ToString(),
                                             uri.URIDataManager.AppType.ToString(),
                                             uri.URIDataManager.SubAppType.ToString(),
                                             uri.URINodeName,
                                             uri.URIId.ToString(),
                                             uri.URIService.PKId.ToString(),
                                             uri.URIMember.ClubInUse.ToString(),
                                             sErrorMessage };
                uri.ErrorMessage = PublishError(uri, x.InnerException,
                                                DataHelpers.MakeStringWithDelimiter(arrErrorMessage,
                                                                                    DataHelpers.STRING_DELIMITER));
            }
            else
            {
                //xml document or file upload error
                uri.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(string.Empty, "APPHELPER_WHOKNOWS");
            }
        }
Esempio n. 21
0
        public static void PublishErrorMessage(DevTreks.Data.ContentURI uri)
        {
            string sErrorMessage = string.Empty;

            if (!string.IsNullOrEmpty(uri.ErrorMessage))
            {
                if (uri.URIDataManager == null)
                {
                    uri.URIDataManager = new DevTreks.Data.ContentURI.DataManager();
                }
                //the error was generated by the search page
                if (uri.URIService == null)
                {
                    uri.URIService = new AccountToService();
                }
                if (uri.URIMember == null)
                {
                    uri.URIMember = new AccountToMember();
                }
                if (uri.URIMember.ClubInUse == null)
                {
                    uri.URIMember.ClubInUse = new Account();
                }
                string[] arrErrorMessage = { uri.URIDataManager.ServerActionType.ToString(),
                                             uri.URIDataManager.AppType.ToString(),
                                             uri.URIDataManager.SubAppType.ToString(),
                                             uri.URINodeName,
                                             uri.URIId.ToString(),
                                             uri.URIService.PKId.ToString(),
                                             uri.URIMember.ClubInUse.ToString(),
                                             uri.ErrorMessage };
                //160 changed from getneworkpath to this
                string sErrorPath = string.Concat(DevTreks.Data.Helpers.AppSettings.GetResourceRootPath(uri, false),
                                                  DevTreks.Exceptions.DevTreksErrors.ERRORFOLDERNAME, DataHelpers.FILE_PATH_DELIMITER);
                uri.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.Publish(DataHelpers.MakeStringWithDelimiter(arrErrorMessage,
                                                                                                                  DataHelpers.STRING_DELIMITER), sErrorPath);
            }
        }
Esempio n. 22
0
        public ExtensionNetwork()
        {
            int    iNetworkId        = -1;
            string sNetworkName      = string.Empty;
            string sNetworkPartName  = string.Empty;
            int    iNetworkGroupId   = 0;
            string sNetworkGroupName = string.Empty;

            this.Id                 = 1;
            this.NetworkId          = iNetworkId;
            this.NetworkName        = sNetworkName;
            this.NetworkURIPartName = sNetworkPartName;
            this.NetworkDescription = "default commons network";
            this.URIFull            = string.Empty;
            //version 2.0.0 standardized on uri.uridatamngr.appsettings
            this.AdminConnection   = string.Empty;
            this.WebFileSystemPath = DataGeneralHelpers.GetDefaultNetworkGroupName();
            this.WebConnection     = string.Empty;
            this.WebDbPath         = string.Empty;
            this.XmlConnection     = string.Empty;
            this.NetworkGroupId    = iNetworkGroupId;
            this.NetworkGroupName  = sNetworkGroupName;
        }
Esempio n. 23
0
        public async Task <ContentURI> MakeNewURIWithGoodContentAndMemberAsync(Microsoft.AspNetCore.Http.HttpContext context,
                                                                               IContentService contentService, IMemberService memberService,
                                                                               ContentURI uri, string newURIPattern)
        {
            ContentURI oNewURI = ContentURI.ConvertShortURIPattern(newURIPattern, uri.URINetwork);

            oNewURI.URIDataManager.FormInput = uri.URIDataManager.FormInput;
            //set uri props needed to get a good filepath
            //set apps, subapps and servicegroups
            GenHelpers.SetApps(oNewURI);
            //set misc. properties needed by subsequent methods
            oNewURI.URIDataManager.PageSize = uri.URIDataManager.PageSize;
            //set member and club
            bool bIsInitView = true;
            bool bHasSet     = await SetClubAndMemberAsync(context, bIsInitView, memberService, oNewURI);

            //set the service for context app (or file paths will be to agreements not apps)
            bHasSet = await contentService.SetServiceAndChangeAppAsync(oNewURI, oNewURI.URIId);

            //set content model properties
            bHasSet = await contentService.SetContentModelAndAncestorsAsync(memberService, oNewURI, bIsInitView);

            return(oNewURI);
        }