예제 #1
0
        protected void Application_Start(object sender, EventArgs e)
        {
            //启动日志模块
            Logger.Current.SetLogger = new LogNet();
            Logger.Current.IsOpenLog = true;
            Logger.CurrentLog.Info("INSTALLING");

            //设置数据库连接执行状况
            AppCons.LogSqlExcu = true;
            //设置第一个数据库
            AppCons.SetDefaultConnect(new MySqlHelper(), ConfigurationManager.AppSettings["ConnectionString"]);
            //是否需要数据库全局参数化
            AppCons.IsParmes = false;
            //是否数据库操作的缓存
            AppCons.IsOpenCache = false;
            //使用第三方的分布式缓存
            //AppCons.CurrentCache =new  RedisCache();
            //使用内置的webcache缓存
            AppCons.CurrentCache = new WebCache();
            //注册ajax
            AppHandlerManager.RegisterAppHandler(new BlackHandler());
            AppHandlerManager.RegisterAppHandler(new TemplateHandler());
            AppHandlerManager.RegisterAppHandler(new KeyWordHandler());
            AppHandlerManager.RegisterAppHandler(new MoHandler());
            AppHandlerManager.RegisterAppHandler(new BatchHistoryHandler());
            AppHandlerManager.RegisterAppHandler(new PhoneHistoryHandler());
            AppHandlerManager.RegisterAppHandler(new UserHandler());
            AppHandlerManager.RegisterAppHandler(new ContactGroupHandler());
            AppHandlerManager.RegisterAppHandler(new ContactHandler());
            AppHandlerManager.RegisterAppHandler(new SmsHandler());
            AppHandlerManager.RegisterAppHandler(new AccountHandler());
            AppHandlerManager.RegisterAppHandler(new Enterprisehandler());
        }
예제 #2
0
파일: Program.cs 프로젝트: ciker/HelloData
        static void Main(string[] args)
        {
            //启动日志模块
            Logger.Current.SetLogger = new ConsoleLog();
            Logger.Current.IsOpenLog = true;
            Logger.CurrentLog.Info("INSTALLING");

            //设置数据库连接执行状况
            AppCons.LogSqlExcu = true;
            //设置第一个数据库
            AppCons.SetDefaultConnect(new SQLliteHelper(), ConfigurationManager.AppSettings["ConnectionString1"]);
            ////设置第二个数据库
            //AppCons.SetSecondConnect(new MySqlHelper(), ConfigurationManager.AppSettings["ConnectionString1"]);
            ////设置更多个数据库
            //AppCons.SetMoreConnect(new SQLliteHelper(), ConfigurationManager.AppSettings["ConnectionString2"]);
            //是否需要数据库全局参数化
            AppCons.IsParmes = false;
            //是否数据库操作的缓存
            AppCons.IsOpenCache = false;
            //使用第三方的分布式缓存
            //AppCons.CurrentCache =new  RedisCache();
            //使用内置的webcache缓存
            AppCons.CurrentCache = new WebCache();

            TestUserManage.Instance.CreateTable();
            TestUser user = TestUserManage.Instance.InsertTable();

            Console.WriteLine(user.firstName);
            //内存数据库的操作



            cms_userManager.Instance.SelectDemo();
            //// 新增demo
            cms_userManager.Instance.Save(new cms_user()
            {
                username = "******" + DateTime.Now.Millisecond,
                password = "******",
                phone    = "",
                isadmin  = true,
                //主键一定要加入
                id = 12
            });

            //if (cms_userManager.Instance.UpdatePwd("1,2,3,4,5") > 0)
            //    Console.WriteLine("success");

            //cms_userManager.Instance.Update(new cms_user()
            //                                    {
            //                                        username = "******" + DateTime.Now.Millisecond,
            //                                        password = "******",
            //                                        id = 12,
            //                                        createtime = null
            //                                    });
            //自定义视图的操作
            //cms_user viewmodel = cms_userManager.Instance.viewtestModel();
            //if (viewmodel != null)
            //    Console.WriteLine("-->VIEWusername:"******"    VIEWid:" + viewmodel.id);
            ////修改demo
            //cms_userManager.Instance.InsertNew(new Entity.cms_user()
            //{
            //    id = 6,//主键查询where条件
            //    username = "******" + "update" + DateTime.Now.Millisecond,
            //    password = "******"
            //});
            ////删除demo
            //Console.WriteLine(cms_userManager.Instance.Delete(1));
            ////获取一个model
            //cms_user model = cms_userManager.Instance.getUser("11");
            //Console.WriteLine(model == null ? "null" : model.username);
            ////分页获取数据
            //PageList<cms_user> list = cms_userManager.Instance.GetList(1, 20);
            //foreach (var item in list)
            //{
            //    Console.WriteLine("-->username:"******"    id:" + item.id);
            //}
            //Console.WriteLine(list.TotalPage);
            //Console.WriteLine(list.TotalCount);

            Logger.CurrentLog.Info("the End!");
            //发送Email
            try
            {
                //MailHelper mailHelper = new MailHelper
                //                            {
                //                                SmtpServer = "smtp.qq.com",
                //                                AdminEmail = "*****@*****.**",
                //                                UserName = "******",
                //                                Password = "******",
                //                                PopServer = "pop.qq.com"
                //                            };


                //string subject = "注册系统邮件验证";
                //string message = String.Format("亲爱的test,您好!<p/>感谢您在我们网站注册成为会员,故系统自动为你发送了这封邮件。请点击下面链接进行验证:<a href='http://icoolly.taobao.com/'>点击验证</a> ");
                ////mailHelper.Send("*****@*****.**", mailHelper.AdminEmail, subject, message, "Low");
                //Logger.CurrentLog.Info("Email is ok!");
            }
            catch (Exception ex)
            {
                Logger.CurrentLog.Info("Email is wrong:" + ex.Message + "");
            }

            ////写入txt
            //ExportTxt export = new ExportTxt();
            //var liststr = new List<string> { "12312", "123asass12" };
            //export.WriteContent(liststr);
            //Console.WriteLine(export.GetFullPath());
            ////写入csv
            //ExportCsv exportsc = new ExportCsv();
            //exportsc.WriteContent(liststr);
            //Console.WriteLine(exportsc.GetFullPath());
            ////写入excel
            //ExportExcle exportex = new ExportExcle();
            //exportex.WriteRow(liststr);
            //Console.WriteLine(exportex.GetFullPath());

            Console.ReadLine();
        }
예제 #3
0
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            bool debugLog = bool.Parse(ConfigurationManager.AppSettings["Debug"].ToString());

            if (debugLog)
            {
                //启动日志模块
                Logger.Current.SetLogger = new ConsoleLog();
                Logger.Current.IsOpenLog = true;
                Logger.CurrentLog.Info("INSTALLING");
            }
            else
            {
                Logger.Current.SetLogger = new LogNet();
                Logger.Current.IsOpenLog = true;
                Logger.CurrentLog.Info("INSTALLING");
            }

            //设置数据库连接模块
            AppCons.LogSqlExcu = bool.Parse(ConfigurationManager.AppSettings["LogSqlExcu"].ToString());
            //设置第一个数据库
            AppCons.SetDefaultConnect(new MySqlHelper(), ConfigurationManager.AppSettings["ConnectionString"]);
            AppCons.IsParmes = bool.Parse(ConfigurationManager.AppSettings["SqlParms"]);
            Logger.CurrentLog.Info("Service_STARTING");
            AppCons.IsOpenCache  = bool.Parse(ConfigurationManager.AppSettings["OpenCache"]);
            AppCons.CurrentCache = new WebCache();

            //注册发送的信道
            ServicesFactory.RegisterApp(new DemoService());
            //YMService ym = new YMService();
            //ym.SendUser = new SendUser();
            //ym.SendUser.serialNumber = ConfigurationManager.AppSettings["ymsn"];
            //ym.SendUser.passwd = ConfigurationManager.AppSettings["ympwd"];
            //ym.SendUser.sdkKey = ConfigurationManager.AppSettings["ymsdkkey"];
            //ym.SendUser.tefuhao = ConfigurationManager.AppSettings["ymtefuhao"];

            //ServicesFactory.RegisterApp(ym);


            DemoService demo = new DemoService();

            demo.SendUser = new SendUser();
            demo.SendUser.serialNumber = ConfigurationManager.AppSettings["ymsn"];
            demo.SendUser.passwd       = ConfigurationManager.AppSettings["ympwd"];
            demo.SendUser.sdkKey       = ConfigurationManager.AppSettings["ymsdkkey"];
            demo.SendUser.tefuhao      = ConfigurationManager.AppSettings["ymtefuhao"];

            ServicesFactory.RegisterApp(demo);

            AppContent.ReadBatch = int.Parse(ConfigurationManager.AppSettings["ReadBatch"]);
            AppContent.ReadTask  = int.Parse(ConfigurationManager.AppSettings["ReadTask"]);

            AppContent.ReadSender     = int.Parse(ConfigurationManager.AppSettings["ReadSender"]);
            AppContent.ReadBatchCount = int.Parse(ConfigurationManager.AppSettings["ReadBatchCount"]);

            AppContent.SendPackCount = int.Parse(ConfigurationManager.AppSettings["SendPackCount"]);

            AppContent.SendMtCount = int.Parse(ConfigurationManager.AppSettings["SendMtCount"]);
            AppContent.IsMoReceive = int.Parse(ConfigurationManager.AppSettings["isMo"]) == 1;
            AppContent.MoReceive   = int.Parse(ConfigurationManager.AppSettings["MoRev"]);
            if (!debugLog)
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new WcfService()
                };
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                BatchReadService readService = new BatchReadService();
                BatchSendService sendService = new BatchSendService();
                ReadMoService    moService   = new ReadMoService();
                moService.Star();
                readService.Star();
                sendService.Star();
                //Logger.CurrentLog.Info("WCF_STARTING");
                //ServiceHost host = new ServiceHost(typeof(SMSServerWcf));
                //if (host.Description.Behaviors.Find<System.ServiceModel.Description.ServiceMetadataBehavior>() == null)
                //{
                //    BindingElement metaElement = new TcpTransportBindingElement();
                //    CustomBinding metaBind = new CustomBinding(metaElement);
                //    host.Description.Behaviors.Add(new System.ServiceModel.Description.ServiceMetadataBehavior());
                //    host.AddServiceEndpoint(typeof(System.ServiceModel.Description.IMetadataExchange), metaBind, "MEX");
                //}
                //host.Open();
                Logger.CurrentLog.Info("状态normal");

                Console.ReadLine();
            }
        }