public ActionResult Save(CompanyAuthorize obj)
        {
            obj.OpenScopeId = Request["OpenScopeId"];
            var op = CompAuthorService.SaveOrUpdate(obj);

            return(new OpActionResult(op));
        }
Exemplo n.º 2
0
        public static OpResult RegisterAgain(CompanyAuthorize comp)
        {
            comp.SerialNo  = "";
            comp.MachineSN = Machine.GetMAC;
            comp.CID       = SysCommonRules.CompanyId;
            if (comp.AppProper != "Y")
            {
                comp.AppProper = "N";
            }
            if (comp.StoreProper != "Y")
            {
                comp.StoreProper = "N";
            }
            if (comp.PosMinorDisp != "Y")
            {
                comp.PosMinorDisp = "N";
            }
            var rt = HttpClient.HttpPost(OmsUrl + "api/outerapi/RegisterAgain", comp.ToJson());

            if (rt == "0")
            {
                return(OpResult.Fail("连接OMS管理平台失败,请检查网络是否正常!"));
            }
            new Pharos.Utility.Config().SetAppSettings(_SerialKey, "");
            RemoveCurrentAuth();
            return(OpResult.Success());
        }
        public ActionResult Save(int?id)
        {
            var obj = new CompanyAuthorize()
            {
                Source = 1, Way = 1, MemberShared = "Y", EffectiveDT = System.DateTime.Now.ToString("yyyy-MM-dd")
            };

            if (id.HasValue)
            {
                obj = CompAuthorService.GetOne(id.Value);
            }
            ViewBag.BusinessModes = ListToSelect(DictionaryService.GetChildList(221, false).Select(o => new SelectListItem()
            {
                Text = o.Title, Value = o.DicSN.ToString()
            }));
            ViewBag.OpenScopeIds = ListToSelect(BusinessService.GetList(false).Select(o => new SelectListItem()
            {
                Text = o.Title, Value = o.ById
            }));
            ViewBag.users = ListToSelect(UserService.GetList(false).Select(o => new SelectListItem()
            {
                Text = o.FullName, Value = o.UserId
            }), emptyTitle: "请选择");
            ViewBag.states = EnumToSelect(typeof(CompanyAuthorizeState));
            return(View(obj.IsNullThrow()));
        }
Exemplo n.º 4
0
 /// <summary>
 /// 验证匹配字段
 /// </summary>
 /// <param name="auth"></param>
 /// <param name="source"></param>
 /// <returns></returns>
 public bool ValidateCompany(CompanyAuthorize auth, CompanyAuthorize source)
 {
     if (auth == null || source == null)
     {
         return(false);
     }
     return(auth.Way == source.Way && auth.Title == source.Title && auth.MachineSN == source.MachineSN &&
            auth.StoreNum == source.StoreNum && auth.Status == source.Status && auth.ValidityNum == source.ValidityNum);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 验证匹配字段
 /// </summary>
 /// <param name="auth"></param>
 /// <param name="source"></param>
 /// <returns></returns>
 public bool ValidateCompany(CompanyAuthorize auth, CompanyAuthorize source)
 {
     if (auth == null || source == null)
     {
         return(false);
     }
     return(auth.Way == source.Way && auth.Title == source.Title && auth.UserNum == source.UserNum && isNull(auth.MachineSN, "") == isNull(source.MachineSN, "") &&
            auth.StoreNum == source.StoreNum && isNull(auth.StoreProper, "N") == isNull(source.StoreProper, "N") && isNull(auth.PosMinorDisp, "N") == isNull(source.PosMinorDisp, "N") &&
            isNull(auth.AppProper, "N") == isNull(source.AppProper, "N") && auth.OpenVersionId == source.OpenVersionId);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 注册请求
        /// </summary>
        /// <param name="company">单位简称</param>
        /// <param name="fullCompany">单位全称</param>
        /// <returns>true:请求成功,false:请求失败</returns>
        public void Register(CompanyAuthorize obj)
        {
            //todo:
            //1. 获取该服务器机器码
            //obj.MachineSN = Machine.GetMAC;
            //obj.Status = 0;
            //2. 将机器码、单位名称 提交给OMS生成客户授权
            //var op= OMSCompanyAuthrizeBLL.Update(obj);
            var config = new Pharos.Utility.Config();

            config.SetAppSettings("CompanyId", obj.CID.ToString());
        }
Exemplo n.º 7
0
 public OpResult Add(CompanyAuthorize obj)
 {
     if (CompanyAuthorRepository.GetQuery(o => o.CID == obj.CID && (o.Status == 0 || o.Status == 1)).Any())
     {
         return(OpResult.Fail("商户已续签!"));
     }
     obj.AppProper    = obj.AppProper ?? "N";
     obj.StoreProper  = obj.StoreProper ?? "N";
     obj.PosMinorDisp = obj.PosMinorDisp ?? "N";
     obj.MemberShared = obj.MemberShared ?? "Y";
     obj.CreateDT     = DateTime.Now;
     obj.CreateUID    = CurrentUser.UID;
     obj.ExpirationDT = DateTime.Parse(obj.EffectiveDT).AddMonths(obj.ValidityNum.GetValueOrDefault()).ToString("yyyy-MM-dd");
     CompanyAuthorRepository.Add(obj);
     return(OpResult.Success());
 }
        public string GetCompany(string companyId)
        {
            var source = new CompanyAuthorize();

            //int compid = 0;
            //if (int.TryParse(companyId, out compid))
            //    source = CompAuthorService.GetOneByCID(compid);
            //else
            //{
            //    var auth = new Sys.SysAuthorize();
            //    source = auth.AnalysisSN(companyId);
            //    if(source!=null)
            //    {
            //        //if (!auth.ValidateCompany(source, CompAuthorService.GetOneByCID(source.Code.GetValueOrDefault())))
            //            source.Code=0;
            //    }
            //}
            return(source == null?"":source.ToJson());
        }
Exemplo n.º 9
0
 public CompanyAuthorize GetCompany([FromBody] CompanyAuthorize obj)
 {
     if (obj.Title.IsNullOrEmpty())
     {
         return(CompAuthorService.GetOneTitleByCID(obj.CID.GetValueOrDefault()));
     }
     else
     {
         if (obj != null)
         {
             var source = CompAuthorService.GetOneTitleByCID(obj.CID.GetValueOrDefault());
             if (!CompAuthorService.ValidateCompany(obj, source))
             {
                 source.CID = 0;
             }
             return(source);
         }
     }
     return(null);
 }
Exemplo n.º 10
0
        static OpResult ValidateProperty(CompanyAuthorize source)
        {
            var companyId = source.ToJson();

            if (source.Way == 1)
            {
                var omsurl = OmsUrl + "api/outerapi/GetCompany";
                companyId = HttpClient.HttpPost(omsurl, companyId);
                if (companyId == "404")//在线且返回空时
                {
                    RemoveCurrentAuth();
                    return(OpResult.Fail("连接OMS管理平台失败,请检查网络是否正常!"));
                }
            }
            var company = companyId.ToObject <CompanyAuthorize>();

            if (company == null)
            {
                return(OpResult.Fail("获取商户信息失败,请确认是否已注册商户!"));
            }
            if (company.Status != 1)
            {
                return(OpResult.Fail("您处于停用或未审核状态,请联系管理员!"));
            }
            if (DateTime.Parse(company.EffectiveDT) > DateTime.Now)
            {
                return(OpResult.Fail("未到生效日期暂不能使用!"));
            }
            if (DateTime.Parse(company.ExpirationDT) <= DateTime.Now)
            {
                return(OpResult.Fail("已过使用期,请联系管理员!"));
            }
            if (company.Way == 2 && company.CID == 0)
            {
                return(OpResult.Fail("基础信息与注册不一致,请联系管理员!"));
            }
            DictRegister[SysCommonRules.CompanyId] = OpResult.Success();
            CurrentStoreUser.Company = company;
            return(DictRegister[SysCommonRules.CompanyId]);
        }
Exemplo n.º 11
0
        public static OpResult HasRegister(string serialno = null)
        {
            var result = true;

            if (DictRegister.ContainsKey(SysCommonRules.CompanyId) && DictRegister[SysCommonRules.CompanyId] != null)
            {
                result = DictRegister[SysCommonRules.CompanyId].Successed;
            }
            if (!result || !DictRegister.ContainsKey(SysCommonRules.CompanyId) || DictRegister[SysCommonRules.CompanyId] == null)
            {
                var op = new OpResult();
                DictRegister[SysCommonRules.CompanyId] = op;
                CurrentStoreUser.Company = null;
                string key       = serialno ?? Pharos.Utility.Config.GetAppSettings(_SerialKey);
                var    companyId = SysCommonRules.CompanyId;
                if (!string.IsNullOrWhiteSpace(key) && companyId > 0)//离线
                {
                    CompanyAuthorize auth = AnalysisSN(key);
                    if (auth == null)
                    {
                        op.Message = "注册序列号不正确!";
                        return(op);
                    }
                    if (auth.CID != companyId)
                    {
                        op.Message = "商户号输入不正确!";
                        return(op);
                    }
                    return(ValidateProperty(auth));
                }
                else if (companyId > 0)
                {
                    return(ValidateProperty(new CompanyAuthorize()
                    {
                        CID = companyId, Way = 1
                    }));
                }
            }
            return(DictRegister[SysCommonRules.CompanyId]);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 生成序列号
        /// </summary>
        /// <param name="company">CompanyAuthorize 单位授权实体类</param>
        /// <returns></returns>
        public string GenerateSN(CompanyAuthorize company)
        {
            if (company != null && company.CID > 0)
            {
                JObject json = new JObject();
                json["CID"]          = company.CID;
                json["Title"]        = company.Title;
                json["Source"]       = company.Source;
                json["Way"]          = company.Way;
                json["BusinessMode"] = company.BusinessMode;

                json["UserNum"]      = company.UserNum;
                json["StoreNum"]     = company.StoreNum;
                json["StoreProper"]  = company.StoreProper;
                json["AppProper"]    = company.AppProper;
                json["PosMinorDisp"] = company.PosMinorDisp;

                json["OpenVersionId"] = company.OpenVersionId;
                json["OpenScopeId"]   = "";
                if (!company.OpenScopeId.IsNullOrEmpty())
                {
                    var scopeids = company.OpenScopeId.Split(',');
                    json["OpenScopeId"] = string.Join(",", BusinessRepository.GetQuery(o => scopeids.Contains(o.ById)).Select(o => o.Title));
                }
                json["EffectiveDT"]  = company.EffectiveDT;
                json["ExpirationDT"] = company.ExpirationDT;
                json["ValidityNum"]  = company.ValidityNum;

                json["SupperAccount"]  = company.SupperAccount;
                json["SupperPassword"] = company.SupperPassword;
                json["MachineSN"]      = company.MachineSN;
                json["Status"]         = company.Status;
                return(DES.Encrypt(json.ToString()));
            }
            else
            {
                return(DES.Encrypt("-1"));
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 从序列号返回对象
        /// </summary>
        /// <param name="sn"></param>
        /// <returns></returns>
        public static CompanyAuthorize AnalysisSN(string sn)
        {
            if (!string.IsNullOrEmpty(sn))
            {
                try
                {
                    var              text    = DES.Decrypt(sn);
                    JObject          json    = JObject.Parse(text);
                    CompanyAuthorize company = new CompanyAuthorize();

                    company.CID          = Convert.ToInt32(json["CID"]);
                    company.Title        = Convert.ToString(json["Title"]);
                    company.Source       = Convert.ToInt16(json["Source"]);
                    company.Way          = Convert.ToInt16(json["Way"]);
                    company.BusinessMode = Convert.ToInt16(json["BusinessMode"]);

                    company.UserNum      = Convert.ToInt16(json["UserNum"]);
                    company.StoreNum     = Convert.ToInt16(json["StoreNum"]);
                    company.StoreProper  = Convert.ToString(json["StoreProper"]);
                    company.AppProper    = Convert.ToString(json["AppProper"]);
                    company.PosMinorDisp = Convert.ToString(json["PosMinorDisp"]);

                    company.OpenVersionId = Convert.ToInt16(json["OpenVersionId"]);
                    company.OpenScopeId   = Convert.ToString(json["OpenScopeId"]);
                    company.EffectiveDT   = Convert.ToString(json["EffectiveDT"]);
                    company.ExpirationDT  = Convert.ToString(json["ExpirationDT"]);
                    company.ValidityNum   = Convert.ToInt16(json["ValidityNum"]);

                    company.SupperAccount  = Convert.ToString(json["SupperAccount"]);
                    company.SupperPassword = Convert.ToString(json["SupperPassword"]);
                    company.MachineSN      = Convert.ToString(json["MachineSN"]);
                    company.Status         = Convert.ToInt16(json["Status"]);
                    return(company);
                }
                catch { }
            }
            return(null);
        }
Exemplo n.º 14
0
 public bool RegisterAgain(CompanyAuthorize company)
 {
     if (company.CID.HasValue)
     {
         var obj = CompanyAuthorRepository.GetQuery(o => o.CID == company.CID.Value).OrderByDescending(o => o.CreateDT).FirstOrDefault();
         if (obj == null)
         {
             return(false);
         }
         obj.Way           = company.Way;
         obj.Title         = company.Title;
         obj.UserNum       = company.UserNum;
         obj.StoreNum      = company.StoreNum;
         obj.StoreProper   = company.StoreProper;
         obj.PosMinorDisp  = company.PosMinorDisp;
         obj.AppProper     = company.AppProper;
         obj.OpenVersionId = company.OpenVersionId;
         obj.MachineSN     = company.MachineSN;
         obj.SerialNo      = company.SerialNo;
         CompanyAuthorRepository.SaveChanges();
         return(true);
     }
     return(false);
 }
Exemplo n.º 15
0
        public static OpResult LoinValidator(int companyId)
        {
            if (companyId <= 0)
            {
                return(OpResult.Fail("商户号为空!"));
            }
            var op     = new OpResult();
            var omsurl = OmsUrl + "api/outerapi/GetCompany";

            if (Pharos.Logic.BLL.UserInfoService.GetUserCount(companyId) <= 0)//首次
            {
                var auth = new CompanyAuthorize()
                {
                    CID = companyId
                };
                var json = HttpClient.HttpPost(omsurl, auth.ToJson());
                if (json == "404")
                {
                    return(OpResult.Fail("连接OMS管理平台失败,请检查网络是否正常!"));
                }
                var obj = json.ToObject <CompanyAuthorize>();
                if (obj == null)
                {
                    string msg = string.Format("<script>if(confirm('商户未注册是否填写注册信息?')) window.location.href='{0}';</script>", Url.GetApplicationPath + "Authorization/outregister?cid=" + companyId);
                    //HttpContext.Current.Response.Write(msg);
                    op.Successed = true;
                }
                else if (obj.Way == 2)
                {
                    string msg = string.Format("<script>if(confirm('商户未激活是否激活?')) window.location.href='{0}';</script>", Url.GetApplicationPath + "Authorization/activate?again=1&cid=" + companyId);
                    HttpContext.Current.Response.Write(msg);
                }
                else
                {
                    return(Activate(null));
                }
            }
            else//再次
            {
                var company = CurrentStoreUser.Company as CompanyAuthorize;
                if (company == null)
                {
                    RemoveCurrentAuth();
                }
                op = HasRegister();
                #region 独立方式附加控制
                if (op.Successed)
                {
                    company = CurrentStoreUser.Company as CompanyAuthorize;
                    if (company != null && company.Way == 2)
                    {
                        var key = Pharos.Utility.Config.GetAppSettings(_SerialKey);
                        if (!key.IsNullOrEmpty())
                        {
                            var apppath = Url.GetApplicationPath;
                            System.Threading.Tasks.Task.Factory.StartNew(() =>
                            {
                                omsurl  = OmsUrl + "api/outerapi/RegisterAgain";
                                var sno = "";
                                if (company.MachineSN.IsNullOrEmpty())
                                {
                                    company.MachineSN = Machine.GetMAC;
                                    sno = HttpClient.HttpPost(omsurl, company.ToJson());//更新机器码
                                }
                                omsurl = OmsUrl + "api/outerapi/GetSerialNo";
                                sno    = HttpClient.HttpPost(omsurl, companyId.ToString());
                                if (!sno.IsNullOrEmpty())
                                {
                                    sno = sno.Replace("\"", "");
                                }
                                if (AnalysisSN(sno) != null && sno != key)
                                {
                                    new Pharos.Utility.Config(apppath).SetAppSettings(_SerialKey, sno);//更新配置
                                    DictRegister[companyId] = null;
                                }
                            });
                        }
                        else
                        {
                            string msg = string.Format("<script>if(confirm('商户未激活是否激活?')) window.location.href='{0}';</script>", Url.GetApplicationPath + "Authorization/activate?again=1&cid=" + companyId);
                            HttpContext.Current.Response.Write(msg);
                            RemoveCurrentAuth();
                            op.Message   = "独立方式,注册系列号不能为空,请联系管理员!";
                            op.Successed = false;
                        }
                        if (!company.MachineSN.IsNullOrEmpty() && company.MachineSN != Machine.GetMAC)
                        {
                            op.Message   = "请在注册时的服务器上使用!";
                            op.Successed = false;
                        }
                    }
                }
                #endregion
            }
            return(op);
        }
Exemplo n.º 16
0
        public ActionResult Register(CompanyAuthorize obj)
        {
            var op = Authorize.RegisterAgain(obj);

            return(Content(op.ToJson()));
        }
        public ActionResult Add(CompanyAuthorize obj)
        {
            var op = CompAuthorService.Add(obj);

            return(new OpActionResult(op));
        }
Exemplo n.º 18
0
 public OpResult SaveOrUpdate(CompanyAuthorize obj)
 {
     if (!TraderRepository.GetQuery(o => o.CID == obj.CID).Any())
     {
         return(OpResult.Fail("商户不存在!"));
     }
     //if(!obj.RealmName.IsNullOrEmpty()) obj.RealmName=obj.RealmName.Trim();
     //if(!obj.RealmName.IsNullOrEmpty() && RealmRepository.GetQuery(o => o.Name == obj.RealmName && o.Url!=obj.RealmUrl).Any())
     //    return OpResult.Fail("子域名已存在!");
     obj.AppProper    = obj.AppProper ?? "N";
     obj.StoreProper  = obj.StoreProper ?? "N";
     obj.PosMinorDisp = obj.PosMinorDisp ?? "N";
     obj.MemberShared = obj.MemberShared ?? "Y";
     if (obj.Id == 0)
     {
         if (CompanyAuthorRepository.GetQuery(o => o.CID == obj.CID).Any())
         {
             return(OpResult.Fail("该商户已存在,如果已过期,请选择续约方式"));
         }
         obj.CreateDT     = DateTime.Now;
         obj.CreateUID    = CurrentUser.UID;
         obj.ExpirationDT = DateTime.Parse(obj.EffectiveDT).AddMonths(obj.ValidityNum.GetValueOrDefault()).ToString("yyyy-MM-dd");
         if (obj.RealmName.IsNullOrEmpty())
         {
             CompanyAuthorRepository.Add(obj);
         }
         else
         {
             //CompanyAuthorRepository.Add(obj, false);
             //RealmRepository.Add(new Realm() { CID = obj.CID.Value, Name = obj.RealmName, State = Convert.ToInt16(obj.RealmState), Url = obj.RealmName + obj.RealmSuffixUrl });
         }
     }
     else
     {
         var res = CompanyAuthorRepository.Get(obj.Id);
         var pwd = res.SupperPassword;
         obj.ToCopyProperty(res, new List <string>()
         {
             "CreateDT", "CreateUID", "CID", "MachineSN", "SerialNo"
         });
         res.ExpirationDT = DateTime.Parse(obj.EffectiveDT).AddMonths(obj.ValidityNum.GetValueOrDefault()).ToString("yyyy-MM-dd");
         if (obj.SupperPassword.IsNullOrEmpty())
         {
             res.SupperPassword = pwd;
         }
         //if(!res.RealmName.IsNullOrEmpty())
         //{
         //    var realm = RealmRepository.Find(o => o.Url == res.RealmUrl && o.CID==res.CID.Value);
         //    if (realm == null)
         //    {
         //        realm = new Realm();
         //        realm.CID = res.CID.Value;
         //        RealmRepository.Add(realm,false);
         //    }
         //    realm.Name = res.RealmName;
         //    realm.Url = res.RealmName + res.RealmSuffixUrl;
         //    realm.State = Convert.ToInt16(res.RealmState);
         //}
         //else if (res.RealmName.IsNullOrEmpty())
         //{
         //    var reals = RealmRepository.GetQuery(o => o.Url == res.RealmUrl && o.CID == res.CID).ToList();
         //    RealmRepository.RemoveRange(reals, false);
         //}
         CompanyAuthorRepository.SaveChanges();
     }
     return(OpResult.Success());
 }
Exemplo n.º 19
0
 public int RegisterAgain([FromBody] CompanyAuthorize company)
 {
     return(Convert.ToInt32(CompAuthorService.RegisterAgain(company)));
 }