public int SaveAs(string id = null, string title = null, string content = null, string categoryID = null, string status = null, string plainText = null , string publishTime = "1990-01-01", string thumbnailSrc = null, string bizMode = null) { var session = SESSION.Current; var inst = new DocItem(); var isNew = false; if (StringChecker.IsNotEmptyObjectId(id)) { inst._id = ObjectId.Parse(id); } else { inst._id = ObjectId.GenerateNewId(); //inst.ID = Guid.NewGuid(); inst.CreateTime = DateTime.Now.AddDays(new Random().Next(-100, 100)); inst.CreatorName = session.UserName; inst.CreatorID = session.UserID; isNew = true; } inst.Title = title; inst.Keyword = "暂空"; inst.Summary = "暂空"; inst.Content = content; inst.ContentLength = content.Length; //inst.CategoryID = categoryID; //inst.CategoryName = CategoryManager.GetInstance().Get(categoryID).Name; //inst.ContentType = "文档库模板"; inst.PublishTime = DateTime.Parse(publishTime); inst.Status = status; inst.PlainText = plainText; inst.PlainTextLength = plainText.Length; inst.UpdateTime = DateTime.Now; if (StringChecker.IsHttpUrl(thumbnailSrc)) { inst.ImageUrl = thumbnailSrc; } else { var pic = (DataSourceBaidu.GetInstance().GetPic(inst.Title)[0] as Dictionary <string, object>)["thumbURL"].ToString(); inst.ImageUrl = pic; } inst.Save(); ///添加记录 //if (isNew) //{ // ModifyLogItem.LogAsNew(inst.id, CONST.DB.DBName_DocService, CONST.DB.CollectionName_DocItem); //} //else //{ // ModifyLogItem.LogAsModify(inst.id, CONST.DB.DBName_DocService, CONST.DB.CollectionName_DocItem); //} return(0); }
static void Main(string[] args) { #region 宿主进程 var json = Convertor.FromJsonToDict2(File.ReadAllText("config.js")); var serviceName = json["ServiceName"].ToString(); StockSynchronizer sync = StockSynchronizer.GetInstance(); var analysor = StockAnalyser.GetInstance(); if ("Test" == serviceName) { } else if ("SyncStockNews" == serviceName) { sync.SyncStockNews(); } else if ("SyncSINADaDan" == serviceName) { sync.SyncSINADaDan(); } else if ("SyncKLineDay" == serviceName) { sync.SyncKLineDay(); } else if ("SyncGSJJ" == serviceName) { sync.SyncGSJJ(); } else if ("SyncBKGN" == serviceName) { sync.SyncBKGN(); } else if ("SyncZJLX" == serviceName) { sync.SyncZJLX(); } else if ("SyncStockCode" == serviceName) { sync.SyncStockCode(); } else if ("SyncCWZY" == serviceName) { sync.SyncCWZY(); } else if ("SyncStockRardar" == serviceName) { sync.SyncStockRardar(); } else if ("SyncRZRQ" == serviceName) { sync.SyncRZRQ(); } else if ("AnalyseRisingStock" == serviceName) { analysor.AnalyseRisingStock(startTime: DateTime.Now.AddDays(-10), endTime: DateTime.Now.AddDays(-5)); } else if ("DocRunner" == serviceName) { //WeChatService.GetAllOrg(); //new DocRunner().DataAnalyse(); var res = new DataSourceBaidu().GetPic("骆驼管家告诉你投资P2P,分散也要懂策略!"); //MongoDB.GetInst("mongodb").Aggregate("DocService", "DocItem", "{}"); //for (int k = 0; k < 1000; k++) //{ // DocManager.GetInstance().Save("测试" + k, "<p>Test"+k+"</p>", "5a78263026b0185ef8d286c2", "2018-02-10 0:0:0", "已发布", null, "Test"); // LOGGER.Log("已添加"+k); //} } else if ("SyncExcel" == serviceName) { //DataSourceSINA.GetInstance().DownloadExcel(); //new DocRunner().DataAnalyse(); //sync.ProcHistory(); //ExcelService.GetInstance().ConvertToJson(@"F:\【工程】2015年年终奖数据.xlsx", "Test", @"F:\Test"); } #endregion Console.WriteLine("全部结束"); Console.ReadKey(); }