// GET: CompanyPayType public ActionResult Index() { var payTypes = CompanyPayTypeHelper.PayTypeList(); var salaryPayType = payTypes.FirstOrDefault(i => i.Id == SalaryPayType); if (salaryPayType == null) { //初次加载,初始化薪资支出与进水支出类别,且不允许删除 List <CompanyPayType> payTypeMods = new List <CompanyPayType> { new CompanyPayType { Id = SalaryPayType, PayType = "员工薪资支出" }, new CompanyPayType { Id = BucketPayType, PayType = "进水支出" } }; MongoBase.Insert(payTypeMods); } ViewBag.flag = "payTypes"; return(View(payTypes)); }
public ActionResult Create(Customer customer) { customer.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <Customer>(customer); return(RedirectToAction("index")); }
public ActionResult Create(CompanyPayType companyPayType) { companyPayType.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <CompanyPayType>(companyPayType); return(RedirectToAction("index")); }
public HttpResponseMessage Home() { var collection = MongoBase.GetCollection(EnumMongodbCollection.Cate); var dictword = collection.AsQueryable <MediaModel>().Take(50).ToList(); return(Request.CreateResponse(HttpStatusCode.OK, dictword)); }
public ActionResult CompanyCreate(CompanyPayRecord companyPayRecord) { //MongoDB采取的是UTC时间,而通常系统用的是Local时间(中国) companyPayRecord.TransTime = DateTime.SpecifyKind(companyPayRecord.TransTime, DateTimeKind.Utc); companyPayRecord.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <CompanyPayRecord>(companyPayRecord); return(RedirectToAction("CompanyRecord")); }
/// <summary> /// 工资发放 /// </summary> /// <param name="staffSalary"></param> /// <returns></returns> public ActionResult PaySalary(StaffSalary staffSalary) { //检查该月份该员工是否已经发过工资 var staffSal = SalaryHelper.CheckIfPaid(staffSalary.StaffId, staffSalary.SalaryMonth); if (staffSal != null) { TempData["CheckErr"] = "该员工" + staffSalary.SalaryMonth.Year + "-" + staffSalary.SalaryMonth.Month + "的薪资已经发放,请核查"; return(RedirectToAction("SalaryList")); } //获取该员工该薪资月的送水记录,统计提成用 var dailyRecords = DailyRecordHelper.DailyRecordList() .Where(item => item.VisitDate.Year == staffSalary.SalaryMonth.Year && item.VisitDate.Month == staffSalary.SalaryMonth.Month && item.StaffId == staffSalary.StaffId); //判断是否需要薪资发放类型 var salaryType = CompanyPayTypeHelper.GetById(SalaryPayType); if (salaryType == null) { MongoBase.Insert(new CompanyPayType { Id = SalaryPayType, PayType = "员工薪资支出" }); } staffSalary.Id = ObjectId.NewObjectId().ToString(); staffSalary.Commission = dailyRecords.Sum(i => i.SendBucketAmount) * Commission(); //提成 MongoBase.Insert(staffSalary); //公司当月支出增多相应金额 CompanyPayRecord companyRecord = new CompanyPayRecord() { Id = ObjectId.NewObjectId().ToString(), IsPayType = true, PayTypeId = SalaryPayType, StaffId = staffSalary.StaffId, TransSum = staffSalary.Salary, TransTime = Convert.ToDateTime(staffSalary.SalaryMonth + "-28") }; MongoBase.Insert(companyRecord); return(RedirectToAction("SalaryList")); }
public ActionResult Create(Products product) { //重名判断 var pro = ProductHelper.GetByName(product.ProductName); if (pro != null) { TempData["isRepeat"] = true; } else { product.Id = ObjectId.NewObjectId().ToString(); product.UpdateTime = DateTime.Now; MongoBase.Insert(product); } return(RedirectToAction("index")); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var jwtBearerConfig = Configuration.GetSection("JwtBearer").Get <JwtBearerConfig>(); services.AddSingleton <IJwtService>(new JwtService(jwtBearerConfig)); var database = new MongoBase(); if (!database.OpenConnection()) { throw new Exception("Could not connect to database"); } services.AddSingleton(database); services.AddScoped <IUserService, UserService>(); services.AddScoped <IBookService, BookService>(); services.AddScoped <ILendService, LendService>(); services.AddScoped <IReservationService, ReservationService>(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => Configuration.Bind("CookieConfig", options)) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters() { ValidateIssuer = true, ValidIssuer = jwtBearerConfig.Issuer, ValidateAudience = true, ValidAudience = jwtBearerConfig.Audience, IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(jwtBearerConfig.Secret)), ValidateLifetime = true, NameClaimType = "name" }; }); services.AddControllersWithViews(); }
public ActionResult Create(Factory factory) { factory.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <Factory>(factory); return(RedirectToAction("index")); }
public UserInfoService(MongoBase <UserInfo> client) { mongoBase = client; }
public void LoadDynamicData() { MongoBase mb = new MongoBase(); mb.LoadDynamicData(); }
public void DynamicDataTest3() { MongoBase mb = new MongoBase(); mb.DynamicDataTest3(); }
public void MongoObjectIdSerialize() { MongoBase mb = new MongoBase(); mb.MongoObjectIdSerialize(); }
public UserService(MongoBase database) { _database = database; }
public LendService(MongoBase database) { _database = database; }
public BookController(MongoBase database, IBookService bookService) : base() { _database = database; _bookService = bookService; }
public BookService(MongoBase database) { _database = database; }
public ActionResult Create(Staff staff) { staff.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert <Staff>(staff); return(RedirectToAction("index")); }
public ReservationService(MongoBase database, ILendService lendService) { _database = database; _lendService = lendService; }
public ActionResult Create(StaffCustomer staffCustomer) { staffCustomer.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert(staffCustomer); return(RedirectToAction("Index")); }
/// <summary> /// 添加日常记账 /// </summary> /// <param name="dailyRecord"></param> /// <param name="hidBuckets"></param> /// <returns></returns> public ActionResult CreateDailyWrite(DailyRecord dailyRecord, string[] hidBuckets) { //MongoDB采取的是UTC时间,而通常系统用的是Local时间(中国) dailyRecord.VisitDate = DateTime.SpecifyKind(dailyRecord.VisitDate, DateTimeKind.Utc); string[] bucketPams = hidBuckets[0].Split(','); if (bucketPams.Length == 1) { if (dailyRecord.EarnMonthEndPrice >= 0 || dailyRecord.EarnWaterCardPrice >= 0) { //添加日常记录 dailyRecord.Id = ObjectId.NewObjectId().ToString(); MongoBase.Insert(dailyRecord); //添加公司下次送水日期 Customer customer = CustomerHelper.GetById(dailyRecord.CustomerId); if (customer != null) { customer.NextDate = dailyRecord.NextDate; customer.NotifyFlag = 1;//开启通知 CustomerHelper.Update(customer); } } } else { for (int i = 0; i < bucketPams.Length; i++) { var t = i % 3; if (t == 0) { dailyRecord.SendProductId = bucketPams[i]; } else if (t == 1) { dailyRecord.SendBucketAmount = int.Parse(bucketPams[i]); } else { dailyRecord.ReceiveEmptyBucketAmount = int.Parse(bucketPams[i]); } if ((i + 1) % 3 == 0) { ////完成一个产品 //更新库存信息 var product = ProductHelper.GetById(dailyRecord.SendProductId); product.StockRemain += dailyRecord.SendBucketAmount; //桶装水库存增加 product.BucketStockRemain += dailyRecord.ReceiveEmptyBucketAmount; //空桶库存增加 ProductHelper.Update(product); //添加一条日常记录 dailyRecord.Id = ObjectId.NewObjectId().ToString(); //同一人在同一公司,资金交易只记一笔(避免汇总数据double);附属产品只记一笔 if (i > 2) { dailyRecord.EarnDeposit = 0; dailyRecord.PayDeposit = 0; dailyRecord.EarnMonthEndPrice = 0; dailyRecord.EarnWaterCardPrice = 0; dailyRecord.WaterDispenser = 0; dailyRecord.WaterHolder = 0; dailyRecord.PushPump = 0; dailyRecord.WaterDispenserBack = 0; dailyRecord.WaterHolderBack = 0; dailyRecord.PushPumpBack = 0; } MongoBase.Insert(dailyRecord); } } } return(RedirectToAction("DailyRecord")); }
static void Main(string[] args) { const string rssUrl = "http://channel9.msdn.com/Feeds/RSS"; XNamespace media = "http://search.yahoo.com/mrss/"; XNamespace itunes = "http://www.itunes.com/dtds/podcast-1.0.dtd"; XNamespace wfw = "http://wellformedweb.org/CommentAPI/"; var content = new HttpClient().GetStringAsync(rssUrl).Result; var list = new List <MediaModel>(); XElement config = XElement.Parse(content); XElement newx = XElement.Parse(config.FirstNode.ToString()); foreach (var item in newx.Descendants("item")) { var category = item.Descendants("category").Select(u => u.Value); var videosElement = item.Descendants(media + "content"); var imagesElement = item.Descendants(media + "thumbnail"); var videos = videosElement.Select(el => new VideoContent() { Duration = el.Attribute("duration") == null ? 0 : long.Parse(el.Attribute("duration").Value), Url = el.Attribute("url").Value, Size = el.Attribute("fileSize") == null ? 0 : long.Parse(el.Attribute("fileSize").Value), Type = el.Attribute("type").Value, }).ToList(); var images = imagesElement.Select(el => new ImageContent() { Height = int.Parse(el.Attribute("height").Value), Url = el.Attribute("url").Value, Width = int.Parse(el.Attribute("width").Value) }).ToList(); var link = item.Element("link").Value; if (link.Contains("http://channel9.msdn.com/coding4fun")) { continue; } var channel = ChannelCommon.GetChannelIdByLink(link); list.Add(new MediaModel { Title = item.Element("title").Value, Description = item.Element("description").Value, ChannelId = channel != null ? channel.Id.ToString() : null, Link = link, Guid = item.Element("guid").Value, Comments = "", Categorys = category.ToList(), Videos = videos, Images = images, Authors = item.Descendants(itunes + "author").Select(u => u.Value).ToList()[0].Split(',').Select(u => u.Trim()).ToList(), UpdateTime = DateTime.UtcNow, CreateTime = Convert.ToDateTime(item.Element("pubDate").Value).ToUniversalTime(), }); } var collection = MongoBase.GetCollection(EnumMongodbCollection.Medias); foreach (var item in list) { Console.WriteLine(item.Title); var dictword = collection.AsQueryable <MediaModel>().Any(u => u.Guid == item.Guid); if (!dictword) { collection.Insert(item.ToBsonDocument()); } } Console.WriteLine("over"); Thread.Sleep(5000); }
public void FindAPI() { MongoBase mb = new MongoBase(); mb.FindAPI(); }