예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        public void Create()
        {
            //Create

            NotifyCustomer();

            ErpService erpService = new ErpService();

            erpService.Save();
        }
예제 #5
0
파일: frmLogin.cs 프로젝트: zanderphh/TMS
 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();
 }
예제 #6
0
        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);
            }));
        }
예제 #7
0
        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);
                        }
                    }
                }
            }
        }
예제 #8
0
        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();
        }
예제 #9
0
 public void Setup()
 {
     _requestProviderMock = new Mock <IRequestProvider>();
     _erpService          = new ErpService(_requestProviderMock.Object);
 }
예제 #10
0
 public CustomerModule(ErpService erpService)
 {
     this.erpService = erpService;
 }