예제 #1
0
        public DataPointHistoryData FindBy(string id)
        {
            DataPointHistoryData dataPointHistoryData = new DataPointHistoryData();
            DataTable            dataTable;

            MySqlParameter[] mySqlPrarameters = { new MySqlParameter("@DataPointHistoryDataId", id) };
            string           sqlQuery         = baseSelectQuery +
                                                "where DataPointHistoryDataId=@DataPointHistoryDataId;";

            try
            {
                dataTable = dbUtility.ExecuteDataTable(sqlQuery, CommandType.Text, mySqlPrarameters);
                if (null != dataTable)
                {
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        dataPointHistoryData = DataMapperFactory.GetDataMapper <DataPointHistoryData>().ConverFrom(dataTable.Rows, i);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(dataPointHistoryData);
            }

            return(dataPointHistoryData);
        }
        public GetCurrentDataBaseLoginInfoResponse GetCurrentDataBaseLoginInfoAndConnetStatus()
        {
            GetCurrentDataBaseLoginInfoResponse response = new GetCurrentDataBaseLoginInfoResponse();

            try
            {
                DbUtility dbUtility = DbUtilityCreator.GetDefaultDbUtility();
                if (null != dbUtility)
                {
                    response.Ip       = dbUtility.SqlconModel.DBIP;
                    response.Account  = dbUtility.SqlconModel.DBUser;
                    response.Password = dbUtility.SqlconModel.DBPasswd;

                    if (dbUtility.TestConnection())
                    {
                        response.DataBaseConnecting = true;
                    }
                    else
                    {
                        response.DataBaseConnecting = false;
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "操作失败。" + ex.Message;
                response.ResponseSucceed = false;
                response.Message         = message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);
            }


            return(response);
        }
예제 #3
0
        public AddModuleResponse AddModule(AddModuleRequst requst)
        {
            AddModuleResponse response = new AddModuleResponse();

            try
            {
                foreach (Module module in requst.ModulesToAdd)
                {
                    _moduleRepository.Add(module);
                }

                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                string message = "添加失败!错误信息:/n" + ex.Message;
                response = new AddModuleResponse()
                {
                    ResponseSucceed = false,
                    Message         = "添加失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
예제 #4
0
        public GetDataPointByModuleResponse GetDataPointInfoByModule(GetDataPointByModuleRequest request)
        {
            GetDataPointByModuleResponse response = new GetDataPointByModuleResponse();

            try
            {
                Query query = new Query();
                query.AddCriterion(Criterion.Create <DataPoint>(p => p.ModuleBelongTo.Id, request.ModuleId, CriteriaOperator.Equal));
                query.OrderByProperty = OrderByClause.Create <DataPoint>(p => p.Number, false);

                IEnumerable <DataPoint> dataPoints = _dataPointRepository.FindBy(query);
                response.DataPointInfoViews = dataPoints.ConverToDataPointInfoViews();
            }
            catch (Exception ex)
            {
                string message = "查询失败!错误信息:/n" + ex.Message;
                response = new GetDataPointByModuleResponse()
                {
                    ResponseSucceed = false,
                    Message         = "查询失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
예제 #5
0
        public GetAllDataPointsInfoResponse GetAllDataPointInfo()
        {
            GetAllDataPointsInfoResponse response = new GetAllDataPointsInfoResponse();

            try
            {
                IEnumerable <DataPoint> allDataPoints = _dataPointRepository.FindAll();
                response.DataPointInfoViews = allDataPoints.ConverToDataPointInfoViews();
            }
            catch (Exception ex)
            {
                string message = "查询失败!\n错误信息:\n" + ex.Message;
                response = new GetAllDataPointsInfoResponse()
                {
                    ResponseSucceed = false,
                    Message         = "查询失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }


            return(response);
        }
예제 #6
0
        public GetAllDataPointsHistoryDataResponse GetAllDataPointsHistoryData()
        {
            GetAllDataPointsHistoryDataResponse response = new GetAllDataPointsHistoryDataResponse();

            try
            {
                IEnumerable <DataPointHistoryData> dataPointHistoryDatas =
                    dataPointHistoryDataRepository.FindAll();

                response.DataPointHistoryDataView =
                    dataPointHistoryDatas.ConvetToDataPointHistoryDataView();
            }
            catch (Exception ex)
            {
                string message = "查询失败!错误信息:/n" + ex.Message;
                response = new GetAllDataPointsHistoryDataResponse()
                {
                    ResponseSucceed = false,
                    Message         = "查询失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
예제 #7
0
        protected void Application_Start()
        {
            //加载控制反转
            BootStrapper.ConfigureDependencies();
            //区域
            AreaRegistration.RegisterAllAreas();
            //配置调用WebApi借口
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            //过滤器
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            //加载路由
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //加载JS/CSS文件
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //加载Mapper
            AutoMapperBootStrapper.ConfigureAutoMapper();
            //配置文件
            ApplicationSettingsFactory.InitializeApplicationSettingsFactory(ObjectFactory.GetInstance <IApplicationSettings>());
            //验证方法
            AuthenticationFactory.InitializeAuthenticationFactory(ObjectFactory.GetInstance <IAuthenticationService>());
            //
            ControllerBuilder.Current.SetControllerFactory(new WangYc.Controllers.IocControllerFactory());
            //日志
            LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>());

            LoggingFactory.GetLogger().Log("Application Started");
            //删除xml的解析 当返回值是string 时 直接返回string不是json对象
            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
        }
예제 #8
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;


            GlobalConfiguration.Configuration.DependencyResolver = new WebApiContrib.IoC.StructureMap.StructureMapResolver(BootStrapper.ConfigureStructureMapWebAPI());

            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            BootStrapper.ConfigureStructureMap();


            Services.AutoMapperBootStrapper.ConfigureAutoMapper();
            RAM.Controllers.AutoMapperBootStrapper.ConfigureAutoMapper();

            LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>());

            EmailServiceFactory.InitializeEmailServiceFactory
                (ObjectFactory.GetInstance <IEmailService>());

            ControllerBuilder.Current.SetControllerFactory(new IOCControllerFactory());

            LoggingFactory.GetLogger().Log("Application Started");
            ModelBinders.Binders.DefaultBinder = new App_Start.GenericModelBinder();
        }
예제 #9
0
 /// <summary>
 /// 记录sql
 /// </summary>
 /// <param name="customerTraceInfo"></param>
 private static void OnCustomerTraceConnection(CustomerTraceInfo customerTraceInfo)
 {
     try
     {
         string sql = Environment.NewLine + "#####################################################" + Environment.NewLine + customerTraceInfo.SqlText;
         try
         {
             sql = customerTraceInfo.CustomerParams.Aggregate(customerTraceInfo.SqlText,
                                                              (current, item) => current.Replace(item.Key, item.Value.Value.ToString()));
         }
         catch (Exception ex)
         {
             //ignore
         }
         sql += Environment.NewLine;
         foreach (var detail in customerTraceInfo.RunTimeList)
         {
             var sencond = (int)detail.Duration.TotalSeconds;
             var time    = sencond + "秒";
             if (sencond < 1)
             {
                 time = detail.Duration.TotalMilliseconds + "豪秒";
             }
             sql += $"Server:{detail.Server},DB名称:{detail.DbName}, 执行时间:{time}" + Environment.NewLine + "#####################################################" + Environment.NewLine;
             LoggingFactory.GetLogger().Log(sql);
         }
     }
     catch (Exception)
     {
         //ignore
     }
 }
예제 #10
0
        private static DataPointHistoryData ConverToDataPointHistoryData(DataRowCollection rows, int i)
        {
            DataPointHistoryData dataPointHistoryData = new DataPointHistoryData();

            try
            {
                dataPointHistoryData.Id = rows[i]["DatapointHistoryDataId"] != null?Convert.ToString(rows[i]["DatapointHistoryDataId"]) : "";

                DataPoint dataPoint = new DataPoint();
                dataPoint.Id = rows[i]["DataPointId"] != null?Convert.ToInt32(rows[i]["DataPointId"]) : -1;

                dataPointHistoryData.DataPoint = dataPoint;

                dataPointHistoryData.DateTime = rows[i]["DateTime"] != null?Convert.ToDateTime(rows[i]["DateTime"]) : new DateTime();

                dataPointHistoryData.Value = rows[i]["Value"] != null?Convert.ToDouble(rows[i]["Value"]) : -1;
            }
            catch (Exception ex)
            {
                string message = DebugBaseMessage + "public static DataPoint ConverToDataPointHistoryData(DataRowCollection rows)\n " + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(dataPointHistoryData);
            }

            return(dataPointHistoryData);
        }
예제 #11
0
        public SetOrderPaymentResponse SetOrderPayment(SetOrderPaymentRequest paymentRequest)
        {
            SetOrderPaymentResponse paymentResponse = new SetOrderPaymentResponse();

            Order order = _orderRepository.FindBy(paymentRequest.OrderId);

            try
            {
                order.SetPayment(PaymentFactory.CreatePayment(paymentRequest.PaymentToken,
                                                              paymentRequest.Amount, paymentRequest.PaymentMerchant
                                                              ));

                _orderRepository.Save(order);
                _uow.Commit();
            }
            catch (OrderAlreadyPaidForException ex)
            {
                //  Out of scope of case study: Refund the payment using the payment service...
                LoggingFactory.GetLogger().Log(ex.Message);
            }
            catch (PaymentAmountDoesNotEqualOrderTotalException ex)
            {
                //  Out of scope of case study: Refund the payment using the payment service...
                LoggingFactory.GetLogger().Log(ex.Message);
            }

            paymentResponse.Order = order.ConvertToOrderView();

            return(paymentResponse);
        }
예제 #12
0
        public ResponseBase UpdateBook(CreateBookRequest request)
        {
            var response = new ResponseBase();

            try
            {
                var book = _bookRepository.GetById(request.Create.Id);
                book.BookCategoryId = request.Create.BookCategoryId;
                book.CoverPage      = request.Create.CoverPage;
                book.CreationDate   = DateTime.Now;
                book.Description    = request.Create.Description;
                book.IsActive       = request.Create.IsActive;
                book.IsbnNumber     = request.Create.IsbnNumber;
                book.Price          = request.Create.Price;
                book.PublishedDate  = request.Create.PublishedDate;
                book.Remarks        = request.Create.Remarks;
                book.TitleB         = request.Create.TitleB;
                book.TitleE         = request.Create.TitleE;
                book.TotalPage      = request.Create.TotalPage;

                _bookRepository.Update(book);
                _bookUnitOfWork.Commit();

                response.TransactionMessage = "Data Updated Successfully";
                response.TransactionStatus  = true;
            }
            catch (InvalidBookException ex)
            {
                response.TransactionMessage = "Failed to Update Data";
                response.TransactionStatus  = false;
                LoggingFactory.GetLogger().Log(ex.Message.ToString());
            }

            return(response);
        }
예제 #13
0
        public DonorCreatorModule(IDonorRepositoty donorRepositoty)
        {
            Post["/donor"] =
                routeParams =>
            {
                var id      = Guid.NewGuid();
                var name    = (string)routeParams.Name;
                var contact = (string)routeParams.Conatact;
                var email   = (string)routeParams.Email;

                var daDonor = new DataAccess.Donor()
                {
                    Id      = id,
                    Name    = name,
                    Contact = contact,
                    Email   = email
                };

                donorRepositoty.AddDonor(daDonor);
                const string subject  = "Donor creation";
                const string messsage = "Hi, Your account has been created";
                LoggingFactory.GetLogger().InfoFormat("Donor is created");
                var emailHandler = new EmailHandler(email, subject, messsage);
                emailHandler.SendEmail();
                return(Negotiate.WithStatusCode(HttpStatusCode.Created));
            };
        }
예제 #14
0
        public void Add(DataPointHistoryData entity)
        {
            MySqlParameter[] mySqlPrarameters =
            {
                //new MySqlParameter("@DataPointHistoryDataId", entity.Id),
                new MySqlParameter("@DataPointHistoryDataId", Guid.NewGuid().ToString("D")),
                new MySqlParameter("@DataPointId",            entity.DataPoint.Id),
                new MySqlParameter("@DateTime",               entity.DateTime),
                new MySqlParameter("@Value",                  entity.Value)
            };

            string sqlString = "insert into numericalcontrolsystem.datapointhistorydata(DataPointHistoryDataId,DataPointId,DateTime,Value) " +
                               "values(@DataPointHistoryDataId,@DataPointId,@DateTime,@Value);";

            try
            {
                dbUtility.ExecuteNonQuery(sqlString, CommandType.Text, mySqlPrarameters);
            }
            catch (Exception ex)
            {
                string message = "添加失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                throw new Exception(message);
            }
        }
예제 #15
0
        public DeleteDataPointHistoryDataResponse DeleteDataPointHistoryData(DeleteDataPointHistoryDataRequst requst)
        {
            DeleteDataPointHistoryDataResponse response = new DeleteDataPointHistoryDataResponse();

            try
            {
                Query query = new Query();
                query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DateTime, requst.BeginTime, CriteriaOperator.GreaterThanOrEqual));
                query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DateTime, requst.EndTime, CriteriaOperator.LesserThanOrEqual));
                query.QueryOperator = QueryOperator.And;

                dataPointHistoryDataRepository.Remove(query);

                unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                string message = "删除失败!错误信息:/n" + ex.Message;
                response = new DeleteDataPointHistoryDataResponse()
                {
                    ResponseSucceed = false,
                    Message         = "删除失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
예제 #16
0
        public IEnumerable <DataPoint> FindAll()
        {
            List <DataPoint> dataPoints = new List <DataPoint>();
            DataTable        dataTable;

            string dataPointQuery = this.baseSelectQuery;

            try
            {
                dataTable = dbUtility.ExecuteDataTable(dataPointQuery, CommandType.Text);
                if (null != dataTable)
                {
                    DataPoint dataPoint;
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        dataPoint = DataMapperFactory.GetDataMapper <DataPoint>().ConverFrom(dataTable.Rows, i);
                        dataPoints.Add(dataPoint);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(dataPoints);
            }

            return(dataPoints);
        }
예제 #17
0
        public GetDataPiontHistoryDataResponse GetDataPiontHistoryData(GetDataPointHistoryDataRequest request)
        {
            GetDataPiontHistoryDataResponse response = new GetDataPiontHistoryDataResponse();

            try
            {
                Query query = new Query();
                query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DataPoint.Id, request.DataPointId, CriteriaOperator.Equal));
                query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DateTime, request.BeginTime, CriteriaOperator.GreaterThanOrEqual));
                query.AddCriterion(Criterion.Create <DataPointHistoryData>(p => p.DateTime, request.EndTime, CriteriaOperator.LesserThanOrEqual));
                query.QueryOperator   = QueryOperator.And;
                query.OrderByProperty = OrderByClause.Create <DataPointHistoryData>(p => p.DateTime, false);

                IEnumerable <DataPointHistoryData> dataPointHistoryDatas =
                    dataPointHistoryDataRepository.FindBy(query);

                response.DataPointHistoryDataView =
                    dataPointHistoryDatas.ConvetToDataPointHistoryDataView();
            }
            catch (Exception ex)
            {
                string message = "查询失败!错误信息:/n" + ex.Message;
                response = new GetDataPiontHistoryDataResponse()
                {
                    ResponseSucceed = false,
                    Message         = "查询失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
예제 #18
0
        public IEnumerable <DataPoint> FindBy(Query query)
        {
            List <DataPoint> dataPoints = new List <DataPoint>();
            DataTable        dataTable;

            List <MySqlParameter> parametersrarameters = new List <MySqlParameter>();

            string resultQuery = query.TranslateIntoSqlString <DataPoint>(this.baseSelectQuery, parametersrarameters);

            try
            {
                dataTable = dbUtility.ExecuteDataTable(resultQuery, CommandType.Text, parametersrarameters.ToArray());
                if (null != dataTable)
                {
                    DataPoint dataPoint;
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        dataPoint = DataMapperFactory.GetDataMapper <DataPoint>().ConverFrom(dataTable.Rows, i);
                        dataPoints.Add(dataPoint);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(dataPoints);
            }

            return(dataPoints);
        }
        public void PaymentCallBack(FormCollection collection)
        {
            int             orderId = _paymentService.GetOrderIdFor(collection);
            GetOrderRequest request = new GetOrderRequest()
            {
                OrderId = orderId
            };

            GetOrderResponse response = _orderService.GetOrder(request);

            OrderPaymentRequest orderPaymentRequest =
                response.Order.ConvertToOrderPaymentRequest();

            TransactionResult transactionResult =
                _paymentService.HandleCallBack(orderPaymentRequest, collection);

            if (transactionResult.PaymentOk)
            {
                SetOrderPaymentRequest paymentRequest = new SetOrderPaymentRequest();
                paymentRequest.Amount          = transactionResult.Amount;
                paymentRequest.PaymentToken    = transactionResult.PaymentToken;
                paymentRequest.PaymentMerchant = transactionResult.PaymentMerchant;
                paymentRequest.OrderId         = orderId;

                _orderService.SetOrderPayment(paymentRequest);
            }
            else
            {
                LoggingFactory.GetLogger().Log(String.Format(
                                                   "Payment not ok for order id {0}, payment token {1}",
                                                   orderId, transactionResult.PaymentToken));
            }
        }
예제 #20
0
        public void Add(DataPoint entity)
        {
            MySqlParameter[] mySqlPrarameters =
            {
                new MySqlParameter("@Number",               entity.Number),
                new MySqlParameter("@Name",                 entity.Name),
                new MySqlParameter("@DeviceAddress",        entity.DeviceAddress),
                new MySqlParameter("@StartRegisterAddress", entity.StartRegisterAddress),
                new MySqlParameter("@DataType",             entity.DataType),
                new MySqlParameter("@DataPointType",        entity.DataPointType),
                new MySqlParameter("@Description",          entity.Description),
                new MySqlParameter("@ModuleId",             entity.ModuleBelongTo.Id)
            };

            string sqlString = "insert into numericalcontrolsystem.datapoint(Number,Name,DeviceAddress,StartRegisterAddress,DataType,DataPointType,Description,ModuleId) " +
                               "values(@Number,@Name,@DeviceAddress,@StartRegisterAddress,@DataType,@DataPointType,@Description,@ModuleId);";

            try
            {
                dbUtility.ExecuteNonQuery(sqlString, CommandType.Text, mySqlPrarameters);
            }
            catch (Exception ex)
            {
                string message = "添加失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);
            }
        }
예제 #21
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();

            BootStrapper.ConfigureDependencies();

            Controllers.AutoMapperBootStrapper.ConfigureAutoMapper();
            Services.AutoMapperBootStrapper.ConfigureAutoMapper();

            ApplicationSettingsFactory.InitializeApplicationSettingsFactory(ObjectFactory.GetInstance <IApplicationSettings>());

            LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>());

            EmailServiceFactory.InitializeEmailServiceFactory(ObjectFactory.GetInstance <IEmailService>());

            ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory());

            DomainEvents.DomainEventHandlerFactory = ObjectFactory.GetInstance <IDomainEventHandlerFactory>();

            Repository.NHibernate.SessionFactory.Init();
            Services.Presentation.SessionFactory.Init();

            LoggingFactory.GetLogger().Log("Application Started");
        }
예제 #22
0
        public void Save(DataPoint entity)
        {
            MySqlParameter[] mySqlPrarameters =
            {
                new MySqlParameter("@DataPointId",          entity.Id),
                new MySqlParameter("@Number",               entity.Number),
                new MySqlParameter("@Name",                 entity.Name),
                new MySqlParameter("@DeviceAddress",        entity.DeviceAddress),
                new MySqlParameter("@StartRegisterAddress", entity.StartRegisterAddress),
                new MySqlParameter("@DataType",             entity.DataType),
                new MySqlParameter("@DataPointType",        entity.DataPointType),
                new MySqlParameter("@Description",          entity.Description),
                new MySqlParameter("@ModuleId",             entity.ModuleBelongTo.Id)
            };

            string sqlString = "updata numericalcontrolsystem.datapoint " +
                               "set Number=@Number, Name=@Name, DeviceAddress=@DeviceAddress, StartRegisterAddress=@StartRegisterAddress, DataType=@DataType, DataPointType=@DataPointType, Description=@Description, ModuleId=@ModuleId " +
                               "where DataPointId=@DataPointId;";

            try
            {
                dbUtility.ExecuteNonQuery(sqlString, CommandType.Text, mySqlPrarameters);
            }
            catch (Exception ex)
            {
                string message = "修改失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);
            }
        }
예제 #23
0
        public AddDataPointResponse AddDataPoint(AddDataPointRequst requst)
        {
            AddDataPointResponse response = new AddDataPointResponse();

            try
            {
                foreach (DataPoint dataPoint in requst.DataPointsToAdd)
                {
                    _dataPointRepository.Add(dataPoint);
                }

                _unitOfWork.Commit();
            }
            catch (Exception ex)
            {
                string message = "添加失败!错误信息:/n" + ex.Message;
                response = new AddDataPointResponse()
                {
                    ResponseSucceed = false,
                    Message         = "添加失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
예제 #24
0
        /// <summary>
        /// Load the settings xml file and retun the Settings Type with Deserialize with xml content
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="fileName">File Name of the custom xml Settings file</param>
        /// <returns>The T type which we have have paased with LoadFromXml<T> </returns>
        private static T LoadFromXml <T>(string fileName) where T : class
        {
            FileStream fs = null;

            try
            {
                //Serialize of the Type
                XmlSerializer serializer = new XmlSerializer(typeof(T));
                fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                return((T)serializer.Deserialize(fs));
            }
            catch (Exception ex)
            {
                //write error log
                //ILoggingService _logger = new LoggingService();
                //_logger.Error(LogUtility.BuildExceptionMessage(ex));
                LoggingFactory.GetLogger().Fatal(LogUtility.BuildExceptionMessage(ex));

                return(null);
            }
            finally
            {
                fs?.Close();
            }
        }
        public ExecuteSqlScriptResponse ExecuteSqlScript(ExecuteSqlScriptRequest request)
        {
            ExecuteSqlScriptResponse response = new ExecuteSqlScriptResponse();

            if (null != request)
            {
                try
                {
                    if (request.SqlScriptFiles.Count > 0)
                    {
                        ExecuteSqlScript(request.SqlScriptFiles);
                    }
                    else
                    {
                        response.ResponseSucceed = false;
                        response.Message         = "无脚本文件";
                    }
                }
                catch (Exception ex)
                {
                    string message = "操作失败。" + ex.Message;
                    response.ResponseSucceed = false;
                    response.Message         = message;
                    LoggingFactory.GetLogger().WriteDebugLogger(message);
                }
            }

            return(response);
        }
예제 #26
0
        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            BootStrapper.ConfigureDependencies();
            //DependencyResolver.SetResolver(new NinjectDependencyResolver());

            Controllers.AutoMapperBootStrapper.ConfigureAutoMapper();
            Services.AutoMapperBootStrapper.ConfigureAutoMapper();


            ApplicationSettingsFactory.InitializeApplicationSettingsFactory
                (ObjectFactory.GetInstance <IApplicationSettings>());

            LoggingFactory.InitializeLogFactory(ObjectFactory.GetInstance <ILogger>());

            EmailServiceFactory.InitializeEmailServiceFactory
                (ObjectFactory.GetInstance <IEmailService>());
            ControllerBuilder.Current.SetControllerFactory(new IoCControllerFactory());


            LoggingFactory.GetLogger().Log("Application Started");
            GlobalConfiguration.Configuration.Formatters.Clear();
            GlobalConfiguration.Configuration.Formatters.Add(new JsonMediaTypeFormatter());
        }
예제 #27
0
        /// <summary>
        /// 初始化主界面
        /// </summary>
        private void InitializeShell()
        {
            App.Current.MainWindow = new NCSMainWindow();
            App.Current.MainWindow.Show();

            LoggingFactory.GetLogger().WriteSystemLogger("加载程序主窗口完成");
        }
예제 #28
0
        ModifyPasswordResponse IUserService.ModifyPwd(ModifyPwdRequest req)
        {
            var resp = new ModifyPasswordResponse();

            try
            {
                var pwd   = EncryptContextFactory.GetContext().Encrypt(req.OldPassword);
                var model = _userDAL.FindBy(m => m.UserName == req.LoginId && m.Password == pwd).SingleOrDefault();
                if (model != null)
                {
                    model.Password = EncryptContextFactory.GetContext().Encrypt(req.NewPassword);
                    _userDAL.Save(model);
                    resp.Message = "密码修改成功!";
                    resp.Succeed = true;
                }
                else
                {
                    resp.Message = "原密码错误";
                }
            }
            catch (Exception ex)
            {
                LoggingFactory.GetLogger().Log(ex.Message);
                LoggingFactory.GetLogger().Log(ex.StackTrace);
                resp.Message = "修改密码失败!";
            }
            return(resp);
        }
예제 #29
0
        public GetAllModuleResponse GetAllModules(GetAllModuleRequest request)
        {
            GetAllModuleResponse response = new GetAllModuleResponse();

            try
            {
                IEnumerable <Module> modules = _moduleRepository.FindAll();

                response.ModuleViews = modules.ConverToModuleViews();
            }
            catch (Exception ex)
            {
                string message = "查询失败!错误信息:/n" + ex.Message;
                response = new GetAllModuleResponse()
                {
                    ResponseSucceed = false,
                    Message         = "查询失败"
                };
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(response);
            }

            return(response);
        }
예제 #30
0
        public void Save(DataPointHistoryData entity)
        {
            MySqlParameter[] mySqlPrarameters =
            {
                new MySqlParameter("@DataPointHistoryDataId", entity.Id),
                new MySqlParameter("@DataPointId",            entity.DataPoint.Id),
                new MySqlParameter("@DateTime",               entity.DateTime),
                new MySqlParameter("@Value",                  entity.Value)
            };

            string sqlString = "updata numericalcontrolsystem.datapointhistorydata " +
                               "set DataPointHistoryDataId=@DataPointHistoryDataId, DataPointId=@DataPointId, DateTime=@DateTime, DataType=@DataType, Value=@Value " +
                               "where DataPointHistoryDataId=@DataPointHistoryDataId;";

            try
            {
                dbUtility.ExecuteNonQuery(sqlString, CommandType.Text, mySqlPrarameters);
            }
            catch (Exception ex)
            {
                string message = "修改失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                throw new Exception(message);
            }
        }