Ejemplo n.º 1
0
        /// <summary>
        /// 取得會員序號
        /// </summary>
        /// <returns>string</returns>
        public async Task <string> GetMemberSerialNumber()
        {
            try
            {
                long count = await this.serialNumberDatas.CountDocumentsAsync(new BsonDocument());

                if (count == 0)
                {
                    await this.serialNumberDatas.InsertOneAsync(new SerialNumberData()
                    {
                        SequenceName = "MemberID", SequenceValue = 100001
                    });
                }

                var filter = Builders <SerialNumberData> .Filter.Eq("SequenceName", "MemberID");

                var update = Builders <SerialNumberData> .Update.Inc("SequenceValue", 1);

                SerialNumberData result = await this.serialNumberDatas.FindOneAndUpdateAsync(filter, update);

                return(result.SequenceValue.ToString());
            }
            catch (Exception ex)
            {
                this.logger.LogError($"Get Member Serial Number Error\n{ex}");
                return(string.Empty);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 建立會員資料
        /// </summary>
        /// <param name="memberData">memberData</param>
        /// <returns>bool</returns>
        public async Task <bool> CreateMemberData(MemberData memberData)
        {
            try
            {
                long count = await this.serialNumberDatas.CountDocumentsAsync(new BsonDocument());

                if (count == 0)
                {
                    await this.serialNumberDatas.InsertOneAsync(new SerialNumberData()
                    {
                        SequenceName = "MemberID", SequenceValue = 100001
                    });
                }

                FilterDefinition <SerialNumberData> filter = Builders <SerialNumberData> .Filter.Eq("SequenceName", "MemberID");

                UpdateDefinition <SerialNumberData> update = Builders <SerialNumberData> .Update.Inc("SequenceValue", 1);

                SerialNumberData result = await this.serialNumberDatas.FindOneAndUpdateAsync(filter, update);

                memberData.MemberID = result.SequenceValue.ToString();
                await this.memberDatas.InsertOneAsync(memberData);

                return(true);
            }
            catch (Exception ex)
            {
                this.logger.LogError($"Create Member Data Error >>> Data:{JsonConvert.SerializeObject(memberData)}\n{ex}");
                return(false);
            }
        }
        public int GetSerialNumberByref(string serialNumber)
        {
            SerialNumberData[] serialNumArray = new SerialNumberData[] { };
            int errorSubSN = imsapi.trGetSerialNumberBySerialNumberRef(sessionContext, init.configHandler.StationNumber, serialNumber, "-1", out serialNumArray);

            LogHelper.Info("trGetSerialNumberBySerialNumberRef(): SN:" + serialNumber + ",ResultCode :" + errorSubSN + "");
            return(errorSubSN);
        }
Ejemplo n.º 4
0
        public SerialNumberData[] GetPCBSNData(string serialNumber)
        {
            SerialNumberData[] serialNumberArray = new SerialNumberData[] { };
            int errorCode = imsapi.trGetSerialNumberBySerialNumberRef(sessionContext, init.configHandler.StationNumber, serialNumber, "-1", out serialNumberArray);

            LogHelper.Info("Api trGetSerialNumberBySerialNumberRef serial number =" + serialNumber + ", result code =" + errorCode);
            return(serialNumberArray);
        }
        public SerialNumberData[] GetSerialNumber(string Temp_PartNo, int numberRecords)
        {
            SerialNumberData[] serialNumberArray = new SerialNumberData[] { };
            int    error    = imsapi.trGetNextSerialNumber(sessionContext, init.configHandler.StationNumber, "-1", Temp_PartNo, numberRecords, out serialNumberArray);
            string errorMsg = UtilityFunction.GetZHSErrorString(error, init, sessionContext);

            LogHelper.Info("API trGetNextSerialNumber:partnumber" + Temp_PartNo + ",ERROR" + error);
            return(serialNumberArray);
        }
        public SerialNumberData[] GetSerialNumberBySNRef(string serialNumberRef)
        {
            int error = 0;

            SerialNumberData[] serialNumberArray = new SerialNumberData[] { };
            error = imsapi.trGetSerialNumberBySerialNumberRef(sessionContext, init.configHandler.StationNumber, serialNumberRef, "-1", out serialNumberArray);
            LogHelper.Info("api trGetSerialNumberBySerialNumberRef (serial number ref = " + serialNumberRef + ",result code = " + error);
            return(serialNumberArray);
        }
Ejemplo n.º 7
0
        public static bool GetBoxBarcode(out string PART_NUMBER, out string SERIAL_NUMBER, out string LEAR_INDEX, out string BOX_BARCODE)
        {
            Logger.Log.Info((object)"GetBoxBarcode(): method called.");
            string BOM_VERSION      = "";
            string PROCESS_LAYER    = "";
            string PROCESS_VERSION  = "";
            string WORKORDER_NUMBER = "";

            PART_NUMBER   = "";
            SERIAL_NUMBER = "";
            LEAR_INDEX    = "";
            BOX_BARCODE   = "";
            SerialNumberData[] serialNumberDataArray = new SerialNumberData[1];
            bool flag;

            try
            {
                Logger.Log.Info((object)"GetBoxBarcode(): Call GetStationSetting()");
                flag = ItacFunctions.GetStationSetting(out BOM_VERSION, out PART_NUMBER, out PROCESS_LAYER, out PROCESS_VERSION, out WORKORDER_NUMBER);
                if (flag)
                {
                    Logger.Log.Info((object)string.Format("Calling: _imsapi.trGetNextSerialNumber (\n _stationNumber: {0}, \n WORKORDER_NUMBER: {1}, \n PART_NUMBER: -1, \n 1. )", (object)ItacFunctions._stationNumber, (object)WORKORDER_NUMBER, (object)PART_NUMBER));
                    int nextSerialNumber = ItacFunctions._imsapi.trGetNextSerialNumber(ItacFunctions._sessionContext, ItacFunctions._stationNumber, WORKORDER_NUMBER, "-1", 1, out serialNumberDataArray);
                    if (nextSerialNumber != 0)
                    {
                        Logger.Log.Error((object)"GetSerialNumberInfo(): _imsapi.trGetNextSerialNumber failed");
                        ItacFunctions.printErrorText(nextSerialNumber);
                        flag = false;
                    }
                    else
                    {
                        SERIAL_NUMBER = (string)serialNumberDataArray[0].serialNumber;
                        Logger.Log.Info((object)string.Format("GetBoxBarcode(): serial number = {0} .", (object)SERIAL_NUMBER));
                    }
                }
                if (flag)
                {
                    Logger.Log.Info((object)"GetBoxBarcode(): Get Index from recipe. Calling GetRecipeData()");
                    flag = ItacFunctions.GetRecipeData("Index", PART_NUMBER, BOM_VERSION, PROCESS_VERSION, out LEAR_INDEX);
                }
                if (flag)
                {
                    BOX_BARCODE = PART_NUMBER + SERIAL_NUMBER + LEAR_INDEX;
                    Logger.Log.Info((object)string.Format("GetBoxBarcode(): PART_NUMBER: {0}, SERIAL_NUMBER: {1}, LEAR_INDEX: {2}, BOX_BARCODE: {3}.", (object)PART_NUMBER, (object)SERIAL_NUMBER, (object)LEAR_INDEX, (object)BOX_BARCODE));
                }
            }
            catch (Exception ex)
            {
                flag = false;
                string str = ex.Source + " " + ex.Message;
                Logger.Log.Fatal((object)str);
            }
            Logger.Log.Info((object)string.Format("GetBoxBarcode(): return with {0}", (object)flag));
            return(flag);
        }
Ejemplo n.º 8
0
        public SerialNumberData[] GetSerialNumber(string workOrderNumber, int numberRecords)
        {
            SerialNumberData[] serialNumberArray = new SerialNumberData[] { };
            int error = imsapi.trGetNextSerialNumber(sessionContext, init.configHandler.StationNumber, workOrderNumber, "-1", numberRecords, out serialNumberArray);

            if (error == 0)
            {
                view.errorHandler(0, init.lang.ERROR_API_CALL_ERROR + " trGetNextSerialNumber " + error, "");
            }
            else
            {
                view.errorHandler(2, init.lang.ERROR_API_CALL_ERROR + " trGetNextSerialNumber " + error, "");
            }
            return(serialNumberArray);
        }
        //----------------------------------------------------------------------------
        public override void Show(object arg = null)
        {
            base.Show(arg);
            serialNumberData = drawData.serialNumberData;

            if (arg != null)
            {
                initialFilterResults = arg as List <ResultData>;
            }

            if (bFirstShow)
            {
                bFirstShow = false;
                SetSumPanelView();
            }
        }
        public SerialNumberData[] GetSerialNumberBySNRef(string serialNumberRef)
        {
            int    error    = 0;
            string errorMsg = "";

            SerialNumberData[] serialNumberArray = new SerialNumberData[] { };
            error = imsapi.trGetSerialNumberBySerialNumberRef(sessionContext, init.configHandler.StationNumber, serialNumberRef, "-1", out serialNumberArray);
            //imsapi.imsapiGetErrorText(sessionContext, error, out errorMsg);
            errorMsg = UtilityFunction.GetZHSErrorString(error, init, sessionContext);
            LogHelper.Info("api trGetSerialNumberBySerialNumberRef (serial number ref = " + serialNumberRef + ",result code = " + error);
            if (error == 0)
            {
                view.errorHandler(0, init.lang.ERROR_API_CALL_ERROR + " trGetSerialNumberInfo " + error, "");
            }
            else
            {
                view.errorHandler(2, init.lang.ERROR_API_CALL_ERROR + " trGetSerialNumberInfo " + error + "," + errorMsg, "");
            }
            return(serialNumberArray);
        }
Ejemplo n.º 11
0
        public static bool AssignSerialNumberMergeAndUploadState(string PROCESS_LAYER, string SERIAL_NUMBER, string SERIAL_NUMBER_POS)
        {
            Logger.Log.Info((object)string.Format("AssignSerialNumberMergeAndUploadState(): PROCESS_LAYER: {0}, SERIAL_NUMBER: {1}, SERIAL_NUMBER_POS: {2}", (object)PROCESS_LAYER, (object)SERIAL_NUMBER, (object)SERIAL_NUMBER_POS));
            SerialNumberData serialNumberData = new SerialNumberData();

            serialNumberData.serialNumber    = SERIAL_NUMBER;
            serialNumberData.serialNumberPos = SERIAL_NUMBER_POS;
            serialNumberData.serialNumberOld = "0";
            bool flag;

            try
            {
                int num = int.Parse(PROCESS_LAYER);
                Logger.Log.Info((object)string.Format("Calling: _imsapi.trAssignSerialNumberMergeAndUploadState( \n _stationNumber: {0},\n processLayer: {1},\n serialNumber: {2},\n serialNumberRefPos: {3},\n KEY.serialNumber: {4},\n KEY.serialNumberPos: {5},\n KEY.serialNumberOld: {6},\n serialNumberSlave: {7},\n doUploadState: 0,\n serialNumberState; 0,\n multiPanel: 1 )", (object)ItacFunctions._stationNumber, (object)num, (object)SERIAL_NUMBER, (object)SERIAL_NUMBER_POS, (object)serialNumberData.serialNumber, (object)serialNumberData.serialNumberPos, (object)serialNumberData.serialNumberOld, (object)SERIAL_NUMBER));
                int resultValue = ItacFunctions._imsapi.trAssignSerialNumberMergeAndUploadState(ItacFunctions._sessionContext, ItacFunctions._stationNumber, num, SERIAL_NUMBER, SERIAL_NUMBER_POS, new SerialNumberData[1]
                {
                    serialNumberData
                }, SERIAL_NUMBER, 0, 0, 0);
                if (resultValue != 0)
                {
                    Logger.Log.Error((object)"AssignSerialNumberMergeAndUploadState(): _imsapi.trAssignSerialNumberMergeAndUploadState failed .");
                    ItacFunctions.printErrorText(resultValue);
                    flag = false;
                }
                else
                {
                    flag = true;
                }
            }
            catch (Exception ex)
            {
                flag = false;
                string str = ex.Source + " " + ex.Message;
                Logger.Log.Fatal((object)str);
            }
            Logger.Log.Info((object)string.Format("VerifyMergeProduct(): return with {0}", (object)flag));
            return(flag);
        }