protected override void OnStart(string[] args) { DebuggableAttribute att = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttribute <DebuggableAttribute>(); if (att.IsJITTrackingEnabled) { //Debug模式才让线程停止10s,方便附加到进程调试 Thread.Sleep(10000); } //配置信息读取 ConfigInit.Init(); //3.系统参数配置初始化 MefConfig.Init(); ConfigManager configManager = MefConfig.TryResolve <ConfigManager>(); configManager.Init(); QuartzHelper.InitScheduler(); QuartzHelper.StartScheduler(); // 保持web服务运行 ThreadPool.QueueUserWorkItem((o) => { //启动站点 Startup.Start(SystemConfig.WebHost, SystemConfig.WebPort); }); }
public Curation() { logger = LogManager.GetLogger("Curation"); logger.Info("Starting Colectica Curation Service"); logger.Info($"Version {RevisionInfo.FullVersionString}"); //logger.Info("Loading Colectica Curation Addins"); // Load Addins string binPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string addinsPath = Path.Combine(binPath, "CurationAddins"); #if ISPRO DdiAddins.Utility.RepositoryHelper.InitializeLogging("CurationService-.log"); MefConfig.RegisterMef(addinsPath, typeof(Colectica.Curation.DdiAddins.DdiAddinManifest).Assembly); string repositoryHostName = Properties.Settings.Default.RepositoryHostName; if (!string.IsNullOrWhiteSpace(repositoryHostName)) { DdiAddins.Utility.RepositoryHelper.RepositoryHostName = repositoryHostName; } DdiAddins.Utility.RepositoryHelper.UserName = Properties.Settings.Default.RepositoryUserName; DdiAddins.Utility.RepositoryHelper.Password = Properties.Settings.Default.RepositoryPassword; #else MefConfig.RegisterMef(addinsPath, typeof(Colectica.Curation.BaseAddins.BaseAddinManifest).Assembly); #endif timer = new Timer(1000); timer.AutoReset = false; // non reentrant timer.Elapsed += timer_Elapsed; }
/// <summary> /// 初始化 /// </summary> public void Init() { Commands = MefConfig.ResolveMany <ICommand>(); Thread thread = new Thread(Run); thread.Start(); }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MefConfig.RegisterMef(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); MefConfig.Register(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MefConfig.RegisterMef(); }
static void Main(string[] args) { MefConfig.Init(); Plugins = MefConfig.ResolveMany <IPlugin>(); foreach (var item in Plugins) { item.Init(); } Console.Read(); }
public String UseVer(int?version) { if (version == null) { version = 1; } MefConfig.Register("Version" + version); return("Using Version" + version); }
static void Main(string[] args) { AdminRun.Run(); if (!SetConsoleCtrlHandler(cancelHandler, true)) { Console.WriteLine("程序监听系统按键异常"); } try { //1.MEF初始化 MefConfig.Init(); //2.数据库初始化连接 ConfigInit.InitConfig(); //3.系统参数配置初始化 ConfigManager configManager = MefConfig.TryResolve <ConfigManager>(); configManager.Init(); Console.Title = SystemConfig.ProgramName; Console.CursorVisible = false; //隐藏光标 //4.任务启动 QuartzHelper.InitScheduler(); QuartzHelper.StartScheduler(); //5.加载SQL信息到缓存中 XmlCommandManager.LoadCommnads(SysConfig.XmlCommandFolder); //测试dapper orm框架 //DapperDemoService.Test(); //启动站点 using (NancyHost host = Startup.Start(SystemConfig.WebPort)) { //调用系统默认的浏览器 string url = string.Format("http://127.0.0.1:{0}", SystemConfig.WebPort); Process.Start(url); Console.WriteLine("系统已启动,当前监听站点地址:{0}", url); //4.消息队列启动 RabbitMQClient.InitClient(); //5.系统命令初始化 CommandHelp.Init(); } } catch (Exception ex) { Console.WriteLine(ex); } Console.Read(); }
void Application_Start(object sender, EventArgs e) { MefConfig.RegisterMef(); // Code that runs on application startup GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //ControllerBuilder.Current.SetControllerFactory(new MefControllerFactory( // Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"))); log4net.Config.XmlConfigurator.Configure(new FileInfo(Server.MapPath("~/Web.config"))); }
protected override void OnStart(string[] args) { try { //1.MEF初始化 MefConfig.Init(); //2.数据库初始化连接 ConfigInit.InitConfig(); //3.系统参数配置初始化 ConfigManager configManager = MefConfig.TryResolve <ConfigManager>(); configManager.Init(); //4.任务启动 QuartzHelper.InitScheduler(); QuartzHelper.StartScheduler(); //5.加载SQL信息到缓存中 XmlCommandManager.LoadCommnads(SysConfig.XmlCommandFolder); //开发时监听资源文件变化,用于实时更新 DevelperHelper.WatcherResourceChange(); // 保持web服务运行 ThreadPool.QueueUserWorkItem((o) => { //7.启动站点 using (NancyHost host = Startup.Start(SystemConfig.WebPort)) { //调用系统默认的浏览器 string url = string.Format("http://127.0.0.1:{0}", SystemConfig.WebPort); LogHelper.WriteLog(string.Format("系统已启动,当前监听站点地址:{0}", url)); try { //4.消息队列启动 RabbitMQClient.InitClient(); } catch (Exception ex) { Console.WriteLine(ex); } //8.系统命令初始化 CommandHelp.Init(); } }); } catch (Exception ex) { LogHelper.WriteLog("服务启动异常", ex); } }
public TagsModule() : base("Tags") { #region "取数接口API" //立即运行一次任务 Get["/UpdateTagHeat"] = r => { string TagGUID = Request.Query["TagGUID"].ToString(); ITagService tagService = MefConfig.TryResolve <ITagService>(); return(Response.AsText(tagService.UpdateHeat(TagGUID).ToString())); }; #endregion }
public LppMvcComposableApplication() { if (_composition == null) { _composition = MefConfig.RegisterMef(); } _composition.RootScope.SatisfyImportsOnce(this); this.BeginRequest += OnBeginRequest; this.EndRequest += OnEndRequest; #if (!DEBUG) this.Error += OnError; #endif }
static void Main(string[] args) { //以管理员身份运行 AdminRun.Run(); //MEF初始化 MefConfig.Init(); //数据库初始化连接 ConfigInit.InitConfig(); //系统参数配置初始化 ConfigManager configManager = MefConfig.TryResolve <ConfigManager>(); configManager.Init(); Console.Title = SystemConfig.ProgramName; Console.CursorVisible = false; //隐藏光标 //任务启动 QuartzHelper.InitScheduler(); QuartzHelper.StartScheduler(); try { //启动站点 using (NancyHost host = Startup.Start(SystemConfig.WebPort)) { //调用系统默认的浏览器 string url = string.Format("http://127.0.0.1:{0}", SystemConfig.WebPort); //Process.Start(url);//自动弹出浏览器 Console.WriteLine("系统已启动,当前监听站点地址:{0}", url); hideConsole("TaskScheduler-任务执行容器"); while (true) { Console.ReadLine(); Console.WriteLine("程序运行中,请勿输入任何内容!"); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadLine(); }
public LoginModule() : base("Login") { Get["/"] = r => { var ErrorMsg = this.Request.Query.ErrorMsg; var UserCode = this.Request.Query.UserCode; return(View["index", new { ErrorMsg = ErrorMsg, UserCode = UserCode, Title = SystemConfig.SystemTitle, ProgramName = SystemConfig.ProgramName, ShowOriginalAccountInfo = SystemConfig.ShowOriginalAccountInfo ? "1" : "0" }]); }; Post["/"] = r => { string UserCode = this.Request.Form.UserCode; string Password = this.Request.Form.Password; IUserService UserService = MefConfig.TryResolve <IUserService>(); if (string.IsNullOrEmpty(UserCode) || string.IsNullOrEmpty(Password)) { return(this.Context.GetRedirect("~/Login?ErrorMsg=" + Uri.EscapeDataString("用户名或密码不能为空") + "&UserCode=" + UserCode)); } UserAccount account = UserService.GetUserInfo(UserCode, DESEncrypt.Encrypt(Password)); if (account == null) { return(this.Context.GetRedirect("~/Login?ErrorMsg=" + Uri.EscapeDataString("用户名或密码错误") + "&UserCode=" + UserCode)); } else { Guid guid = Guid.ParseExact(account.UserGUID, "N"); Session["UserInfo"] = account; return(this.Login(guid, DateTime.Now.AddMinutes(30))); } }; //退出登录 Get["/Exit"] = r => { Session.DeleteAll(); return(this.Context.GetRedirect("~/Login")); }; }
/// <summary> /// 获取系统所有命令 /// </summary> /// <returns>系统所有命令</returns> public static Dictionary <string, ICommand> GetAllCommand() { if (CommandDict == null) { CommandDict = new Dictionary <string, ICommand>(StringComparer.OrdinalIgnoreCase); string key = string.Empty; var listCommand = MefConfig.ResolveMany <ICommand>().OrderBy(e => e.GetCommandKey()).ToList(); foreach (var item in listCommand) { key = item.GetCommandKey(); if (!string.IsNullOrEmpty(key)) { CommandDict[key] = item; } } } return(CommandDict); }
public ConfigModule() : base("Config") { //列表 Get["/Grid"] = r => { manager = MefConfig.TryResolve <ConfigManager>(); return(View["Grid"]); }; //取数接口API #region ///// <summary> ///// 获取所有配置信息 ///// </summary> ///// <returns>所有配置信息</returns> Get["/GetAllOption"] = r => { return(Response.AsJson(manager.GetAllOption())); }; ///// <summary> ///// 获取指定项配置信息 ///// </summary> ///// <param name="GroupType">分组项</param> ///// <returns>所有配置信息</returns> Get["/GetOptionByGroup"] = r => { string GroupType = Request.Query["GroupType"].ToString(); return(Response.AsJson(manager.GetOptionByGroup(GroupType))); }; ///// <summary> ///// 保存数据 ///// </summary> Post["/"] = r => { OptionViewModel value = this.Bind <OptionViewModel>(); return(Response.AsJson(manager.Save(value))); }; #endregion }
static void Main(string[] args) { AdminRun.Run(); //1.MEF初始化 MefConfig.Init(); //2. ConfigInit.InitConfig(); //3.系统参数配置初始化 ConfigManager configManager = MefConfig.TryResolve <ConfigManager>(); configManager.Init(); QuartzHelper.InitScheduler(); QuartzHelper.StartScheduler(); try { //启动站点 using (NancyHost host = Startup.Start(SystemConfig.WebPort)) { //调用系统默认的浏览器 string url = string.Format("http://127.0.0.1:{0}", SystemConfig.WebPort); Process.Start(url); Console.WriteLine("系统监听站点地址:{0}", url); Console.WriteLine("程序已启动,按任意键退出"); Console.ReadLine(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } //ParseExpressCode(); //ExpressUtil.HandleProecssInfo(""); //MessageHelper.SendMessage(new Guid("6282AA73-2A58-E511-8D70-00155D0C740D")); //new Ywdsoft.Task.TaskSet.SendMessageJob().Execute(null); Console.Read(); }
public HomeModule() { //主页 Get["/"] = r => { return(Response.AsRedirect("/Home/Index")); }; //主页 Get["/Home/Index"] = r => { return(View["index", new { UserName = UserAccountInfo.UserName, Title = SystemConfig.SystemTitle, ProgramName = SystemConfig.ProgramName }]); }; ///桌面 Get["/DestTop"] = r => { return(View["DestTop", MachineNumber.GetMachineInfo()]); }; //修改密码 Post["/Home/ChgPwd"] = r => { ApiResult <string> result = new ApiResult <string>(); string PasswordOne = this.Request.Form.PasswordOne; string PasswordTwo = this.Request.Form.PasswordTwo; IUserService UserService = MefConfig.TryResolve <IUserService>(); if (string.IsNullOrEmpty(PasswordOne) || string.IsNullOrEmpty(PasswordTwo) || !PasswordOne.Equals(PasswordTwo)) { result.HasError = true; result.Message = "两次密码不一致"; } else { UserService.ChgPwd(UserAccountInfo.UserGUID, DESEncrypt.Encrypt(PasswordOne)); } return(result); }; }
/// <summary> /// 初始化MQ连接 和消息接收 /// </summary> public static void InitClient() { try { InitMQConnection(); //接收消息 MessageTransmit messageTransmit = MefConfig.TryResolve <MessageTransmit>(); if (messageTransmit.Actions != null && messageTransmit.Actions.Count() > 0) { ReciveMessage((routingKey, message) => { //消息分发处理 messageTransmit.Transmit(message, routingKey); }); } } catch (Exception ex) { LogHelper.WriteLog("RabbitMQ连接异常,可能由于主机IP用户名密码相关信息配置错误", ex); throw ex; } }
protected void Application_Start() { var logger = LogManager.GetLogger("MvcApplication"); logger.Info("Entering Application_Start()"); logger.Info("Version: " + RevisionInfo.FullVersionString); string addinsPath = System.IO.Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, "CurationAddins"); HostingEnvironment.RegisterVirtualPathProvider(new EmbeddedViewPathProvider()); #if ISPRO MefConfig.RegisterMef(addinsPath, typeof(MvcApplication).Assembly, typeof(Colectica.Curation.DdiAddins.DdiAddinManifest).Assembly); #else MefConfig.RegisterMef(addinsPath, typeof(MvcApplication).Assembly, typeof(Colectica.Curation.BaseAddins.BaseAddinManifest).Assembly); #endif AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ControllerBuilder.Current.SetControllerFactory(new CurationControllerFactory()); }
public ExcelModule() : base("Excel") { //任务列表 Post["/GridExport"] = r => { string excelParam = Request.Form["excelParam"]; if (string.IsNullOrEmpty(excelParam)) { return(""); } ExcelInfo info = JsonConvert.DeserializeObject <ExcelInfo>(excelParam); if (string.IsNullOrEmpty(info.FileName)) { info.FileName = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ".xls"; } else { if (!info.FileName.EndsWith(".xls")) { info.FileName = info.FileName + ".xls"; } } MemoryStream ms = info.ExportExeclStream(); byte[] msbyte = ms.GetBuffer(); ms.Dispose(); ms = null; return(new Response() { Contents = stream => { stream.Write(msbyte, 0, msbyte.Length); }, ContentType = "application/msexcel", StatusCode = HttpStatusCode.OK, Headers = new Dictionary <string, string> { { "Content-Disposition", string.Format("attachment;filename={0}", System.Web.HttpUtility.UrlPathEncode(info.FileName)) }, { "Content-Length", msbyte.Length.ToString() } } }); }; /// <summary> /// 导出Excel模版 /// </summary> /// <param name="type">业务类型</param> /// <param name="FunctionCode">对应功能模块Code</param> /// <returns></returns> Get["/DownLoadTemplate"] = r => { if (AllImports == null) { AllImports = MefConfig.ResolveMany <ExcelImport>(); } string strType = Request.Query["type"]; ExcelImportType type = EnumHelper.StringToEnum <ExcelImportType>(strType); var handler = AllImports.FirstOrDefault(e => e.Type == type); if (handler == null) { throw new Exception("未找到“" + type.ToString() + "”相应处理模块"); } string path = ExcelImporMapper.GetTemplatePath(type); if (File.Exists(path)) { try { string FileName = Path.GetFileName(path); return(new Response() { Contents = stream => { handler.GetExportTemplate(path, stream); }, ContentType = MimeHelper.GetMineType(path), StatusCode = HttpStatusCode.OK, Headers = new Dictionary <string, string> { { "Content-Disposition", string.Format("attachment;filename={0}", System.Web.HttpUtility.UrlPathEncode(FileName)) } } }); } catch (Exception ex) { throw ex; } } else { throw new Exception("未找到“" + type.ToString() + "”对应模版文件"); } }; /// <summary> /// 导出Excel模版 /// </summary> /// <returns></returns> Post["/ImportTemplate"] = r => { ImportResult result = new ImportResult(); try { if (AllImports == null) { AllImports = MefConfig.ResolveMany <ExcelImport>(); } string ywType = Request.Query["type"]; if (string.IsNullOrEmpty(ywType)) { throw new ArgumentNullException("ywType"); } //业务类型 ExcelImportType type = EnumHelper.StringToEnum <ExcelImportType>(ywType); //文件 HttpFile file = Request.Files.First(); var handler = AllImports.FirstOrDefault(e => e.Type == type); if (handler == null) { throw new Exception("未找到“" + type.ToString() + "”相应处理模块"); } result = handler.ImportTemplate(file.Value, file.Name, null); if (result.IsSuccess) { //是否获取详细数据,决定后台是否返回 result.ExtraInfo string ReturnDetailData = Request.Query["ReturnDetailData"]; if (string.IsNullOrEmpty(ReturnDetailData) || ReturnDetailData != "1") { result.ExtraInfo = null; } } else { //设置错误模版http路径 result.Message = Request.Url.SiteBase + result.Message; } } catch (Exception ex) { result.IsSuccess = false; result.Message = ex.Message; LogHelper.WriteLog("Excel导入异常", ex); } return(Response.AsJson(result)); }; }
public ConfigModule() : base("Config") { //列表 Get["/Grid"] = r => { manager = MefConfig.TryResolve <ConfigManager>(); return(View["Grid"]); }; //取数接口API #region ///// <summary> ///// 获取所有配置信息 ///// </summary> ///// <returns>所有配置信息</returns> Get["/GetAllOption"] = r => { ITagService tagService = MefConfig.TryResolve <ITagService>(); IEnumerable <Tags> listTags = tagService.GetTags(TagsSourceType.ConfigHandler); var list = manager.GetAllOption(); List <ConfigViewModel> listDto = new List <ConfigViewModel>(); ConfigViewModel configModel = null; foreach (var item in list) { configModel = Mapper.DynamicMap <OptionViewModel, ConfigViewModel>(item); configModel.TagList = listTags.Where(e => e.SourceId == item.Group.GroupType).ToList(); listDto.Add(configModel); } return(Response.AsJson(listDto)); }; ///// <summary> ///// 获取指定项配置信息 ///// </summary> ///// <param name="GroupType">分组项</param> ///// <returns>所有配置信息</returns> Get["/GetOptionByGroup"] = r => { string GroupType = Request.Query["GroupType"].ToString(); var model = manager.GetOptionByGroup(GroupType); ConfigViewModel configModel = Mapper.DynamicMap <OptionViewModel, ConfigViewModel>(model); ITagService tagService = MefConfig.TryResolve <ITagService>(); configModel.TagList = tagService.GetTags(TagsSourceType.ConfigHandler, GroupType); return(Response.AsJson(configModel)); }; ///// <summary> ///// 保存数据 ///// </summary> Post["/"] = r => { ConfigViewModel value = this.Bind <ConfigViewModel>(); ITagService tagService = MefConfig.TryResolve <ITagService>(); //保存标签信息 if (value.TagList == null || value.TagList.Count == 0) { //删除标签 tagService.DeleteTags(TagsSourceType.ConfigHandler, value.Group.GroupType); } else { //保存标签 tagService.SaveTags(value.TagList, TagsSourceType.ConfigHandler, value.Group.GroupType, "admin"); } return(Response.AsJson(manager.Save(Mapper.DynamicMap <ConfigViewModel, OptionViewModel>(value)))); }; #endregion }
public void IngestIntoCurator(Group group, HttpRequestBase request, string userName) { MefConfig.RegisterMef(string.Empty); // Load and populate all the StudyUnits in the group. using (var db = new ApplicationDbContext()) { var organization = OrganizationHelper.GetOrganizationByHost(request, db); string storagePath = SettingsHelper.GetProcessingDirectory(organization, db); var user = db.Users.Where(x => x.UserName == userName) .Include(x => x.Organizations) .FirstOrDefault(); // For every StudyUnit int i = 1; foreach (StudyUnit study in group.StudyUnits) { Console.WriteLine("Study " + i.ToString()); // Create a CatalogRecord and add it to the database. var record = new CatalogRecord(); record.Id = study.Identifier; record.Organization = organization; // See if we can find a user with the contributor name. // Otherwise just use the current user. string contributorName = study.DublinCoreMetadata.Contributor.Best; string[] parts = contributorName.Split(new char[] { ' ' }); if (parts.Length == 2) { string first = parts[0]; string last = parts[1]; var contribUser = db.Users.FirstOrDefault(x => x.FirstName == first && x.LastName == last); if (contribUser != null) { record.CreatedBy = contribUser; } } if (record.CreatedBy == null) { record.CreatedBy = user; } record.CreatedDate = DateTime.UtcNow; record.Version = 1; record.LastUpdatedDate = DateTime.UtcNow; record.Status = CatalogRecordStatus.New; record.DepositAgreement = organization.DepositAgreement; var log = new Event() { EventType = ImportEventType, Timestamp = DateTime.UtcNow, User = user, RelatedCatalogRecord = record, Title = "Import" }; record.Title = FixString(study.DublinCoreMetadata.Title.Current); if (string.IsNullOrWhiteSpace(record.Title)) { record.Title = "Missing title"; } Directory.CreateDirectory(Path.Combine(storagePath, record.Id.ToString())); record.Keywords = study.Coverage.TopicalCoverage.Subjects.Select(x => x.Value).FirstOrDefault(); record.AccessStatement = FixString(study.DublinCoreMetadata.Rights.Current); record.AuthorsText = study.DublinCoreMetadata.Creator.Current; record.ResearchDesign = study.DataCollections.First().Methodology.Methodology.First().Description.Best; record.Location = study.Coverage.SpatialCoverage.Description.Current; record.InclusionExclusionCriteria = study.DataCollections.First().Methodology.SamplingProcedure.First().Description.Best; record.UnitOfObservation = study.AnalysisUnit.Value; record.DataSource = study.DublinCoreMetadata.Source.Current; record.ArchiveDate = study.DublinCoreMetadata.Date; record.Number = study.DublinCoreMetadata.Identifiers.First().Identifier; if (study.Coverage.TemporalCoverage.Dates.Count != 0) { var date = study.Coverage.TemporalCoverage.Dates[0]; var dateModel = new DateModel(); dateModel.dateType = "Date"; dateModel.date = date.Date.DateOnly.Value.ToString("yyyy-MM-dd"); dateModel.isRange = false; record.FieldDates = Newtonsoft.Json.JsonConvert.SerializeObject(dateModel); } record.OwnerText = study.DublinCoreMetadata.Publisher.Current; List <string> kindofdata = new List <string>(); foreach (var data in study.KindsOfData) { kindofdata.Add(data.Value); } record.DataType = string.Join(",", kindofdata.ToArray()); //record.IspsID = study.DublinCoreMetadata.Identifiers; //record.DataSourceInformation = record.DataSourceInformation = GetUserAttribute(study, "DataSourceInformation"); record.SampleSize = GetUserAttribute(study, "SampleSize"); record.RandomizationProcedure = GetUserAttribute(study, "RandomizationProcedure"); record.Treatment = GetUserAttribute(study, "Treatment"); record.TreatmentAdministration = GetUserAttribute(study, "TreatmentAdministration"); record.OutcomeMeasures = GetUserAttribute(study, "OutcomeMeasures"); //record.OwnerContact = record.RelatedDatabase = GetUserAttribute(study, "RelatedDatabase"); //record.PrincipalInvestigator = enumerator.Current.Value.Value; //record.AreaOfStudy = GetUserAttribute(study, "AreaOfStudy"); //record.Discipline= //record.FeatureImage = //record.FeatureText = record.LocationDetails = GetUserAttribute(study, "LocationDetails"); //record.DrupalNodeID = record.RelatedProjects = GetUserAttribute(study, "RelatedProjects"); record.RelatedPublications = GetUserAttribute(study, "RelatedPublications"); db.CatalogRecords.Add(record); CreateTaskStatuses(record, user, db); // For every PhysicalInstance in the StudyUnit foreach (var pi in study.PhysicalInstances) { // Create a ManagedFile in the curation system. var file = new ManagedFile(); file.Id = pi.Identifier; file.CatalogRecord = record; file.Number = GetUserAttribute(pi, "DataFileNumber"); file.Version = 1; //file.Number = ++record.LastFileNumber; file.CreationDate = DateTime.UtcNow; file.Status = FileStatus.Accepted; file.UploadedDate = DateTime.UtcNow; file.AcceptedDate = DateTime.UtcNow; // Map the Handle to the PersisentLink file.PersistentLink = pi.FileIdentifications .Select(x => x.Uri.ToString()) .Where(x => x.Contains("hdl.handle.net")) .FirstOrDefault(); file.Name = pi.DublinCoreMetadata.Title.Best; if (string.IsNullOrWhiteSpace(file.Name)) { file.Name = "Unnamed file"; } file.Title = pi.Description.Best; if (string.IsNullOrWhiteSpace(file.Title)) { file.Title = "Untitled"; } file.PublicName = file.Title; file.FormatName = pi.Format; file.IsPublicAccess = pi.FileIdentifications .Select(x => x.IsPublic) .FirstOrDefault(); file.Owner = user; var temp = GetSize(pi); //file.Size = Convert.ToInt64(GetUserAttribute(pi, "FileSize").Split('.')[0]); file.Size = temp; file.Type = "Data"; file.Software = MetadataHelpers.GetSoftware(file.Name); db.Files.Add(file); TaskHelpers.AddProcessingTasksForFile(file, record, db); log.RelatedManagedFiles.Add(file); // TODO Ingest all the files into the processing space. // For now, write a dummy file. //string dummyPath = Path.Combine(storagePath, record.Id.ToString(), file.Name); //File.WriteAllText(dummyPath, "This is a placeholder file without real content."); } // For every OtherMaterial in the StudyUnit foreach (var material in study.OtherMaterials) { // Create a ManagedFile in the curation system. var file = new ManagedFile(); file.CatalogRecord = record; file.Id = Guid.NewGuid(); file.Status = FileStatus.Accepted; file.UploadedDate = DateTime.UtcNow; // TODO get the historical date if (material.UrlReference != null) { file.PersistentLink = material.UrlReference.ToString(); } file.Name = material.DublinCoreMetadata.Title.Best; if (string.IsNullOrWhiteSpace(file.Name)) { file.Name = "Unnamed file"; } file.Title = material.DublinCoreMetadata.Description.Best; if (string.IsNullOrWhiteSpace(file.Title)) { file.Title = "Unnamed"; } file.Owner = user; //file.Size = GetSize(pi); file.Type = "Other"; file.Number = material.DublinCoreMetadata.Identifiers.Select(x => x.Identifier).FirstOrDefault(); file.FormatName = material.MimeType; file.IsPublicAccess = material.DublinCoreMetadata.Rights.Best != "Not Public"; long size = 0; string sizeStr = material.UserIds .Where(x => x.Type == "Size") .Select(x => x.Identifier) .FirstOrDefault(); if (long.TryParse(sizeStr, out size)) { file.Size = size; } db.Files.Add(file); TaskHelpers.AddProcessingTasksForFile(file, record, db); // TODO Ingest all the files into the processing space. // For now, write a dummy file. //string dummyPath = Path.Combine(storagePath, record.Id.ToString(), file.Name); //File.WriteAllText(dummyPath, "This is a placeholder file without real content."); } db.Events.Add(log); try { db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.Message); } i++; } } }
public LoginModule() : base("Login") { Get["/"] = r => { var ErrorMsg = this.Request.Query.ErrorMsg; var UserCode = this.Request.Query.UserCode; return(View["index", new { ErrorMsg = ErrorMsg, UserCode = UserCode, Title = SystemConfig.SystemTitle, ProgramName = SystemConfig.ProgramName, ShowOriginalAccountInfo = SystemConfig.ShowOriginalAccountInfo ? "1" : "0" }]); }; Post["/"] = r => { string UserCode = ""; string Password = ""; if (this.Request.Url.ToString().Contains("args")) { string args = this.Request.Query.args; args = Utility.Encrypt.DESEncrypt.Decrypt(args, "!2#3@1YV"); UserCode = args.Split('|')[0]; Password = args.Split('|')[1]; } else { UserCode = this.Request.Form.UserCode; Password = this.Request.Form.Password; } IUserService UserService = MefConfig.TryResolve <IUserService>(); if (string.IsNullOrEmpty(UserCode) || string.IsNullOrEmpty(Password)) { return(this.Context.GetRedirect("~/Login?ErrorMsg=" + Uri.EscapeDataString("用户名或密码不能为空") + "&UserCode=" + UserCode)); } UserAccount account = UserService.GetUserInfo(UserCode, DESEncrypt.Encrypt(Password)); if (account == null) { return(this.Context.GetRedirect("~/Login?ErrorMsg=" + Uri.EscapeDataString("用户名或密码错误") + "&UserCode=" + UserCode)); } else { Guid guid = Guid.ParseExact(account.UserGUID, "N"); Session["UserInfo"] = account; return(this.Login(guid, DateTime.Now.AddDays(1))); } }; Get["/SignIn"] = r => { string UserCode = ""; string Password = ""; if (this.Request.Url.ToString().Contains("args")) { string args = this.Request.Query.args; args = Utility.Encrypt.DESEncrypt.Decrypt(args, "!2#3@1YV"); UserCode = args.Split('|')[0]; Password = args.Split('|')[1]; } else { UserCode = this.Request.Form.UserCode; Password = this.Request.Form.Password; } IUserService UserService = MefConfig.TryResolve <IUserService>(); if (string.IsNullOrEmpty(UserCode) || string.IsNullOrEmpty(Password)) { return(this.Context.GetRedirect("~/Login?ErrorMsg=" + Uri.EscapeDataString("用户名或密码不能为空") + "&UserCode=" + UserCode)); } UserAccount account = UserService.GetUserInfo(UserCode, DESEncrypt.Encrypt(Password)); if (account == null) { return(this.Context.GetRedirect("~/Login?ErrorMsg=" + Uri.EscapeDataString("用户名或密码错误") + "&UserCode=" + UserCode)); } else { Guid guid = Guid.ParseExact(account.UserGUID, "N"); Session["UserInfo"] = account; return(this.Login(guid, DateTime.Now.AddDays(1), "/Task/Grid")); } }; //退出登录 Get["/Exit"] = r => { Session.DeleteAll(); return(this.Context.GetRedirect("~/Login")); }; }
protected override void OnStart(string[] args) { AppDomain.MonitoringIsEnabled = true; AdminRun.Run(); DebuggableAttribute att = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttribute <DebuggableAttribute>(); if (att.IsJITTrackingEnabled) { //Debug模式才让线程停止10s,方便附加到进程调试 Thread.Sleep(10000); } if (!SetConsoleCtrlHandler(cancelHandler, true)) { LogHelper.WriteLog("程序监听系统按键异常"); } try { //1.MEF初始化 MefConfig.Init(); LogHelper.WriteLog("MEF初始化"); //2.数据库初始化连接 ConfigInit.InitConfig(); LogHelper.WriteLog("数据库初始化连接"); //3.系统参数配置初始化 ConfigManager configManager = MefConfig.TryResolve <ConfigManager>(); configManager.Init(); LogHelper.WriteLog("系统参数配置初始化"); //4.任务启动 QuartzHelper.InitScheduler(); QuartzHelper.StartScheduler(); LogHelper.WriteLog("任务启动"); //5.加载SQL信息到缓存中 XmlCommandManager.LoadCommnads(SysConfig.XmlCommandFolder); LogHelper.WriteLog("加载SQL信息到缓存中"); //测试dapper orm框架 //DapperDemoService.Test(); #region 控制台用死循环监听 ////启动站点 //using (NancyHost host = Startup.Start(SystemConfig.WebPort)) //{ // //调用系统默认的浏览器 // string url = string.Format("http://127.0.0.1:{0}", 9059); // Process.Start(url); // LogHelper.WriteLog( string.Format("系统已启动,当前监听站点地址:{0}", url)); // //4.消息队列启动 // RabbitMQClient.InitClient(); // LogHelper.WriteLog("消息队列启动"); // ////5.系统命令初始化 // CommandHelp.Init(); // LogHelper.WriteLog("系统命令初始化"); //} #endregion ///Window服务用线程池 ThreadPool.QueueUserWorkItem((o) => { //启动站点 string url = string.Format("http://127.0.0.1:{0}", SysConfig.WebPort); Startup.Start(SysConfig.WebPort); LogHelper.WriteLog(string.Format("系统已启动,当前监听站点地址:{0}", url)); //4.消息队列启动 //RabbitMQClient.InitClient(); LogHelper.WriteLog("消息队列启动"); }); } catch (Exception ex) { LogHelper.WriteLog(ex.Message); } }
protected void Application_Start() { MefConfig.RegisterMef(); GlobalConfiguration.Configure(WebApiConfig.Register); }