public void EnterSN()
 {
     SN.SendKeys(ConfigurationManager.AppSettings["Surname"]);
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Inicializa Configuración Inicial
            MainSettings MS = new MainSettings();

            if (!MS.ok)
            {
                return;
            }

            GeneraLog = MS.GeneraLog;
            GeneraLog.EnvioSunat01("= = = = INICIO DE ENVÍO A SUNAT = = = =");

            // Verificamos si es que el nombre del documento está en args[]
            if (args.Length < 1)
            {
                //args = new string[2];
                GeneraLog.EnvioSunat01(": : MODO MANUAL");
                GeneraLog.EnvioSunat01("Ingrese el nombre del documento a procesar: ");
                args = Console.ReadLine().Split(' ');
                GeneraLog.EnvioSunat01("Nombre del documento ingresado manualmente: " + args[0]);
            }

            GeneraLog.EnvioSunat01("Nombre del Documento a envíar a SUNAT: " + args[0]);

            //DocumentName = "20544014189-RR-20171024-1";
            DocumentName = args[0];
            if (args.Length > 1)
            {
                if (args[1].ToUpper() == "Q")
                {
                    isQuery = true;
                }
            }

            if (!Fill())
            {
                return;
            }

            MS.DocumentName = DocumentName;
            MS.DocumentType = DocumentType;
            MS.RucNumber    = RucNumber;
            MS.getFileNames();

            if (MS.DocumentType.StartsWith("R"))
            {
                isSummary = true;
                if (MS.DocumentType == "RC")
                {
                    SummaryType = "B";
                }
                if (MS.DocumentType == "RA")
                {
                    SummaryType = "A";
                }
                if (MS.DocumentType == "RR")
                {
                    SummaryType = "A";
                }
            }

            string typedoc = string.Empty;

            if (MS.DocumentName.ToLower().Contains("r"))
            {
                if (MS.DocumentName.ToLower().Contains("rc-"))
                {
                    typedoc = "B";
                }
                if (MS.DocumentName.ToLower().Contains("ra-"))
                {
                    typedoc = "A";
                }
                if (MS.DocumentName.ToLower().Contains("rr-"))
                {
                    typedoc = "A";
                }
            }

            #region Validacion de RUC
            if (!MS.Load(RucNumber))
            {
                if (MS.Envi == "")
                {
                    GeneraLog.LecturaArchivo($"El Tipo de Documento {DocumentType} no está habilitado para el envío a Sunat");
                    GeneraLog.EnvioSunat01("= = = = FIN    DE ENVÍO A SUNAT = = = =");
                    return;
                }
                else
                {
                    GeneraLog.LecturaArchivo($"La empresa con el RUC:{RucNumber} no está habilitada");
                    GeneraLog.EnvioSunat01("= = = = FIN    DE ENVÍO A SUNAT = = = =");
                    return;
                }
            }
            #endregion

            DatabaseConnection DB = new DatabaseConnection(MS);

            // Verificamos en la Base de Datos el numero de Documento ingresado
            int a = DB.SP_ObtenerDocumentoXML(DocumentName);
            MS = DB.MS;


            #region Error de Consulta
            if (a == -1)
            {
                GeneraLog.EnvioSunat01("Error al momento de consultar el documento");
            }
            #endregion
            #region Documento no Existe
            else if (a == 0)
            {
                GeneraLog.EnvioSunat01($"El Documento {DocumentName} no existe en base de datos");
            }
            #endregion
            #region Documento ya ha sido enviado
            else if (a == 1)
            {
                GeneraLog.EnvioSunat01($"El Documento {DocumentName} ya ha sido enviado a SUNAT");
            }
            #endregion

            #region Documento puede ser enviado
            else if (a == 2)
            {
                GeneraLog.EnvioSunat01($"El Documento {DocumentName} está listo para ser enviado a SUNAT");
                if (zipFile(DB, MS))
                {
                    GeneraLog.EnvioSunat01($"Documento comprimido en {MS.ZIPEFileLocation}");
                    SunatConnection SN = null;
                    if ("20|40|RR".Contains(DocumentType))
                    {
                        SN = new SunatConnection("Retenciones", MS);
                    }
                    else if ("01|07|08|RC|RA".Contains(DocumentType) && !DocumentSerie.StartsWith("B"))
                    {
                        SN = new SunatConnection("Documentos", MS);
                    }
                    else if ("03|".Contains(DocumentType) || DocumentSerie.StartsWith("B"))
                    {
                        if (MS.Envi == "HML")
                        {
                            SN = new SunatConnection("Documentos", MS);
                        }
                    }
                    else
                    {
                        GeneraLog.EnvioSunat01($"Documento {DocumentType} no configurado en ambiente {MS.Envi}");
                    }
                    //Thread.Sleep(5000);
                    if (SN != null)
                    {
                        #region Consulta de Ticket
                        if (isQuery)
                        {
                            Tuple <string, bool> XQ = null;
                            XQ = SN.ObtenerEstadoUnit(MS.im);

                            if (XQ.Item2)
                            {
                                #region my change
                                if (XQ.Item1 != null && XQ.Item1.Length > 200)//valida que sea un xml
                                {
                                    //aqui descomprime el cdr
                                    if (UnZipCDR(MS, XQ.Item1))
                                    {
                                        //obtiene el codigo de respuesta en el cdr
                                        #region insert cdr and update document header
                                        var rs = ADE.Extras.Common.Method.Methods.Instance.GetActionCodeResponse_CDR(MS);
                                        switch (rs)
                                        {
                                        case "SOK":    //ok
                                        case "OBS":    //obsv
                                        {
                                            DB.SP_InsertaCDRResumen(CDR, MS.id, SummaryType);
                                            GeneraLog.EnvioSunat01("CDR guardado correctamente");
                                            GetNotes(DB, MS);

                                            GeneraLog.EnvioSunat01("Documento ha sido aceptado correctamente por SUNAT");
                                            //DB.addRSunatResponse(MS.id, "7", CDRmsg, MS.im, SummaryType);
                                            DB.addRSunatResponse(MS.id, "SOK", CDRmsg, MS.im, SummaryType);

                                            #region RA, RR NOTIFICACION
                                            string path    = Directory.GetCurrentDirectory();
                                            string pathlog = MS.LOGS + "7_NotificacionBaja.log";
                                            //if (typedoc.Contains("A"))
                                            //{
                                            var list = DB.Get_ListDocument_AN(MS.id);
                                            if (list.Count > 0)
                                            {
                                                foreach (var d in list)
                                                {
                                                    if (d.TO.Length > 5 && d.TypeRC == "ANS")
                                                    {
                                                        var res = ADE.Extras.Common.Method.Methods.Instance.SendNotify(path, d);
                                                        ADE.Extras.Common.Method.Methods.Instance.WriteLog(pathlog, "------------------------- INICIO -------------------------");
                                                        ADE.Extras.Common.Method.Methods.Instance.WriteLog(pathlog, "Enviando notificación de baja");
                                                        ADE.Extras.Common.Method.Methods.Instance.WriteLog(pathlog, "Documento    : " + d.Num_CE);
                                                        ADE.Extras.Common.Method.Methods.Instance.WriteLog(pathlog, "Email Destino: " + d.TO);
                                                        ADE.Extras.Common.Method.Methods.Instance.WriteLog(pathlog, "Resultado    : " + res);
                                                        ADE.Extras.Common.Method.Methods.Instance.WriteLog(pathlog, "-------------------------- FIN ---------------------------");

                                                        ADE.Extras.Common.Method.Methods.Instance.ConsoleLog("------------------------- INICIO -------------------------");
                                                        ADE.Extras.Common.Method.Methods.Instance.ConsoleLog("Enviando notificación de baja");
                                                        ADE.Extras.Common.Method.Methods.Instance.ConsoleLog("Documento    : " + d.Num_CE);
                                                        ADE.Extras.Common.Method.Methods.Instance.ConsoleLog("Email Destino: " + d.TO);
                                                        ADE.Extras.Common.Method.Methods.Instance.ConsoleLog("Resultado    : " + res);
                                                        ADE.Extras.Common.Method.Methods.Instance.ConsoleLog("-------------------------- FIN ---------------------------");
                                                    }
                                                }
                                            }
                                            //typedoc = string.Empty;
                                            //}
                                            #endregion

                                            break;
                                        }

                                        case "RCHZ":    //rechazado
                                        {
                                            string item1 = string.Empty;
                                            if (XQ.Item1 != null && XQ.Item1.Length > 200)
                                            {
                                                item1 = "CDR";
                                            }
                                            else
                                            {
                                                item1 = XQ.Item1;
                                            }

                                            DB.SP_InsertaCDRResumen(CDR, MS.id, SummaryType);
                                            GeneraLog.EnvioSunat01("CDR guardado correctamente");
                                            GetNotes(DB, MS);

                                            GeneraLog.EnvioSunat01("Documento fue enviado pero tiene errores: " + item1);
                                            //DB.addRSunatResponse(MS.id, "6", CDRmsg, MS.im, SummaryType);
                                            DB.addRSunatResponse(MS.id, "SRE", CDRmsg, MS.im, SummaryType);
                                            break;
                                        }

                                        case "EXC":    //exception
                                        {
                                            string item1 = string.Empty;
                                            if (XQ.Item1 != null && XQ.Item1.Length > 200)
                                            {
                                                item1 = "CDR";
                                            }
                                            else
                                            {
                                                item1 = XQ.Item1;
                                            }

                                            GeneraLog.EnvioSunat01("Se detectaron excepciones al enviar el archivo: " + item1);
                                            break;
                                        }

                                        case "":    //cuando no se obtuvo codigo del cdr
                                        {
                                            string item1 = string.Empty;
                                            if (XQ.Item1 != null && XQ.Item1.Length > 200)
                                            {
                                                item1 = "CDR";
                                            }
                                            else
                                            {
                                                item1 = XQ.Item1;
                                            }

                                            GeneraLog.EnvioSunat01("El procedimiento no devolvio un cdr: " + item1);
                                            break;
                                        }
                                        }
                                        #endregion
                                    }
                                    else
                                    {
                                        GeneraLog.EnvioSunat01("Error al descomprimir cdr");
                                    }
                                }
                                else
                                {
                                    GeneraLog.EnvioSunat01("El procedimiento no devolvio un cdr: " + XQ.Item1);
                                }
                                #endregion
                                //aqui va el unzip de consulta ticket
                                //aqui ternima el unzip de consulta ticket
                            }
                            else
                            {
                                #region code 99

                                if (XQ.Item1 != null && XQ.Item1.Length > 200)//valida que sea un xml
                                {
                                    if (UnZipCDR(MS, XQ.Item1))
                                    {
                                        DB.SP_InsertaCDRResumen(CDR, MS.id, SummaryType);
                                        GeneraLog.EnvioSunat01("CDR guardado correctamente");
                                        GetNotes(DB, MS);

                                        string item1 = string.Empty;
                                        if (XQ.Item1 != null && XQ.Item1.Length > 200)
                                        {
                                            item1 = "CDR";
                                        }
                                        else
                                        {
                                            item1 = XQ.Item1;
                                        }

                                        GeneraLog.EnvioSunat01("Documento fue enviado pero tiene errores: " + item1);
                                        //DB.addRSunatResponse(MS.id, "6", CDRmsg, MS.im, SummaryType);
                                        DB.addRSunatResponse(MS.id, "SRE", CDRmsg, MS.im, SummaryType);
                                    }
                                }
                                else
                                {
                                    string item1 = string.Empty;
                                    if (XQ.Item1 != null && XQ.Item1.Length > 200)
                                    {
                                        item1 = "CDR";
                                    }
                                    else
                                    {
                                        item1 = XQ.Item1;
                                    }

                                    GeneraLog.EnvioSunat01("El proceso devolvio: " + item1 + ", " + XQ.Item2);
                                }
                                #endregion
                                //GeneraLog.EnvioSunat01("El procedimiento no devolvio un cdr: " + XQ.Item1);
                                //GeneraLog.EnvioSunat01("Resumen ha sido rechazado");  //descomentar
                                //DB.addRSunatResponse(MS.id, "6", "", MS.im, SummaryType); //descomentar
                            }
                        }
                        #endregion

                        #region Envío a Sunat
                        else
                        {
                            Tuple <string, bool> XA = null;
                            if (isSummary)
                            {
                                XA = SN.EnviarResumen(ZIP, MS.ZIPEFileName);
                            }
                            else
                            {
                                XA = SN.EnviarDocumento(ZIP, MS.ZIPEFileName);
                            }

                            #region Envio Correcto
                            if (XA.Item2)
                            {
                                #region Resumenes-solo se enviara hasta el ticket,
                                if (isSummary)
                                {
                                    //aqui quite una parte
                                    DB.addRSunatResponse(MS.id, "ESX", "", XA.Item1, SummaryType);
                                    //aqui termina
                                }
                                #endregion

                                #region Documentos
                                else
                                {
                                    if (UnZipCDR(MS, XA.Item1))
                                    {
                                        DB.SP_InsertaCDR(CDR, DocumentName, "3");
                                        GeneraLog.EnvioSunat01("CDR guardado correctamente");
                                        GetNotes(DB, MS);

                                        int SNCode;
                                        if (int.TryParse(CDRcod, out SNCode))
                                        {
                                            if (SNCode == 0)
                                            {
                                                GeneraLog.EnvioSunat01("Documento ha sido aceptado correctamente por SUNAT");
                                                var res = DB.SP_ActualizaEstado(MS.id, "7", DocumentName);
                                                if (res < 0)
                                                {
                                                    DB.SP_ActualizaEstado(MS.id, "7", DocumentName);
                                                }
                                                GenerateMAILPDF(MS, DB, "7");
                                            }
                                            if (SNCode >= 2000 && SNCode <= 3999)
                                            {
                                                GeneraLog.EnvioSunat01("Documento ha sido rechazado por SUNAT");
                                                DB.SP_ActualizaEstado(MS.id, "6", DocumentName);
                                                GenerateMAILPDF(MS, DB, "6");
                                            }
                                            if (SNCode >= 4000 || CDRnotes.Count > 0)
                                            {
                                                GeneraLog.EnvioSunat01("Documento fue aceptado pero tiene observaciones");
                                                DB.SP_ActualizaEstado(MS.id, "5", DocumentName);
                                                GenerateMAILPDF(MS, DB, "5");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        GeneraLog.EnvioSunat01($"Se produjo un error en la descompresión del documento");
                                    }
                                }
                                #endregion
                            }
                            #endregion

                            #region Error/Excepcion de Envio
                            else
                            {
                                int    ErrCode;
                                string ErrSunat = (XA.Item1.Length > 3 ? XA.Item1.Substring(XA.Item1.Length - 4, 4) : XA.Item1);

                                #region Error Conocido
                                if (int.TryParse(ErrSunat, out ErrCode))
                                {
                                    if (isSummary)
                                    {
                                        if (ErrCode >= 2000 && ErrCode <= 3999)
                                        {
                                            MS.GeneraLog.EnvioSunat01($"El Documento ha sido rechazado por Sunat");
                                            //DB.addRSunatResponse(MS.id, "6", $"{ErrCode.ToString()} - El Documento ha sido rechazado por Sunat", "", SummaryType);
                                            DB.addRSunatResponse(MS.id, "SRE", $"{ErrCode.ToString()} - El Documento ha sido rechazado por Sunat", "", SummaryType);
                                        }
                                    }
                                    else
                                    {
                                        if ("20|40".Contains(DocumentType))
                                        {
                                            if (ErrCode == 2282)
                                            {
                                                MS.GeneraLog.EnvioSunat01($"El Documento ya ha sido enviado a Sunat anteriormente");
                                                MS.GeneraLog.EnvioSunat01($"Actualizando estado en Base de Datos");
                                                DB.SP_ActualizaEstado(MS.id, "7", DocumentName);
                                                DB.SP_InsertaMensajeRespuesta(MS.id, "0", $"El Comprobante  numero {DocumentSplit[2]}-{DocumentSplit[3]}, ha sido aceptado");
                                            }
                                            else
                                            {
                                                if (ErrCode >= 2000 && ErrCode <= 3999)
                                                {
                                                    MS.GeneraLog.EnvioSunat01($"El Documento ha sido rechazado por Sunat");
                                                    DB.SP_ActualizaEstado(MS.id, "6", DocumentName);

                                                    //Cambio del dia 10-05-2018
                                                    DB.SP_InsertaMensajeRespuesta_2(MS.id, XA.Item1);
                                                    GenerateMAILPDF(MS, DB, "6");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            DB.SP_ActualizaEstado(MS.id, "4", DocumentName);
                                        }
                                    }
                                }
                                #endregion

                                #region Error Desconocido
                                else
                                {
                                    if (isSummary)
                                    {
                                    }
                                    else
                                    {
                                        DB.SP_ActualizaEstado(MS.id, "4", DocumentName);
                                    }
                                }
                                #endregion
                            }
                            #endregion
                        }
                        #endregion
                    }
                }
                else
                {
                    GeneraLog.EnvioSunat01($"Se produjo un error en la compresión del documento");
                    GeneraLog.EnvioSunat01("= = = = FIN    DE ENVÍO A SUNAT = = = =");
                    return;
                }
            }
            #endregion

            GeneraLog.EnvioSunat01("= = = = FIN    DE ENVÍO A SUNAT = = = =");
            GeneraLog.RegistraLog(DocumentName + ".txt");
        }
Beispiel #3
0
        /// <summary>
        /// 獲取批次抽樣數量
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras">1個參數,SKU 保存的位置</param>
        public static void GetSampleQtyDataloader(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            Row_C_SKU_SAMPLE RLotSku;
            Row_C_AQLTYPE    RAqltype;
            T_C_AQLTYPE      QR = new T_C_AQLTYPE(Station.SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);
            T_C_SKU_SAMPLE   TR = new T_C_SKU_SAMPLE(Station.SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);

            if (Paras.Count != 10)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }
            MESStationSession SessionSN         = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);
            MESStationSession SessionSKU        = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);
            MESStationSession SessionAQLTYPE    = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);
            MESStationSession SessionLotQTY     = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);
            MESStationSession SessionSAMPLEQTY  = Station.StationSession.Find(t => t.MESDataType == Paras[4].SESSION_TYPE && t.SessionKey == Paras[4].SESSION_KEY);
            MESStationSession SessionREJECTQTY  = Station.StationSession.Find(t => t.MESDataType == Paras[5].SESSION_TYPE && t.SessionKey == Paras[5].SESSION_KEY);
            MESStationSession SessionPassQty    = Station.StationSession.Find(t => t.MESDataType == Paras[6].SESSION_TYPE && t.SessionKey == Paras[6].SESSION_KEY);
            MESStationSession SessionFailQty    = Station.StationSession.Find(t => t.MESDataType == Paras[7].SESSION_TYPE && t.SessionKey == Paras[7].SESSION_KEY);
            MESStationSession SessionLotNewFlag = Station.StationSession.Find(t => t.MESDataType == Paras[8].SESSION_TYPE && t.SessionKey == Paras[8].SESSION_KEY);
            MESStationSession SessionLotNo      = Station.StationSession.Find(t => t.MESDataType == Paras[9].SESSION_TYPE && t.SessionKey == Paras[9].SESSION_KEY);

            if (SessionSN == null)
            {
                //throw new Exception("请输入SN!");
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE }));
            }
            SN ObjSN = (SN)SessionSN.Value;

            //if (SessionSKU == null)
            //{
            //    SessionSKU = new MESStationSession() { MESDataType = Paras[1].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[1].SESSION_KEY, ResetInput = Input };
            //    Station.StationSession.Add(SessionSKU);
            //}

            if (SessionAQLTYPE == null)
            {
                SessionAQLTYPE = new MESStationSession()
                {
                    MESDataType = Paras[2].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[2].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SessionAQLTYPE);
            }

            if (SessionLotQTY == null)
            {
                SessionLotQTY = new MESStationSession()
                {
                    MESDataType = Paras[3].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[3].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SessionLotQTY);
            }

            if (SessionSAMPLEQTY == null)
            {
                SessionSAMPLEQTY = new MESStationSession()
                {
                    MESDataType = Paras[4].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[4].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SessionSAMPLEQTY);
            }

            if (SessionREJECTQTY == null)
            {
                SessionREJECTQTY = new MESStationSession()
                {
                    MESDataType = Paras[5].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[5].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SessionREJECTQTY);
            }

            if (SessionPassQty == null)
            {
                SessionPassQty = new MESStationSession()
                {
                    MESDataType = Paras[6].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[6].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SessionPassQty);
            }

            if (SessionFailQty == null)
            {
                SessionFailQty = new MESStationSession()
                {
                    MESDataType = Paras[7].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[7].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SessionFailQty);
            }

            if (SessionLotNewFlag == null)
            {
                SessionLotNewFlag = new MESStationSession()
                {
                    MESDataType = Paras[8].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[8].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SessionLotNewFlag);
            }

            if (SessionLotNo == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[9].SESSION_TYPE + Paras[9].SESSION_KEY }));
            }

            try
            {
                if ((string)SessionLotNewFlag.Value == "1")
                {
                    if (Paras[1].VALUE.ToString() == "ALL")
                    {
                        RLotSku              = TR.GetBySkuNo(Paras[1].VALUE.ToString(), ObjSN.NextStation, Station.SFCDB);
                        RAqltype             = QR.GetByAqltype(RLotSku.AQL_TYPE, Station.SFCDB);
                        SessionAQLTYPE.Value = RAqltype.AQL_TYPE;
                        //Marked by LLF
                        //SessionLotQTY.Value = RAqltype.LOT_QTY;
                        //SessionSAMPLEQTY.Value = RAqltype.SAMPLE_QTY;
                        //SessionREJECTQTY.Value = RAqltype.REJECT_QTY;
                    }
                    else
                    {
                        RLotSku              = TR.GetBySkuNo(ObjSN.SkuNo, ObjSN.NextStation, Station.SFCDB);
                        RAqltype             = QR.GetByAqltype(RLotSku.AQL_TYPE, Station.SFCDB);
                        SessionAQLTYPE.Value = RAqltype.AQL_TYPE;
                        //Marked by LLF
                        //SessionLotQTY.Value = RAqltype.LOT_QTY;
                        //SessionSAMPLEQTY.Value = RAqltype.SAMPLE_QTY;
                        //SessionREJECTQTY.Value = RAqltype.REJECT_QTY;
                    }
                    SessionPassQty.Value   = 0;
                    SessionFailQty.Value   = 0;
                    SessionLotQTY.Value    = 0;
                    SessionSAMPLEQTY.Value = 0;
                    SessionREJECTQTY.Value = 0;
                }
                else
                {
                    SessionAQLTYPE.Value   = ((LotNo)SessionLotNo.Value).AQL_TYPE;
                    SessionLotQTY.Value    = ((LotNo)SessionLotNo.Value).LOT_QTY;
                    SessionSAMPLEQTY.Value = ((LotNo)SessionLotNo.Value).SAMPLE_QTY;
                    SessionREJECTQTY.Value = ((LotNo)SessionLotNo.Value).REJECT_QTY;
                    SessionPassQty.Value   = ((LotNo)SessionLotNo.Value).PASS_QTY;
                    SessionFailQty.Value   = ((LotNo)SessionLotNo.Value).FAIL_QTY;
                }

                //Station.AddMessage("MES00000104", new string[] { "AQLTYPE", RAqltype.AQL_TYPE, "LotQTY", RAqltype.LOT_QTY.ToString(), "SAMPLEQTY", RAqltype.SAMPLE_QTY.ToString(), "REJECTQTY", RAqltype.REJECT_QTY.ToString() }, MESReturnView.Station.StationMessageState.Message);
                Station.AddMessage("MES00000104", new string[] { "AQLTYPE", SessionAQLTYPE.Value.ToString(), "LotQTY", SessionLotQTY.Value.ToString(), "SAMPLEQTY", SessionSAMPLEQTY.Value.ToString(), "REJECTQTY", SessionREJECTQTY.Value.ToString() }, MESReturnView.Station.StationMessageState.Message);
            }
            catch (Exception ex)
            {
                string msgCode = ex.Message;
                throw ex;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 從第一個輸入框加載PanelSN
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        /// Add by LLF 2018-02-01
        //public static void SNInputDataloader(MESStationBase Station, MESStationInput Input, List<R_Station_Action_Para> Paras)
        //{
        //    string StrSN = Input.Value.ToString();

        //    MESStationSession SNSession = new MESStationSession() { MESDataType = Paras[0].SESSION_TYPE, SessionKey = Paras[0].SESSION_KEY, ResetInput = Input };
        //    Station.StationSession.Add(SNSession);

        //    SNSession.InputValue = Input.Value.ToString();
        //    SNSession.Value = StrSN;
        //}

        public static void SNLinkKeypartDataloader(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            List <Dictionary <string, string> > KPList = new List <Dictionary <string, string> >();
            int SeqNo = 0;

            KPList = null;
            if (Paras.Count != 5)
            {
                string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000057");
                throw new MESReturnMessage(errMsg);
            }
            string            Sn        = Input.Value.ToString();
            MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SNSession == null)
            {
                SNSession = new MESStationSession()
                {
                    MESDataType = Paras[0].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[0].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SNSession);
            }
            MESStationSession WOSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (WOSession == null)
            {
                WOSession = new MESStationSession()
                {
                    MESDataType = Paras[1].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[1].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(WOSession);
            }
            MESStationSession SubKPSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (SubKPSession == null)
            {
                SubKPSession = new MESStationSession()
                {
                    MESDataType = Paras[2].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[2].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SubKPSession);
            }
            MESStationSession MainKPSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (MainKPSession == null)
            {
                MainKPSession = new MESStationSession()
                {
                    MESDataType = Paras[3].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[3].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(MainKPSession);
            }
            MESStationSession KPListSession = Station.StationSession.Find(t => t.MESDataType == Paras[4].SESSION_TYPE && t.SessionKey == Paras[4].SESSION_KEY);

            if (KPListSession == null)
            {
                KPListSession = new MESStationSession()
                {
                    MESDataType = Paras[4].SESSION_TYPE, SessionKey = Paras[4].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(KPListSession);
            }

            KPListSession.Value = KPList;
            //SN sn = null;
            //WorkOrder wo = null;
            SN        sn = new SN();
            WorkOrder wo = new WorkOrder();

            wo = (WorkOrder)WOSession.Value;
            T_C_KEYPART tck = new T_C_KEYPART(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            //sn.Load(Sn,Station.SFCDB,DB_TYPE_ENUM.Oracle);
            //wo.Init(sn.WorkorderNo,Station.SFCDB,DB_TYPE_ENUM.Oracle);
            List <C_KEYPART> keyparts = tck.GetKeypartListByWOAndStation(Station.SFCDB, wo.WorkorderNo, Station.StationName);

            if (keyparts.Count > 0)
            {
                SeqNo = (int)((C_KEYPART)keyparts[0]).SEQ_NO;
                SubKPSession.Value  = keyparts.Where(s => s.SEQ_NO == SeqNo).ToList();
                MainKPSession.Value = keyparts.Where(s => s.SEQ_NO > SeqNo).ToList();
            }
            else
            {
                string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000190");
                throw new MESReturnMessage(errMsg);
            }
        }
        private void SalvarAlterações_Click(object sender, RoutedEventArgs e)
        {
            //Criando objeto "cadastrarSpot" a partir do método Models-CadastrarEquipamento:
            AtualizarCadastroEquipamento atualizar = new AtualizarCadastroEquipamento();

            atualizar.Cliente     = Cliente.Text;
            atualizar.Contato     = Contato.Text;
            atualizar.Email       = Email.Text;
            atualizar.Senha       = Senha.Text;
            atualizar.Dongle      = Dongle.Text;
            atualizar.SN          = SN.Text;
            atualizar.Data        = Data.Text;
            atualizar.Tipo        = Tipo.Text;
            atualizar.Func        = Func.Text;
            atualizar.Obs         = Obs.Text;
            atualizar.Placa       = Placa.Text;
            atualizar.NomePc      = NomePc.Text;
            atualizar.Licença     = Licença.Text;
            atualizar.FlopSec     = FlopSec.Text;
            atualizar.Produto     = Produto.Text;
            atualizar.Mac         = MacAdd.Text;
            atualizar.DataLicença = DataLicença.Text;

            if (string.IsNullOrEmpty(Negócio))
            {
                atualizar.Negócio = "Nulo";
            }
            else
            {
                atualizar.Negócio = Negócio;
            }

            try
            {
                //Validando campos que não podem ficar em branco:
                if (string.IsNullOrWhiteSpace(Cliente.Text))
                {
                    throw new ApplicationException("Preencha o campo 'Cliente'");
                }
                if (string.IsNullOrWhiteSpace(Senha.Text))
                {
                    throw new ApplicationException("Preencha o campo 'Contra Senha'");
                }
                if (string.IsNullOrWhiteSpace(Dongle.Text))
                {
                    throw new ApplicationException("Preencha o campo 'Senha Dongle'");
                }
                if (string.IsNullOrWhiteSpace(SN.Text))
                {
                    throw new ApplicationException("Preencha o campo 'Numero de Série'");
                }
                if (string.IsNullOrWhiteSpace(Tipo.Text))
                {
                    throw new ApplicationException("Preencha o campo 'Tipo de Licença'");
                }
                if (string.IsNullOrWhiteSpace(Licença.Text))
                {
                    throw new ApplicationException("Preencha o campo 'Licença'");
                }

                //Chama o procedimento que executa o comando SQL para escrever na tabela.
                atualizar.AtualizarEquip();

                //Limpa todos os campos:
                Cliente.Clear();
                Contato.Clear();
                Senha.Clear();
                Email.Clear();
                Dongle.Clear();
                SN.Clear();
                Data.Clear();
                DataLicença.Clear();
                Tipo.Clear();
                Func.Clear();
                Obs.Clear();
                Placa.Clear();
                Licença.Clear();
                FlopSec.Clear();
                NomePc.Clear();
                MacAdd.Clear();
                Produto.Clear();
                Block_Garantia.Text    = " ";
                Block_Premium.Text     = " ";
                Block_Negócio.Text     = " ";
                RadVenda.IsChecked     = false;
                RadDemo.IsChecked      = false;
                RadAlguel.IsChecked    = false;
                RadFeira.IsChecked     = false;
                DataLicença.FontWeight = FontWeights.Regular;
                DataLicença.Foreground = Brushes.DimGray;
            }
            catch (Exception erro)
            {
                new CaixaDeMensagem(erro.Message);
            }
        }
Beispiel #6
0
        public static void RouteDatachecker(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            string       ErrMessage = "";
            List <R_MRB> GetMRBList = new List <R_MRB>();
            R_MRB        New_R_MRB  = new R_MRB();
            T_R_MRB      TR_MRB     = new T_R_MRB(Station.SFCDB, Station.DBType);

            if (Paras.Count != 3)
            {
                throw new Exception("參數數量不正確!");
            }
            MESStationSession SnSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SnSession == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }
            else if (SnSession.Value == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].VALUE + Paras[0].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }
            SN ObjSn = (SN)SnSession.Value;

            MESStationSession WoSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (WoSession == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }
            WorkOrder ObjWo = (WorkOrder)WoSession.Value;

            MESStationSession StationSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (StationSession == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }
            else if (StationSession.Value == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].VALUE + Paras[2].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }

            string NextStation = StationSession.Value.ToString();

            try
            {
                GetMRBList = TR_MRB.GetMrbInformationBySN(ObjSn.SerialNo, Station.SFCDB);

                if (GetMRBList == null || GetMRBList.Count == 0)
                {
                    ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "R_MRB:" + ObjSn.SerialNo });
                    throw new MESReturnMessage(ErrMessage);
                }
                //MESStationInput I = Station.Inputs.Find(t => t.DisplayName == "StationName");
                //List<object> snStationList = I.DataForUse;
                //snStationList.Clear();
                //snStationList.Add(""); ///BY SDL  加載頁面默認賦予空值,操作員必須點選其他有內容選項

                Route routeDetail = new Route(ObjWo.RouteID, GetRouteType.ROUTEID, Station.SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle);
                List <RouteDetail> routeDetailList = routeDetail.DETAIL;
                RouteDetail        h = routeDetailList.Find(t => t.STATION_NAME == GetMRBList[0].NEXT_STATION || t.STATION_TYPE == GetMRBList[0].NEXT_STATION);
                if (h == null)   //R_MRB next_station欄位的值
                {
                    ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000205", new string[] { ObjSn.SerialNo, ObjWo.WorkorderNo });
                    throw new MESReturnMessage(ErrMessage);
                }

                RouteDetail g = routeDetailList.Find(t => t.STATION_NAME == NextStation);
                if (g == null)  //REWORK選擇的要打回工站
                {
                    ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { NextStation });
                    throw new MESReturnMessage(ErrMessage);
                }

                if (g.SEQ_NO > h.SEQ_NO)
                {
                    ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000211", new string[] {  });
                    throw new MESReturnMessage(ErrMessage);
                }


                Station.AddMessage("MES00000026", new string[] {  }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #7
0
        public static void SNInputToLot(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            OleExec DB          = Station.SFCDB;
            string  strSql      = "";
            var     LOT_session = Station.StationSession.Find(t => t.MESDataType == "LOTNO" && t.SessionKey == "1");

            if (LOT_session == null)
            {
                LOT_session = new MESStationSession()
                {
                    MESDataType = "LOTNO", SessionKey = "1"
                };
                Station.StationSession.Add(LOT_session);
            }
            var LOT_COUNT_session = Station.StationSession.Find(t => t.MESDataType == "LOT_COUNT" && t.SessionKey == "1");

            if (LOT_COUNT_session == null)
            {
                LOT_COUNT_session = new MESStationSession()
                {
                    MESDataType = "LOT_COUNT", SessionKey = "1", Value = 0
                };
                Station.StationSession.Add(LOT_COUNT_session);
            }

            var SN_Session = Station.StationSession.Find(t => t.MESDataType == "SN" && t.SessionKey == "1");

            SN sn = (SN)SN_Session.Value;

            if (sn.CompletedFlag != "1")
            {
                throw new Exception($@"'{sn.SerialNo}'  is not  Completed");
            }
            string           lotno = "";//LOT_session.Value.ToString();
            T_R_LOT_STATUS   TRLS  = new T_R_LOT_STATUS(DB, DB_TYPE_ENUM.Oracle);
            Row_R_LOT_STATUS RRLS  = (Row_R_LOT_STATUS)TRLS.NewRow();

            if (LOT_session.Value == null)
            {
                RRLS.ID              = TRLS.GetNewID(Station.BU, DB);
                RRLS.SKUNO           = sn.SkuNo;
                RRLS.LOT_QTY         = 0;
                RRLS.LOT_STATUS_FLAG = "0";
                RRLS.SAMPLE_STATION  = Station.DisplayName;
                RRLS.CLOSED_FLAG     = "0";
                RRLS.LOT_NO          = SNMaker.SNmaker.GetNextSN("HWDLOT", DB);
                RRLS.EDIT_TIME       = DateTime.Now;
                RRLS.EDIT_EMP        = Station.LoginUser.EMP_NO;
                DB.ExecSQL(RRLS.GetInsertString(DB_TYPE_ENUM.Oracle));
                RRLS.AcceptChange();
                lotno = RRLS.LOT_NO;
            }
            else
            {
                lotno  = LOT_session.Value.ToString();
                strSql = $@"select * from R_LOT_STATUS where lot_no = '{lotno}'";
                var d = DB.RunSelect(strSql);
                RRLS.loadData(d.Tables[0].Rows[0]);
            }
            LOT_session.Value = lotno;
            if (RRLS.CLOSED_FLAG == "1")
            {
                throw new Exception($@"LotNo '{RRLS.LOT_NO}' is closed");
            }


            strSql = $@"select l.lot_no from r_lot_status l inner join r_lot_detail d on 
l.lot_no = d.lot_id  where sn = '{sn.SerialNo}' and l.lot_no like 'LOT-%' and d.status = '0'";

            var data = DB.RunSelect(strSql);

            if (data.Tables[0].Rows.Count > 0)
            {
                throw new Exception($@"'{sn.SerialNo}'  is in lot'{data.Tables[0].Rows[0]["lot_no"].ToString()}'");
            }
            if (sn.SkuNo != RRLS.SKUNO)
            {
                throw new Exception($@"'{sn.SerialNo}': '{sn.SkuNo}'  but lot is '{RRLS.SKUNO}'");
            }

            T_R_LOT_DETAIL TRLD = new T_R_LOT_DETAIL(DB, DB_TYPE_ENUM.Oracle);
            R_LOT_DETAIL   R    = new R_LOT_DETAIL();

            R.ID        = TRLD.GetNewID(Station.BU, DB);
            R.LOT_ID    = RRLS.LOT_NO;
            R.SN        = sn.SerialNo;
            R.STATUS    = "0";
            R.EDIT_EMP  = Station.LoginUser.EMP_NO;
            R.EDIT_TIME = DateTime.Now;
            DB.ORM.Insertable <R_LOT_DETAIL>(R).ExecuteCommand();

            T_R_SN TRS = new T_R_SN(DB, DB_TYPE_ENUM.Oracle);

            TRS.RecordPassStationDetail(sn.SerialNo, Station.Line, Station.StationName, Station.DisplayName, Station.BU, DB);

            int count = DB.ORM.Queryable <R_LOT_DETAIL>().Where(t => t.LOT_ID == R.LOT_ID).Count();

            RRLS.LOT_QTY   = count;
            RRLS.EDIT_TIME = DateTime.Now;
            RRLS.EDIT_EMP  = Station.LoginUser.EMP_NO;
            DB.ExecSQL(RRLS.GetUpdateString(DB_TYPE_ENUM.Oracle));
            RRLS.AcceptChange();
            LOT_COUNT_session.Value = count;
            Station.NextInput       = Station.Inputs[1];
        }
Beispiel #8
0
        public void startWO(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec Sfcdb  = this.DBPools["SFCDB"].Borrow();
            string  WO     = Data["WO"].ToString();
            T_R_SN  t_r_sn = new T_R_SN(Sfcdb, this.DBTYPE);
            string  id     = t_r_sn.findOneSNByWO(WO, Sfcdb);

            if (!string.IsNullOrEmpty(id))
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "工单已展开,不能重复展开";
                return;
            }
            T_R_WO_HEADER_TJ   t_R_WO_HEADER_TJ = new T_R_WO_HEADER_TJ(Sfcdb, this.DBTYPE);
            Row_R_WO_HEADER_TJ row_R_WO_HEADER  = t_R_WO_HEADER_TJ.GetWo(WO, Sfcdb);
            T_C_SKU            table_sku        = new T_C_SKU(Sfcdb, this.DBTYPE);
            string             user             = this.LoginUser.EMP_NO;

            MESDataObject.Module.SkuObject SkuObject = table_sku.GetSkuBySkuno(row_R_WO_HEADER.MATNR, Sfcdb);
            float qty = float.Parse(row_R_WO_HEADER.GAMNG);

            qty = 5;
            //获取路由id
            T_R_SKU_ROUTE t_R_SKU_ROUTE = new T_R_SKU_ROUTE(Sfcdb, this.DBTYPE);
            string        routeid       = t_R_SKU_ROUTE.getRouteIdBySkuName(row_R_WO_HEADER.MATNR, Sfcdb);
            //获取keypartlistid
            T_C_KP_LIST   t_C_KP_LIST    = new T_C_KP_LIST(Sfcdb, this.DBTYPE);
            List <string> keypartlistids = t_C_KP_LIST.GetListIDBySkuno(row_R_WO_HEADER.MATNR, Sfcdb);

            if (keypartlistids.Count == 0)
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "未配置keypartlistid";
                return;
            }
            //生成工单基础表
            T_R_WO_BASE t_R_WO_BASE = new T_R_WO_BASE(Sfcdb, this.DBTYPE);

            t_R_WO_BASE.deleteWOByWo(WO, Sfcdb);
            t_R_WO_BASE.addWOByWOHeader(BU, user, routeid, row_R_WO_HEADER, Sfcdb);

            WorkOrder objWorkorder = new WorkOrder();

            objWorkorder.Init(WO, Sfcdb);
            objWorkorder.WorkorderNo = WO;
            objWorkorder.KP_LIST_ID  = keypartlistids[0].ToString();
            objWorkorder.SkuNO       = row_R_WO_HEADER.MATNR;

            //生成SN
            for (int i = 0; i < qty; i++)
            {
                String nextSN = SNmaker.GetNextSN(SkuObject.SnRule, Sfcdb, WO);
                Console.Out.WriteLine(nextSN);
                t_r_sn.addStartSNRecords(BU, user, WO, routeid, row_R_WO_HEADER, nextSN, Sfcdb);
            }
            //生成keypartlistid

            List <R_SN> r_sns = t_r_sn.GETSN(WO, Sfcdb);

            for (int i = 0; i < r_sns.Count; i++)
            {
                T_C_KP_LIST c_kp_list = new T_C_KP_LIST(Sfcdb, this.DBTYPE);
                if (objWorkorder.KP_LIST_ID != "" && c_kp_list.KpIDIsExist(objWorkorder.KP_LIST_ID, Sfcdb))
                {
                    SN             snObject = new SN();
                    MESStationBase Station  = new MESStationBase();
                    Station.BU        = this.LoginUser.BU;
                    Station.LoginUser = this.LoginUser;
                    Station.SFCDB     = Sfcdb;
                    snObject.InsertR_SN_KP(objWorkorder, r_sns[i], Sfcdb, Station, this.DBTYPE);
                }
            }


            StationReturn.Data    = qty;
            StationReturn.Status  = StationReturnStatusValue.Pass;
            StationReturn.Message = MESReturnMessage.GetMESReturnMessage("MSGCODE20180801141046");
        }
Beispiel #9
0
        /// <summary>
        /// 處理SN狀態/記錄過站記錄/統計良率 for TCQS
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void TCQSPassStationAction(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            SN     SnObject = null;
            T_R_SN TRSN     = new T_R_SN(Station.SFCDB, Station.DBType);
            T_R_TCQS_YIELD_RATE_DETAIL TRTCQS = new T_R_TCQS_YIELD_RATE_DETAIL(Station.SFCDB, Station.DBType);
            R_TCQS_YIELD_RATE_DETAIL   RTCQS  = new R_TCQS_YIELD_RATE_DETAIL();
            string ErrMessage = string.Empty;
            string DeviceName = string.Empty;
            //獲取DB時間,所有數據更新使用同一時間
            DateTime DT = Station.GetDBDateTime();

            if (Paras.Count != 4)
            {
                //參數不正確:配置表中参数不够,应该为 {0} 个,实际只有 {1} 个!
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000051", new string[] { "3", Paras.Count.ToString() });
                throw new MESReturnMessage(ErrMessage);
            }

            //獲取到 SN 對象
            MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SNSession == null)
            {
                //无法获取到 {0} 的数据,请检查工站配置!
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }
            SnObject = (SN)SNSession.Value;

            //STATUS,方便過站處理/寫良率和UPH使用
            MESStationSession StatusSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (StatusSession == null)
            {
                //如果沒有,則創建一個該工站的StatusSession,且SN狀態默認為該Action中設定的狀態Value = Paras[1].VALUE
                StatusSession = new MESStationSession()
                {
                    MESDataType = Paras[1].SESSION_TYPE, InputValue = Input.Value.ToString(), Value = Paras[1].VALUE, SessionKey = Paras[1].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(StatusSession);
                //如果該工站沒有設定默認狀態,則默認為PASS
                if (StatusSession.Value == null ||
                    (StatusSession.Value != null && StatusSession.Value.ToString() == ""))
                {
                    StatusSession.Value = "PASS";
                }
            }

            //Device:站點名稱
            MESStationSession DeviceSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (DeviceSession != null)
            {
                DeviceName = DeviceSession.Value.ToString();
            }
            else //如果站點名稱不存在,則默認為工站名稱
            {
                DeviceName = Station.StationName;
            }

            //TCQSRecord:TCQS良率統計記錄
            MESStationSession TCQSSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (TCQSSession == null)
            {
                //无法获取到 {0} 的数据,请检查工站配置!
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }
            else
            {
                RTCQS = (R_TCQS_YIELD_RATE_DETAIL)TCQSSession.Value;
            }

            //如果過站,則按MES原邏輯處理
            if (RTCQS.TOTAL_FRESH_BUILD_QTY > 0 || RTCQS.TOTAL_REWORK_BUILD_QTY > 0)
            {
                TRSN.PassStation(SnObject.SerialNo, Station.Line, Station.StationName, DeviceName, Station.BU, StatusSession.Value.ToString(), Station.LoginUser.EMP_NO, Station.SFCDB);
            }
            //所有測試記錄,都要統計在TCQS的三個表中(TCQS_Yield/Tmp_ATEData/R_SN_Detail)
            ErrMessage = TRTCQS.RecordTCQSYieldRate(RTCQS, SnObject.SerialNo, Station.BU, Station.SFCDB);
            Station.AddMessage("MES00000150", new string[] { SnObject.SerialNo, "TCQS Yield Rate" }, StationMessageState.Pass);
        }
Beispiel #10
0
        public static void CartionAndPalletAction(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            OleExec SFCDB = Station.SFCDB;
            string  Run   = "";

            try
            {
                Run = (Station.StationSession.Find(T => T.MESDataType == Paras[0].SESSION_TYPE && T.SessionKey == Paras[0].SESSION_KEY).Value).ToString();
                if (Run.ToUpper() == "FALSE")
                {
                    return;
                }
            }
            catch
            {
            }
            MESStationSession sessionSN = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionSN == null)
            {
                throw new System.Exception("sessionSN miss ");
            }

            MESStationSession sessionCartion = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (sessionCartion == null)
            {
                throw new System.Exception("sessionCartion miss ");
            }

            MESStationSession sessionPallet = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (sessionPallet == null)
            {
                throw new System.Exception("sessionPallet miss ");
            }

            MESStationSession sessionPrintPL = Station.StationSession.Find(t => t.MESDataType == "ISPRINT_PL" && t.SessionKey == "1");

            if (sessionPrintPL == null)
            {
                sessionPrintPL = new MESStationSession()
                {
                    MESDataType = "ISPRINT_PL", SessionKey = "1", Value = "FALSE"
                };
                Station.StationSession.Add(sessionPrintPL);
            }
            sessionPrintPL.Value = "FALSE";
            MESStationSession sessionPrintCTN = Station.StationSession.Find(t => t.MESDataType == "ISPRINT_CTN" && t.SessionKey == "1");

            if (sessionPrintCTN == null)
            {
                sessionPrintCTN = new MESStationSession()
                {
                    MESDataType = "ISPRINT_CTN", SessionKey = "1", Value = "FALSE"
                };
                Station.StationSession.Add(sessionPrintCTN);
            }
            sessionPrintCTN.Value = "FALSE";

            SN SN = (SN)sessionSN.Value;

            if (SN.isPacked(Station.SFCDB))
            {
                throw new System.Exception($@"{SN.SerialNo} is packed!");
            }

            CartionBase cartion = (CartionBase)sessionCartion.Value;
            PalletBase  Pallet  = (PalletBase)sessionPallet.Value;



            cartion.Add(SN, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);

            if (cartion.DATA.MAX_QTY <= cartion.GetCount(Station.SFCDB))
            {
                sessionPrintCTN.Value = "TRUE";
                //設置打印變量
                MESStationSession CTNPrintSession = Station.StationSession.Find(T => T.MESDataType == "PRINT_CTN" && T.SessionKey == "1");
                if (CTNPrintSession == null)
                {
                    CTNPrintSession = new MESStationSession()
                    {
                        MESDataType = "PRINT_CTN", SessionKey = "1"
                    };
                    Station.StationSession.Add(CTNPrintSession);
                }
                CTNPrintSession.Value = cartion.DATA.PACK_NO;
                T_C_PACKING      TCP           = new T_C_PACKING(Station.SFCDB, DB_TYPE_ENUM.Oracle);
                List <C_PACKING> PackConfigs   = TCP.GetPackingBySku(SN.SkuNo, Station.SFCDB);
                C_PACKING        CartionConfig = PackConfigs.Find(T => T.PACK_TYPE == "CARTON");
                C_PACKING        PalletConfig  = PackConfigs.Find(T => T.PACK_TYPE == "PALLET");
                if (CartionConfig == null)
                {
                    throw new Exception("Can't find CartionConfig");
                }
                if (PalletConfig == null)
                {
                    throw new Exception("Can't find PalletConfig");
                }
                if (Pallet.DATA.MAX_QTY <= Pallet.GetCount(Station.SFCDB))
                {
                    sessionPrintPL.Value = "TRUE";
                    //設置打印變量
                    MESStationSession PlPrintSession = Station.StationSession.Find(T => T.MESDataType == "PRINT_PL" && T.SessionKey == "1");
                    if (PlPrintSession == null)
                    {
                        PlPrintSession = new MESStationSession()
                        {
                            MESDataType = "PRINT_PL", SessionKey = "1"
                        };
                        Station.StationSession.Add(PlPrintSession);
                    }
                    PlPrintSession.Value = Pallet.DATA.PACK_NO;

                    Pallet.DATA.CLOSED_FLAG = "1";
                    Pallet.DATA.EDIT_TIME   = DateTime.Now;
                    Pallet.DATA.EDIT_EMP    = Station.LoginUser.EMP_NO;
                    Station.SFCDB.ExecSQL(Pallet.DATA.GetUpdateString(DB_TYPE_ENUM.Oracle));

                    Pallet.DATA = PackingBase.GetNewPacking(PalletConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
                }
                cartion.DATA.CLOSED_FLAG = "1";
                cartion.DATA.EDIT_TIME   = DateTime.Now;
                cartion.DATA.EDIT_EMP    = Station.LoginUser.EMP_NO;
                Station.SFCDB.ExecSQL(cartion.DATA.GetUpdateString(DB_TYPE_ENUM.Oracle));
                cartion.DATA = PackingBase.GetNewPacking(CartionConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);

                Pallet.Add(cartion, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
            }
            sessionCartion.Value = cartion;
            sessionPallet.Value  = Pallet;

            cartion.DATA.AcceptChange();
            Pallet.DATA.AcceptChange();
        }
Beispiel #11
0
 public void SecondN(string SurName)
 {
     SN.SendKeys(SurName);
 }
        /// <summary>
        /// 維修輸入SN Fail狀態檢查
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void SNRepairFailChecker(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            OleExec sfcdb = Station.SFCDB;
            //input test

            /*string inputValue = Input.Value.ToString();
             * if (string.IsNullOrEmpty(inputValue))
             * {
             *  throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000006", new string[] { "SN輸入值" }));
             * }
             * SN sn = new SN(inputValue, sfcdb, DB_TYPE_ENUM.Oracle);*/

            MESStationSession SN_Session = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE &&
                                                                       t.SessionKey == Paras[0].SESSION_KEY);

            if (SN_Session == null)
            {
                foreach (R_Station_Output output in Station.StationOutputs)
                {
                    Station.StationSession.Find(s => s.MESDataType == output.SESSION_TYPE && s.SessionKey == output.SESSION_KEY).Value = "";
                }
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SN" }));
            }
            SN sn = (SN)SN_Session.Value;

            if (sn.RepairFailedFlag == "0")
            {
                foreach (R_Station_Output output in Station.StationOutputs)
                {
                    Station.StationSession.Find(s => s.MESDataType == output.SESSION_TYPE && s.SessionKey == output.SESSION_KEY).Value = "";
                }
                //正常品
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000078", new string[] { sn.SerialNo }));
            }
            List <R_REPAIR_MAIN> repairMains = new T_R_REPAIR_MAIN(sfcdb, DB_TYPE_ENUM.Oracle).GetRepairMainBySN(sfcdb, sn.SerialNo);

            if (repairMains == null || repairMains.Count == 0)
            {
                foreach (R_Station_Output output in Station.StationOutputs)
                {
                    Station.StationSession.Find(s => s.MESDataType == output.SESSION_TYPE && s.SessionKey == output.SESSION_KEY).Value = "";
                }
                //無維修主檔信息
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000079", new string[] { "SN", sn.SerialNo }));
            }
            R_REPAIR_MAIN rm = repairMains.Find(r => r.CLOSED_FLAG == "0");

            if (rm == null)
            {
                foreach (R_Station_Output output in Station.StationOutputs)
                {
                    Station.StationSession.Find(s => s.MESDataType == output.SESSION_TYPE && s.SessionKey == output.SESSION_KEY).Value = "";
                }
                //無維修主檔信息
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000079", new string[] { "SN", sn.SerialNo }));
            }
            //foreach (R_REPAIR_MAIN rm in repairMains)
            //{
            //    //存在closed_flag=0
            //    if (rm.CLOSED_FLAG != "0")
            //    {
            //        foreach (R_Station_Output output in Station.StationOutputs)
            //        {
            //            Station.StationSession.Find(s => s.MESDataType == output.SESSION_TYPE && s.SessionKey == output.SESSION_KEY).Value = "";
            //        }
            //        throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000097", new string[] {"SN", rm.SN }));
            //    }
            //}
            Station.AddMessage("MES00000046", new string[] { "OK" }, StationMessageState.Pass);
        }
Beispiel #13
0
        public static void SNLinkPassAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            string                SubSn                = "";
            SN                    SubSNObj             = new SN();
            SN                    SnObj                = new SN();
            WorkOrder             WO                   = new WorkOrder();
            T_R_SN                Table_R_SN           = new T_R_SN(Station.SFCDB, Station.DBType);
            T_R_SN_STATION_DETAIL Table_SnDetail       = new T_R_SN_STATION_DETAIL(Station.SFCDB, Station.DBType);
            T_R_SN_KEYPART_DETAIL Table_R_Keypart      = new T_R_SN_KEYPART_DETAIL(Station.SFCDB, Station.DBType);
            string                ErrMessage           = string.Empty;
            List <C_KEYPART>      SubKPList            = new List <C_KEYPART>();
            List <C_KEYPART>      MainKPList           = new List <C_KEYPART>();
            string                StrNextStation       = "";
            string                Status               = "";
            R_SN                  R_Sn                 = null;
            T_R_WO_BASE           WoTable              = null; //add by LLF
            List <Dictionary <string, string> > KPList = new List <Dictionary <string, string> >();

            if (Paras.Count == 0)
            {
                throw new Exception("參數數量不正確!");
            }

            MESStationSession SubSNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SubSNSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }

            MESStationSession SubKPSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (SubKPSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            }

            MESStationSession MainKPSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (MainKPSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY }));
            }

            MESStationSession KPListSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (KPListSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY }));
            }

            MESStationSession WOSession = Station.StationSession.Find(t => t.MESDataType == Paras[4].SESSION_TYPE && t.SessionKey == Paras[4].SESSION_KEY);

            if (WOSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[4].SESSION_TYPE + Paras[4].SESSION_KEY }));
            }

            MESStationSession NextStationSession = Station.StationSession.Find(t => t.MESDataType == Paras[5].SESSION_TYPE && t.SessionKey == Paras[5].SESSION_KEY);

            if (NextStationSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[5].SESSION_TYPE + Paras[5].SESSION_KEY }));
            }

            MESStationSession StatusSession = Station.StationSession.Find(t => t.MESDataType == Paras[6].SESSION_TYPE && t.SessionKey == Paras[6].SESSION_KEY);

            if (StatusSession == null)
            {
                StatusSession = new MESStationSession()
                {
                    MESDataType = Paras[6].SESSION_TYPE, SessionKey = Paras[6].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(StatusSession);
                if (string.IsNullOrEmpty(Paras[0].VALUE))
                {
                    StatusSession.Value = "PASS";
                }
            }
            Status = StatusSession.Value.ToString();

            MESStationSession ClearFlagGSession = Station.StationSession.Find(t => t.MESDataType == Paras[7].SESSION_TYPE && t.SessionKey == Paras[7].SESSION_KEY);

            if (ClearFlagGSession == null)
            {
                ClearFlagGSession = new MESStationSession()
                {
                    MESDataType = Paras[7].SESSION_TYPE, SessionKey = Paras[7].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(ClearFlagGSession);
            }
            ClearFlagGSession.Value = "false";

            StrNextStation = SnObj.StringListToString((List <string>)NextStationSession.Value);
            //StrNextStation = NextStationSession.Value.ToString();
            SubKPList  = (List <C_KEYPART>)SubKPSession.Value;
            MainKPList = (List <C_KEYPART>)MainKPSession.Value;
            KPList     = (List <Dictionary <string, string> >)KPListSession.Value;
            SubSNObj   = (SN)SubSNSession.Value;
            WO         = (WorkOrder)WOSession.Value;
            SubSn      = SubSNObj.SerialNo;
            R_Sn       = Table_R_SN.GetById(SubSNObj.ID, Station.SFCDB);
            if (SubKPList.Count + MainKPList.Count == KPList.Count)
            {
                Table_R_SN.UpdateSNKeyparStatus(SubSNObj.ID, Station.LoginUser.EMP_NO, "0", Station.SFCDB);
                Table_R_SN.InsertLinkSN(SubSn, WO.WorkorderNo, WO.SkuNO, WO.RouteID, WO.KP_LIST_ID, Station.StationName, StrNextStation, Station.LoginUser.EMP_NO, Station.BU, Station.SFCDB, SubSNObj.Plant);
                //更新Main KP SN
                foreach (Dictionary <string, string> DicMainKP in KPList)
                {
                    int SeqNo = Convert.ToInt16(DicMainKP["SEQ_NO"]);
                    if (DicMainKP["KP_TYPE"] == "MAIN_SN")
                    {
                        Table_R_SN.UpdateSNKeyparStatus(DicMainKP["KP_SN_ID"], Station.LoginUser.EMP_NO, "1", Station.SFCDB);
                    }
                    //写KP
                    Table_R_Keypart.INSN_KEYPART_DETAIL(Station.SFCDB, Station.BU, SubSNObj.ID, DicMainKP["SN"], DicMainKP["KEYPART_SN"], Station.StationName, DicMainKP["PART_NO"], SeqNo, DicMainKP["CATEGORY_NAME"], DicMainKP["CATEGORY"], Station.LoginUser.EMP_NO);
                }

                //寫過站記錄
                Table_R_SN.LinkPassStationDetail(R_Sn, WO.WorkorderNo, WO.SkuNO, WO.RouteID, Station.Line, Station.StationName, Station.StationName, Station.LoginUser.EMP_NO, Station.BU, Station.SFCDB);

                //add by LLF
                WoTable = new T_R_WO_BASE(Station.SFCDB, Station.DBType);
                WoTable.AddCountToWo(WO.WorkorderNo, 1, Station.SFCDB); // 更新 R_WO_BASE 中的數據

                //寫良率,UPH
                Table_R_SN.RecordUPH(WO.WorkorderNo, 1, SubSn, Status, Station.Line, Station.StationName, Station.LoginUser.EMP_NO, Station.BU, Station.SFCDB);
                Table_R_SN.RecordYieldRate(WO.WorkorderNo, 1, SubSn, Status, Station.Line, Station.StationName, Station.LoginUser.EMP_NO, Station.BU, Station.SFCDB);

                KPListSession.Value     = null;
                ClearFlagGSession.Value = "true";
                Station.AddMessage("MES00000195", new string[] { SubSn, StrNextStation }, MESReturnView.Station.StationMessageState.Pass);
            }
        }
Beispiel #14
0
        public static void SNLinkMainSNKPAction(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            List <Dictionary <string, string> > KPList      = new List <Dictionary <string, string> >();
            List <Dictionary <string, string> > KPList_Temp = new List <Dictionary <string, string> >();
            Dictionary <string, string>         DicKP       = new Dictionary <string, string>();
            List <C_KEYPART> MainKP      = null;
            C_KEYPART        MainKP_Temp = null;

            WorkOrder WO         = null;
            SN        MainSnObj  = null;
            SN        SubSnObj   = null;
            string    SubSn      = "";
            string    ErrMessage = string.Empty;

            if (Paras.Count == 0)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }

            MESStationSession SubSNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SubSNSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }

            MESStationSession MainSNSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (MainSNSession == null)
            {
                MainSNSession = new MESStationSession()
                {
                    MESDataType = Paras[1].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[1].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(MainSNSession);
            }

            MESStationSession MainKPSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (MainKPSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY }));
            }

            MESStationSession KPListSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (KPListSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY }));
            }

            MainSnObj   = (SN)MainSNSession.Value;
            SubSnObj    = (SN)SubSNSession.Value;
            MainKP      = (List <C_KEYPART>)MainKPSession.Value;
            MainKP_Temp = MainKP.Find(c => c.PART_NO == MainSnObj.SkuNo);

            if (MainKP_Temp == null)
            {
                throw new Exception("MainSN 料號與配置的料號不一致!");
            }

            KPList = (List <Dictionary <string, string> >)KPListSession.Value;
            //SubSn = KPList.Find(kp => kp["KP_TYPE"].ToString() == "SUB_SN")["SUB_SN"].ToString();
            DicKP["SN"]            = SubSnObj.SerialNo;
            DicKP["SN_ID"]         = SubSnObj.ID;
            DicKP["KEYPART_SN"]    = MainSnObj.SerialNo;
            DicKP["KP_SN_ID"]      = MainSnObj.ID;
            DicKP["PART_NO"]       = MainSnObj.SkuNo;
            DicKP["SEQ_NO"]        = MainKP_Temp.SEQ_NO.ToString();
            DicKP["CATEGORY_NAME"] = MainKP_Temp.CATEGORY_NAME;
            DicKP["CATEGORY"]      = MainKP_Temp.CATEGORY;
            DicKP["KP_TYPE"]       = "MAIN_SN";

            KPList.Add(DicKP);
            KPListSession.Value = KPList;
        }
Beispiel #15
0
        public static void SNLinkSubSNKPAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            List <Dictionary <string, string> > KPList      = new List <Dictionary <string, string> >();
            List <Dictionary <string, string> > KPList_Temp = new List <Dictionary <string, string> >();
            Dictionary <string, string>         DicKP       = new Dictionary <string, string>();
            List <C_KEYPART> SubKP = new List <C_KEYPART>();

            WorkOrder WO         = null;
            SN        Sn         = null;
            string    ErrMessage = string.Empty;

            if (Paras.Count == 0)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }

            MESStationSession SubSNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SubSNSession == null)
            {
                SubSNSession = new MESStationSession()
                {
                    MESDataType = Paras[0].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[0].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(SubSNSession);
            }

            MESStationSession SubKPSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (SubKPSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            }

            MESStationSession KPListSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (KPListSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY }));
            }

            Sn    = (SN)SubSNSession.Value;
            SubKP = (List <C_KEYPART>)SubKPSession.Value;

            DicKP["SN"]            = Sn.SerialNo;
            DicKP["SN_ID"]         = Sn.ID;
            DicKP["KEYPART_SN"]    = Sn.SerialNo;
            DicKP["KP_SN_ID"]      = Sn.ID;
            DicKP["PART_NO"]       = Sn.SkuNo;
            DicKP["SEQ_NO"]        = SubKP[0].SEQ_NO.ToString();
            DicKP["CATEGORY_NAME"] = SubKP[0].CATEGORY_NAME;
            DicKP["CATEGORY"]      = SubKP[0].CATEGORY;
            DicKP["KP_TYPE"]       = "SUB_SN";

            KPList.Add(DicKP);
            KPListSession.Value = KPList;
            //MESStationSession WOSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);
            //if (SubSNSession == null)
            //{
            //    SubSNSession = new MESStationSession() { MESDataType = Paras[3].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[3].SESSION_KEY, ResetInput = Input };
            //    Station.StationSession.Add(SubSNSession);
            //}

            //wO = (WorkOrder)WOLoadPoint.Value;
            //snob.Load(sn,Station.SFCDB,DB_TYPE_ENUM.Oracle);
            //SN snob = new SN(sn, Station.SFCDB, DB_TYPE_ENUM.Oracle);
            //if (snob == null)
            //{
            //    throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SN Point" }));
            //}
            //T_C_KEYPART tck = new T_C_KEYPART(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            //T_R_SN_KEYPART_DETAIL T_kd = new T_R_SN_KEYPART_DETAIL(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            //List<C_KEYPART> KEYPARTS = tck.GetKeypartListByWOAndStation(Station.SFCDB, wO.WorkorderNo, Station.StationName);
            //if (KEYPARTS.Count > 0)
            //{
            //    T_kd.INSN_KEYPART_DETAIL(Station.SFCDB, Station.BU, snob.ID, snob.SerialNo, sn, Station.StationName, KEYPARTS[0].PART_NO, KEYPARTS[0].SEQ_NO, KEYPARTS[0].CATEGORY_NAME, Station.LoginUser.EMP_NO);
            //    Station.AddMessage("MES00000180", new string[] { "SUB_SN", sn }, StationMessageState.Pass);
            //}
            //else
            //{
            //    ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { sn });
            //    throw new MESReturnMessage(ErrMessage);
            //}
        }