public ActionResult getrecord(int pagesize, int pageno, int? mid, string name, string begintime, string endtime)
        {
            try
            {
                MachineDAL dal = new MachineDAL();
                TemperatureRecordDAL trDAL = new TemperatureRecordDAL();
                MachineModel model = dal.QuerySingle(" id=" + mid.TryParseInt());
                IList<TemperatureRecordModel> list = new List<TemperatureRecordModel>();
                int record = 0;
                string where = " 1=1";
                if (!name.IsNullOrEmpty())
                    where += " and (MachineName like'%" + name + "%' or MachineCode like'%" + name + "%')";
                else if (model != null)
                {
                    where += " and MachineID=" + model.ID;
                }
                if (begintime.TryParseDateTime() > DateTime.MinValue)
                    where += " and addtime>='" + begintime + "'";
                if (endtime.TryParseDateTime() > DateTime.MinValue)
                    where += " and addtime<'" + endtime.TryParseDateTime().AddDays(1) + "'";

                list = trDAL.QuerySQL(pagesize, pageno, out record, where, "AddTime desc");
                if (list != null && list.Count > 0)
                    return Content(true.ToResult(record.ToString(), list).ToJsonString());
                else
                    return Content(false.ToResult("没有查询到任何数据").ToJsonString());
            }
            catch (Exception ex)
            {
                Log.Default.Error(ex);
                return Content(false.ToResult("网络异常,请稍后重试").ToJsonString());
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Gets all unique machine Ids.
 /// </summary>
 /// <returns></returns>
 public static List <string> GetMachineIDs()
 {
     try
     {
         return(MachineDAL.GetMachineIDs());
     }
     catch
     {
         throw;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 初始化机台相关数据
        /// </summary>
        private bool InitMachineEmployeeAndParameterCode()
        {
            // 获取并存储所有机台信息
            List <Machine> machines = MachineDAL.SelectAll();

            if (machines != null && machines.Count > 0)
            {
                foreach (Machine machine in machines)
                {
                    Configuration.MachineMap[machine.MachineName] = machine;
                }
            }
            else
            {
                return(false);
            }

            // 获取并存储所有员工信息
            List <Employee> employees = EmployeeDAL.SelectAll();

            if (employees != null && employees.Count > 0)
            {
                foreach (Employee employee in employees)
                {
                    Configuration.EmployeeMap[employee.EmployeeCode] = employee;
                }
            }
            else
            {
                return(false);
            }

            // 获取并存储所有参数信息
            List <ParameterCode> parameterCodes = ParameterCodeDAL.SelectAll();

            if (parameterCodes != null && parameterCodes.Count > 0)
            {
                Configuration.ParameterCodeArray
                    = new string[parameterCodes.Last().ParameterTypeId + 1];
                foreach (ParameterCode paramCode in parameterCodes)
                {
                    Configuration.ParameterCodeArray[
                        paramCode.ParameterTypeId] = paramCode.ParameterName;
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        public string TemperatureRecord(JObject obj)
        {
            MachineDAL machineDAL = new MachineDAL();
            MachineModel machine = machineDAL.QuerySingle(" MachineCode='" + obj["mc"].ToString() + "'");
            if (machine != null && machine.ID > 0)
            {
                TemperatureRecordModel model = new TemperatureRecordModel();
                model.MachineName = machine.MachineName;
                model.AddTime = DateTime.Now;
                model.MachineCode = obj["mc"].TryParseString();
                model.Temperature = obj["tt"].TryParseDecimal(8);
                model.Longitude = obj["lon"].TryParseDecimal(10);
                model.Latitude = obj["lat"].TryParseDecimal(10);
                model.RemainingPower = obj["rp"].TryParseDecimal(2);
                model.WorkingMode = obj["wm"].TryParseString();
                model.SignalStrength = obj["ss"].TryParseString();
                model.IP = obj["ip"].TryParseString();
                model.Port = obj["port"].TryParseInt();
                model.WorkingFrequency = obj["wf"].TryParseString();
                TemperatureRecordDAL dal = new TemperatureRecordDAL();
                dal.InsertSQL(model);

                SystemConfigDAL conDAL = new SystemConfigDAL();
                SystemConfigModel conMinModel = conDAL.QuerySingle(" ConfigKey='TemperatureMinValue'");
                SystemConfigModel conMaxModel = conDAL.QuerySingle(" ConfigKey='TemperatureMaxValue'");
                if ((conMinModel != null && model.Temperature < conMinModel.ConfigValue.TryParseDecimal()) || (conMaxModel != null && model.Temperature > conMaxModel.ConfigValue.TryParseDecimal()))
                {
                    SystemConfigModel conMobile = conDAL.QuerySingle(" ConfigKey='TemperatureMobile'");
                    SystemConfigModel conContent = conDAL.QuerySingle(" ConfigKey='SMSTemperatureTemplate'");
                    if (conMobile != null && !conMobile.ConfigValue.IsNullOrEmpty() && conContent != null && !conContent.ConfigValue.IsNullOrEmpty())
                    {
                        foreach (string mobile in conMobile.ConfigValue.Split(','))
                        {
                            string content = string.Format(conContent.ConfigValue, model.MachineCode, model.Temperature);
                            StringBuilder sbTemp = new StringBuilder();
                            string url = "http://api.sms.cn/mtutf8/";
                            string data = "uid=" + ConfigurationManager.AppSettings["SMSUserName"] +
                                "&pwd=" + ConfigurationManager.AppSettings["SMSPassword"] + "&mobile=" + mobile + "&content=" + Server.UrlEncode(content);
                            sbTemp.Append(data);
                            byte[] bTemp = System.Text.Encoding.GetEncoding("GBK").GetBytes(sbTemp.ToString());
                            string res = doPostRequest(url, bTemp);
                            Log.Default.Debug("温度短信报警:" + res);
                        }
                    }
                }

                return true.ToResult().ToJsonString();
            }
            return false.ToResult("后台无此机器码").ToJsonString();
        }
Esempio n. 5
0
        public void TestGetMachineIDs()
        {
            List <string> ids = MachineDAL.GetMachineIDs();

            Assert.AreEqual("Machine1", ids[0]);
            Assert.AreEqual("Machine2", ids[1]);
            Assert.AreEqual("Machine3", ids[2]);
            Assert.AreEqual("Machine4", ids[3]);
            Assert.AreEqual("Machine5", ids[4]);
            Assert.AreEqual("Machine6", ids[5]);

            CleanUp();

            List <string> emptyIds = MachineDAL.GetMachineIDs();

            Assert.AreEqual(null, emptyIds);
        }
        public KumasAndIplikUOW(string ConnectionString = null)
        {
            if (ConnectionString == null)
            {
                Context = new KumasAndIplikContext(ConnectionStringGetter.Get());
            }
            else
            {
                Context = new KumasAndIplikContext(ConnectionString);
            }

            CrashRegister       = new CrashRegisterDAL(Context);
            Factory             = new FactoryDAL(Context);
            Machine             = new MachineDAL(Context);
            MachineComponent    = new MachineComponentDAL(Context);
            StenterMachine      = new StenterMachineDAL(Context);
            Employee            = new EmployeeDAL(Context);
            ManipulatorEmployee = new ManipulatorEmployeeDAL(Context);
        }
Esempio n. 7
0
        //Genera el archivo txt en disco local.
        public string DownloadFileFlat(string prmIPAddress, string prmFileName)
        {
            var machinePropertiesList = new MachineDAL().GetMachinePropertiesByIP(prmIPAddress);

            return(FileMachineBL.generateFileFlat(prmFileName, machinePropertiesList));
        }