Esempio n. 1
0
        /// <summary>
        /// 获取所有本地化业务参数配置
        /// </summary>
        /// <param name="GroupType">配置项大类</param>
        /// <param name="Key">配置项小类</param>
        /// <returns>指定配置项</returns>
        public static Options GetLocalOptionsByKey(string GroupType, string Key)
        {
            string localPath = ConfigInit.GetLocalConfigPath();

            if (File.Exists(localPath))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(localPath);
                string xmlPath = "//CustomLocalParams/BusinessParams[@key='" + GroupType + "']/param[@key='" + Key + "']";
                var    node    = doc.SelectSingleNode(xmlPath);
                if (node != null)
                {
                    Options      op   = null;
                    XmlAttribute attr = null;
                    attr = node.Attributes["key"];
                    string key = attr != null ? attr.Value : string.Empty;
                    if (!string.IsNullOrEmpty(key))
                    {
                        op       = new Options();
                        op.Key   = key;
                        op.Value = node.InnerText;
                    }
                    return(op);
                }
            }
            return(null);
        }
 protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
 {
     // ConfigInit is a static class with a simple check, to see if the configuration was already initialized
     // the same method ConfigInig.Configure() is also called in the Global.asax in Application_Start
     ConfigInit.Configure();
     return(base.CreateServiceHost(serviceType, baseAddresses));
 }
Esempio n. 3
0
 public void Start()
 {
     //配置信息读取
     ConfigInit.InitConfig();
     QuartzHelper.InitScheduler();
     QuartzHelper.StartScheduler();
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            AdminRun.Run();
            ConfigInit.InitConfig();
            QuartzHelper.InitScheduler();
            QuartzHelper.StartScheduler();
            try
            {
                string url = string.Format("http://127.0.0.1:{0}", SysConfig.WebPort);
                //启动站点
                using (NancyHost host = Startup.Start(SysConfig.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();
        }
Esempio n. 5
0
        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);
            });
        }
Esempio n. 6
0
 static void Main(string[] args)
 {
     ConfigInit.InitConfig();
     //ParseExpressCode();
     //ExpressUtil.HandleProecssInfo(ExpressUtil.GetCorrectIP(""));
     //MessageHelper.SendMessage(new Guid("6282AA73-2A58-E511-8D70-00155D0C740D"));
     //new Mysoft.Task.TaskSet.SendMessageJob().Execute(null);
 }
Esempio n. 7
0
 protected void Application_Start()
 {
     // 配置信息读取
     ConfigInit.InitConfig();
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     // 获取远程任务服务器上的 Scheduler
     QuartzHelper.InitRemoteScheduler();
 }
Esempio n. 8
0
        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();
        }
Esempio n. 9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ConfigInit.InitConfig();

            // 获取远程任务服务器上的 Scheduler
            QuartzHelper.InitRemoteScheduler();
        }
Esempio n. 10
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="env"></param>
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(AppContext.BaseDirectory)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddJsonFile($"ocelot.json", optional: false, reloadOnChange: true)
                          .AddEnvironmentVariables();

            configuration = builder.Build().EnableTemplateSupport();
            configuration.GetReloadToken().RegisterChangeCallback(OnSettingChanged, configuration);
            ConfigInit.InitConfig(configuration);
        }
 protected override void OnStart(string[] args)
 {
     //DebuggableAttribute att = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttribute<DebuggableAttribute>();
     //if (att.IsJITTrackingEnabled)
     //{
     //    //Debug模式才让线程停止10s,方便附加到进程调试
     //    Thread.Sleep(10000);
     //}
     //配置信息读取
     ConfigInit.InitConfig();
     QuartzHelper.InitScheduler();
     QuartzHelper.StartScheduler();
 }
Esempio n. 12
0
        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);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 获取所有本地化业务参数配置
        /// </summary>
        /// <param name="GroupType">配置项大类</param>
        /// <returns>所有配置项</returns>
        public static List <Options> GetLocalOptions(string GroupType)
        {
            string localPath = ConfigInit.GetLocalConfigPath();

            if (File.Exists(localPath))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(localPath);
                string xmlPath = "//CustomLocalParams/BusinessParams";
                if (!string.IsNullOrEmpty(GroupType))
                {
                    xmlPath += "[@key='" + GroupType + "']";
                }
                var nodes = doc.SelectNodes(xmlPath);
                if (nodes != null)
                {
                    List <Options> list = new List <Options>();
                    Options        op   = null;
                    XmlAttribute   attr = null;
                    foreach (XmlNode node in nodes)
                    {
                        attr = node.Attributes["key"];
                        string OptionType = attr != null ? attr.Value : string.Empty;
                        var    childNodes = node.ChildNodes;
                        if (childNodes != null)
                        {
                            foreach (XmlNode childNode in childNodes)
                            {
                                if (childNode.Attributes == null)
                                {
                                    continue;
                                }
                                attr = childNode.Attributes["key"];
                                string key = attr != null ? attr.Value : string.Empty;
                                if (!string.IsNullOrEmpty(key))
                                {
                                    op            = new Options();
                                    op.OptionType = OptionType;
                                    op.Key        = key;
                                    op.Value      = childNode.InnerText;
                                    list.Add(op);
                                }
                            }
                        }
                    }
                    return(list);
                }
            }
            return(new List <Options>());
        }
Esempio n. 14
0
 static void Main(string[] args)
 {
     ConfigInit.InitConfig();
     strConnect = SysConfig.SqlConnect;
     MakeEntityUtil();
     //ParseExpressCode();
     //ExpressUtil.HandleProecssInfo("");
     //MessageHelper.SendMessage(new Guid("6282AA73-2A58-E511-8D70-00155D0C740D"));
     new Mysoft.Task.TaskSet.SendSmsJob().Execute(null);
     //new Mysoft.Task.TaskSet.SplitPhoneJob().Execute(null);
     //new Mysoft.Task.TaskSet.ReviewSms().Execute(null);
     Console.WriteLine("操作完成===");
     Console.Read();
 }
Esempio n. 15
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="env"></param>
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          //.SetBasePath(AppContext.BaseDirectory)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
            ConfigInit.InitConfig(Configuration);
            EFInitializer.UnSafeInit();
            XmlCommandManager.UnSafeInit();
        }
Esempio n. 16
0
        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();
        }
Esempio n. 17
0
        public async Task <ActionResult> GetGridData(UpdateRequestData UserModel)
        {
            var azureconfiguration = ConfigInit.getConfiguration();

            var            cosmosDBResponse       = new CosmosAPIService();
            DocumentClient documentClient         = new DocumentClient(new Uri(azureconfiguration.AzureCosmosDBConnectionString), azureconfiguration.AzureCosmonDBPrimaryKey1);
            var            createDataBaseResponse = await documentClient.CreateDatabaseIfNotExistsAsync(new Microsoft.Azure.Documents.Database {
                Id = "CognitiveAPIDemoDataSource"
            });

            var createDataBaseCollectionResponse = await documentClient.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri("CognitiveAPIDemoDataSource"), new DocumentCollection { Id = "PocCollection" }, new RequestOptions { OfferThroughput = 1000 });

            var documentResponse = await cosmosDBResponse.UpdateDocumentCollection(UserModel, documentClient);

            if (!documentResponse)
            {
                return(Json(new { cosmosID = UserModel.cosmosID, imageText = UserModel.imageText, status = "Fail" }));
            }

            return(Json(new { cosmosID = UserModel.cosmosID, imageText = UserModel.imageText, status = "Success" }));
        }
Esempio n. 18
0
        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);
            }
        }
Esempio n. 19
0
 /// <summary>
 /// 配置文件改变
 /// </summary>
 /// <param name="state"></param>
 private void OnSettingChanged(object state)
 {
     ConfigInit.InitConfig(state as IConfiguration);
 }
Esempio n. 20
0
 public CloseOrderWithNoPay()
 {
     ConfigInit.Init();
 }
Esempio n. 21
0
 public OrderTest()
 {
     ConfigInit.Init();
 }
Esempio n. 22
0
        public async Task <ActionResult> DoFileUploads(HttpPostedFileBase[] files)
        {
            // Step 1: Intialize the Azure Configuration form azure settings config
            var azureconfiguration = ConfigInit.getConfiguration();

            // Step 2: Intialize the Azure DataLake Storage
            var                storageAccountConnectionString_File = CloudStorageAccount.Parse(azureconfiguration.AzureStorageConnectionString);
            CloudFileClient    cloudFileClient = storageAccountConnectionString_File.CreateCloudFileClient();
            CloudFileShare     cloudFileShare  = cloudFileClient.GetShareReference(azureconfiguration.AzureFileStorageReference);
            CloudFileDirectory rootDir         = cloudFileShare.GetRootDirectoryReference();
            CloudFile          fileSas         = null;

            // Step 3: Intailize the API Client
            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", azureconfiguration.AzureVisionAPISubscriptionKey);
            HttpResponseMessage response;

            // Step 4: Intailize the Cosmos DB
            var            cosmosDBResponse       = new CosmosAPIService();
            DocumentClient documentClient         = new DocumentClient(new Uri(azureconfiguration.AzureCosmosDBConnectionString), azureconfiguration.AzureCosmonDBPrimaryKey1);
            var            createDataBaseResponse = await documentClient.CreateDatabaseIfNotExistsAsync(new Microsoft.Azure.Documents.Database {
                Id = "CognitiveAPIDemoDataSource"
            });

            var createDataBaseCollectionResponse = await documentClient.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri("CognitiveAPIDemoDataSource"), new DocumentCollection { Id = "PocCollection" }, new RequestOptions { OfferThroughput = 1000 });

            List <APIData> objrApiData = new List <APIData>();

            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].FileName.EndsWith(".jpg") || files[i].FileName.EndsWith(".png"))
                {
                    bytesFromImage = getbyteFromInputStream(files[i].InputStream, files[i].ContentLength);

                    if (cloudFileShare.Exists())
                    {
                        fileSas = rootDir.GetFileReference(Path.GetFileName(files[i].FileName));
                        fileSas.UploadFromStream(new MemoryStream(bytesFromImage));
                    }


                    // Extracting Image :
                    using (ByteArrayContent content = new ByteArrayContent(bytesFromImage))
                    {
                        content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                        response = await client.PostAsync(azureconfiguration.AzureVisionAPIEndPoint + "?" + "mode=Handwritten", content);
                    }

                    if (response.IsSuccessStatusCode)
                    {
                        string operationLocation = response.Headers.GetValues("Operation-Location").FirstOrDefault();
                        string contentString;
                        int    res = 0;
                        do
                        {
                            System.Threading.Thread.Sleep(1000);
                            response = await client.GetAsync(operationLocation);

                            contentString = await response.Content.ReadAsStringAsync();

                            ++res;
                        }while (res < 10 && contentString.IndexOf("\"status\":\"Succeeded\"") == -1);

                        if (res == 10 && contentString.IndexOf("\"status\":\"Succeeded\"") == -1)
                        {
                            //return null;
                        }

                        var           rootobject = JsonConvert.DeserializeObject <RootObject>(contentString);
                        StringBuilder builder    = new StringBuilder();
                        for (int s = 0; s < rootobject.recognitionResult.lines.Count; s++)
                        {
                            builder.Append(rootobject.recognitionResult.lines[s].text.ToString());
                        }
                        objrApiData.Add(new APIData()
                        {
                            OCRID     = Guid.NewGuid().ToString(),
                            imageData = bytesFromImage,
                            imageText = builder.ToString(),
                            ImageUrl  = Path.GetFileName(files[i].FileName),//fileSas.Uri.AbsoluteUri.ToString(),
                            pid       = i,
                            sid       = "text" + i,
                            Error     = "no Error",
                            Remarks   = "No Remarks Found"
                        });
                    }
                    else
                    {
                        string errorString = await response.Content.ReadAsStringAsync();

                        var errorObject = JsonConvert.DeserializeObject <VisionAPIErrorMessage>(errorString);

                        objrApiData.Add(new APIData()
                        {
                            OCRID     = Guid.NewGuid().ToString(),
                            imageData = bytesFromImage,
                            imageText = errorObject.error.message.ToString(),
                            ImageUrl  = Path.GetFileName(files[i].FileName),//fileSas.Uri.AbsoluteUri.ToString(),
                            pid       = i,
                            sid       = "text" + i,
                            Error     = errorObject.error.message.ToString(),
                            Remarks   = "Image scanning Failed"
                        });
                    }
                }
            }
            var dbProcessingResponse = await cosmosDBResponse.CreateDocumentCollection(objrApiData, documentClient);

            TempData["objrApiData"] = objrApiData;
            return(RedirectToAction("ShowResults"));
        }