public void RegisterJobTypes(ErpService service) { var assemblies = AppDomain.CurrentDomain.GetAssemblies() .Where(a => !(a.FullName.ToLowerInvariant().StartsWith("microsoft.") || a.FullName.ToLowerInvariant().StartsWith("system."))); foreach (var assembly in assemblies) { foreach (Type type in assembly.GetTypes()) { if (!type.IsSubclassOf(typeof(ErpJob))) { continue; } var attributes = type.GetCustomAttributes(typeof(JobAttribute), true); if (attributes.Length != 1) { continue; } var attribute = attributes[0] as JobAttribute; JobType internalJobType = new JobType(); internalJobType.Id = attribute.Id; internalJobType.Name = attribute.Name; internalJobType.DefaultPriority = (JobPriority)((int)attribute.DefaultPriority); internalJobType.AllowSingleInstance = attribute.AllowSingleInstance; internalJobType.CompleteClassName = type.FullName; internalJobType.ErpJobType = type; RegisterJobType(internalJobType); } } }
public void RegisterJobTypes(ErpService service) { foreach (ErpPlugin plugin in service.Plugins) { foreach (var jobType in plugin.GetJobTypes()) { if (!jobType.IsSubclassOf(typeof(ErpJob))) { throw new Exception($"'{jobType.FullName}' does not inherite ErpJob."); } var attributes = jobType.GetCustomAttributes(typeof(JobAttribute), true); if (attributes.Length != 1) { throw new Exception($"'{jobType.FullName}' missing or more than one ErpJobAttribute."); } var attribute = attributes[0] as JobAttribute; JobType internalJobType = new JobType(); internalJobType.Id = attribute.Id; internalJobType.Name = attribute.Name; internalJobType.DefaultPriority = (JobPriority)((int)attribute.DefaultPriority); internalJobType.AllowSingleInstance = attribute.AllowSingleInstance; internalJobType.CompleteClassName = jobType.FullName; internalJobType.ErpJobType = jobType; RegisterJobType(internalJobType); } } }
private ErpService.ShippingInfo ErpProcessOrder(Order order) { ErpService.ShippingInfo info = ErpService.ProcessOrder(order); if (info.Status == ErpService.ShippingStatus.Success) { return(info); } throw new ErpService.ErpException("Info status = " + info.Status); }
public void Create() { //Create NotifyCustomer(); ErpService erpService = new ErpService(); erpService.Save(); }
private void cmbLine_SelectedIndexChanged(object sender, EventArgs e) { if (-1 == cmbLine.SelectedIndex) { return; } ConfigHelper.SetConfigValue("DSN", cmbLine.SelectedValue.ToString()); WinAPI.WritePrivateProfileString("DBLine", "Line", cmbLine.SelectedIndex.ToString(), Application.StartupPath + @"\Config.ini"); ErpWs.FetchConnString(); ErpService.FetchConnString(); }
private Result <ErpService.ShippingInfo> ErpProcessOrder(Order order) { return(Result <ErpService.ShippingInfo> .ToResult(() => { ErpService.ShippingInfo info = ErpService.ProcessOrder(order); if (info.Status == ErpService.ShippingStatus.Success) { return info; } throw new ErpService.ErpException("Info status = " + info.Status); })); }
public static void RegisterHooks(ErpService service) { var assemblies = AppDomain.CurrentDomain.GetAssemblies() .Where(a => !(a.FullName.ToLowerInvariant().StartsWith("microsoft.") || a.FullName.ToLowerInvariant().StartsWith("system."))); foreach (var assembly in assemblies) { foreach (Type type in assembly.GetTypes()) { var attachAttributes = type.GetCustomAttributes(typeof(HookAttachmentAttribute), true); HookAttachmentAttribute attachAttribute = null; if (attachAttributes.Length == 1 && type.IsClass) { attachAttribute = (HookAttachmentAttribute)attachAttributes[0]; } if (attachAttribute != null) { foreach (var typeInterface in type.GetInterfaces()) { var hookAttributes = typeInterface.GetCustomAttributes(typeof(HookAttribute), true); HookAttribute hookAttribute = null; if (hookAttributes.Length == 1 && type.IsClass) { hookAttribute = (HookAttribute)hookAttributes[0]; } if (hookAttribute == null) { continue; } if (!hooksDict.ContainsKey(typeInterface)) { hooksDict[typeInterface] = new List <HookInfo>(); } HookInfo hookInfo = new HookInfo(); hookInfo.Type = type; hookInfo.AttachAttribute = attachAttribute; hookInfo.HookAttribute = hookAttribute; hookInfo.Instance = Activator.CreateInstance(type); hooksDict[typeInterface].Add(hookInfo); } } } } }
private static void InitErpEngine() { CultureInfo customCulture = new CultureInfo("en-US"); customCulture.NumberFormat.NumberDecimalSeparator = "."; CultureInfo.DefaultThreadCurrentCulture = customCulture; CultureInfo.DefaultThreadCurrentUICulture = customCulture; var configurationBuilder = new ConfigurationBuilder().AddJsonFile("config.json".ToApplicationPath()); ErpSettings.Initialize(configurationBuilder.Build()); DbContext.CreateContext(ErpSettings.ConnectionString); ErpService service = new ErpService(); service.InitializeSystemEntities(); ErpAutoMapperConfiguration.Configure(ErpAutoMapperConfiguration.MappingExpressions); //here put additional automapper configuration if needed ErpAutoMapper.Initialize(ErpAutoMapperConfiguration.MappingExpressions); //register hooks HookManager.RegisterHooks(service); DbContext.CloseContext(); }
public void Setup() { _requestProviderMock = new Mock <IRequestProvider>(); _erpService = new ErpService(_requestProviderMock.Object); }
public CustomerModule(ErpService erpService) { this.erpService = erpService; }