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);
        }
        public async Task <bool> SetService(HttpContext context)
        {
            //the search page's service drop down list selection is
            //added to the partialUriPattern being searched
            bool bHasSet = false;

            if (this.SearchManagerData.SearchResult.URINodeName.StartsWith(
                    DataAppHelpers.Agreement.AGREEMENT_TYPES.service.ToString()))
            {
                //service nodes can cause apps to change
                ContentService contentService = new ContentService(this.SearchManagerData.SearchResult);
                bHasSet = await contentService.SetServiceAndChangeAppAsync(this.SearchManagerData.SearchResult,
                                                                           this.SearchManagerData.SearchResult.URIId);

                contentService.Dispose();
            }
            else
            {
                if (this.SearchManagerData.SearchResult.URIDataManager.FormInput != null &&
                    this.SearchManagerData.SearchResult.URIDataManager.ServerSubActionType ==
                    DataHelpers.SERVER_SUBACTION_TYPES.searchbyservice)
                {
                    bHasSet = await SetServiceFilter(context);
                }
            }
            return(bHasSet);
        }
Beispiel #3
0
        public static async Task <XmlDocument> GetEditDocAsync(ContentURI uri)
        {
            XmlDocument oDevTrekDoc = null;

            if (uri.URIDataManager.UseSelectedLinkedView == false)
            {
                if (await DataHelpers.FileStorageIO.URIAbsoluteExists(
                        uri, uri.URIClub.ClubDocFullPath))
                {
                    oDevTrekDoc = new XmlDocument();
                    XmlReader reader = await DataHelpers.FileStorageIO.GetXmlReaderAsync(uri,
                                                                                         uri.URIClub.ClubDocFullPath);

                    if (reader != null)
                    {
                        using (reader)
                        {
                            oDevTrekDoc.Load(reader);
                        }
                    }
                }
                else
                {
                    //files should already be on hand
                    uri.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                        string.Empty, "EDITHELPER_NOEDITDOC");
                }
            }
            else
            {
                //uri is selectedLinkedViewURI
                IContentService contentService      = new ContentService(uri);
                XmlReader       oSelectedViewReader = await contentService.GetURISecondBaseDocAsync(uri);

                contentService.Dispose();
                if (oSelectedViewReader != null)
                {
                    using (oSelectedViewReader)
                    {
                        oDevTrekDoc = new XmlDocument();
                        oDevTrekDoc.Load(oSelectedViewReader);
                    }
                }
                if (oDevTrekDoc == null)
                {
                    //database xmldoc fields should already be on hand
                    uri.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                        string.Empty, "EDITHELPER_NOSELECTEDLV");
                }
            }
            return(oDevTrekDoc);
        }
Beispiel #4
0
        public async Task <bool> SaveSelectedLinkedViewAsync(ContentURI selectedLinkedViewURI,
                                                             XElement devTrekDoc)
        {
            bool bIsCompleted = false;

            //addins save their own file system state (in AddInRunHelper)
            if (selectedLinkedViewURI.URIDataManager.UseSelectedLinkedView &&
                selectedLinkedViewURI.URIDataManager.ServerSubActionType
                != DevTreks.Data.Helpers.GeneralHelpers.SERVER_SUBACTION_TYPES.runaddin)
            {
                //save in the file system
                bIsCompleted = await DevTreks.Data.EditHelpers.EditHelper.SaveEditsAsync(devTrekDoc,
                                                                                         selectedLinkedViewURI);

                //save the custom doc in the db (if it is being edited
                if (selectedLinkedViewURI.URIDataManager.ServerActionType
                    == DevTreks.Data.Helpers.GeneralHelpers.SERVER_ACTION_TYPES.edit)
                {
                    XmlReader oEditedDocReader
                        = await DataHelpers.FileStorageIO.GetXmlReaderAsync(selectedLinkedViewURI,
                                                                            selectedLinkedViewURI.URIClub.ClubDocFullPath);

                    if (oEditedDocReader != null)
                    {
                        using (oEditedDocReader)
                        {
                            //reset linkedview to original properties prior to edits
                            SetLinkedViewPropertiesAfterEdit(selectedLinkedViewURI);
                            IContentService contentService = new ContentService(selectedLinkedViewURI);
                            bool            bIsMetaData    = false;
                            bool            bIsSaved       = await contentService.SaveURISecondBaseDocAsync(
                                selectedLinkedViewURI, bIsMetaData,
                                Path.GetFileName(selectedLinkedViewURI.URIClub.ClubDocFullPath),
                                oEditedDocReader);

                            contentService.Dispose();
                        }
                    }
                }
            }
            else
            {
                bIsCompleted = await DevTreks.Data.EditHelpers.EditHelper.SaveEditsAsync(
                    devTrekDoc, selectedLinkedViewURI);
            }
            bIsCompleted = true;
            return(bIsCompleted);
        }
Beispiel #5
0
        public async Task <bool> UpdateAddInParamsAsync(ContentURI docToCalcURI, ContentURI calcDocURI)
        {
            bool                         bHasUpdatedParams = false;
            StringDictionary             colDeletes        = new StringDictionary();
            IDictionary <string, string> colUpdates        = new Dictionary <string, string>();

            GetEditParameters(calcDocURI, ref colDeletes, ref colUpdates);
            if (colDeletes.Count > 0 || colUpdates.Count > 0)
            {
                //uri is always a linkedviewpack, calcDocURIPattern is always a linkedview,
                //so always same apps (i.e. no need for MakeNewURI())
                ContentURI oTempDocURI = new ContentURI(calcDocURI);
                //tempCalcDocPath has a random id and can't be used
                //calcDocURIPattern needs _temp suffix, so updates
                //know that it is not a db update
                oTempDocURI.URIFileExtensionType
                    = DataHelpers.GeneralHelpers.FILENAME_EXTENSIONS.temp.ToString();
                oTempDocURI.UpdateURIPattern();
                oTempDocURI.URIClub.ClubDocFullPath
                    = calcDocURI.URIDataManager.TempDocPath;
                oTempDocURI.URIMember.MemberDocFullPath
                    = calcDocURI.URIDataManager.TempDocPath;
                if (await DataHelpers.FileStorageIO.URIAbsoluteExists(docToCalcURI,
                                                                      oTempDocURI.URIClub.ClubDocFullPath))
                {
                    IContentService contentService = new ContentService(docToCalcURI);
                    XElement        calcDocXml     = await DevTreks.Data.Helpers.FileStorageIO.LoadXmlElementAsync(
                        docToCalcURI, oTempDocURI.URIClub.ClubDocFullPath);

                    bool bIsOkToSave = await contentService.UpdateAsync(oTempDocURI,
                                                                        colDeletes, colUpdates, calcDocXml);

                    contentService.Dispose();
                }
                bHasUpdatedParams = true;
            }
            return(bHasUpdatedParams);
        }
        //=====================================================================

        /// <summary>
        /// This is used to get the MSDN URL for the given .NET Framework member ID
        /// </summary>
        /// <param name="id">The member ID to look up</param>
        /// <returns>The MSDN URL for the member ID or null if not found</returns>
        public string GetMsdnUrl(string id)
        {
            string endPoint = null;
            bool   success  = false;

            if (msdnService != null && !cachedMsdnIds.TryGetValue(id, out endPoint))
            {
                getContentRequest msdnRequest = new getContentRequest();
                msdnRequest.contentIdentifier = "AssetId:" + id;
                msdnRequest.locale            = this.Locale;

                try
                {
                    getContentResponse msdnResponse = msdnService.GetContent(msdnRequest);
                    endPoint = msdnResponse.contentId;
                    success  = true;
                }
                catch (WebException ex)
                {
                    // Ignore failures, just turn off the service and note the last error for the caller
                    msdnService.Dispose();
                    msdnService = null;

                    this.DisabledReason = ex.Message;
                    Exception innerEx = ex.InnerException;

                    while (innerEx != null)
                    {
                        this.DisabledReason += "\r\n" + innerEx.Message;
                        innerEx              = innerEx.InnerException;
                    }

                    // Don't save changes to the cache
                    this.CacheItemsAdded = false;
                }
                catch (SoapException ex)
                {
                    if (ex.Message.IndexOf("content identifier not found", StringComparison.OrdinalIgnoreCase) != -1 ||
                        ex.Detail.OuterXml.IndexOf("mtpsContentIdentifierNotFound", StringComparison.Ordinal) != -1)
                    {
                        // Lookup failed (ID not found).  Cache the result though since it isn't there.
                        success = true;

                        // For certain inherited explicitly implemented interface members, Microsoft is using
                        // incorrect member IDs in the XML comments files and on the content service.  If the
                        // failed member ID looks like one of them, try using the broken ID for the look up.
                        string brokenId = id;

                        if (reDictionaryEII.IsMatch(brokenId))
                        {
                            brokenId = reGenericEII.Replace(brokenId, "#I$1{TKey@TValue}#");
                        }
                        else
                        if (reGenericEII.IsMatch(brokenId))
                        {
                            brokenId = reGenericEII.Replace(brokenId, "#I$1{T}#");
                        }

                        // Don't bother if they are the same
                        if (brokenId != id)
                        {
                            endPoint = this.GetMsdnUrl(brokenId);

                            if (endPoint != null)
                            {
                                endPoint = endPoint.Substring(endPoint.LastIndexOf('/') + 1);
                            }
                        }
                    }
                    else
                    {
                        // Ignore failures, just turn off the service and note the last error for the caller
                        msdnService.Dispose();
                        msdnService = null;

                        this.DisabledReason = ex.Message;
                        Exception innerEx = ex.InnerException;

                        while (innerEx != null)
                        {
                            this.DisabledReason += "\r\n" + innerEx.Message;
                            innerEx              = innerEx.InnerException;
                        }

                        // Don't save changes to the cache
                        this.CacheItemsAdded = false;
                    }
                }

                // We'll cache the result but will only mark the cache as changed if successful so as not to
                // save null results from failures caused by issues other than not being found.
                cachedMsdnIds[id] = endPoint;

                if (success)
                {
                    this.CacheItemsAdded = true;
                }
            }

            if (String.IsNullOrEmpty(endPoint))
            {
                return(null);
            }

            return(String.Format(CultureInfo.InvariantCulture, "http://msdn2.microsoft.com/{0}/library/{1}",
                                 this.Locale, endPoint));
        }