Exemple #1
0
        public void TestInsert( )
        {
            var k = 0;

            for (var i = 0; i < 100; i++)
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        GlobalVar.DbHelper.BeginTransaction();

                        var model = new BS_Template
                        {
                            id      = Guid.NewGuid().ToString(),
                            code    = k.ToString(),
                            name    = "测试" + k,
                            remarks = "测试" + k,
                            type    = "1"
                        };
                        Insert(model);

                        GlobalVar.DbHelper.CommitTransaction();

                        k++;
                    }
                    catch (Exception ex)
                    {
                        GlobalVar.DbHelper.RollbackTransaction();
                        TyLog.WriteError(ex.Message);
                    }
                });
            }
        }
Exemple #2
0
 //测试删除
 public void TestDelete(string[] ids)
 {
     try
     {
         GlobalVar.DbHelper.BeginTransaction();
         foreach (var t in ids)
         {
             Del(t);
         }
         GlobalVar.DbHelper.CommitTransaction();
     }
     catch (Exception ex)
     {
         GlobalVar.DbHelper.RollbackTransaction();
         TyLog.WriteError(ex.Message);
     }
 }
Exemple #3
0
        //执行方法 json形式
        public string Fun(string functionName, string jsonData)
        {
            string responseStr;
            var    serviceName = System.Configuration.ConfigurationManager.AppSettings["ServiceName"];

            try
            {
                var dll       = AppDomain.CurrentDomain.BaseDirectory + $@"{serviceName}.dll";
                var className = $@"{serviceName}.Index";
                var assembly  = Assembly.LoadFile(dll);
                var type      = assembly.GetType(className);
                responseStr = $@"{(string)type.InvokeMember(functionName, BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] { jsonData })}";
            }
            catch (Exception e)
            {
                TyLog.WriteError(e);
                responseStr = string.Empty;
            }
            return(responseStr);
        }
Exemple #4
0
        //测试修改
        public void TestUpdate(List <BS_Template> lb)
        {
            var rnd = new Random();

            try
            {
                //GlobalVar.DbHelper.BeginTransaction();
                foreach (var t in lb)
                {
                    t.remarks = "测试" + rnd.Next(1, 9999).ToString("0000");
                    Update(t);
                }
                //GlobalVar.DbHelper.CommitTransaction();
            }
            catch (Exception ex)
            {
                GlobalVar.DbHelper.RollbackTransaction();
                TyLog.WriteError(ex.Message);
            }
        }
Exemple #5
0
        private static void Main()
        {
            TyCore.DeleteExit();//禁用关闭按钮
            if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + "TYExServiceCore.exe.config"))
            {
                File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "TYExServiceCore.exe.config", Properties.Resources.TYExServiceCore_exe);
            }
            var host = new ServiceHost(typeof(TyService));

            host.Opened += delegate
            {
                Console.WriteLine($@"服务已开启 ... ... {Environment.NewLine}时间:{DateTime.Now}");
            };
            host.Closed += delegate
            {
                Console.WriteLine($@"服务已关闭 ... ...{Environment.NewLine}时间:{DateTime.Now}");
            };
            try
            {
                host.Open();
                if (ConfigurationManager.AppSettings["ServiceDeBug"] == "false")
                {
                    TyCore.ShowConsole(0);
                    TyCore.AutoStart(@"TYExServiceCore");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(@"服务开启异常,请检查服务器配置!");
                TyLog.WriteError(e);
                Console.Read();
                return;
            }
            while (true)
            {
                Console.Read();
            }
        }