Ejemplo n.º 1
0
        public ProcessMsg ExportTraySumPartCSV(List <string> trayIds, string filename, List <string> fieldNames)
        {
            ProcessMsg msg = new ProcessMsg()
            {
                result = false
            };

            try
            {
                List <TrayPackView> tpv = TrayPackViewHelper.GetTPVByTrayIdsGropSumPartNr(trayIds);
                // List<TrayPackView> ts = tpv.ToList();
                List <string> updateTrayIds = new List <string>();
                CSVDataSet    ds            = new CSVDataSet();
                foreach (TrayPackView v in tpv)
                {
                    CSVDataRecord r      = new CSVDataRecord();
                    List <string> values = ClassUtil.GetModelValues(fieldNames, v);
                    if (values != null)
                    {
                        foreach (string value in values)
                        {
                            r.Add(value);
                        }
                    }
                    //r.Add(v.partNr);
                    //r.Add(v.capa.ToString());
                    if (TrayPackStatusHelper.CanAddPrefix(v.tstatus))
                    {
                        r.Add(v.TsStatusCN);
                    }

                    ds.Add(r);
                    if (TrayPackStatusHelper.CanUpdateToExported(v.tstatus))
                    {
                        updateTrayIds.Add(v.trayId);
                    }
                }
                CSVUtil.GenCSVFile(ds, filename);
                if (updateTrayIds.Count > 0)
                {
                    TraysHelper.UpdateTraysStatus(updateTrayIds, TrayStatus.Exported);
                }
                msg.result = true;
                msg.AddMessage(ReturnCode.OK, "成功导出CSV文件");
            }
            catch (Exception e)
            {
                msg.AddMessage(ReturnCode.Error, e.Message);
            }
            return(msg);
        }
Ejemplo n.º 2
0
        public PrintDataMessage GenSingleTrayLabel(string trayId, string dateFormat, string[] keepers)
        {
            PrintDataMessage    pdm = new PrintDataMessage();
            ValidateMsg <Trays> msg = TraysHelper.TrayCanPrint(trayId);

            if (msg.Valid)
            {
                List <TrayPackView> tpv = TrayPackViewHelper.GetTPVByTrayIdsGropSumPartNr(new List <string>()
                {
                    trayId
                });
                string[]         dateFormats = dateFormat.Split(',');
                List <PrintTask> tasks       = new List <PrintTask>();
                foreach (string keeper in keepers)
                {
                    RecordSet rs   = new RecordSet();
                    PrintTask task = new PrintTask()
                    {
                        DataSet = rs
                    };
                    foreach (TrayPackView t in tpv)
                    {
                        RecordData label = new RecordData();
                        label.Add("TrayId", t.trayId);
                        label.Add("Warehouse", t.warehouse);
                        label.Add("Position", t.position);
                        label.Add("customerPNr", t.customerPartNr);
                        label.Add("PartNr", t.partNr);
                        label.Add("Capa", t.capa.ToString());
                        label.Add("Keeper", keeper);
                        label.Add("CreateTime", t.createTime.ToString(dateFormats[0]));
                        label.Add("StoreCreateTime", t.createTime.ToString(dateFormats[1]));
                        rs.Add(label);
                    }
                    tasks.Add(task);
                }
                pdm.PrintTask      = tasks;
                pdm.ReturnedResult = true;
            }
            else
            {
                pdm.ReturnedResult = false;
                pdm.ReturnedMessage.Add(msg.ToString());
            }
            return(pdm);
        }