Exemplo n.º 1
0
        public virtual void ReceiveMoveReason(Reasons reason, string code)
        {
            try
            {
                if (reason == null)
                {
                    throw new ArgumentNullException("reason");
                }
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    Reasons model       = DomainControllerFactory.Create <ReasonsController>().GetReason(reason.Name, reason.MoveType) as Reasons;
                    var     existReason = model ?? reason;
                    //existReason.Name = reason.Name;
                    existReason.Description = reason.Description;
                    existReason.ReasonsType = ReasonsType.MOVER;
                    //
                    InvOrgIdExtension.SetInvOrgId(existReason, PlatformEnvironment.InvOrgId);
                    RF.Save(existReason);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("移动原因数据下载异常:" + e);
            }
        }
Exemplo n.º 2
0
        public virtual void SaveOrUpdateCost(Factory factory, string code)
        {
            try
            {
                // SetInvOrgIdByCorporation(inv_org);
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    var existFactory = (DomainControllerFactory.Create <FactoryController>().GetList(new FactoryCriteria()
                    {
                        Code = factory.Code
                    }).Concrete()).FirstOrDefault() ?? factory;

                    factory = existFactory;

                    InvOrgIdExtension.SetInvOrgId(factory, PlatformEnvironment.InvOrgId);
                    RF.Save(factory);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("成本中心数据下载异常:" + e.Message);
            }
        }
Exemplo n.º 3
0
        public virtual void ReceivePurchase(PurchaseGroup purchase, string code)
        {
            try
            {
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    var existOrganization = DomainControllerFactory.Create <PurchaseGroupController>().GetPurchaseGroupByCode(purchase.Code) ?? purchase;
                    var userModel         = DomainControllerFactory.Create <UserController>().FetchBy("", purchase.Name).FirstOrDefault() as User;
                    if (userModel != null)
                    {
                        existOrganization.BuyerId = userModel.Id;
                    }
                    existOrganization.Code  = purchase.Code;
                    existOrganization.Name  = purchase.Code;
                    existOrganization.Phone = purchase.Phone;
                    existOrganization.Fax   = purchase.Fax;

                    //
                    InvOrgIdExtension.SetInvOrgId(existOrganization, PlatformEnvironment.InvOrgId);
                    RF.Save(existOrganization);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("采购组基础主数据 下载异常:" + e.Message);
            }
        }
Exemplo n.º 4
0
        public void APT_Register_Identity_UserName()
        {
            var repo = RF.ResolveInstance <UserRepository>();

            using (RF.TransactionScope(repo))
            {
                var controller = DomainControllerFactory.Create <AccountController>();

                var res = controller.Register(new User());
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.RegisterUserNameInvalid, res.StatusCode);

                res = controller.Register(new User
                {
                    UserName = "******",
                    Password = controller.EncodePassword("hqf")
                });
                Assert.IsTrue(res.Success);

                res = controller.Register(new User
                {
                    UserName = "******",
                    Password = controller.EncodePassword("hqf")
                });
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.RegisterUserNameDuplicated, res.StatusCode);
            }
        }
Exemplo n.º 5
0
        public void SNPT_SpecificTime()
        {
            using (RF.TransactionScope(SerialNumberPlugin.DbSettingName))
            {
                var name = "testACP";

                var controller = DomainControllerFactory.Create <SerialNumberController>();
                var sni        = controller.CreateDailySerialNumberInfo(name);

                var next = controller.GenerateNext(name, DateTime.Parse("2000-01-01"));
                Assert.AreEqual("2000010100000001", next);
                next = controller.GenerateNext(name, DateTime.Parse("2000-01-01"));
                Assert.AreEqual("2000010100000002", next);

                next = controller.GenerateNext(name, DateTime.Parse("2016-05-01"));
                Assert.AreEqual("2016050100000001", next);

                next = controller.GenerateNext(sni, DateTime.Parse("2016-05-02"));
                Assert.AreEqual("2016050200000001", next);
                next = controller.GenerateNext(sni, DateTime.Parse("2016-05-02"));
                Assert.AreEqual("2016050200000002", next);
                next = controller.GenerateNext(sni, DateTime.Parse("2016-05-02"));
                Assert.AreEqual("2016050200000003", next);

                var valueRepo = RF.ResolveInstance <SerialNumberValueRepository>();
                var value     = valueRepo.GetByTime(sni, DateTime.Parse("2016-05-02"));
                Assert.AreEqual(3, value.RollValue);
            }
        }
Exemplo n.º 6
0
        public void APT_Login_Failed_UserDisabled()
        {
            var repo = RF.ResolveInstance <UserRepository>();

            using (RF.TransactionScope(repo))
            {
                var controller = DomainControllerFactory.Create <AccountController>();
                controller.MaxLoginFailedTimes = 3;

                repo.Save(new User
                {
                    UserName = "******",
                    RealName = "hqf",
                    Password = controller.EncodePassword("hqf")
                });

                User user = null;
                var  res  = controller.LoginByUserName("hqf", "hqf", out user);
                Assert.IsTrue(res.Success);

                user.IsDisabled = true;
                repo.Save(user);

                res = controller.LoginByUserName("hqf", "hqf", out user);
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.LoginUserDisabled, res.StatusCode, "用户已经被禁用。");
            }
        }
Exemplo n.º 7
0
        public void SSPT_GetValue_T()
        {
            var repo = RF.ResolveInstance <GlobalSettingRepository>();

            using (RF.TransactionScope(repo))
            {
                var key = "SystemSettingsPluginTest_TestKey";

                var controller = DomainControllerFactory.Create <GlobalSettingController>();
                try
                {
                    controller.GetValue <int>(key);
                    Assert.IsTrue(false, "不存在,应该抛出异常。");
                }
                catch (InvalidProgramException)
                {
                }

                repo.Save(new GlobalSetting
                {
                    Key   = key,
                    Value = "1"
                });

                var value = controller.GetValue <int>(key);
                Assert.AreEqual(1, value);
            }
        }
Exemplo n.º 8
0
        public void RBAC_UserRole_GetRoleListTest()
        {
            this._controller = DomainControllerFactory.Create <UserRoleController>();

            var userRoleRepository = RepositoryFacade.ResolveInstance <UserRoleRepository>();
            var userRepository     = RepositoryFacade.ResolveInstance <UserRepository>();
            var roleRepository     = RepositoryFacade.ResolveInstance <RoleRepository>();

            using (RepositoryFacade.TransactionScope(userRoleRepository))
            {
                var user = new User {
                    Id = 1, UserName = "******", RealName = "Test_001", Email = "*****@*****.**", PhoneNumber = "18666666666"
                };
                var role = new Role {
                    Id = 1, Code = Guid.NewGuid().ToString("N"), Description = "", Name = "管理员"
                };

                userRepository.Save(user);
                roleRepository.Save(role);
                userRoleRepository.Save(new UserRole {
                    User = user, Role = role
                });

                var roleList = roleRepository.GetRoleByUserId(user.Id);

                Assert.IsNotNull(roleList);
                Assert.IsTrue(roleList.Count == 1);
            }
        }
Exemplo n.º 9
0
        public virtual void SaveOrUpdateSupplier(Supplier supplier, string code)
        {
            try
            {
                //if (corporation.IsNullOrWhiteSpace()) throw new ArgumentNullException("corporation");
                //SetInvOrgIdByCorporation(corporation);
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    ////获取客户
                    var existSupplier = DomainControllerFactory.Create <SupplierController>()
                                        .GetSupplierByCode(supplier.Code) ?? supplier;

                    //ItemExtendsion.SetErpUpdate(item, item.UpdateDate);
                    existSupplier.Name        = supplier.Name;
                    existSupplier.Description = supplier.Description;
                    //supplier.PersistenceStatus = existSupplier.PersistenceStatus;

                    //InvOrgIdExtension.SetInvOrgId(supplier, PlatformEnvironment.InvOrgId);
                    RF.Save(existSupplier);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("供应商基础主数据下载异常:" + e.Message);
            }
        }
Exemplo n.º 10
0
        public void APT_Register_Identity_EmailAndUserName()
        {
            var repo = RF.ResolveInstance <UserRepository>();

            using (RF.TransactionScope(repo))
            {
                var controller = DomainControllerFactory.Create <AccountController>();
                controller.IdentityMode = UserIdentityMode.Email | UserIdentityMode.UserName;

                var res = controller.Register(new User());
                Assert.IsFalse(res.Success);

                res = controller.Register(new User
                {
                    Email    = "*****@*****.**",
                    Password = controller.EncodePassword("hqf")
                });
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.RegisterUserNameInvalid, res.StatusCode);

                res = controller.Register(new User
                {
                    UserName = "******",
                    Password = controller.EncodePassword("hqf")
                });
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.RegisterEmailInvalid, res.StatusCode);

                res = controller.Register(new User
                {
                    UserName = "******",
                    Email    = "*****@*****.**",
                    Password = controller.EncodePassword("hqf")
                });
                Assert.IsTrue(res.Success);

                res = controller.Register(new User
                {
                    UserName = "******",
                    Email    = "*****@*****.**",
                    Password = controller.EncodePassword("hqf")
                });
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.RegisterEmailDuplicated, res.StatusCode);

                res = controller.Register(new User
                {
                    UserName = "******",
                    Email    = "*****@*****.**",
                    Password = controller.EncodePassword("hqf")
                });
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.RegisterUserNameDuplicated, res.StatusCode);
            }
        }
Exemplo n.º 11
0
        public void APT_Register_Validate_Password()
        {
            var repo = RF.ResolveInstance <UserRepository>();

            using (RF.TransactionScope(repo))
            {
                var controller = DomainControllerFactory.Create <AccountController>();

                var res = controller.Register(new User
                {
                    UserName = "******",
                    Email    = "*****@*****.**",
                });
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.RegisterPropertiesInvalid, res.StatusCode);
            }
        }
Exemplo n.º 12
0
        public void SNPT_DailySerialNumberInfo()
        {
            using (RF.TransactionScope(SerialNumberPlugin.DbSettingName))
            {
                var name       = "testACP";
                var controller = DomainControllerFactory.Create <SerialNumberController>();
                var sni        = controller.CreateDailySerialNumberInfo(name);

                var today = DateTime.Today.ToString("yyyyMMdd");

                var next = controller.GenerateNext(name);
                Assert.AreEqual(today + "00000001", next);
                next = controller.GenerateNext(name);
                Assert.AreEqual(today + "00000002", next);
                next = controller.GenerateNext(sni);
                Assert.AreEqual(today + "00000003", next);
            }
        }
Exemplo n.º 13
0
        public void APT_Register_Success()
        {
            var repo = RF.ResolveInstance <UserRepository>();

            using (RF.TransactionScope(repo))
            {
                var controller = DomainControllerFactory.Create <AccountController>();

                var res = controller.Register(new User
                {
                    UserName = "******",
                    RealName = "hqf",
                    Password = controller.EncodePassword("hqf")
                });

                Assert.IsTrue(res.Success);
            }
        }
Exemplo n.º 14
0
        public void SSPT_SetValue_CreateOnNull()
        {
            var repo = RF.ResolveInstance <GlobalSettingRepository>();

            using (RF.TransactionScope(repo))
            {
                var key = "SystemSettingsPluginTest_TestKey";

                var item = repo.GetByKey(key);
                Assert.IsNull(item);

                var controller = DomainControllerFactory.Create <GlobalSettingController>();
                controller.SetValue(key, 3);

                item = repo.GetByKey(key);
                Assert.IsNotNull(item);
                Assert.AreEqual("3", item.Value);
            }
        }
Exemplo n.º 15
0
        public void RBAC_Role_SetRoleOperation()
        {
            var controller = DomainControllerFactory.Create <RoleController>();
            var repo       = RepositoryFacade.ResolveInstance <RoleOperationRepository>();

            using (RepositoryFacade.TransactionScope(repo))
            {
                var tuple    = RBAC_InitRBAC();
                var originId = repo.GetAll()[0].OperationId;
                var role     = tuple.Item2;
                var resource = tuple.Item4;
                var delopId  = Convert.ToInt64(resource.ResourceOperationList[1].Id);
                controller.SetRoleOperation(role.Id, new List <long> {
                    delopId
                });
                var savedId = repo.GetAll()[0].OperationId;
                Assert.AreNotEqual(originId, savedId);
            }
        }
Exemplo n.º 16
0
        public void APT_Login_Failed_MaxLoginTimes()
        {
            var repo = RF.ResolveInstance <UserRepository>();

            using (RF.TransactionScope(repo))
            {
                var controller = DomainControllerFactory.Create <AccountController>();
                controller.MaxLoginFailedTimes = 3;

                repo.Save(new User
                {
                    UserName = "******",
                    RealName = "hqf",
                    Password = controller.EncodePassword("hqf")
                });

                User user = null;
                var  res  = controller.LoginByUserName("hqf", "hqf1", out user);
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.LoginPasswordError, res.StatusCode);
                Assert.AreEqual(1, user.LoginFailedTimes);

                res = controller.LoginByUserName("hqf", "hqf2", out user);
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.LoginPasswordError, res.StatusCode);
                Assert.AreEqual(2, user.LoginFailedTimes);

                res = controller.LoginByUserName("hqf", "hqf3", out user);
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.LoginPasswordError, res.StatusCode);
                Assert.AreEqual(3, user.LoginFailedTimes);

                res = controller.LoginByUserName("hqf", "hqf4", out user);
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.LoginExceedMaxFailedTimes, res.StatusCode, "最多只能输入3次密码错误。");
                Assert.AreEqual(3, user.LoginFailedTimes);

                res = controller.LoginByUserName("hqf", "hqf", out user);
                Assert.IsFalse(res.Success);
                Assert.AreEqual(ResultCodes.LoginExceedMaxFailedTimes, res.StatusCode, "最多只能输入3次密码错误。");
                Assert.AreEqual(3, user.LoginFailedTimes);
            }
        }
Exemplo n.º 17
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var controller = DomainControllerFactory.Create <AccountController>();
                var res        = controller.LoginByUserName(txtUserName.Text, txtPassword.Password, out User user);

                if (!res)
                {
                    MessageBox.Show(res.Message, "登录失败");
                }
                else
                {
                    this.DialogResult = true;
                }
            }
            catch (Exception ex)
            {
                ex.Alert();
            }
        }
Exemplo n.º 18
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            #region 验证
            if (UserNameTextEdit.Text.Trim().Length == 0)
            {
                errorProvider1.SetError(UserNameTextEdit, "登陆用户名不能为空!");
                return;
            }
            errorProvider1.Clear();
            if (PwdTextEdit.Text.Trim().Length == 0)
            {
                errorProvider1.SetError(PwdTextEdit, "密码不能为空!");
                return;
            }
            errorProvider1.Clear();
            #endregion

            var controller = DomainControllerFactory.Create <AccountController>();
            controller.IdentityMode = UserIdentityMode.Email | UserIdentityMode.UserName;
            _userInfo = null;
            //var res = controller.Register(new User
            //{
            //    UserName = "******",
            //    RealName = "admin",
            //    Password = controller.EncodePassword("admin"),
            //    Email = "*****@*****.**"
            //});

            var reslogin = controller.LoginByUserName(UserNameTextEdit.Text.Trim(), PwdTextEdit.Text.Trim(), out _userInfo);
            if (reslogin.Success)
            {
                this.DialogResult = DialogResult.OK; //返回一个登录成功的对话框状态
                this.Close();                        //关闭登录窗口
            }
            else
            {
                MessageDxUtil.ShowError(reslogin.Message);
                this.UserNameTextEdit.Focus();
            }
        }
Exemplo n.º 19
0
        public virtual void SaveOrUpdateItem(Item item, string itemCode)
        {
            try
            {
                //if (factoryCode.IsNullOrWhiteSpace()) throw new ArgumentNullException("factoryCode");
                //SetInvOrgIdByFactoryCode(factoryCode);
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    //获取物料
                    var existItem = DomainControllerFactory.Create <ItemController>().GetByCode(item.Code) ?? item;

                    //if (ItemExtendsion.GetErpUpdate(existItem) == item.UpdateDate && !isForce) return;
                    //ItemExtendsion.SetErpUpdate(item, item.UpdateDate);
                    //existItem.PersistenceStatus = item.PersistenceStatus;

                    existItem.DataSource      = EumDataSource.ERP;
                    existItem.Name            = string.IsNullOrEmpty(item.Name) ? item.Code : item.Name;
                    existItem.Description     = item.Description;
                    existItem.MeasurementUnit = item.MeasurementUnit;
                    existItem.ItemType        = item.ItemType;
                    existItem.State           = item.State;
                    existItem.CustomerType    = item.CustomerType;
                    existItem.BaseModel       = item.BaseModel;
                    existItem.InerCode        = item.InerCode;
                    existItem.ReplaceItem     = item.ReplaceItem;
                    existItem.MdmItemCode     = item.MdmItemCode;
                    existItem.SmallCategory   = item.SmallCategory;
                    //物料关联物料组,并保存
                    ItemSmallCategory existCategory = UpdateOrAdd(item.Category);
                    existItem.CategoryId = existCategory.Id;
                    //InvOrgIdExtension.SetInvOrgId(item, PlatformEnvironment.InvOrgId);
                    RF.Save(existItem);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
            }
        }
Exemplo n.º 20
0
        public virtual Result DownloadProBom(string itemCode)
        {
            Result rs = new Result();

            try
            {
                var list = RFC_ProductBom.GetErpBom(itemCode);
                if (itemCode.IsNotEmpty() && list.Count() <= 0)
                {
                    rs.Success = false;
                    rs.Message = "找不到物料:" + itemCode + " 的BOM信息";
                    return(rs);
                }
                foreach (var bom in list)
                {
                    var batch_no = Guid.NewGuid().ToSafeString();
                    var flag     = ReceiveBom(bom, itemCode, batch_no);
                    if (!flag)
                    {
                        continue;
                    }
                    var model = DomainControllerFactory.Create <WorkOrderController>()
                                .FindProductBom(bom.Item.Code);
                    var del_ls = model.DetailList.Concrete().Where(p => p.DownBatchNo != batch_no);
                    foreach (var item in del_ls)
                    {
                        item.PersistenceStatus = PersistenceStatus.Deleted;
                        RF.Save(item);
                    }
                }
                rs.Success = true;
                return(rs);
            }
            catch (Exception ex)
            {
                rs.Success = false;
                rs.Message = ex.Message;
                return(rs);
            }
        }
Exemplo n.º 21
0
        public virtual void SaveOrUpdateBom(WorkOrderBom woBom, string batch_no)
        {
            try
            {
                using (var trans = RF.TransactionScope(WMSEntityDataProvider.ConnectionStringName))
                {
                    var ctl = DomainControllerFactory.Create <WorkOrderController>();
                    //查找工单
                    var workOder = ctl.GetWorkOrderByWo(woBom.WorkOrder.WorkOrderNo);
                    if (workOder == null)
                    {
                        return;
                    }
                    var item = DomainControllerFactory.Create <ItemController>().GetByCode(woBom.Item.Code);
                    if (item == null)
                    {
                        return;
                    }
                    var wareHouse = DomainControllerFactory.Create <WarehouseController>().GetWarehouse(woBom.SourceWarehouse.Code);
                    //获取工单Bom
                    var existBom = ctl.FindWoBom(workOder.Id, item.Id).Concrete().FirstOrDefault() ?? woBom;

                    existBom.WorkOrderId       = workOder.Id;
                    existBom.ItemId            = item.Id;
                    existBom.RequireQty        = woBom.RequireQty;
                    existBom.SingleQty         = woBom.SingleQty;
                    existBom.Unit              = woBom.Unit;
                    existBom.SourceWarehouseId = wareHouse == null ? 0 : wareHouse.Id;
                    existBom.IsRecoilItem      = woBom.IsRecoilItem;
                    existBom.BatchNo           = batch_no;
                    RF.Save(existBom);
                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("工单Bom数据下载异常:" + e.Message);
            }
        }
Exemplo n.º 22
0
        public void APT_Login_Failed()
        {
            var repo = RF.ResolveInstance <UserRepository>();

            using (RF.TransactionScope(repo))
            {
                var controller = DomainControllerFactory.Create <AccountController>();

                repo.Save(new User
                {
                    UserName = "******",
                    RealName = "hqf",
                    Password = controller.EncodePassword("hqf")
                });

                User user = null;
                var  res  = controller.LoginByUserName("hqf", "hqf1", out user);
                Assert.IsFalse(res.Success);
                Assert.IsNotNull(user);
                Assert.AreEqual(ResultCodes.LoginPasswordError, res.StatusCode);
            }
        }
Exemplo n.º 23
0
        public void RBAC_UserRole_HasRoleTest()
        {
            this._controller = DomainControllerFactory.Create <UserRoleController>();

            var userRoleRepository = RepositoryFacade.ResolveInstance <UserRoleRepository>();
            var userRepository     = RepositoryFacade.ResolveInstance <UserRepository>();
            var roleRepository     = RepositoryFacade.ResolveInstance <RoleRepository>();

            using (RepositoryFacade.TransactionScope(userRepository))
            {
                var user = new User {
                    Id = 1, UserName = "******", RealName = "Test_001", Email = "*****@*****.**", PhoneNumber = "18666666666"
                };
                var role = new Role {
                    Id = 1, Code = Guid.NewGuid().ToString("N"), Description = "", Name = "管理员"
                };

                userRepository.Save(user);
                roleRepository.Save(role);
                userRoleRepository.Save(new UserRole {
                    User = user, Role = role
                });

                var result1 = this._controller.HasRole(new User {
                    Id = user.Id
                }, new Role {
                    Id = role.Id
                });
                var result2 = this._controller.HasRole(new User {
                    Id = user.Id
                }, new Role {
                    Id = role.Id + 1L
                });

                Assert.IsTrue(result1);
                Assert.IsFalse(result2);
            }
        }
Exemplo n.º 24
0
        public void SSPT_SetValue_WithoutDescription()
        {
            var repo = RF.ResolveInstance <GlobalSettingRepository>();

            using (RF.TransactionScope(repo))
            {
                var key = "SystemSettingsPluginTest_TestKey";

                repo.Save(new GlobalSetting
                {
                    Key         = key,
                    Value       = "2",
                    Description = "2"
                });

                var controller = DomainControllerFactory.Create <GlobalSettingController>();
                controller.SetValue(key, 3);

                var item = repo.GetByKey(key);
                Assert.IsNotNull(item);
                Assert.AreEqual("2", item.Description);
            }
        }
Exemplo n.º 25
0
        public void SSPT_GetValueOrDefault()
        {
            var repo = RF.ResolveInstance <GlobalSettingRepository>();

            using (RF.TransactionScope(repo))
            {
                var key = "SystemSettingsPluginTest_TestKey";

                var controller = DomainControllerFactory.Create <GlobalSettingController>();
                var value      = controller.GetValueOrDefault(key, 1);

                Assert.AreEqual(1, value);

                repo.Save(new GlobalSetting
                {
                    Key   = key,
                    Value = "2"
                });

                value = controller.GetValueOrDefault(key, 1);
                Assert.AreEqual(2, value);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 下载工单Bom
        /// </summary>
        public virtual Result DownloadMoBom(string workOrderNo)
        {
            Result rs = new Result();

            try
            {
                var list = Download.RFC_MoBom.GetErpMoBom(workOrderNo);
                if (workOrderNo.IsNotEmpty() && list.Count() <= 0)
                {
                    rs.Success = false;
                    rs.Message = "找不到工单:" + workOrderNo;
                    return(rs);
                }
                var batch_no = Guid.NewGuid().ToSafeString();
                foreach (var bom in list)
                {
                    SaveOrUpdateBom(bom, batch_no);
                }
                var ctl = DomainControllerFactory.Create <WorkOrderController>();
                //查找工单
                var workOder = ctl.GetWorkOrderByWo(workOrderNo);
                var del_ls   = workOder.WorkOrderBOMList.Concrete().Where(p => p.BatchNo != batch_no);
                foreach (var item in del_ls)
                {
                    item.PersistenceStatus = PersistenceStatus.Deleted;
                    RF.Save(item);
                }
                rs.Success = true;
                return(rs);
            }
            catch (Exception ex)
            {
                rs.Success = false;
                rs.Message = ex.Message;
                return(rs);
            }
        }
Exemplo n.º 27
0
        public void APT_Login_Success_Email()
        {
            var repo = RF.Concrete <UserRepository>();

            using (RF.TransactionScope(repo))
            {
                var controller = DomainControllerFactory.Create <AccountController>();

                controller.Register(new User
                {
                    UserName = "******",
                    Email    = "*****@*****.**",
                    Password = controller.EncodePassword("hqf")
                });

                User user = null;
                var  res  = controller.LoginByEmail("*****@*****.**", "hqf", out user);
                Assert.IsTrue(res.Success);
                Assert.IsNotNull(user);
                Assert.AreEqual("hqf", user.UserName);
                Assert.AreEqual("*****@*****.**", user.Email);
                Assert.AreEqual(controller.EncodePassword("hqf"), user.Password);
            }
        }
Exemplo n.º 28
0
        public virtual void SaveOrUpdateCustomer(Customer customer, string Code)
        {
            try
            {
                //if (corporation.IsNullOrWhiteSpace()) throw new ArgumentNullException("corporation");
                //SetInvOrgIdByCorporation(corporation);
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    //获取客户
                    var criteria = new CustomerCriteria()
                    {
                        PagingInfo = new PagingInfo(1, int.MaxValue)
                    };
                    criteria.Code = customer.Code;
                    var existCustomer = DomainControllerFactory.Create <CustomerController>()
                                        .GetList(criteria).Concrete().FirstOrDefault() ?? customer;

                    //ItemExtendsion.SetErpUpdate(item, item.UpdateDate);
                    existCustomer.Name      = customer.Name;
                    existCustomer.SalesArea = customer.SalesArea;

                    //customer.PersistenceStatus = existCustomer.PersistenceStatus;
                    //customer.Id = existCustomer.Id;
                    //organization.DataSource = EumDataSource.ERP;

                    InvOrgIdExtension.SetInvOrgId(customer, PlatformEnvironment.InvOrgId);
                    RF.Save(existCustomer);

                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("客户基础主数据下载异常:" + e.Message);
            }
        }
Exemplo n.º 29
0
        public virtual void SaveOrUpdateWarehouse(Warehouse warehouse, string code)
        {
            try
            {
                //if (corporation.IsNullOrWhiteSpace()) throw new ArgumentNullException("invOrg");
                //SetInvOrgIdByCorporation(corporation);
                using (var trans = RF.TransactionScope(BDEntityDataProvider.ConnectionStringName))
                {
                    var factory = DomainControllerFactory.Create <OrganizationController>().GetOrganizationList(new OrganizationCriteria {
                        Code = warehouse.Factory.Code
                    }).FirstOrDefault() as Organization;
                    if (factory == null)
                    {
                        throw new Exception("不存在工厂:" + warehouse.Factory.Code);
                    }
                    ////获取仓库
                    var existWarehouse = DomainControllerFactory.Create <WarehouseController>()
                                         .GetWarehouseList(new WarehouseCriteria {
                        Code = warehouse.Code
                    }).Concrete().FirstOrDefault() ?? warehouse;

                    existWarehouse.Name      = warehouse.Name;
                    existWarehouse.FactoryId = factory.Id;
                    //warehouse.PersistenceStatus = existWarehouse.PersistenceStatus;
                    //organization.DataSource = EumDataSource.ERP;

                    InvOrgIdExtension.SetInvOrgId(existWarehouse, PlatformEnvironment.InvOrgId);
                    RF.Save(existWarehouse);
                    trans.Complete();
                }
            }
            catch (Exception e)
            {
                throw new Exception("仓库基础主数据下载异常:" + e.Message);
            }
        }
Exemplo n.º 30
0
        public void APT_Login_Success()
        {
            var repo = RF.ResolveInstance <UserRepository>();

            using (RF.TransactionScope(repo))
            {
                var controller = DomainControllerFactory.Create <AccountController>();

                controller.Register(new User
                {
                    UserName = "******",
                    RealName = "hqf",
                    Password = controller.EncodePassword("hqf")
                });

                User user = null;
                var  res  = controller.LoginByUserName("hqf", "hqf", out user);
                Assert.IsTrue(res.Success);
                Assert.IsNotNull(user);
                Assert.AreEqual("hqf", user.UserName);
                Assert.AreEqual("hqf", user.RealName);
                Assert.AreEqual(controller.EncodePassword("hqf"), user.Password);
            }
        }