示例#1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="file"></param>
        /// <param name="dir"></param>
        /// <returns></returns>
        public static SourceFile SaveFile(System.Web.HttpPostedFileBase file, string dir, object obj)
        {
            SourceFile img = new SourceFile();

            string FtpServerHttpUrl = System.Configuration.ConfigurationManager.AppSettings["FtpServerHttpUrl"];
            string FtpServer = System.Configuration.ConfigurationManager.AppSettings["FtpServer"];
            string FtpUser = System.Configuration.ConfigurationManager.AppSettings["FtpUser"];
            string FtpPassWord = System.Configuration.ConfigurationManager.AppSettings["FtpPassWord"];

            string Dir = DateTime.Now.ToString("yyyyMMdd");
            FTPHelper ftp = new FTPHelper(FtpServer, dir + "/" + Dir, FtpUser, FtpPassWord);

            FileInfo file2 = new FileInfo(file.FileName);

            //string fileName = Guid.NewGuid() + file2.Extension;//文件的真实存储名是GUID
            IdWorker workId = new IdWorker();
            string fileName = workId.nextId() + file2.Extension;//新的自定义能全局的Id,
            ftp.Upload(file, fileName);

            img.Domain = FtpServerHttpUrl;
            img.Server = ftp.FtpServer;
            img.Path = ftp.FtpRemotePath + "/" + fileName;
            img.FileName = file.FileName;//上传时的文件名
            //img.Guid = fileName;
            img.Extension = file2.Extension;
            //img.AddTime = DateTime.Now;
            img.AddUserId = int.Parse(obj.ToString());

            return img;
        }
示例#2
0
        public ActionResult PostAdd(ProductModel parm)
        {
            #region 初始化参数
            Product model = new Product();

            model.AddTime = DateTime.Now;
            model.AddUserId = AdminUser.ID;
            model.State = RowState.有效;
            //model.Guid = Guid.NewGuid().ToString();
            IdWorker workId = new IdWorker();
            model.Guid = workId.nextId().ToString();
            model.DeptId = AdminUser.DeptId;

            model.Desc = parm.Desc;
            model.Name = parm.Name;
            model.CostScore = parm.CostScore;
            model.Count = parm.Count;
            model.EndTime = parm.EndTime;
            model.StartTime = parm.StartTime;
            model.Price = parm.Price;
            model.BarCode = parm.BarCode;
            model.Type = parm.Type;
            model.Sponsors = parm.Sponsors;
            foreach (var item in parm.SourceFileList)
            {
                item.Guid = model.Guid;
                item.AddTime = DateTime.Now;

            }

            model.LogoGuid = Guid.NewGuid().ToString();
            foreach (var item in parm.SourceFileListLogo)
            {
                item.Guid = model.LogoGuid;
                item.AddTime = DateTime.Now;

            }
            model.AdGuid = Guid.NewGuid().ToString();
            foreach (var item in parm.SourceFileListAd)
            {
                item.Guid = model.AdGuid;
                item.AddTime = DateTime.Now;

            }
            #endregion

            using (LoveBankDBContext db = new LoveBankDBContext())
            {

                db.Add(model);
                db.SaveChanges();
                db.T_SourceFile.AddRange(parm.SourceFileList);
                db.T_SourceFile.AddRange(parm.SourceFileListLogo);
                db.T_SourceFile.AddRange(parm.SourceFileListAd);
                db.SaveChanges();

                return Success("添加成功");

            }
        }
示例#3
0
文件: Program.cs 项目: gowhy/LoveBank
        static void Start(IAppBuilder app)
        {
            //var ids=  IdWorker.GetId();

            IdWorker workId = new IdWorker();
            long id = workId.nextId();

            IList<long> list = new List<long>();

            list.Add(id);

            //for (int i = 0; i < 1000; i++)
            //{
            //    Task t1 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t1.Start();
            //    Task t2 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t2.Start();
            //    Task t3 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t3.Start();

            //    Task t4 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t4.Start();
            //    Task t5 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t5.Start();
            //    Task t6 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t6.Start();

            //    Task t7 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t7.Start();
            //    Task t8 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t8.Start();
            //    Task t9 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t9.Start();

            //    Task t10 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    t10.Start();
            //    //Task t11 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    //t11.Start();
            //    //Task t12 = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
            //    //t12.Start();

            //}
            Hashtable tb = new Hashtable();
            Task[] tas = new Task[10];
            //tb.Add(1, 1);
            //tb.Add(1, 1);
            for (int i = 0; i < tas.Length; i++)
            {
                //tas[i] = new Task(() => { list.Add(workId.nextId()); Console.WriteLine(workId.nextId()); });
                tas[i] = new Task(() => {
                    for (int j= 0; j < 10; j++)
                    {
                        //var idsb =(new IdWorker(0,1)).GetId();
                        var idsb = workId.nextId();
                        tb.Add(idsb, idsb); Console.WriteLine(idsb);
                    }

                });
                tas[i].Start();
            }
            Task.WaitAll(tas);
             //           List<RawWeeklyAccounts> list;

             //var q=from r in list.GroupBy(x=>x.MsuName)
             //      order r by r.weeknumber
             //      select new WeeklyAccounts
             //      {
             //         Weeknumber=r.weeknumber,
             //         TotalAccounts=r.TotalAccounts
             //      };

            //var s = from c in list.GroupBy(x=>x) orderby c select c ;

            return;
            // First, initialize Quartz.NET as usual. In this sample app I'll configure Quartz.NET by code.
            var schedulerFactory = new StdSchedulerFactory();
            var scheduler = schedulerFactory.GetScheduler();
            scheduler.Start();

            // I'll add some global listeners
            //scheduler.ListenerManager.AddJobListener(new GlobalJobListener());
            //scheduler.ListenerManager.AddTriggerListener(new GlobalTriggerListener());

            // A sample trigger and job
            var trigger = TriggerBuilder.Create()
                .WithIdentity("myTrigger")
                .WithSchedule(DailyTimeIntervalScheduleBuilder.Create()
                    .WithIntervalInSeconds(60*10))//10分钟执行一次
                .StartNow()
                .Build();
            var job = new JobDetailImpl("crawlInfoJob", null, typeof(CrawlInfoJob));
            scheduler.ScheduleJob(job, trigger);
        }