Esempio n. 1
0
        /// <summary>
        /// Get the projection pair for A, the control-state projection, and the register-state projection.
        /// Gets also the function combine that combines the projections back to the original register format
        /// combine(control_state,register_state).
        /// </summary>
        internal void GetProjectionPair(IRegisterInfo <TERM> A, out TERM control_proj, out TERM register_proj, out Func <TERM, TERM, TERM> combine)
        {
            var v      = MkRegister(solver.GetSort(A.InitialRegister));
            var projs  = new List <Pair <TERM, bool> >(GetRegisterProjections(v, v, A)).ToArray();
            var first  = Array.ConvertAll(Array.FindAll(projs, p => p.Second), pair => pair.First);
            var second = Array.ConvertAll(Array.FindAll(projs, p => !p.Second), pair => pair.First);

            if (first.Length == 0)        //no control projection
            {
                control_proj  = solver.UnitConst;
                register_proj = v;
                combine       = ((x1, x2) => x2);
            }
            else if (second.Length == 0)  //no register projection
            {
                control_proj  = v;
                register_proj = solver.UnitConst;
                combine       = ((x1, x2) => x1);
            }
            else
            {
                control_proj  = (first.Length == 1 ? first[0] : solver.MkTuple(first));
                register_proj = (second.Length == 1 ? second[0] : solver.MkTuple(second));
                var control_sort     = solver.GetSort(control_proj);
                var tmp_control_var  = solver.MkVar(2, control_sort);
                var register_sort    = solver.GetSort(register_proj);
                var tmp_register_var = solver.MkVar(3, register_sort);
                List <KeyValuePair <TERM, TERM> > subst_list;
                var skel  = MkTupleVarSkeleton(v, out subst_list);
                var subst = new Dictionary <TERM, TERM>();
                int m     = 0;
                int n     = 0;
                for (int i = 0; i < subst_list.Count; i++)  //subst_list has the same length as projs
                {
                    if (projs[i].Second)
                    {
                        subst[subst_list[i].Key] = (first.Length == 1 ? tmp_control_var : solver.MkProj(m++, tmp_control_var));
                    }
                    else
                    {
                        subst[subst_list[i].Key] = (second.Length == 1 ? tmp_register_var : solver.MkProj(n++, tmp_register_var));
                    }
                }
                var combined_reg = solver.Simplify(solver.ApplySubstitution(skel, subst));
                combine = (x1, x2) => solver.ApplySubstitution(combined_reg, tmp_control_var, x1, tmp_register_var, x2);
            }
        }
Esempio n. 2
0
        public IUserService Register(IRegisterInfo info)
        {
            ExceptionHelper.ThrowIfNull(info, "info");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyMobile(info.Mobile), "mobile", "手机格式不正确");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyEmail(info.Email), "email", "邮箱格式不正确");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyPassword(info.Password), "password", "密码格式不正确,密码长度为6-20位");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.Name, "name", "名称不能为空");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.Company, "company", "公司不能为空");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.AreaNo, "areaNo", "没有选择地区");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.Address, "address", "地址不能为空");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.IndustryNo, "industryNo", "没有选择行业类别");

            ExceptionHelper.ThrowIfTrue(!IsUsableMobile(info.Mobile), "mobile", "此手机号已经被注册");
            ExceptionHelper.ThrowIfTrue(!IsUsableEmail(info.Email), "email", "此邮箱已经被注册");
            using (var scope = new System.Transactions.TransactionScope())
            {
                _MobileManager.Verify(info.Code, info.Mobile);
                var entity = new Data.User
                {
                    address              = info.Address.SafeTrim(),
                    area_no              = info.AreaNo.SafeTrim(),
                    industry_no          = info.IndustryNo.SafeTrim(),
                    company              = info.Company.Trim(),
                    email                = info.Email.Trim(),
                    employees_count_type = info.EmployeesCountRange,
                    is_purchaser         = info.IsPurchaser,
                    mobile               = info.Mobile.Trim(),
                    name            = info.Name.Trim(),
                    neet_invoice    = info.NeetInvoice,
                    tel             = info.Tel == null ? null : info.Tel.Trim(),
                    pwd             = new Security.MD5().Encrypt(info.Password.Trim()),
                    last_login_date = DateTime.Now,
                    register_date   = DateTime.Now,
                    enabled         = true,
                };
                _UserRepository.Add(entity);
                _UserRepository.SaveChanges();
                scope.Complete();

                return(GetUser(entity));
            }
        }
Esempio n. 3
0
        IEnumerable <Pair <TERM, bool> > GetRegisterProjections(TERM x, TERM proj, IRegisterInfo <TERM> A)
        {
            var sort = solver.GetSort(proj);

            if (sort.Equals(solver.BoolSort))
            {
                yield return(new Pair <TERM, bool>(proj, true));
            }
            else if (!solver.IsTupleSort(sort))
            {
                Predicate <TERM> pred = r =>
                {
                    var t   = solver.Simplify(solver.ApplySubstitution(proj, x, r));
                    var res = t.Equals(proj) || solver.IsGround(t);
                    return(res);
                };

                if (A.IsTrueForAllRegisterUpdates(pred))
                {
                    yield return(new Pair <TERM, bool>(proj, true));
                }
                else
                {
                    yield return(new Pair <TERM, bool>(proj, false));
                }
            }
            else
            {
                for (int i = 0; i < solver.GetTupleLength(sort); i++)
                {
                    foreach (var pair in GetRegisterProjections(x, solver.MkProj(i, proj), A))
                    {
                        yield return(pair);
                    }
                }
            }
        }
Esempio n. 4
0
 public CaseController()
 {
     IRegisterInfo  = new DAL.RegisterInfoDal();
     IFollowDetails = new DAL.FollowDetailsDal();
 }
Esempio n. 5
0
 public ReturnCaseController()
 {
     IRegisterInfo = new DAL.RegisterInfoDal();
     IReturnCase   = new DAL.ReturnCaseDal();
 }
Esempio n. 6
0
        public IUserService Register(IRegisterInfo info)
        {
            ExceptionHelper.ThrowIfNull(info, "info");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyMobile(info.Mobile), "mobile", "手机格式不正确");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyEmail(info.Email), "email", "邮箱格式不正确");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyPassword(info.Password), "password", "密码格式不正确,密码长度为6-20位");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.Name, "name", "名称不能为空");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.Company, "company", "公司不能为空");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.AreaNo, "areaNo", "没有选择地区");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.Address, "address", "地址不能为空");
            ExceptionHelper.ThrowIfNullOrWhiteSpace(info.IndustryNo, "industryNo", "没有选择行业类别");

            ExceptionHelper.ThrowIfTrue(!IsUsableMobile(info.Mobile), "mobile", "此手机号已经被注册");
            ExceptionHelper.ThrowIfTrue(!IsUsableEmail(info.Email), "email", "此邮箱已经被注册");
            using (var scope = new System.Transactions.TransactionScope())
            {
                _MobileManager.Verify(info.Code, info.Mobile);
                var entity = new Data.User
                {
                    address = info.Address.SafeTrim(),
                    area_no = info.AreaNo.SafeTrim(),
                    industry_no = info.IndustryNo.SafeTrim(),
                    company = info.Company.Trim(),
                    email = info.Email.Trim(),
                    employees_count_type = info.EmployeesCountRange,
                    is_purchaser = info.IsPurchaser,
                    mobile = info.Mobile.Trim(),
                    name = info.Name.Trim(),
                    neet_invoice = info.NeetInvoice,
                    tel = info.Tel == null ? null : info.Tel.Trim(),
                    pwd = new Security.MD5().Encrypt(info.Password.Trim()),
                    last_login_date = DateTime.Now,
                    register_date = DateTime.Now,
                    enabled = true,
                };
                _UserRepository.Add(entity);
                _UserRepository.SaveChanges();
                scope.Complete();

                return GetUser(entity);
            }
        }
Esempio n. 7
0
 public CaseController()
 {
     IRegisterInfo = new BLL.RegisterInfoBLL();
 }