Пример #1
0
        /// <summary>
        /// 此功能用于执行特定SQL语句,返回表
        /// </summary>
        /// <returns>Tables()</returns>
        /// <param name="queryString"></param>
        public static DataTable ExecuteSQLDtQuery(string queryString)
        {
            IDBHelper dbHelper = new PostgreHelper();
            DataSet   ds       = dbHelper.ExecuteQuery(connectionString, CommandType.Text, queryString, null);

            return(ds.Tables[0]);
        }
        /// <summary>
        /// 此功能用于ync三菱PLC报警实时信息的查看操作
        /// </summary>
        /// <returns>Tables()</returns>
        public static DataTable SelMitsubishiRealTimeAlarmQuery(string machineid, string startime, string endtime)
        {
            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "SELECT * FROM public.mitalarm WhERE strip='" + machineid + "' AND strtime>'" + startime + "' AND strtime<'" + endtime + "'";
            DataSet   ds          = dbHelper.ExecuteQuery(connectionString, CommandType.Text, queryString, null);

            return(ds.Tables[0]);
        }
        /// <summary>
        /// 此功能用于ync三菱PLC报警配置的查看操作
        /// </summary>
        /// <returns>Tables()</returns>
        public static DataTable SelMitsubishiAlarmQuery()
        {
            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "SELECT * FROM public.ync_mitsubishi_alarmconfig";
            DataSet   ds          = dbHelper.ExecuteQuery(connectionString, CommandType.Text, queryString, null);

            return(ds.Tables[0]);
        }
        /// <summary>
        /// 此功能用于ync工厂的信息,包含工厂,车间,生产线,机床id列表,机床name列表
        /// </summary>
        /// <returns>Tables(工厂,车间,生产线,机床id列表,机床name列表)</returns>
        public static DataTable GetFactoryOrgInfoQuery()
        {
            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "public.yncfactoryorginfo()";
            DataSet   ds          = dbHelper.ExecuteQuery(connectionString, CommandType.StoredProcedure, queryString, null);

            return(ds.Tables[0]);
        }
        /// <summary>
        /// 此功能用于ync指定车间/生产线/机床ID的oee
        /// </summary>
        /// <returns>Tables()</returns>
        public static DataTable GetOeeDataQuery(string Onelevel, string Twolevel, string Threelevel, string machineid, string Startime, string Endtime)
        {
            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "public.ync_ncs_oee('" + Onelevel + "','" + Twolevel + "','" + Threelevel + "','" + machineid + "','" + Startime + "','" + Endtime + "')";
            DataSet   ds          = dbHelper.ExecuteQuery(connectionString, CommandType.StoredProcedure, queryString, null);

            return(ds.Tables[0]);
        }
        /// <summary>
        /// 此功能用于ync指定生产线的刀具信息,包含刀夹、T代码、当前值、予置值、目标值、剩余值、、刀具名称,刀补值:(刀长-磨损)
        /// </summary>
        /// <returns>Tables()</returns>
        public static DataTable GetLineToolStatesQuery(string Onelevel, string Twolevel, string Threelevel)
        {
            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "public.yncLineToolStates('" + Onelevel + "','" + Twolevel + "','" + Threelevel + "')";
            DataSet   ds          = dbHelper.ExecuteQuery(connectionString, CommandType.StoredProcedure, queryString, null);

            return(ds.Tables[0]);
        }
        public static DataTable GetPlantStatesAllQuery(string Onelevel, string Twolevel)
        {
            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "public.yncpgmachinestatesall('" + Onelevel + "','" + Twolevel + "','C')";
            DataSet   ds          = dbHelper.ExecuteQuery(connectionString, CommandType.StoredProcedure, queryString, null);

            return(ds.Tables[0]);
        }
        public static DataSet GetSingleMachineInfoQuery(string MachineID)
        {
            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "public.pgsinglemachineinfo('" + MachineID + "')";
            DataSet   ds          = dbHelper.ExecuteQuery(connectionString, CommandType.StoredProcedure, queryString, null);

            return(ds);
        }
        /// <summary>
        /// 此功能用于ync废品量的查看操作
        /// </summary>
        /// <returns>Tables()</returns>
        public static DataTable SelMachineScrapQuery(string Onelevel, string Twolevel, string Threelevel, string machineid, string startime, string endtime)
        {
            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "SELECT * FROM public.ync_scrap_quantity WHERE machineid='" + machineid + "' AND inputdate>='" + startime + "' AND inputdate<='" + endtime + "' ORDER BY inputdate";
            DataSet   ds          = dbHelper.ExecuteQuery(connectionString, CommandType.Text, queryString, null);

            return(ds.Tables[0]);
        }
        public static DataTable GetPlantStatesRemtimQuery(string Onelevel, string Twolevel, string DbColumnName)
        {
            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "public.yncpgplantstates('" + Onelevel + "','" + Twolevel + "')";
            DataSet   ds          = dbHelper.ExecuteQuery(connectionString, CommandType.StoredProcedure, queryString, null);

            ds.Tables[0].Columns.Remove(DbColumnName);
            return(ds.Tables[0]);
        }
        /// <summary>
        /// 此功能用于ync三菱PLC报警实时信息的查看操作
        /// </summary>
        /// <returns>Tables()</returns>
        public static DataTable GetMitsubishiAlarmQuery(string Onelevel, string Twolevel, string Threelevel, string machineid, string altypeno, string Startime, string Endtime)
        {
            IDBHelper dbHelper = new PostgreHelper();
            //string queryString = "SELECT * FROM public.mitalarm WhERE strip='" + machineid + "' AND strtime>'" + startime + "' AND strtime<'" + endtime + "'";
            string  queryString = string.Format("public.ync_mitalarms('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", Onelevel, Twolevel, Threelevel, machineid, altypeno, Startime, Endtime);
            DataSet ds          = dbHelper.ExecuteQuery(connectionString, CommandType.StoredProcedure, queryString, null);

            return(ds.Tables[0]);
        }
        /// <summary>
        /// 此功能用于ync获取指定时间段的机器产量信息。可筛选功能。
        /// </summary>
        /// <returns>Tables()</returns>
        public static DataTable GetMachineOutputQuery(string Onelevel, string Twolevel, string Threelevel, string Startime, string Endtime, string Workpieceid, string Machinename)
        {
            Stopwatch watch = Stopwatch.StartNew();

            watch.Start();

            IDBHelper dbHelper    = new PostgreHelper();
            string    queryString = "public.yncmachineouputq('" + Onelevel + "','" + Twolevel + "','" + Threelevel + "','" + Workpieceid + "','" + Machinename + "','" + Startime + "','" + Endtime + "')";
            string    s           = "dbHelper 成功!耗时:" + "/n" + watch.ElapsedMilliseconds + "毫秒";

            Debug.WriteLine(s);
            DataSet ds = dbHelper.ExecuteQuery(connectionString, CommandType.StoredProcedure, queryString, null);

            s = "ds 成功!耗时:" + "/n" + watch.ElapsedMilliseconds + "毫秒";
            Debug.WriteLine(s);
            return(ds.Tables[0]);
        }