Exemplo n.º 1
0
        public Messages Execute(ActionEventArgs actionEventArgs)
        {
            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);
            try
            {
                ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
                //填写SIMULATION 检查工单、ID、途程、操作
                // 联美兰达的下料不检查途程
                //messages.AddMessages( dataCollect.CheckID(actionEventArgs));
                if (messages.IsSuccess())
                {
                    // 联美兰达下料不更新Simulation
                    //messages.AddMessages( dataCollect.Execute(actionEventArgs));
                    if (messages.IsSuccess())
                    {
                        /*	由于界面上会自动调用GOOD采集,因此不用写报表
                         * //填写测试报表
                         * ReportHelper reportCollect= new ReportHelper(this.DataProvider);
                         * messages.AddMessages(reportCollect.ReportLineQuanMaster(this.DataProvider,actionEventArgs.ActionType,actionEventArgs.ProductInfo));
                         * messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider,actionEventArgs.ActionType,actionEventArgs.ProductInfo));
                         */

                        //Laws Lu,2005/10/20,新增	使用配置文件来控制物料模块是否使用
                        if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
                        {
                            BenQGuru.eMES.Material.CastDownHelper castHelper = new BenQGuru.eMES.Material.CastDownHelper(DataProvider);
                            ArrayList arRcard = new ArrayList();


                            castHelper.GetAllRCardByMo(ref arRcard, actionEventArgs.ProductInfo.NowSimulation.RunningCard, actionEventArgs.ProductInfo.NowSimulation.MOCode);
                            if (arRcard.Count == 0)
                            {
                                arRcard.Add(actionEventArgs.RunningCard);
                            }
                            string runningCards = "('" + String.Join("','", (string[])arRcard.ToArray(typeof(string))) + "')";

                            object[] objs = (actionEventArgs as DropMaterialEventArgs).OnwipItems;
                            //下料并归还库房
                            BenQGuru.eMES.Material.WarehouseFacade wfacade = new BenQGuru.eMES.Material.WarehouseFacade(this.DataProvider);
                            wfacade.RemoveWarehouse(
                                objs
                                , runningCards
                                , actionEventArgs.ProductInfo.NowSimulation.MOCode
                                , actionEventArgs.UserCode
                                , actionEventArgs.ProductInfo.NowSimulationReport.StepSequenceCode
                                , actionEventArgs.ProductInfo.NowSimulation.OPCode);
                        }
                        else    // Added by Icyer 2006/11/16
                        {
                            DropMaterialEventArgs arg = (DropMaterialEventArgs)actionEventArgs;
                            if (arg.OnwipItems != null)
                            {
                                // 查询需要管控的KeyPart
                                ArrayList listKeyPart    = new ArrayList();
                                ArrayList listAllKeyPart = new ArrayList();

                                //ArrayList partsToUnload = new ArrayList();
                                //ArrayList partsToReplace = new ArrayList();

                                //for (int i = 0; i < arg.OnwipItems.Length; i++)
                                //{
                                //    BenQGuru.eMES.Material.InnoObject io = (BenQGuru.eMES.Material.InnoObject)arg.OnwipItems[i];

                                //    if (io.NewBarcode.Trim().Length > 0)
                                //        partsToReplace.Add(io);
                                //    else
                                //        partsToUnload.Add(io);
                                //}

                                string            sql               = string.Empty;
                                CastDownHelper    castDownHelper    = new CastDownHelper(DataProvider);
                                BaseModelFacade   baseModelFacade   = new BaseModelFacade(this.DataProvider);
                                DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
                                ShiftModelFacade  shiftModelFacade  = new ShiftModelFacade(this.DataProvider);

                                DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                                foreach (InnoObject io in arg.OnwipItems)
                                {
                                    //获取arRcard
                                    ArrayList arRcard = new ArrayList();
                                    castDownHelper.GetAllRCard(ref arRcard, actionEventArgs.ProductInfo.NowSimulation.RunningCard);
                                    if (arRcard.Count == 0)
                                    {
                                        arRcard.Add(actionEventArgs.RunningCard);
                                    }

                                    //获取dropop
                                    Operation2Resource objOP  = baseModelFacade.GetOperationByResource(arg.ResourceCode);
                                    string             dropop = string.Empty;
                                    if (objOP != null)
                                    {
                                        dropop = objOP.OPCode;
                                    }

                                    #region 针对旧料所作的动作

                                    string runningCards = "('" + String.Join("','", (string[])arRcard.ToArray(typeof(string))) + "')";
                                    sql = string.Format("update TBLONWIPITEM set TRANSSTATUS='{0}',ActionType=" + (int)MaterialType.DropMaterial +
                                                        ",DropOP = '" + dropop + "'" +
                                                        ",DropUser='******'" +
                                                        ",DropDate=" + dbDateTime.DBDate +
                                                        ",DropTime=" + dbDateTime.DBTime +
                                                        " where RCARD in {1} and ActionType='{2}'" +
                                                        " and MCARD in ('" + io.MCard.Trim().ToUpper() + "')"
                                                        , TransactionStatus.TransactionStatus_YES
                                                        , runningCards
                                                        , (int)Web.Helper.MaterialType.CollectMaterial);
                                    this.DataProvider.CustomExecute(new SQLCondition(sql));

                                    if (io.MCardType == MCardType.MCardType_Keyparts)
                                    {
                                        sql = "update TBLSIMULATIONREPORT set IsLoadedPart='0',LoadedRCard='' " +
                                              " where RCARD in ('" + io.MCard.Trim().ToUpper() + "')";
                                        this.DataProvider.CustomExecute(new SQLCondition(sql));

                                        sql = "update TBLITEMLOTDETAIL set SERIALSTATUS='STORAGE' " +
                                              " where SERIALNO in ('" + io.MCard.Trim().ToUpper() + "')";
                                        this.DataProvider.CustomExecute(new SQLCondition(sql));
                                    }

                                    #endregion

                                    #region 针对新料所做的动作

                                    if (io.NewBarcode.Trim().Length > 0)
                                    {
                                        object[] oldOnWIPItemList = dataCollectFacade.QueryOnWIPItem(io.MCard, runningCards, ((int)Web.Helper.MaterialType.DropMaterial).ToString());

                                        if (oldOnWIPItemList != null && oldOnWIPItemList.Length > 0)
                                        {
                                            OnWIPItem oldOnWIPItem = (OnWIPItem)oldOnWIPItemList[0];
                                            OnWIPItem newOnWIPItem = dataCollectFacade.CreateNewOnWIPItem();

                                            newOnWIPItem.RunningCard      = oldOnWIPItem.RunningCard;
                                            newOnWIPItem.MSequence        = oldOnWIPItem.MSequence;
                                            newOnWIPItem.MOCode           = oldOnWIPItem.MOCode;
                                            newOnWIPItem.ModelCode        = oldOnWIPItem.ModelCode;
                                            newOnWIPItem.ItemCode         = oldOnWIPItem.ItemCode;
                                            newOnWIPItem.MItemCode        = oldOnWIPItem.MItemCode;
                                            newOnWIPItem.MCardType        = oldOnWIPItem.MCardType;
                                            newOnWIPItem.Qty              = oldOnWIPItem.Qty;
                                            newOnWIPItem.RouteCode        = oldOnWIPItem.RouteCode;
                                            newOnWIPItem.OPCode           = oldOnWIPItem.OPCode;
                                            newOnWIPItem.ResourceCode     = oldOnWIPItem.ResourceCode;
                                            newOnWIPItem.SegmentCode      = oldOnWIPItem.SegmentCode;
                                            newOnWIPItem.StepSequenceCode = oldOnWIPItem.StepSequenceCode;
                                            newOnWIPItem.EAttribute1      = oldOnWIPItem.EAttribute1;
                                            newOnWIPItem.MOSeq            = oldOnWIPItem.MOSeq;

                                            newOnWIPItem.MCARD          = io.NewBarcode;
                                            newOnWIPItem.LotNO          = io.NewLotNo;
                                            newOnWIPItem.PCBA           = io.NewPCBA;
                                            newOnWIPItem.BIOS           = io.NewBIOS;
                                            newOnWIPItem.Version        = io.NewVersion;
                                            newOnWIPItem.VendorItemCode = io.NewVendorItemCode;
                                            newOnWIPItem.VendorCode     = io.NewVendorCode;
                                            newOnWIPItem.DateCode       = io.NewDateCode;

                                            newOnWIPItem.TransactionStatus = TransactionStatus.TransactionStatus_NO;
                                            newOnWIPItem.ActionType        = (int)Web.Helper.MaterialType.CollectMaterial;
                                            newOnWIPItem.MaintainUser      = actionEventArgs.UserCode;
                                            newOnWIPItem.MaintainDate      = dbDateTime.DBDate;
                                            newOnWIPItem.MaintainTime      = dbDateTime.DBTime;

                                            //RunningCardSequence取当前RCard的最小再减一
                                            newOnWIPItem.RunningCardSequence = dataCollectFacade.GetMinRCardSequenceFromOnWipItem(runningCards);

                                            //重新抓取ShiftTypeCode、ShiftCode、TimePeriodCode
                                            StepSequence stepSequence = (StepSequence)baseModelFacade.GetStepSequence(newOnWIPItem.StepSequenceCode);
                                            if (stepSequence == null)
                                            {
                                                newOnWIPItem.ShiftTypeCode = stepSequence.ShiftTypeCode;
                                            }
                                            else
                                            {
                                                newOnWIPItem.ShiftTypeCode = oldOnWIPItem.ShiftTypeCode;
                                            }

                                            TimePeriod timePeriod = (TimePeriod)shiftModelFacade.GetTimePeriod(newOnWIPItem.ShiftTypeCode, dbDateTime.DBTime);
                                            if (timePeriod != null)
                                            {
                                                newOnWIPItem.TimePeriodCode = timePeriod.TimePeriodCode;
                                                newOnWIPItem.ShiftCode      = timePeriod.ShiftCode;
                                            }

                                            dataCollectFacade.AddOnWIPItem(newOnWIPItem);
                                        }

                                        if (io.MCardType == MCardType.MCardType_Keyparts)
                                        {
                                            sql = "update TBLSIMULATIONREPORT set IsLoadedPart='1',LoadedRCard='" + String.Join(",", (string[])arRcard.ToArray(typeof(string))) + "' " +
                                                  " where RCARD in ('" + io.NewBarcode.Trim().ToUpper() + "')";
                                            this.DataProvider.CustomExecute(new SQLCondition(sql));

                                            sql = "update TBLITEMLOTDETAIL set SERIALSTATUS='UNSTORAGE' " +
                                                  " where SERIALNO in ('" + io.NewBarcode.Trim().ToUpper() + "')";
                                            this.DataProvider.CustomExecute(new SQLCondition(sql));
                                        }

                                        // Added By Hi1/Venus.feng on 20081114 for Hisense Version : Add Remove Pallet and Carton
                                        // 拆箱和拆Pallet
                                        DataCollectFacade dcf = new DataCollectFacade(this.DataProvider);

                                        if (messages.IsSuccess())
                                        {
                                            messages.AddMessages(dcf.RemoveFromPallet(io.NewBarcode.Trim().ToUpper(), actionEventArgs.UserCode, true));
                                            if (messages.IsSuccess())
                                            {
                                                messages.ClearMessages();
                                            }
                                        }

                                        if (messages.IsSuccess())
                                        {
                                            messages.AddMessages(dcf.RemoveFromCarton(io.NewBarcode.Trim().ToUpper(), actionEventArgs.UserCode));
                                            if (messages.IsSuccess())
                                            {
                                                messages.ClearMessages();
                                            }
                                        }
                                        // End Added
                                    }

                                    #endregion
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                messages.Add(new Message(e));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }
Exemplo n.º 2
0
        public object[] QueryTryNo(
            string itemCodes, string moCodes, string modelCodes,
            string startSn, string endSn, string TryNo,
            int inclusive, int exclusive)
        {
            string itemCondition = "";

            if (itemCodes != "" && itemCodes != null)
            {
                itemCondition = string.Format(
                    @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
            }

            string moCondition = "";

            if (moCodes != "" && moCodes != null)
            {
                moCondition = string.Format(
                    @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
            }

            string modelCondition = "";

            if (modelCodes != "" && modelCodes != null)
            {
                modelCondition = string.Format(
                    @" and modelcode in ({0})", FormatHelper.ProcessQueryValues(modelCodes));
            }

            string         SnCondition    = string.Empty;
            CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);

            if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
            {
                ArrayList array = new ArrayList();
                array.Add(startSn);
                castDownHelper.GetAllRCard(ref array, startSn);

                string[] rCards = (string[])array.ToArray(typeof(System.String));

                SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
            }
            else if (string.Compare(startSn, endSn, true) != 0)
            {
                ArrayList array = new ArrayList();
                castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                string rcardCondition = string.Empty;
                if (array.Count > 0)
                {
                    for (int i = 0; i < array.Count; i++)
                    {
                        if (i < array.Count - 1)
                        {
                            rcardCondition += array[i].ToString() + " union ";
                        }
                        else
                        {
                            rcardCondition += array[i].ToString();
                        }
                    }
                }
                SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                if (rcardCondition != string.Empty)
                {
                    SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                }
                SnCondition += " ) ";
            }

            string TryNoCondition = "";

            if (TryNo != "" && TryNo != null)
            {
                TryNoCondition = string.Format(
                    @" and TRYNO like '{0}%'", TryNo.ToUpper());
            }

            string sql = string.Format(
                @"select distinct {0} from TBLONWIPTRY where 1=1 {1}{2}{3}{4}{5}",
                DomainObjectUtility.GetDomainObjectFieldsString(typeof(QDOTryNo)),
                itemCondition, moCondition, modelCondition, SnCondition, TryNoCondition);

#if DEBUG
            Log.Info(
                new PagerCondition(
                    sql,
                    "mocode,itemcode",
                    inclusive, exclusive, true).SQLText);
#endif

            object[] objs = this.DataProvider.CustomQuery(
                typeof(QDOTryNo),
                new PagerCondition(
                    sql,
                    "mocode,itemcode",
                    inclusive, exclusive, true));


            if (objs != null)
            {
                foreach (QDOTryNo obj in objs)
                {
                    object[] sn = this.DataProvider.CustomQuery(typeof(Simulation),
                                                                new SQLCondition(
                                                                    string.Format(@"select ProductStatus from TBLSIMULATION where RCARD = '{0}'", obj.RunningCard)));
                    if (sn != null)
                    {
                        object[] sn2 = this.DataProvider.CustomQuery(typeof(Simulation),
                                                                     new SQLCondition(
                                                                         string.Format(
                                                                             @"select tblts.tsstatus as ProductStatus from TBLSIMULATION,tblts 
							where TBLSIMULATION.RCARD = tblts.rcard
							and tblsimulation.rcardseq = tblts.rcardseq
							and tblsimulation.mocode = tblts.mocode  
							and TBLSIMULATION.rcard = '{0}' "                            , obj.RunningCard)));
                        if (sn2 != null)
                        {
                            obj.SNState = (sn2[0] as Simulation).ProductStatus;
                        }
                        else
                        {
                            obj.SNState = (sn[0] as Simulation).ProductStatus;
                        }
                    }
                    else
                    {
                        obj.SNState = ProductStatus.OffLine;
                    }

                    object[] onWip = this.DataProvider.CustomQuery(typeof(OnWIP),
                                                                   new SQLCondition(String.Format(
                                                                                        @"select opcode from tblonwip where rcard ='{0}'     
							and (rcardseq,mocode) in 
							(select rcardseq,mocode
									from (select rcardseq, mocode
											from tblonwip
											where rcard = '{0}'
											order by mdate * 1000000 + mtime desc)
									where rownum = 1)"                                    , obj.RunningCard)));

                    if (onWip != null)
                    {
                        obj.CollectionOPCODE = obj.OPCode;                              //采集工位
                        obj.OPCode           = ((OnWIP)onWip[0]).OPCode;                //当前工位
                    }
                }
            }

            return(objs);
        }
Exemplo n.º 3
0
        public int QueryTryNoCount(
            string itemCodes, string moCodes, string modelCodes,
            string startSn, string endSn, string TryNo)
        {
            string itemCondition = "";

            if (itemCodes != "" && itemCodes != null)
            {
                itemCondition = string.Format(
                    @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
            }

            string moCondition = "";

            if (moCodes != "" && moCodes != null)
            {
                moCondition = string.Format(
                    @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
            }

            string modelCondition = "";

            if (modelCodes != "" && modelCodes != null)
            {
                modelCondition = string.Format(
                    @" and modelcode in ({0})", FormatHelper.ProcessQueryValues(modelCodes));
            }

            string         SnCondition    = string.Empty;
            CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);

            if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
            {
                ArrayList array = new ArrayList();
                array.Add(startSn);
                castDownHelper.GetAllRCard(ref array, startSn);

                string[] rCards = (string[])array.ToArray(typeof(System.String));

                SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
            }
            else if (string.Compare(startSn, endSn, true) != 0)
            {
                ArrayList array = new ArrayList();
                castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                string rcardCondition = string.Empty;
                if (array.Count > 0)
                {
                    for (int i = 0; i < array.Count; i++)
                    {
                        if (i < array.Count - 1)
                        {
                            rcardCondition += array[i].ToString() + " union ";
                        }
                        else
                        {
                            rcardCondition += array[i].ToString();
                        }
                    }
                }
                SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                if (rcardCondition != string.Empty)
                {
                    SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                }
                SnCondition += " ) ";
            }

            string TryNoCondition = "";

            if (TryNo != "" && TryNo != null)
            {
                TryNoCondition = string.Format(
                    @" and TRYNO like '{0}%'", TryNo.ToUpper());
            }

            string sql = string.Format(
                @"select {0} from TBLONWIPTRY where 1=1 {1}{2}{3}{4}{5}",
                "count(mocode)",
                itemCondition, moCondition, modelCondition, SnCondition, TryNoCondition);

#if DEBUG
            Log.Info(
                new SQLCondition(
                    sql).SQLText);
#endif

            return(this.DataProvider.GetCount(
                       new SQLCondition(
                           sql)));
        }
        public object[] QuerySoftwareVersion(
            string itemCodes, string moCodes,
            string startSn, string endSn,
            string softwareName, string softwareVersion,
            int inclusive, int exclusive)
        {
            string itemCondition = "";

            if (itemCodes != "" && itemCodes != null)
            {
                itemCondition = string.Format(
                    @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
            }

            string moCondition = "";

            if (moCodes != "" && moCodes != null)
            {
                moCondition = string.Format(
                    @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
            }

            string         SnCondition    = string.Empty;
            CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);

            if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
            {
                ArrayList array = new ArrayList();
                array.Add(startSn);
                castDownHelper.GetAllRCard(ref array, startSn);

                string[] rCards = (string[])array.ToArray(typeof(System.String));

                SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
            }
            else if (string.Compare(startSn, endSn, true) != 0)
            {
                ArrayList array = new ArrayList();
                castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                string rcardCondition = string.Empty;
                if (array.Count > 0)
                {
                    for (int i = 0; i < array.Count; i++)
                    {
                        if (i < array.Count - 1)
                        {
                            rcardCondition += array[i].ToString() + " union ";
                        }
                        else
                        {
                            rcardCondition += array[i].ToString();
                        }
                    }
                }
                SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                if (rcardCondition != string.Empty)
                {
                    SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                }
                SnCondition += " ) ";
            }

            string nameCondition = "";

            if (softwareName != "" && softwareName != null)
            {
                nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
            }

            string versionCondition = "";

            if (softwareVersion != "" && softwareVersion != null)
            {
                versionCondition = string.Format(@" and SOFTVER like '{0}%'", softwareVersion);
            }

            string sql = string.Format(@"select distinct {0} from TBLONWIPSOFTVER where 1=1 {1}{2}{3}{4}{5}",
                                       DomainObjectUtility.GetDomainObjectFieldsString(typeof(OnWIPSoftVersion)),
                                       itemCondition, moCondition, SnCondition,
                                       nameCondition, versionCondition);

#if DEBUG
            Log.Info(
                new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true).SQLText);
#endif

            return(this.DataProvider.CustomQuery(
                       typeof(OnWIPSoftVersion),
                       new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true
                                          )));
        }
        public object[] QuerySoftwareVersion(
            string itemCodes, string moCodes,
            string startSn, string endSn,
            int startDate, int endDate,
            string compareResult,
            string softwareName, string softwareVersion,
            int inclusive, int exclusive)
        {
            if (compareResult == SoftCompareStatus.Success)
            {
                #region 比对成功的信息 TBLONWIPSOFTVER

                string itemCondition = "";
                if (itemCodes != "" && itemCodes != null)
                {
                    itemCondition = string.Format(
                        @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
                }

                string moCondition = "";
                if (moCodes != "" && moCodes != null)
                {
                    moCondition = string.Format(
                        @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
                }

                string         SnCondition    = string.Empty;
                CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);
                if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
                {
                    ArrayList array = new ArrayList();
                    array.Add(startSn);
                    castDownHelper.GetAllRCard(ref array, startSn);

                    string[] rCards = (string[])array.ToArray(typeof(System.String));

                    SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
                }
                else if (string.Compare(startSn, endSn, true) != 0)
                {
                    ArrayList array = new ArrayList();
                    castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                    string rcardCondition = string.Empty;
                    if (array.Count > 0)
                    {
                        for (int i = 0; i < array.Count; i++)
                        {
                            if (i < array.Count - 1)
                            {
                                rcardCondition += array[i].ToString() + " union ";
                            }
                            else
                            {
                                rcardCondition += array[i].ToString();
                            }
                        }
                    }
                    SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                    if (rcardCondition != string.Empty)
                    {
                        SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                    }
                    SnCondition += " ) ";
                }

                string nameCondition = "";
                if (softwareName != "" && softwareName != null)
                {
                    nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
                }

                string versionCondition = "";
                if (softwareVersion != "" && softwareVersion != null)
                {
                    versionCondition = string.Format(@" and SOFTVER like '{0}%'", softwareVersion);
                }

                string sql = string.Format(@"select distinct {0} from TBLONWIPSOFTVER where 1=1 {1}{2}{3}{4}{5}",
                                           DomainObjectUtility.GetDomainObjectFieldsString(typeof(OnWIPSoftVersion)),
                                           itemCondition, moCondition, SnCondition,
                                           nameCondition, versionCondition);

#if DEBUG
                Log.Info(
                    new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true).SQLText);
#endif

                return(this.DataProvider.CustomQuery(
                           typeof(OnWIPSoftVersion),
                           new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true
                                              )));

                #endregion
            }
            else if (compareResult == SoftCompareStatus.Failed)
            {
                #region 比对失败的信息 TBLVERSIONERROR


                string itemCondition = "";
                if (itemCodes != "" && itemCodes != null)
                {
                    itemCondition = string.Format(
                        @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
                }

                string moCondition = "";
                if (moCodes != "" && moCodes != null)
                {
                    moCondition = string.Format(
                        @" and TBLVERSIONERROR.mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
                }

                string         SnCondition    = string.Empty;
                CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);
                if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
                {
                    ArrayList array = new ArrayList();
                    array.Add(startSn);
                    castDownHelper.GetAllRCard(ref array, startSn);

                    string[] rCards = (string[])array.ToArray(typeof(System.String));

                    SnCondition = string.Format(" and TBLVERSIONERROR.rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
                }
                else if (string.Compare(startSn, endSn, true) != 0)
                {
                    ArrayList array = new ArrayList();
                    castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                    string rcardCondition = string.Empty;
                    if (array.Count > 0)
                    {
                        for (int i = 0; i < array.Count; i++)
                        {
                            if (i < array.Count - 1)
                            {
                                rcardCondition += array[i].ToString() + " union ";
                            }
                            else
                            {
                                rcardCondition += array[i].ToString();
                            }
                        }
                    }
                    SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("TBLVERSIONERROR.rcard", startSn.ToUpper(), endSn.ToUpper());

                    if (rcardCondition != string.Empty)
                    {
                        SnCondition += string.Format(" or TBLVERSIONERROR.rcard in ({0}) ", rcardCondition);
                    }
                    SnCondition += " ) ";
                }

                string nameCondition = "";
                if (softwareName != "" && softwareName != null)
                {
                    nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
                }

                string versionCondition = "";
                if (softwareVersion != "" && softwareVersion != null)
                {
                    versionCondition = string.Format(@" and MOVERSIONINFO like '{0}%'", softwareVersion);
                }

                string dateCondition = "";
                if (startDate != 0 && endDate != 0)
                {
                    dateCondition = FormatHelper.GetDateRangeSql("TBLVERSIONERROR.mdate", startDate, endDate);
                }

                string sql = string.Format(@"select distinct TBLVERSIONERROR.* ,tblonwipsoftver.RCARDSEQ,SOFTNAME,TPCODE,SHIFTCODE,SHIFTTYPECODE,RESCODE,OPCODE,SSCODE,SEGCODE,ROUTECODE,MODELCODE,ITEMCODE
							 from TBLVERSIONERROR left join tblonwipsoftver on (TBLVERSIONERROR.rcard = tblonwipsoftver.rcard)
							 where 1=1 {0}{1}{2}{3}{4}{5}"                            ,
                                           itemCondition, moCondition,
                                           SnCondition, dateCondition,
                                           nameCondition, versionCondition);

#if DEBUG
                Log.Info(
                    new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true).SQLText);
#endif

                return(this.DataProvider.CustomQuery(
                           typeof(OnWIPSoftVersionError),
                           new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true
                                              )));

                #endregion
            }

            return(null);
        }
        public int QuerySoftwareVersionCount(
            string itemCodes, string moCodes,
            string startSn, string endSn,
            int startDate, int endDate,
            string compareResult,
            string softwareName, string softwareVersion)
        {
            if (compareResult == SoftCompareStatus.Success)
            {
                #region 比对成功的信息 TBLONWIPSOFTVER

                string itemCondition = "";
                if (itemCodes != "" && itemCodes != null)
                {
                    itemCondition = string.Format(
                        @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
                }

                string moCondition = "";
                if (moCodes != "" && moCodes != null)
                {
                    moCondition = string.Format(
                        @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
                }

                string         SnCondition    = string.Empty;
                CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);
                if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
                {
                    ArrayList array = new ArrayList();
                    array.Add(startSn);
                    castDownHelper.GetAllRCard(ref array, startSn);

                    string[] rCards = (string[])array.ToArray(typeof(System.String));

                    SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
                }
                else if (string.Compare(startSn, endSn, true) != 0)
                {
                    ArrayList array = new ArrayList();
                    castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                    string rcardCondition = string.Empty;
                    if (array.Count > 0)
                    {
                        for (int i = 0; i < array.Count; i++)
                        {
                            if (i < array.Count - 1)
                            {
                                rcardCondition += array[i].ToString() + " union ";
                            }
                            else
                            {
                                rcardCondition += array[i].ToString();
                            }
                        }
                    }
                    SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                    if (rcardCondition != string.Empty)
                    {
                        SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                    }
                    SnCondition += " ) ";
                }

                string nameCondition = "";
                if (softwareName != "" && softwareName != null)
                {
                    nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
                }

                string versionCondition = "";
                if (softwareVersion != "" && softwareVersion != null)
                {
                    versionCondition = string.Format(@" and SOFTVER like '{0}%'", softwareVersion);
                }

                string sql = string.Format(@"select {0} from TBLONWIPSOFTVER where 1=1 {1}{2}{3}{4}{5}",
                                           "count(mocode)",
                                           itemCondition, moCondition, SnCondition,
                                           nameCondition, versionCondition);

#if DEBUG
                Log.Info(
                    new SQLCondition(sql).SQLText);
#endif
                return(this.DataProvider.GetCount(
                           new SQLCondition(sql)));

                #endregion
            }
            else if (compareResult == SoftCompareStatus.Failed)
            {
                #region 比对失败的信息 TBLVERSIONERROR

                string itemCondition = "";
                if (itemCodes != "" && itemCodes != null)
                {
                    itemCondition = string.Format(
                        @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
                }

                string moCondition = "";
                if (moCodes != "" && moCodes != null)
                {
                    moCondition = string.Format(
                        @" and TBLVERSIONERROR.mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
                }

                string         SnCondition    = string.Empty;
                CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);
                if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
                {
                    ArrayList array = new ArrayList();
                    array.Add(startSn);
                    castDownHelper.GetAllRCard(ref array, startSn);

                    string[] rCards = (string[])array.ToArray(typeof(System.String));

                    SnCondition = string.Format(" and TBLVERSIONERROR.rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
                }
                else if (string.Compare(startSn, endSn, true) != 0)
                {
                    ArrayList array = new ArrayList();
                    castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                    string rcardCondition = string.Empty;
                    if (array.Count > 0)
                    {
                        for (int i = 0; i < array.Count; i++)
                        {
                            if (i < array.Count - 1)
                            {
                                rcardCondition += array[i].ToString() + " union ";
                            }
                            else
                            {
                                rcardCondition += array[i].ToString();
                            }
                        }
                    }
                    SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("TBLVERSIONERROR.rcard", startSn.ToUpper(), endSn.ToUpper());

                    if (rcardCondition != string.Empty)
                    {
                        SnCondition += string.Format(" or TBLVERSIONERROR.rcard in ({0}) ", rcardCondition);
                    }
                    SnCondition += " ) ";
                }

                string nameCondition = "";
                if (softwareName != "" && softwareName != null)
                {
                    nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
                }

                string versionCondition = "";
                if (softwareVersion != "" && softwareVersion != null)
                {
                    versionCondition = string.Format(@" and MOVERSIONINFO like '{0}%'", softwareVersion);
                }

                string dateCondition = "";
                if (startDate != 0 && endDate != 0)
                {
                    dateCondition = FormatHelper.GetDateRangeSql("TBLVERSIONERROR.mdate", startDate, endDate);
                }

                string sql = string.Format(@"select  count(PKID)
							 from TBLVERSIONERROR left join tblonwipsoftver on (TBLVERSIONERROR.rcard = tblonwipsoftver.rcard)
							 where 1=1 {1}{2}{3}{4}"                            ,
                                           itemCondition, moCondition,
                                           SnCondition, dateCondition,
                                           nameCondition, versionCondition);

#if DEBUG
                Log.Info(sql);
#endif

                return(this.DataProvider.GetCount(new SQLCondition(sql)));


                #endregion
            }

            return(0);
        }