Ejemplo n.º 1
0
        /// <summary>
        /// 返回标签配置类,供GetRomMap(LabelConfig labelConfig,string labelSn)使用
        /// </summary>
        /// <param name="pn">料号</param>
        /// <param name="result">获取料号配置是否成功</param>
        /// <param name="msg">错误信息</param>
        /// <returns>标签配置类型</returns>
        public LabelConfig GetLabelConfig(string pn, ref bool result, ref string msg)
        {
            LabelConfig labelConfig = new LabelConfig();

            result = Dao.QueryPn(pn, ref labelConfig, ref msg);
            return(labelConfig);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 年年周周
        /// </summary>
        /// <param name="labelSn"></param>
        /// <param name="labelConfig"></param>
        /// <param name="weekStart"></param>
        /// <param name="weekType"></param>
        /// <returns></returns>
        private string GetDateFromWeek_YYWW(string labelSn, LabelConfig labelConfig, DayOfWeek weekStart = DayOfWeek.Monday, CalendarWeekRule weekType = CalendarWeekRule.FirstDay)
        {
            string year = SubLeft(DateTime.Today.ToString("yyyy"), 2) +
                          labelSn.Substring(labelConfig.YearStart, labelConfig.YearEnd - labelConfig.YearStart + 1);
            string week = labelSn.Substring(labelConfig.WeekStart, labelConfig.WeekEnd - labelConfig.WeekStart + 1);

            return(Week2Date(int.Parse(year), int.Parse(week), weekStart, weekType));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据料号,标签返回romMap
        /// </summary>
        /// <param name="pn">料号</param>
        /// <param name="labelSn">标签sn</param>
        /// <returns>交错数组</returns>
        public byte[][] GetRomMapCross(string pn, string labelSn)
        {
            bool        result      = false;
            string      msg         = "";
            LabelConfig labelConfig = GetLabelConfig(pn, ref result, ref msg);

            return(GetRomMapCross(labelConfig, labelSn));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 年年天天天
        /// </summary>
        /// <param name="labelSn"></param>
        /// <param name="labelConfig"></param>
        /// <returns></returns>
        private string GetDateFromDay(string labelSn, LabelConfig labelConfig)
        {
            string year = SubLeft(DateTime.Today.ToString("yyyy"), 2) +
                          labelSn.Substring(labelConfig.YearStart, labelConfig.YearEnd - labelConfig.YearStart + 1);
            string day  = labelSn.Substring(labelConfig.DayStart, labelConfig.DayEnd - labelConfig.DayStart + 1);
            string week = labelSn.Substring(labelConfig.WeekStart, labelConfig.WeekEnd - labelConfig.WeekStart + 1);

            return(new DateTime(int.Parse(year), 1, 1).AddDays(int.Parse(day) - 1).ToString("yyyyMMdd"));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 计算年月日等类型的日期
        /// </summary>
        /// <param name="labelSn"></param>
        /// <param name="labelConfig"></param>
        /// <param name="noUse">不用的日期</param>
        /// <returns>形如20181114的8位日期</returns>
        private string GetDate(string labelSn, LabelConfig labelConfig, string noUse)
        {
            if (labelConfig.YearStart == labelConfig.YearEnd)
            {
                //年的起始位和结束位一样,则日期类型为年月日
                if (labelConfig.MonthStart != labelConfig.MonthEnd ||
                    labelConfig.MonthStart != labelConfig.MonthEnd)
                {
                    throw new Exception("年月日类型的标签年为一位时,月和天也必须为一位");
                }

                string year = SubLeft(DateTime.Now.Year.ToString(), 3) +
                              labelSn.Substring(labelConfig.YearStart, 1);
                string month = int.Parse(labelSn.Substring(labelConfig.MonthStart,
                                                           labelConfig.MonthEnd - labelConfig.MonthStart + 1), NumberStyles.HexNumber).ToString("D2");
                string[] days =
                {
                    //一位天的表示方法
                    "1", "2", "3", "4", "5",
                    "6", "7", "8", "9", "A",
                    "B", "C", "D", "E", "F",
                    "G", "H", "I", "J", "K",
                    "L", "M", "N", "O", "P",
                    "Q", "R", "S", "T", "U",
                    "V", "W", "X", "Y", "Z"
                };
                var dayListTemp = days.ToList();
                for (int i = 0; i < noUse.Length; i++)
                {
                    dayListTemp.Remove(noUse.Substring(i, 1));
                }

                var    dayList  = dayListTemp.Take(31);
                string dayStr   = labelSn.Substring(labelConfig.DayStart, 1);
                int    dayIndex = dayList.ToList().IndexOf(dayStr);
                if (dayIndex < 0)
                {
                    throw new Exception("天数字符串:" + dayStr + "不合法");
                }

                string day = (dayIndex + 1).ToString("D2");
                return(year + month + day);
            }
            else
            {
                //年的起始位和结束位不一样一样,则日期类型为年年月月日日
                return("20" + labelSn.Substring(labelConfig.YearStart,
                                                labelConfig.YearEnd - labelConfig.YearStart + 1) +
                       labelSn.Substring(labelConfig.MonthStart,
                                         labelConfig.MonthEnd - labelConfig.MonthStart + 1) +
                       labelSn.Substring(labelConfig.DayStart,
                                         labelConfig.DayEnd - labelConfig.DayEnd + 1));
            }
        }
Ejemplo n.º 6
0
        private string FillSn(SnDate snDate, LabelConfig labelConfig)
        {
            if (labelConfig.SnFormat.Trim() == "")
            {
                return(snDate.Sn);
            }

            string snFormat = labelConfig.SnFormat;

            string[] keyFormats = { "(YMD1)", "(YMD)", "y^", "yy", "(c)Y", "(c)M", "mm", "ww", "(dd)", "(ddd)", "(YMD2)", "(YMD3)" };
            foreach (string key in keyFormats)
            {
                if (snFormat.Contains(key))
                {
                    snFormat = DateReplace(snFormat, snDate.Date, key, labelConfig.WeekType, labelConfig.WeekStartDay);
                }
            }

            snFormat = SnReplace(snFormat, snDate.Sn);
            return(snFormat);
        }
Ejemplo n.º 7
0
        private SnDate Label2SnDate(string labelSn, LabelConfig labelConfig)
        {
            SnDate ret = new SnDate();

            switch (labelConfig.Description)
            {
            case "NoSN":
                ret.Sn   = SubRight(labelSn, 4);
                ret.Date = "20" + SubLeft(SubRight(labelSn, 12), 6);
                break;

            case "NoDate":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = DateTime.Today.ToString("yyyyMMdd");
                break;

            case "年月日":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = GetDate(labelSn, labelConfig, "IOQU");
                break;

            case "年月日2":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = GetDate(labelSn, labelConfig, "WXYZ");
                break;

            case "年月日3":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = GetDate(labelSn, labelConfig, "WXYZ");
                break;

            case "年月日4":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = GetDate(labelSn, labelConfig, "IOQ");
                break;

            case "年月日5":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = GetDate(labelSn, labelConfig, "WXYZ");
                break;

            case "年月日7":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = GetDate(labelSn, labelConfig, "IOX");
                break;

            case "年月日8":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = GetDate(labelSn, labelConfig, "IOYZ");
                break;

            case "年周":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = GetDateFromWeek_YYWW(labelSn, labelConfig);
                break;

            case "年天":
                ret.Sn   = labelSn.Substring(labelConfig.SnStart, labelConfig.SnEnd - labelConfig.SnStart + 1);
                ret.Date = GetDateFromDay(labelSn, labelConfig);
                break;

            default:
                ret.Sn   = "";
                ret.Date = DateTime.Today.ToString("yyyyMMdd");
                break;
            }

            ret.Sn   = FillSn(ret, labelConfig);
            ret.Date = SubRight(ret.Date, 6);
            return(ret);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 根据标签配置,标签返回模板内容
 /// </summary>
 /// <param name="labelConfig">标签配置</param>
 /// <param name="labelSn">sn</param>
 /// <returns>二维数组</returns>
 public byte[,] GetRomMapArray(LabelConfig labelConfig, string labelSn)
 {
     return(CrossByte2Array(GetRomMapCross(labelConfig, labelSn)));
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 根据标签配置,标签返回模板内容
        /// </summary>
        /// <param name="labelConfig">标签配置</param>
        /// <param name="labelSn">标签sn</param>
        /// <returns>交错数组</returns>
        public byte[][] GetRomMapCross(LabelConfig labelConfig, string labelSn)
        {
            SnDate snDate = Label2SnDate(labelSn, labelConfig);

            return(FillBytes(labelConfig.TempeleteBytes, snDate.Sn, snDate.Date, labelConfig.DateCode8Value_0X30, labelConfig.Customer));
        }