Ejemplo n.º 1
0
        public virtual ActionResult Add()
        {
            var id         = Id;
            var targetId   = this.TargetId;
            var categoryId = this.CategoryId;

            if (id.HasValue)
            {
                var r = IComCountService.Add(id.Value, this.Count, this.Table);
                return(this.ResponseJson(r));
            }
            else if (targetId.HasValue && IValidatorTool.IsNotEmpty(categoryId))
            {
                var r = IComCountService.Add(targetId.Value, categoryId, this.Count, this.Table);
                return(this.ResponseJson(r));
            }
            else
            {
                return(ResponseJson(new GenericExecResult <object>()
                {
                    Success = false,
                    Message = "请输入相应的参数id或targetId与categoryId"
                }));
            }
        }
Ejemplo n.º 2
0
 public virtual ActionResult Find()
 {
     if (this.Id.HasValue)
     {
         var r = IComCountService.FindById(this.Id.Value);
         return(this.ResponseJson(r));
     }
     else if (TargetId.HasValue && IValidatorTool.IsNotEmpty(CategoryId))
     {
         var r = IComCountService.FindFirstOrDefaultByTargetIdAndCategoryId(this.TargetId.Value, this.CategoryId, this.Table);
         return(this.ResponseJson(r));
     }
     else if (this.TargetId.HasValue)
     {
         var r = IComCountService.FindByTargetId(this.TargetId.Value, this.Table);
         return(this.ResponseJson(r));
     }
     else
     {
         return(ResponseJson(new GenericExecResult <object>()
         {
             Success = false,
             Message = "请输入相应的参数id或targetId与categoryId"
         }));
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //   IComCountDao k = ServiceFactory.Get<IComCountDao>();
            var t1 = new ThreadStart(() =>
            {
                try
                {
                    var ioc = ToolFactory.Ioc;

                    SyncObj1 = Thread.CurrentThread.Name;
                    // Thread.Sleep(new Random().Next(100, 200));
                    var obj = ioc.Get <object>("NHibernateSessionFactory");
                    var localSessionFactoryObjectThreadSafe = ioc.Get <LocalSessionFactoryObjectThreadSafe>("&NHibernateSessionFactory");

                    IComCountService a = ServiceFactory.Get <IComCountService>();
                    var list           = a.FindAll();

                    //foreach (var item in list.Data)
                    //{
                    //    System.Console.WriteLine(string.Format("{0},{1}", Thread.CurrentThread.Name, item.Id));
                    //}
                }
                catch (Exception ex)
                {
                    var kk = 0;
                }
            });

            for (var i = 0; i < 5; i++)
            {
                var thread = new Thread(t1);
                thread.Name = i.ToString();
                thread.Start();
            }
            //  System.Console.ReadLine();
        }