public IdCollection GetTemplateIds(string sDatabaseName) { #region VARIABLES List <Guid> oGuidList; IdCollection oTemplateIdsCollection; #endregion oTemplateIdsCollection = null; using (var oContentService = new GenContentServiceProxy()) { oGuidList = oContentService.GetTemplateIDs(sDatabaseName); } if (oGuidList != null && oGuidList.Count > 0) { oTemplateIdsCollection = new IdCollection(); if (oGuidList != null) { foreach (var oGuid in oGuidList) { oTemplateIdsCollection.Add(new ID(oGuid)); } } } return(oTemplateIdsCollection); }
public override ID SelectSingleID(string query, CallContext context) { Guid oResult; ID oSelectedId; bool bFound; oSelectedId = ID.Null; bFound = false; using (var oContentService = new GenContentServiceProxy()) { oResult = oContentService.SelectSingleID(query, context.DataManager.Database.Name); } if (oResult != null && oResult == Guid.Empty) { oSelectedId = ID.Parse(oSelectedId); bFound = true; } if (bFound) { UpdateContext(oSelectedId, context); context.Abort(); } return(oSelectedId); }
/// <summary> /// Execute the selection /// </summary> /// <param name="sQuery"></param> /// <param name="context"></param> /// <returns></returns> public override IDList SelectIDs(string sQuery, CallContext context) { List <Guid> oResults; IDList oSelectedIds; bool bFound; Sitecore.Diagnostics.Log.Debug(string.Format("SelectIDs Start, Query:{0}", sQuery), this); oSelectedIds = new IDList(); bFound = false; using (var oContentService = new GenContentServiceProxy()) { oResults = oContentService.SelectIDs(sQuery, context.DataManager.Database.Name); } if (oResults != null && oResults.Count > 0) { foreach (var oItemId in oResults) { oSelectedIds.Add(ID.Parse(oItemId)); } bFound = true; } if (bFound) { UpdateContext(oSelectedIds, context); context.Abort(); } return(oSelectedIds); }
/// <summary> /// Loads the fields for the collection of items passed as parameters /// </summary> /// <param name="parameters"></param> /// <param name="prefetchData"></param> protected virtual void LoadItemFields(object[] parameters, SafeDictionary <ID, PrefetchData> prefetchData) { LanguageCollection languages = this.GetLanguages(); List <string> oItemIds; PrefetchData data = null; ID oCurrentItemId; List <FieldContract> oGenFieldsForItem; ID @null = ID.Null; Dictionary <string, List <FieldContract> > oItemsWithFields; oItemIds = ParseIDsFromParameters(parameters); Sitecore.Diagnostics.Log.Debug("LoadItemFields - Begins", this); if (oItemIds != null) { using (var oContentService = new GenContentServiceProxy()) { oItemsWithFields = oContentService.GetItemsFields(oItemIds, this.CurrentDatabase); } foreach (string sItemId in oItemIds) { if (ID.TryParse(sItemId, out oCurrentItemId)) { if (oCurrentItemId != @null) { data = prefetchData[oCurrentItemId]; if (data != null) { data.InitializeFieldLists(languages); } @null = oCurrentItemId; } oGenFieldsForItem = oItemsWithFields[sItemId]; if ((data != null) && oGenFieldsForItem != null && oGenFieldsForItem.Count > 0) { foreach (FieldContract oGenField in oGenFieldsForItem) { data.AddField(oGenField.Language, oGenField.Version, ID.Parse(oGenField.Id), oGenField.Value); Sitecore.Diagnostics.Log.Debug(string.Format("Field:{0} Value:{1} Language:{2} Version:{3}", oGenField.Id, oGenField.Value, oGenField.Language, oGenField.Version), this); } } } } } }
public override bool BlobStreamExists(Guid oBlobId, CallContext context) { #region VARIABLES bool bBlobExists; //Add variables here... #endregion Sitecore.Diagnostics.Log.Debug(string.Format("BlobStreamExists Start, Id:{0}", oBlobId), this); using (var oContentService = new GenContentServiceProxy()) { bBlobExists = oContentService.BlobStreamExists(oBlobId, context.DataManager.Database.Name); } Sitecore.Diagnostics.Log.Debug(string.Format("BlobStreamExists Ends, Exits:{0}", bBlobExists), this); return(bBlobExists); }
/// <summary> /// Load the childs for the items passed through the parameters /// </summary> /// <param name="condition"></param> /// <param name="parameters"></param> /// <param name="prefetchData"></param> protected virtual void LoadChildIds(object[] parameters, SafeDictionary <ID, PrefetchData> prefetchData) { List <string> oItemIds; PrefetchData data = null; ID @null; ID oCurrentItemId; List <Guid> oChildIds; Dictionary <Guid, List <Guid> > oItemsWithChilds; @null = ID.Null; oItemIds = ParseIDsFromParameters(parameters); if (oItemIds != null) { using (var oContentService = new GenContentServiceProxy()) { oItemsWithChilds = oContentService.GetItemsChildIDs(oItemIds, this.CurrentDatabase); } foreach (var oItemChild in oItemsWithChilds) { oCurrentItemId = ID.Parse(oItemChild.Key); if (oCurrentItemId != @null) { data = prefetchData[oCurrentItemId]; @null = oCurrentItemId; } if (data != null) { oChildIds = oItemChild.Value; foreach (Guid oChild in oChildIds) { data.AddChildId(ID.Parse(oChild)); } } } } }
public override System.IO.Stream GetBlobStream(Guid oBlobId, CallContext context) { #region VARIABLES System.IO.MemoryStream oBlobStream; //Add variables here... #endregion Sitecore.Diagnostics.Log.Debug(string.Format("GetBlobStream Start, Id:{0}", oBlobId), this); using (var oContentService = new GenContentServiceProxy()) { oBlobStream = oContentService.GetBlobStream(oBlobId, context.DataManager.Database.Name); } if (oBlobStream == null) { Sitecore.Diagnostics.Log.Error(string.Format("GetBlobStream Unable to get BLOB with Id:{0}", oBlobId), this); } return(oBlobStream); }
/// <summary> /// Gets all the languages available in the current database /// </summary> /// <returns></returns> protected virtual LanguageCollection LoadLanguages() { #region VARIABLES LanguageCollection oLanguages; List <LanguageContract> oGenLanguages; ID oLanguageOriginItemId; Language oLanguage; #endregion oLanguages = null; using (var oContentService = new GenContentServiceProxy()) { oGenLanguages = oContentService.GetLanguages(this.CurrentDatabase); } if (oGenLanguages != null) { oLanguages = new LanguageCollection(); foreach (LanguageContract sGenLanguage in oGenLanguages) { if (!string.IsNullOrEmpty(sGenLanguage.OriginItemId) && !string.IsNullOrEmpty(sGenLanguage.Name) && !string.Equals(sGenLanguage.Name, "*") && ID.TryParse(sGenLanguage.OriginItemId, out oLanguageOriginItemId)) { if (Language.TryParse(sGenLanguage.Name, out oLanguage) && !oLanguages.Contains(oLanguage)) { oLanguage.Origin.ItemId = oLanguageOriginItemId; oLanguages.Add(oLanguage); } } } } return(oLanguages); }
/// <summary> /// Loads a set item definitions into the cache by using the parameters array passed as parameter. Parameters are in the form of {"ItemId", "{Sitecore Id}"} /// </summary> /// <param name="parameters"></param> /// <param name="prefetchData"></param> protected virtual void LoadItemDefinitions(object[] parameters, SafeDictionary <ID, PrefetchData> prefetchData) { #region VARIABLES ItemDefinition oItemDefinition; string sItemId; int iParameterIndex; List <string> oItemIds; List <ItemDefinitionContract> oItemDefinitions; PrefetchData oData; //Add variables here... #endregion if (parameters != null && parameters.Length > 1) { oItemIds = new List <string>(); for (iParameterIndex = 0; iParameterIndex < parameters.Length; iParameterIndex += 2) { if (ID.IsID(parameters[iParameterIndex + 1].ToString())) { sItemId = parameters[iParameterIndex + 1].ToString(); oItemIds.Add(sItemId); } } if (oItemIds.Count > 0) { using (var oContentService = new GenContentServiceProxy()) { oItemDefinitions = oContentService.GetItemDefinitions(oItemIds, this.CurrentDatabase); } if (oItemDefinitions != null && oItemDefinitions.Count > 0) { try { foreach (ItemDefinitionContract oItemDefinitionContract in oItemDefinitions) { oItemDefinition = new Sitecore.Data.ItemDefinition( new Sitecore.Data.ID(oItemDefinitionContract.Id), !string.IsNullOrEmpty(oItemDefinitionContract.Name) ? oItemDefinitionContract.Name : string.Empty, !string.IsNullOrEmpty(oItemDefinitionContract.TemplateId) ? new Sitecore.Data.ID(oItemDefinitionContract.TemplateId) : null, !string.IsNullOrEmpty(oItemDefinitionContract.BranchId) ? new Sitecore.Data.ID(oItemDefinitionContract.BranchId) : null ); oData = new PrefetchData(oItemDefinition, !string.IsNullOrEmpty(oItemDefinitionContract.ParentId) ? new Sitecore.Data.ID(oItemDefinitionContract.ParentId) : ID.Null); prefetchData[oItemDefinition.ID] = oData; Sitecore.Diagnostics.Log.Debug(string.Format("GetItemDefinition, Item Cached:{0}", oItemDefinition.ID.ToString()), this); } } catch { Sitecore.Diagnostics.Log.Error("GetItemDefinition, Unable to get item definitions", this); throw; } } } } }