Esempio n. 1
0
        /// <summary>
        /// 根据sql语句执行增删改操作,返回受影响的行数
        /// </summary>
        /// <param name="strSql">sql语句</param>
        /// <returns></returns>
        public static int ExcuteBySql(string strSql)
        {
            int    i       = 0;
            string strConn = SqlDataHelper.GetConnectionString();

            using (SqlConnection connection = new SqlConnection(strConn))
            {
                if (connection.State == ConnectionState.Closed)
                {
                    connection.Open();
                }
                SqlTransaction transaction = connection.BeginTransaction();//开启事务
                SqlCommand     command     = connection.CreateCommand();
                command.Connection     = connection;
                command.CommandTimeout = iTimeOut;
                command.Transaction    = transaction;
                try
                {
                    command.CommandText = strSql;
                    i = command.ExecuteNonQuery();
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    InsertLog.Insert(ex.Message, ex);
                }
                finally
                {
                    connection.Close();
                }
            }

            return(i);
        }
        //java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AUTOINCREMENT
        //   , ContentValue text not null
        //   , ContentComment text not n' at line 3
        //   at com.google.cloud.sql.jdbc.internal.Exceptions.newSqlException(Exceptions.java:219)
        //   at com.google.cloud.sql.jdbc.internal.SqlProtoClient.check(SqlProtoClient.java:198)
        //   at com.google.cloud.sql.jdbc.internal.SqlProtoClient.executeSql(SqlProtoClient.java:87)
        //   at com.google.cloud.sql.jdbc.internal.SqlProtoClient.executeSql(SqlProtoClient.java:76)
        //   at com.google.cloud.sql.jdbc.Connection.executeSql(Connection.java:528)
        //   at com.google.cloud.sql.jdbc.Statement.executeSqlImpl(Statement.java:280)
        //   at com.google.cloud.sql.jdbc.Statement.executeImpl(Statement.java:154)
        //   at com.google.cloud.sql.jdbc.Statement.executeUpdateImpl(Statement.java:341)
        //   at com.google.cloud.sql.jdbc.Statement.executeUpdate(Statement.java:336)
        //   at ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteCommand.ExecuteNonQuery(__SQLiteCommand.java:282)
        //   ... 66 more

        #region queries

        public void InsertLog(InsertLog value)
        {
            Console.WriteLine("enter InsertLog");
            WithWriteConnection(
                c =>
                {
                    Console.WriteLine("before InsertLog ExecuteNonQuery ");
                    value.ExecuteNonQuery(c);
                    Console.WriteLine("after InsertLog ExecuteNonQuery ");
                }
             );
            Console.WriteLine("exit InsertLog");
        }
        public IList <MirasysDeviceDetails> GetMirasysCamDeviceList(string MirasysNvrIP, string MirasysNvrPort, string MirasysUserName, string MirasysPassword)
        {
            try
            {
                InsertLog.AddLog("MirasyInterfaceService GetMirasysCamDeviceList() DevList MirasysNvrIP:" + MirasysNvrIP + "--!--MirasysNvrPort:" + MirasysNvrPort + "--!--MirasysUserName:"******"--!--MirasysNvrPort:" + MirasysPassword);
                var DevList = MirasysVaInterface.getCamDeviceList();

                InsertLog.AddLog("MirasyInterfaceService GetMirasysCamDeviceList() DevList Count:" + DevList.Count());

                return(DevList);
            }
            catch (Exception ex)
            {
                InsertLog.AddLog("MirasyInterfaceService GetMirasysCamDeviceList() Exception:" + ex.Message);
            }
            return(null);
        }
Esempio n. 4
0
        public HttpResponseMessage ImportOrder([FromBody] OrderInfoListClient orderInfoListClient)
        {
            InsertLog.Insert("订单导入数据获得的订单数据", orderInfoListClient.xmOrderInfoClientList.Count.ToString());
            _utilManager.Write(JsonConvert.SerializeObject(orderInfoListClient));
            var apiMessage = new ApiMassage();

            apiMessage.Header = new Header();
            var str = string.Empty;

            if (orderInfoListClient.xmOrderInfoClientList.Count == 0)
            {
                apiMessage.Header.IsSuccess = false;
                apiMessage.Header.Message   = "请求的参数为空";
                str = JsonConvert.SerializeObject(apiMessage);
                return(_utilManager.HttpMessage(str));
            }
            var nostatus = new List <string>()
            {
                "待付款", "待使用", "已完成", "已发货"
            };
            var clientOrderList = orderInfoListClient.xmOrderInfoClientList.Where(m => !nostatus.Contains(m.OrderStatus)).ToList();

            if (clientOrderList.Count > 500 || clientOrderList.Count == 0)
            {
                apiMessage.Header.IsSuccess = false;
                apiMessage.Header.Message   = "传入的订单条数不能超过500!或者少于0";
                str = JsonConvert.SerializeObject(apiMessage);
                return(_utilManager.HttpMessage(str));
            }
            _orderInsertManager.InsertXMOrderInfo(clientOrderList, apiMessage.Header);
            if (string.IsNullOrWhiteSpace(apiMessage.Header.Message))
            {
                apiMessage.Header.IsSuccess = true;
                apiMessage.Header.Message   = "接口接收订单数量:" + clientOrderList.Count.ToString() + "处理成功!";
            }
            else
            {
                apiMessage.Header.IsSuccess = false;
            }
            //apiMessage.Header.Message += errorStr;
            str = JsonConvert.SerializeObject(apiMessage);
            InsertLog.Insert("订单导入数据返回值", str);
            return(_utilManager.HttpMessage(str));
            //return JsonConvert.SerializeObject(apiMessage);
        }
        internal static IMirasyInterfaceService Initialise(MirasysVaInterface _MirasysVaInterface)
        {
            InsertLog.AddLog("MirasyInterfaceService Initialise()");
            MirasysVaInterface = _MirasysVaInterface;
            var service = new MirasyInterfaceService();
            Uri httpUrl = new Uri("https://localhost:6530/MirasyInterfaceService");

            WebServiceHost controllerHost
                = new WebServiceHost(typeof(MirasyInterfaceService), httpUrl);

            WebHttpBinding _webhttpbis = new WebHttpBinding(WebHttpSecurityMode.Transport);

            _webhttpbis.ReceiveTimeout         = TimeSpan.Parse("00:10:00");
            _webhttpbis.CloseTimeout           = TimeSpan.Parse("00:10:00");
            _webhttpbis.OpenTimeout            = TimeSpan.Parse("00:10:00");
            _webhttpbis.SendTimeout            = TimeSpan.Parse("00:10:00");
            _webhttpbis.MaxBufferPoolSize      = 2147483647; //524288;
            _webhttpbis.MaxBufferSize          = 2147483647;
            _webhttpbis.MaxReceivedMessageSize = 2147483647; //1073741823;
            _webhttpbis.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;


            var endpoint = controllerHost.AddServiceEndpoint(typeof(IMirasyInterfaceService), _webhttpbis, "");//WSHttpBinding

            ServiceThrottlingBehavior throttleBehavior = new ServiceThrottlingBehavior
            {
                MaxConcurrentCalls     = 500,
                MaxConcurrentInstances = 500,
                MaxConcurrentSessions  = 500,
            };

            controllerHost.Description.Behaviors.Add(throttleBehavior);

            var _ServiceMetadataBehavior = controllerHost.Description.Behaviors.Find <ServiceMetadataBehavior>();

            if (_ServiceMetadataBehavior == null)
            {
                _ServiceMetadataBehavior = new ServiceMetadataBehavior();
                controllerHost.Description.Behaviors.Add(_ServiceMetadataBehavior);
            }

            _ServiceMetadataBehavior.HttpGetEnabled  = true;
            _ServiceMetadataBehavior.HttpsGetEnabled = true;

            var _ServiceDebugBehavior = controllerHost.Description.Behaviors.Find <ServiceDebugBehavior>();

            if (_ServiceDebugBehavior == null)
            {
                _ServiceDebugBehavior = new ServiceDebugBehavior();
                controllerHost.Description.Behaviors.Add(_ServiceDebugBehavior);
            }
            _ServiceDebugBehavior.IncludeExceptionDetailInFaults = true;

            var serviceCredential = controllerHost.Description.Behaviors.Find <ServiceCredentials>();

            if (serviceCredential == null)
            {
                serviceCredential = new ServiceCredentials();
                controllerHost.Description.Behaviors.Add(serviceCredential);
            }

            serviceCredential.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine,
                                                                StoreName.My,
                                                                X509FindType.FindByThumbprint,
                                                                "f55bf424542522c6a6d833f933431a31baaf43de");
            controllerHost.Open();
            InsertLog.AddLog("MirasyInterfaceService Started Successfully");
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);   //amit 04112016

            return(null);
        }