Esempio n. 1
0
        internal string GetAddinChangeLog(string addin)
        {
            Assembly asm = Assembly.Load(addin);

            foreach (var type in asm.GetTypes())
            {
                object[] custAttr = type.GetCustomAttributes(typeof(AddInAttribute), true);
                if (custAttr.Count() > 0)
                {
                    AddInAttribute attr = (AddInAttribute)custAttr[0];
                    if (attr.ChangeLogResource != null)
                    {
                        using (var stream = asm.GetManifestResourceStream(attr.ChangeLogResource))
                        {
                            if (stream != null)
                            {
                                StreamReader sr = new StreamReader(stream);
                                return(sr.ReadToEnd());
                            }
                        }
                    }
                }
            }
            return(string.Empty);
        }
Esempio n. 2
0
        internal static string GetModuleDescription(object module)
        {
            AddInAttribute ma = Attribute.GetCustomAttribute(module.GetType(), typeof(AddInAttribute)) as AddInAttribute;

            if (!Object.Equals(null, ma))
            {
                return(ma.Description);
            }
            else
            {
                return(string.Empty);
            }
        }
Esempio n. 3
0
        public static string GetModuleDescription(Type type)
        {
            AddInAttribute ma = Attribute.GetCustomAttribute(type, typeof(AddInAttribute)) as AddInAttribute;

            if (!Object.Equals(null, ma))
            {
                return(ma.Description);
            }
            else
            {
                return(string.Empty);
            }
        }
Esempio n. 4
0
        public static string GetModuleName(object module)
        {
            AddInAttribute ma = Attribute.GetCustomAttribute(module.GetType(), typeof(AddInAttribute)) as AddInAttribute;

            if (!Object.Equals(null, ma))
            {
                return(ma.Name);
            }
            else
            {
                return(string.Empty);
            }
        }
Esempio n. 5
0
        public static Guid GetModuleGuid(object module)
        {
            AddInAttribute ma = Attribute.GetCustomAttribute(module.GetType(), typeof(AddInAttribute)) as AddInAttribute;

            if (!Object.Equals(null, ma))
            {
                return(new Guid(ma.Guid));
            }
            else
            {
                return(Guid.Empty);
            }
        }
Esempio n. 6
0
        internal bool AddinIsValid(string addin, out DateTime dueDate)
        {
            string xmlKey;
            string licenseXml;

            dueDate = DateTime.MinValue;
            AddInAttribute addinAttribute = getAddinAttribute(addin);

            if (string.IsNullOrWhiteSpace(addinAttribute.LicenseFile))
            {
                dueDate = DateTime.MaxValue;
                return(true);
            }
            xmlKey = readKeyXML(addin, addinAttribute.LicenseFile);

            if (string.IsNullOrWhiteSpace(xmlKey) || string.IsNullOrWhiteSpace(addinAttribute.Namespace))
            {
                return(false);
            }

            licenseXml = licenseDAO.GetLicense(addinAttribute.Namespace);

            if (licenseXml == null || !CheckSignature(licenseXml, xmlKey))
            {
                return(false);
            }

            string sysNumber     = sapApp.Company.SystemId;
            string installNumber = sapApp.Company.InstallationId;

            LicenseHeader licenseFile = licenseXml.Deserialize <LicenseHeader>();

            if (!string.IsNullOrEmpty(licenseFile.SystemNumber) &&
                !string.IsNullOrEmpty(licenseFile.InstallNumber) &&
                licenseFile.SystemNumber == sysNumber && licenseFile.InstallNumber == installNumber)
            {
                List <LicenseModule> licenseModules = licenseFile.Items.Where(i => i.Name == addin).ToList();;
                if (licenseModules != null && licenseModules.Count() > 0)
                {
                    dueDate = licenseModules[0].ExpirationDate;
                }
            }

            return(GetDate() < dueDate);
        }
Esempio n. 7
0
 public static string GetModuleDescription(object module)
 {
     if (module is EAS.Modularization.IModule)
     {
         return((module as EAS.Modularization.IModule).Description);
     }
     else
     {
         AddInAttribute ma = Attribute.GetCustomAttribute(module.GetType(), typeof(AddInAttribute)) as AddInAttribute;
         if (!Object.Equals(null, ma))
         {
             return(ma.Description);
         }
         else
         {
             return(string.Empty);
         }
     }
 }
Esempio n. 8
0
        public object Aggregate(AddInEntity entity, AddInAttribute attribute, Format format)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity", Message.Get("Common.NullArgument", "entity"));
            }

            if (attribute == null)
            {
                throw new ArgumentNullException("attribute", Message.Get("Common.NullArgument", "attribute"));
            }

            if (format == null)
            {
                throw new ArgumentNullException("format", Message.Get("Common.NullArgument", "format"));
            }

            return(entity.ID + "|" + attribute.ID + "|" + format.ID);
        }
Esempio n. 9
0
        public static string GetModuleName(object module)
        {
            string name = string.Empty;

            //1.读数据库
            Guid Guid = GetModuleGuid(module);

            if (Guid != Guid.Empty)
            {
                string sGuid = Guid.ToString();
                var    mx    = XContext.ModuleList.Where(p => p.Guid == sGuid).FirstOrDefault();
                if (mx == null)
                {
                    mx = XContext.ModuleList.Where(p => p.Guid == sGuid.ToUpper()).FirstOrDefault();
                }
                if (mx != null)
                {
                    name = mx.Name;
                }
            }

            if (module is EAS.Modularization.IAddIn)
            {
                return((module as EAS.Modularization.IAddIn).Name);
            }
            else
            {
                AddInAttribute ma = Attribute.GetCustomAttribute(module.GetType(), typeof(AddInAttribute)) as AddInAttribute;
                if (!Object.Equals(null, ma))
                {
                    name = ma.Name;
                }
                else
                {
                    name = string.Empty;
                }
            }

            return(name);
        }
Esempio n. 10
0
        private XDocument LoadResourceForms(Assembly addinAsm, Type type, string resourceKey)
        {
            string asmKey = addinAsm.GetName().FullName;

            if (!assemblyLoaded.Contains(asmKey)) // Load AddInAttribute.
            {
                AddInAttribute addInAttribute = (from definedType in addinAsm.GetTypes()
                                                 from attribute in definedType.GetCustomAttributes(true)
                                                 where attribute is AddInAttribute
                                                 select(AddInAttribute) attribute).If(x => x.Count() > 0).With(x => x.First());
                if (addInAttribute != null && !string.IsNullOrWhiteSpace(addInAttribute.B1SResource))
                {
                    LoadAssemblyResources(addinAsm, addInAttribute);
                }
                assemblyLoaded.Add(asmKey);
            }

            var formAttributes =
                (from attribute in type.GetCustomAttributes(true)
                 where attribute is FormAttribute
                 select(FormAttribute) attribute).ToList();

            foreach (var formAttribute in formAttributes)
            {
                LoadAssemblyFormResource(addinAsm, formAttribute);
            }

            if (!formSRFResource.ContainsKey(asmKey) || !formSRFResource[asmKey].ContainsKey(resourceKey))
            // we should have found the form at this point.
            {
                Logger.Warn(string.Format(Messages.ResourceNotFound, asmKey, resourceKey));
            }
            else
            {
                return(formSRFResource[asmKey][resourceKey]);
            }
            return(null);
        }
Esempio n. 11
0
        private void ParseB1SFormSRF(XDocument doc, AddInAttribute addInAttribute, string assemblyName,
                                     Dictionary <string, XDocument> formDictionary)
        {
            if (doc != null)
            {
                var vsicreated = (from elem in doc.Descendants()
                                  where elem.Name == "project" &&
                                  elem.Attribute("name").Value == "VSIcreated"
                                  select elem);
                if (vsicreated == null)
                {
                    Logger.Error(string.Format(Messages.B1SResourceVSICreatedNotFound, assemblyName));
                    throw new ArgumentException(string.Format(Messages.B1SResourceVSICreatedNotFound, assemblyName));
                }
                var contents = (from elem in vsicreated.First().Elements()
                                where elem.Name == "file"
                                select elem).ToList();
                if (contents == null)
                {
                    Logger.Error(string.Format(Messages.B1SResourceKeyNotFound, assemblyName, "*"));
                    throw new ArgumentException(string.Format(Messages.B1SResourceKeyNotFound, assemblyName, "*"));
                }

                foreach (var content in contents)
                {
                    string name = content.Attribute("name").Value;
                    if (!formDictionary.ContainsKey(name))
                    {
                        formDictionary.Add(name, XDocument.Parse(content.Element("content").Attribute("desc").Value));
                    }
                }
            }
            else
            {
                Logger.Error(string.Format(Messages.B1SResourceMissing, assemblyName));
                throw new ArgumentException(string.Format(Messages.B1SResourceMissing, assemblyName));
            }
        }
Esempio n. 12
0
        private void LoadAssemblyResources(System.Reflection.Assembly asm, AddInAttribute addInAttribute)
        {
            using (var resource = asm.GetManifestResourceStream(addInAttribute.B1SResource))
            {
                if (resource != null)
                {
                    var doc = XDocument.Load(resource);
                    var key = asm.GetName().FullName;

                    Dictionary <string, XDocument> formDictionary;
                    if (!formSRFResource.ContainsKey(key))
                    {
                        formDictionary = new Dictionary <string, XDocument>();
                        formSRFResource.Add(key, formDictionary);
                    }
                    else
                    {
                        formDictionary = formSRFResource[key];
                    }

                    ParseB1SFormSRF(doc, addInAttribute, key, formDictionary);
                }
            }
        }
Esempio n. 13
0
        private void ParseB1SFormSRF(XDocument doc, AddInAttribute addInAttribute, string assemblyName,
                                Dictionary<string, XDocument> formDictionary)
        {
            if (doc != null)
            {
                var vsicreated = (from elem in doc.Descendants()
                                  where elem.Name == "project" &&
                                      elem.Attribute("name").Value == "VSIcreated"
                                  select elem);
                if (vsicreated == null)
                {
                    Logger.Error(string.Format(Messages.B1SResourceVSICreatedNotFound, assemblyName));
                    throw new ArgumentException(string.Format(Messages.B1SResourceVSICreatedNotFound, assemblyName));
                }
                var contents = (from elem in vsicreated.First().Elements()
                               where elem.Name == "file"
                               select elem).ToList();
                if (contents == null)
                {
                    Logger.Error(string.Format(Messages.B1SResourceKeyNotFound, assemblyName, "*"));
                    throw new ArgumentException(string.Format(Messages.B1SResourceKeyNotFound, assemblyName, "*"));
                }

                foreach (var content in contents)
                {
                    string name = content.Attribute("name").Value;
                    if (!formDictionary.ContainsKey(name))
                    {
                        formDictionary.Add(name, XDocument.Parse(content.Element("content").Attribute("desc").Value));
                    }
                }
            }
            else
            {
                Logger.Error(string.Format(Messages.B1SResourceMissing, assemblyName));
                throw new ArgumentException(string.Format(Messages.B1SResourceMissing, assemblyName));
            }
        }
Esempio n. 14
0
        private void LoadAssemblyResources(System.Reflection.Assembly asm, AddInAttribute addInAttribute)
        {
            using (var resource = asm.GetManifestResourceStream(addInAttribute.B1SResource))
            {
                if (resource != null)
                {
                    var doc = XDocument.Load(resource);
                    var key = asm.GetName().FullName;

                    Dictionary<string, XDocument> formDictionary;
                    if (!formSRFResource.ContainsKey(key))
                    {
                        formDictionary = new Dictionary<string, XDocument>();
                        formSRFResource.Add(key, formDictionary);
                    }
                    else
                    {
                        formDictionary = formSRFResource[key];
                    }

                    ParseB1SFormSRF(doc, addInAttribute, key, formDictionary);
                }
            }
        }
Esempio n. 15
0
        void InitializeNavigationDebug()
        {
            //=======================================================

            Assembly assembly = EAS.Objects.ClassProvider.GetAssembly(SLContext.Instance.Assembly);

            System.Type[] types = assembly.GetTypes();

            List <NavigateModule> moduleList = new List <NavigateModule>();
            List <NavigateGroup>  groupList  = new List <NavigateGroup>();

            #region 提取模块

            foreach (System.Type type in types)
            {
                AddInAttribute ma = Attribute.GetCustomAttribute(type, typeof(AddInAttribute)) as AddInAttribute;
                if (!Object.Equals(null, ma))
                {
                    NavigateModule dataEntity = new NavigateModule();
                    dataEntity.Guid        = ma.Guid;
                    dataEntity.Name        = ma.Name;
                    dataEntity.Description = ma.Description;
                    dataEntity.Assembly    = MetaHelper.GetAssemblyString(type);
                    dataEntity.Type        = MetaHelper.GetTypeString(type);
                    dataEntity.Version     = MetaHelper.GetVersionString(type);
                    dataEntity.Developer   = MetaHelper.GetDeveloperString(type);
                    moduleList.Add(dataEntity);
                }
            }

            foreach (NavigateModule item in moduleList)
            {
                if (item.GroupName == null)
                {
                    item.GroupName = string.Empty;
                }

                if (item.GroupName.Length == 0)
                {
                    item.GroupName = "调试模块";
                }

                NavigateGroup GX = groupList.Where(p => p.Name == item.GroupName).FirstOrDefault();

                if (GX != null)
                {
                    item.GroupID = GX.ID;
                }
                else
                {
                    GX            = new NavigateGroup();
                    GX.ParentID   = Guid.Empty.ToString().ToUpper();
                    GX.ID         = Guid.NewGuid().ToString().ToUpper();
                    GX.Name       = item.GroupName;
                    GX.Attributes = 0xffff;
                    groupList.Add(GX);
                    item.GroupID = GX.ID;
                }
            }

            #endregion

            (this.m_Menu as INavigation).Initialize(groupList, moduleList);
        }