Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="log"></param>
        /// <param name="strDeviceId"></param>
        /// <returns></returns>
        public bool AddDeviceProduceLogPar(DeviceProduceLogPar log, string strDeviceId)
        {
            try
            {
                bool isAdd = false;

                if (log != null)
                {
                    using (DataModels.HnfactoryautodbDB dataContext = new DataModels.HnfactoryautodbDB())
                    {
                        //日志流水编号{设备编号}-{年月日时分秒}
                        string strNewLogCode = string.Format("{0}-{1}-{2:yyMMddHHmmss}", strDeviceId, log.ParType.ToString(), DateTime.Now);

                        log.LogParId = strNewLogCode;

                        DataModels.LDeviceproducelogpar data = log.ToData();
                        dataContext.Insert <DataModels.LDeviceproducelogpar>(data);
                        isAdd = true;
                    }
                }

                return(isAdd);
            }
            catch
            {
                throw;
            }
        }
        internal DataModels.LDeviceproducelogpar ToData()
        {
            DataModels.LDeviceproducelogpar data = new DataModels.LDeviceproducelogpar();

            data.Id                 = this.Id;
            data.LogParId           = this.LogParId;
            data.DeviceProduceLogId = this.DeviceProduceLogId;
            data.Created            = this.Created;
            data.SensorId           = this.SensorId;
            data.SensorStatus       = this.SensorStatus.ToString();
            data.ParType            = this.ParType.ToString();
            data.ParUnit            = this.ParUnit;
            data.ParValue           = this.ParValue;

            return(data);
        }