コード例 #1
0
        /// <summary>
        /// Assembly is Uploaded if it is database.
        /// We dont do Smart updates
        /// </summary>
        /// <param name="org"></param>
        /// <param name="pathToAssembly"></param>
        /// <param name="assembly"></param>
        public static void UpdateAssembly(CrmOrganization org, string pathToAssembly, CrmPluginAssembly assembly,
                                          params PluginType[] type)
        {
            if (org == null)
            {
                throw new ArgumentNullException("org");
            }
            else if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }

            PluginAssembly ptl = (PluginAssembly)assembly.GenerateCrmEntities()[PluginAssembly.EntityLogicalName];

            //If the assembly path is not set, then the content does not need to be updated
            if (!string.IsNullOrEmpty(pathToAssembly) &&
                assembly.SourceType == CrmAssemblySourceType.Database)
            {
                ptl.Content = Convert.ToBase64String(File.ReadAllBytes(pathToAssembly));
            }

            if (null != type && 0 != type.Length)
            {
                ptl.pluginassembly_plugintype = type;
            }

            org.OrganizationService.Update(ptl);
            OrganizationHelper.RefreshAssembly(org, assembly);
        }