Esempio n. 1
0
        static internal string GetRibbonLocationFiltersAsString(RibbonLocationFilters enumValue)
        {
            List <string> valueArray  = new List <string>();
            string        returnValue = "None";

            if (enumValue.HasFlag(RibbonLocationFilters.Form) || enumValue.HasFlag(RibbonLocationFilters.All))
            {
                valueArray.Add("Form");
            }
            if (enumValue.HasFlag(RibbonLocationFilters.HomepageGrid) || enumValue.HasFlag(RibbonLocationFilters.All))
            {
                valueArray.Add("HomepageGrid");
            }
            if (enumValue.HasFlag(RibbonLocationFilters.SubGrid) || enumValue.HasFlag(RibbonLocationFilters.All))
            {
                valueArray.Add("SubGrid");
            }
            if (returnValue == "None")
            {
                valueArray.AddRange(new List <string>()
                {
                    "Form", "HomepageGrid", "SubGrid"
                });
            }
            returnValue = String.Join(" ", valueArray.ToArray());

            return(returnValue);
        }
        private byte[] ExportEntityRibbonByteArray(string entityName, RibbonLocationFilters filter)
        {
            RetrieveEntityRibbonRequest entRibReq = new RetrieveEntityRibbonRequest()
            {
                RibbonLocationFilter = filter,
                EntityName           = entityName,
            };

            RetrieveEntityRibbonResponse entRibResp = (RetrieveEntityRibbonResponse)_service.Execute(entRibReq);

            return(entRibResp.CompressedEntityXml);
        }
Esempio n. 3
0
        private string ExportingEntityRibbon(string entityName, RibbonLocationFilters filter)
        {
            byte[] byteXml = ExportEntityRibbonByteArray(entityName, filter);

            XElement doc = null;

            using (var memStream = new MemoryStream())
            {
                memStream.Write(byteXml, 0, byteXml.Length);

                memStream.Position = 0;

                doc = XElement.Load(memStream);
            }

            return(doc.ToString());
        }
Esempio n. 4
0
        private byte[] ExportEntityRibbonByteArray(string entityName, RibbonLocationFilters filter)
        {
            RetrieveEntityRibbonRequest entRibReq = new RetrieveEntityRibbonRequest()
            {
                RibbonLocationFilter = filter,
                EntityName           = entityName,
            };

            RetrieveEntityRibbonResponse entRibResp = (RetrieveEntityRibbonResponse)_service.Execute(entRibReq);

            string fileName  = entityName.ToLower() + ".zip";
            string directory = FileOperations.GetConnectionIntellisenseDataFolderPathRibbons(this._service.ConnectionData.ConnectionId);

            string filePath = Path.Combine(directory, fileName);

            var arrayXml = FileOperations.UnzipRibbon(entRibResp.CompressedEntityXml);

            try
            {
                File.WriteAllBytes(filePath, entRibResp.CompressedEntityXml);

                using (var memStream = new MemoryStream())
                {
                    memStream.Write(arrayXml, 0, arrayXml.Length);

                    memStream.Position = 0;

                    XDocument doc = XDocument.Load(memStream);

                    if (!_service.ConnectionData.RibbonIntellisense.EntitiesRibbonData.ContainsKey(entityName))
                    {
                        _service.ConnectionData.RibbonIntellisense.EntitiesRibbonData.TryAdd(entityName, new Intellisense.Model.RibbonIntellisenseData(entityName));
                    }

                    _service.ConnectionData.RibbonIntellisense.EntitiesRibbonData[entityName].LoadDataFromRibbon(doc);
                }
            }
            catch (Exception ex)
            {
                DTEHelper.WriteExceptionToOutput(this._service.ConnectionData, ex);
            }

            return(arrayXml);
        }
Esempio n. 5
0
 public Task <byte[]> ExportEntityRibbonByteArrayAsync(string entityName, RibbonLocationFilters filter)
 {
     return(Task.Run(() => ExportEntityRibbonByteArray(entityName, filter)));
 }
Esempio n. 6
0
 public Task <string> ExportEntityRibbonAsync(string entityName, RibbonLocationFilters filter)
 {
     return(Task.Run(() => ExportingEntityRibbon(entityName, filter)));
 }
Esempio n. 7
0
 /// <summary>Initializes a new instance of the  <see cref="T:Microsoft.Crm.Sdk.Messages.RetrieveEntityRibbonRequest"></see> class.</summary>
 public RetrieveEntityRibbonRequest()
 {
     this.RequestName          = "RetrieveEntityRibbon";
     this.EntityName           = (string)null;
     this.RibbonLocationFilter = (RibbonLocationFilters)0;
 }