Пример #1
0
        public List<NotifyStdWeightResponse> NotifyStdWeight(NotifyStdWeight[] StdWeightItems)
        {
            string connectionDB = "SD_DBServer";
            string connectionDB_EDI = "SD_DBServer_EDI";
            string methodName = MethodBase.GetCurrentMethod().Name;
            BaseLog.LoggingBegin(logger, methodName);

            try
            {            
                //1.檢查必要的input parameter
                Execute.ValidateParameter(connectionDB, StdWeightItems);

                //3.執行DB insert
                Execute.Process(connectionDB, connectionDB_EDI, StdWeightItems);

                //4.Build Response Message
                List<NotifyStdWeightResponse> pgiresponse = Execute.BuildResponseMsg(connectionDB, StdWeightItems);

                return pgiresponse;
            }
            catch (Exception e)
            {
                logger.Error(MethodBase.GetCurrentMethod(), e);
                //  UTL.SendMail("test", e.Message);
                //4.Build Response Error Message
                List<NotifyStdWeightResponse> ResponseList = new List<NotifyStdWeightResponse>();
                foreach (NotifyStdWeight item in StdWeightItems)
                {
                    NotifyStdWeightResponse response = new NotifyStdWeightResponse();
                    string SerialNumber = "";
                    string State = "F";
                    response.SerialNumber = SerialNumber;
                    response.Plant = item.Plant;
                    response.Model = item.Model;
                    response.Result = State;
                    ResponseList.Add(response);
                }
                return ResponseList;
            }
            finally
            {
                BaseLog.LoggingEnd(logger, methodName);
            }
        
        }
Пример #2
0
        //4.Build Response message structure
        public static List<NotifyStdWeightResponse> BuildResponseMsg(string connectionDB, NotifyStdWeight[] results)
        {
            int dbIndex = 0;
            string methodName = MethodBase.GetCurrentMethod().Name;
            BaseLog.LoggingBegin(logger, methodName);
            List<NotifyStdWeightResponse> ResponseList = new List<NotifyStdWeightResponse>();
            try
            {
                foreach (NotifyStdWeight item in results)
                {
                    BaseLog.LoggingInfo(logger, "SerialNumber: \r\n{0}", ObjectTool.ObjectTostring(item.SerialNumber));

                    NotifyStdWeightResponse response = new NotifyStdWeightResponse();
                    string SerialNumber = item.SerialNumber;
                    string State = SQL.GetStdWeightState(connectionDB, dbIndex, SerialNumber);
                    if (State == "N") State = "F";
                    response.SerialNumber = item.SerialNumber;
                    response.Plant = item.Plant;
                    response.Model = item.Model; 
                    response.Result = State;
                    ResponseList.Add(response);
                }

                return ResponseList;
            }
            catch (Exception e)
            {
                BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e);
                throw e;
            }
            finally
            {
                BaseLog.LoggingEnd(logger, methodName);
            }                 

        }