Пример #1
0
        static void Main(string[] args)
        {
            var sessionFactory = CreateSessionFactory();

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    Feature feat = new Feature {
                        Name = "featuretest", Percentage = 50, IsEnabled = true, LastModifiedDate = DateTime.Now
                    };
                    FeatureGroup grp = new FeatureGroup {
                        Feature = feat, Name = "group1"
                    };
                    FeatureUser usr = new FeatureUser {
                        Feature = feat, Name = "user1"
                    };
                    session.SaveOrUpdate(feat);
                    session.SaveOrUpdate(grp);
                    session.SaveOrUpdate(usr);
                    Feature globFeat = new Feature {
                        Name = "globalfeat", Percentage = 100, IsEnabled = true, LastModifiedDate = DateTime.Now
                    };
                    session.SaveOrUpdate(globFeat);
                    transaction.Commit();
                }
            }

            Console.Read();
        }
Пример #2
0
        public ActionResult DeleteDistribution(long id)
        {
            FeatureUser featureUser = db.FeatureUsers.Get(id);

            if (featureUser != null)
            {
                db.FeatureUsers.Remove(featureUser);
                db.Complete();
            }
            return(RedirectToAction("FeaturesDistributionList"));
        }
Пример #3
0
        public void SetMigrateAnonymous()
        {
            var userId = WebCommon.GetUserId();
            IList <SiteMenusInfo> smis = new List <SiteMenusInfo>();
            UserProfileInfo       upi  = new UserProfileInfo();
            var menuBll = new SiteMenus();

            if (Roles.GetRolesForUser().Length == 0)
            {
                var      guestRole = new SiteRoles().GetAspnetModel(Membership.ApplicationName, "guest");
                string[] accessIds = { guestRole.Id.ToString() };
                smis = menuBll.GetMenusAccess(Membership.ApplicationName, accessIds, false);
                upi  = new UserProfileInfo {
                    SiteCode = AppCode, SiteTitle = GlobalConfig.SiteTitle
                };
            }
            else
            {
                var accessIds = new List <string>();
                accessIds.Add(userId.ToString());
                var roleIds = new SiteRoles().GetAspnetRoleIds(Membership.ApplicationName, Roles.GetRolesForUser());
                foreach (var item in roleIds)
                {
                    accessIds.Add(item.ToString());
                }
                var    isAdmin = HttpContext.Current.User.IsInRole("Administrators");
                Task[] tasks   = new Task[2];
                tasks[0] = Task.Factory.StartNew(() =>
                {
                    var fuInfo = new FeatureUser().GetModel(userId, "UserProfile");
                    if (fuInfo != null)
                    {
                        upi.SiteCode    = fuInfo.SiteCode;
                        upi.SiteTitle   = fuInfo.SiteTitle;
                        upi.SiteLogo    = string.IsNullOrWhiteSpace(fuInfo.SiteLogo) ? "" : WebCommon.GetSiteAppName() + fuInfo.SiteLogo;
                        upi.CultureName = fuInfo.CultureName;
                    }
                });

                tasks[1] = Task.Factory.StartNew(() =>
                {
                    smis = menuBll.GetMenusAccess(Membership.ApplicationName, accessIds.ToArray(), isAdmin);
                });
                Task.WaitAll(tasks);
            }

            var Profile = new CustomProfileCommon();

            Profile.UserMenus = JsonConvert.SerializeObject(smis);
            Profile.UserInfo  = JsonConvert.SerializeObject(upi);

            Profile.Save();
        }
Пример #4
0
 public ActionResult DistributeFeatures([Bind(Include = "FeatureId,UserId")] FeatureUser featureUser)
 {
     if (ModelState.IsValid)
     {
         var f = db.Features.Get(featureUser.FeatureId);
         if (!(f.FeatureUsers.Count() > 0))
         {
             db.FeatureUsers.Add(featureUser);
             db.Complete();
         }
         return(RedirectToAction("Index"));
     }
     return(View(featureUser));
 }
Пример #5
0
 public ResResultModel GetFeatureUserInfo(string username, string typeName)
 {
     try
     {
         var bll    = new FeatureUser();
         var fuInfo = bll.GetModel(SecurityService.GetUserId(username), typeName);
         if (fuInfo == null)
         {
             fuInfo = new FeatureUserInfo();
         }
         return(ResResult.Response(true, "", JsonConvert.SerializeObject(fuInfo)));
     }
     catch (Exception ex)
     {
         return(ResResult.Response(false, ex.Message, ""));
     }
 }
Пример #6
0
        protected void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
        {
            AnonymousIdentificationModule.ClearAnonymousIdentifier();

            try
            {
                var userId    = WebCommon.GetUserId();
                var menuBll   = new SiteMenus();
                var accessIds = new List <string>();
                accessIds.Add(userId.ToString());
                Task[] tasks = new Task[3];
                tasks[0] = Task.Factory.StartNew(() =>
                {
                    var roleIds = new SiteRoles().GetAspnetRoleIds(Roles.GetRolesForUser());
                    foreach (var item in roleIds)
                    {
                        accessIds.Add(item.ToString());
                    }
                });
                var userProfileInfo = new UserProfileInfo();
                tasks[1] = Task.Factory.StartNew(() =>
                {
                    var fuInfo = new FeatureUser().GetModel(userId, "UserProfile");
                    if (fuInfo != null)
                    {
                        userProfileInfo.SiteCode    = fuInfo.SiteCode;
                        userProfileInfo.SiteTitle   = fuInfo.SiteTitle;
                        userProfileInfo.SiteLogo    = string.IsNullOrWhiteSpace(fuInfo.SiteLogo) ? "" : WebCommon.GetSiteAppName() + fuInfo.SiteLogo;
                        userProfileInfo.CultureName = fuInfo.CultureName;
                    }
                });
                IList <SiteMenusInfo> maList = new List <SiteMenusInfo>();
                tasks[2] = Task.Factory.StartNew(() =>
                {
                    maList = menuBll.GetMenusAccess(Membership.ApplicationName, accessIds.ToArray(), User.IsInRole("Administrators"));
                });
                Task.WaitAll(tasks);

                var Profile = new CustomProfileCommon();
                Profile.UserMenus = JsonConvert.SerializeObject(maList);
                Profile.UserInfo  = JsonConvert.SerializeObject(userProfileInfo);

                Profile.Save();
            }
            catch { }
        }
Пример #7
0
        private void GetFeatureUserInfo(HttpContext context)
        {
            var userId   = Guid.Parse(Membership.GetUser(context.Request.Form["UserName"]).ProviderUserKey.ToString());
            var typeName = context.Request.Form["TypeName"];

            var             bll    = new FeatureUser();
            FeatureUserInfo fuInfo = bll.GetModel(userId, typeName);

            if (fuInfo != null)
            {
                context.Response.Write(ResResult.ResJsonString(true, "", JsonConvert.SerializeObject(fuInfo)));
            }
            else
            {
                context.Response.Write(ResResult.ResJsonString(true, "", "{}"));
            }
        }
Пример #8
0
        public ResResultModel SaveFeatureUser(FeatureUserFmModel model)
        {
            try
            {
                var featureId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(model.FeatureId))
                {
                    Guid.TryParse(model.FeatureId, out featureId);
                }
                var userId = SecurityService.GetUserId(model.UserName);

                var fuBll = new FeatureUser();
                fuBll.DoFeatureUser(userId, featureId, model.TypeName, true);

                return(ResResult.Response(true, "", ""));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Пример #9
0
        public string SaveOrderScan(string orderCode, string customerCode, string orderStep, string loginId, string deviceId, string latlng)
        {
            try
            {
                new CustomException(string.Format("SaveOrderScan--orderCode:{0}--customerCode:{1}--orderStep:{2}--loginId:{3}--deviceId:{4}--latlng:{5}", orderCode, customerCode, orderStep, loginId, deviceId, latlng));

                orderCode    = orderCode.Trim();
                customerCode = customerCode.Trim();
                orderStep    = orderStep.Trim();
                loginId      = loginId.Trim();
                deviceId     = deviceId.Trim();
                latlng       = latlng.Trim();
                var ip              = HttpClientHelper.GetClientIp(HttpContext.Current);
                var currTime        = DateTime.Now;
                var latlngPlace     = string.Empty;
                var ipPlace         = string.Empty;
                var orderId         = Guid.Empty;
                var staffCodeOfTake = string.Empty;
                var staffCode       = string.Empty;
                var takeTime        = DateTime.Parse("1754-01-01");
                var reachTime       = takeTime;
                if (orderStep == "已取件")
                {
                    staffCode = loginId;
                    takeTime  = currTime;
                }
                else if (orderStep == "已送达")
                {
                    staffCodeOfTake = loginId;
                    reachTime       = currTime;
                }


                var oBll         = new OrderMake();
                var opBll        = new OrderProcess();
                var effect       = 0;
                var oldOrderInfo = oBll.GetModel(orderCode, customerCode);
                if (oldOrderInfo != null)
                {
                    orderId = oldOrderInfo.Id;
                    if (orderStep == "已送达")
                    {
                        oldOrderInfo.StaffCodeOfTake = staffCodeOfTake;
                        oldOrderInfo.ReachTime       = reachTime;
                        oBll.Update(oldOrderInfo);
                    }
                }
                else
                {
                    var userId = WebCommon.GetUserId();
                    if (userId.Equals(Guid.Empty))
                    {
                        throw new ArgumentException(MC.Login_NotExist);
                    }
                    var appCode = Auth.AppCode;
                    var fuInfo  = new FeatureUser().GetModel(userId, "UserProfile");
                    if (fuInfo != null)
                    {
                        appCode = fuInfo.SiteCode;
                    }

                    orderId      = Guid.NewGuid();
                    oldOrderInfo = new OrderMakeInfo(orderId, appCode, userId, customerCode, orderCode, "", "", "", "", "", "", "", staffCode, staffCodeOfTake, takeTime, reachTime, "", "", 0, 0, 0, 0, 0, "", "", currTime, currTime);
                    effect       = oBll.InsertByOutput(oldOrderInfo);
                }
                var opInfo    = new OrderProcessInfo(Guid.Empty, orderId, loginId, orderStep, "", deviceId, latlng, latlngPlace, ip, ipPlace, currTime, currTime);
                var oldOpInfo = opBll.GetModel(orderId, orderStep);
                if (oldOpInfo != null)
                {
                    opInfo.Id       = oldOpInfo.Id;
                    opInfo.Pictures = oldOpInfo.Pictures;
                    if (oldOpInfo.Ip == ip)
                    {
                        opInfo.IpPlace = oldOpInfo.IpPlace;
                    }
                    if (oldOpInfo.Latlng == latlng)
                    {
                        opInfo.LatlngPlace = oldOpInfo.LatlngPlace;
                    }
                    effect = opBll.Update(opInfo);
                }
                else
                {
                    opInfo.Id = Guid.NewGuid();
                    effect    = opBll.InsertByOutput(opInfo);
                }
                if (string.IsNullOrWhiteSpace(opInfo.IpPlace) || string.IsNullOrWhiteSpace(opInfo.LatlngPlace))
                {
                    new RunQueueAsyn().Insert(new RunQueueInfo(EnumData.EnumRunQueue.BaiduMapRestApi.ToString(), string.Format(@"{{""Latlng"":""{0}"",""Ip"":""{1}"",""OrderProcessId"":""{2}""}}", latlng, ip, opInfo.Id), EnumData.EnumRunQueue.BaiduMapRestApi.ToString(), 0));
                }
                if (effect > 0)
                {
                    return(ResResult.ResJsonString(true, "", opInfo.Id));
                }
                else
                {
                    return(ResResult.ResJsonString(false, MC.M_Save_Error, ""));
                }
            }
            catch (Exception ex)
            {
                new CustomException("SaveOrderScan--", ex);
                return(ResResult.ResJsonString(false, ex.Message, ""));
            }
        }