BS 架构,Oracle数据库 扫入条码速度很慢,如何追踪哪里慢?如何解决,谢谢大家!

.Net技术 码拜 10年前 (2015-05-11) 1433次浏览 0个评论

公司上了一个新系统,只有C#源代码与数据库连接信息,其它的东西都没有,逻辑也不清楚。
用户只是反映在扫入Wafer时(Textbox),速度非常慢,要等15秒左右。
我是新手,特来请教大家,请大家积极参与帮忙,非常感谢~!

我认为应该从源码或者Oracle数据库入手,个人感觉影响速度的应该是如下的事件:
ttbWafer_TextChanged
但是不知道这个是什么意思,能够看到哪里慢(SQL语句还是application慢?):WaferList.FirstOrDefault(p => p.WAFERID == strWaferID || p.EPILASERMARK == strWaferID);

Oracle数据库初次接触,他们公司用的是Oracle 11,工具是Toad
如果Oracle 能够像SQL Server那样,用Profile能够追踪到哪个客户端,哪个程序用的那些SQL 语句,估计也能找到慢的原因。(ADDM AWR Report 能够达到目的吗?在哪里会显示,哪条语句慢?谢谢)
请教大家如何能够从数据库,或者代码中找到,哪个语句慢或者程序的运行时间是否长?然后我才能去建立主键或者索引什么的,来提高速度,再次感谢!

// C# 源代码如下,系统是BS架构的,在一个界面上,扫入一个Wafer条码,要等很久才有反映。
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using Ares.Cimes.IntelliService;
using Ares.Cimes.IntelliService.Common;
using Ares.Cimes.IntelliService.DbTableSchema;
using Ares.Cimes.IntelliService.Info;
using Ares.Cimes.IntelliService.Transaction;
using Ares.Cimes.IntelliService.Web;
using Focus.Message;
using Focus.RuleUtility;
using System.Threading;

namespace Focus.WIP
{

    /// <summary>
    /// ProcCreateLot 的摘要描述。
    /// </summary>
    public partial class ProcCreateLotByWafer : RulePageBase
    {
        private WorkOrderInfoEx WorkOrderData
        {
            get
            {
                if (this[“WorkOrderData”] == null)
                {
                    throw new CimesException(Msg.Error.TheWorkOrderDoesNotExist());
                }

                return (WorkOrderInfoEx)this[“WorkOrderData”];
            }
            set
            {
                this[“WorkOrderData”] = value;
            }
        }

        private WorkOrderInfo TargetWorkOrderData
        {
            get
            {
                if (this[“TargetWorkOrderData”] == null)
                {
                    throw new CimesException(Msg.Error.TheWorkOrderDoesNotExist());
                }

                return (WorkOrderInfo)this[“TargetWorkOrderData”];
            }
            set
            {
                this[“TargetWorkOrderData”] = value;
            }
        }

        private List<WMSLotInfo> WaferList
        {
            get
            {
                if (this[“WaferList”] == null)
                    this[“WaferList”] = new List<WMSLotInfo>();

                return (List<WMSLotInfo>)this[“WaferList”];
            }
            set
            {
                this[“WaferList”] = value;
            }
        }

        private List<WMSLotInfo> SelectWaferList
        {
            get
            {
                if (this[“SelectWaferList”] == null)
                    this[“SelectWaferList”] = new List<WMSLotInfo>();

                return (List<WMSLotInfo>)this[“SelectWaferList”];
            }
            set
            {
                this[“SelectWaferList”] = value;
            }
        }

        private decimal LotSize
        {
            get
            {
                #region 檢查批號數量必須為大於0的整數。
                if (ttbLotSize.Text.IsNullOrTrimEmpty())
                {
                    throw new CimesException(Msg.Error.PleaseInput(lblLotSize.Text));
                }
                if (!ciMes.Data.ciMesQuery.IsInt(ttbLotSize.Text))
                {
                    throw new CimesException(Msg.Error.InputValueHasInvalidFormatPleaseInputInteger(lblLotSize.Text));
                }
                if (Convert.ToInt32(ttbLotSize.Text) <= 0)
                {
                    throw new CimesException(Msg.Error.ContentMustBeLargeThanZero(lblLotSize.Text));
                }
                #endregion

                return Convert.ToInt32(ttbLotSize.Text);
            }
            set
            {
                ttbLotSize.Text = value.ToString();
            }
        }

        protected override void OnInit(EventArgs e)
        {
            CurrentUpdatePanel = UpdatePanel1;
            //gvQuery.CimesCheckBoxFieldChecked += new Ares.Cimes.IntelliService.Web.UI.CimesGridView.CimesCheckBoxFieldCheckedEventHandler(gvQuery_CimesCheckBoxFieldChecked);
            ttbWO.TextChanged += new EventHandler(ttbWO_TextChanged);
            base.OnInit(e);
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (!UserProfileInfo.CheckUserRight(User.Identity.Name, ProgramRight))
                {
                    HintAndRedirect(Msg.Error.NoAuthority(User.Identity.Name, ProgramRight));
                    return;
                }

                if (!IsPostBack)
                {
                    AjaxFocus(ttbWO);
                    WorkOrderData = null;
                    ClearTextBox();
                    ReSetButton();
                    ClearDataGrid();

                    var fromUrl = Request.ApplicationPath + “/ChipRule/WIP/ProcCreateLotByWafer.aspx?ProgramRightSID=” + ProgramRightSID;
                    btnWOSelect.OnClientClick = “window.parent.openDialogWin(“”” + Request.ApplicationPath + “/ChipRule/WIP/WOSelector.aspx?ProgramRightSID=” + ProgramRightSID + “&FromUrl=” + Server.UrlEncode(fromUrl) + “””,550,600);return;”;
                    if (!Request[“WorkOrder”].IsNullOrTrimEmpty())
                    {
                        ttbWO.Text = Request[“WorkOrder”];
                        QueryData();
                    }
                }
                else
                {
                    gvQuery.DataSource = SelectWaferList;
                }
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }

        void ttbWO_TextChanged(object sender, EventArgs e)
        {
            try
            {
                var workOrderData = WorkOrderInfo.GetWorkOrderByWorkOrder(ttbWO.Must(lblWO));
                if (workOrderData == null)
                {
                    throw new CimesException(Msg.Error.TheWorkOrderDoesNotExist() + “(” + ttbWO.Text + “)”);
                }
                if (workOrderData.Quantity <= workOrderData.ReleaseQuantity)
                {
                    throw new CimesException(Msg.Error.WorkOrderQtyWasReleaseEnd());
                }
                if (workOrderData.Flag != “Release” && workOrderData.Flag != “Created”)
                {
                    throw new CimesException(Msg.Error.WorkOrderFlagError(workOrderData.Flag));
                }
                QueryData();
            }
            catch (Exception ex)
            {
                ClearTextBox();
                ClearDataGrid();
                AjaxFocus(ttbWO);
                ttbWO.Text = string.Empty;
                HandleError(ex);
            }
        }

        /// <summary>
        /// 清除畫面上所有的欄位資料
        /// </summary>
        private void ClearTextBox()
        {
            ttbRecipeVersion.Text = string.Empty;
            ttbWO.Text = string.Empty;
            ttbWOQty.Text = string.Empty;
            ttbUnReleaseQty.Text = string.Empty;
            ttbRoute.Text = string.Empty;
            ttbDeviceName.Text = string.Empty;
            ttbWafer.Text = string.Empty;
            ttbSelectedQty.Text = “0”;
            LotSize = 0;
        }

        /// <summary>
        /// 重新設定UI物件的狀態
        /// </summary>
        private void ReSetButton()
        {
            btnOK.Enabled = false;
        }

   //未完待续 ,代码太长了

// 接上面代码

     /// <summary>
        /// 清除DataGrid的資料
        /// </summary>
        private void ClearDataGrid()
        {
            WaferList = new List<WMSLotInfo>();
            SelectWaferList = new List<WMSLotInfo>();
            gvQuery.Initialize();
        }

        /// <summary>
        /// 查詢工單的資料
        /// </summary>
        private void QueryData()
        {
            try
            {
                string sWO = ttbWO.Text.Trim().ToUpper();
                string waferID = ttbWafer.Text.Trim();
                ClearTextBox();
                ReSetButton();
                ClearDataGrid();

                ttbWO.Text = sWO;

                if (sWO.IsNullOrTrimEmpty())
                {
                    AjaxFocus(ttbWO);
                    ProgramInformationBlock1.ShowException(Msg.Error.PleaseInput(lblWO.Text));
                    return;
                }

                TargetWorkOrderData = null;
                #region 取得製令資訊,及畫面上欄位:QUANTITY RELEASEQTY ROUTE(生產流程) PROCESSCODE DEVICE(品號)
                WorkOrderData = WorkOrderInfoEx.GetWorkOrderByWorkOrder(sWO);
                if (WorkOrderData == null)
                {
                    AjaxFocus(ttbWO);
                    lblStandardProdFlag.Text = string.Empty;
                    throw new CimesException(Msg.Error.TheWorkOrderDoesNotExist());
                }

                string flag = WorkOrderData.Flag.ToUpper();
                if (flag != “RELEASE” && flag != “CREATED”)
                {
                    throw new CimesException(Msg.Error.WorkOrderStatusNotSomethingCanNotUse(sWO, “Release、Created”, ProgramInformationBlock1.Caption));
                }

                //未發放數量 = 工單數量 – 已發放數量
                var unReleaseQty = WorkOrderData.Quantity – WorkOrderData.ReleaseQuantity;
                if (unReleaseQty <= 0)
                {
                    throw new CimesException(Msg.Error.WorkOrderQtyWereReleaseFinished());
                }
                #endregion

                TargetWorkOrderData = InfoCenter.GetBySQL<WorkOrderInfo>(“SELECT * FROM MES_WPC_WO WHERE ERPWO = #[STRING] AND MAINFLAG = “”Y”””, WorkOrderData[“ERPWO”].ToString());
                if (TargetWorkOrderData == null)
                {
                    throw new CimesException(“工单: ” + WorkOrderData.WorkOrder + “所属的目标成品工单不存在!”);
                }
                var activeVersion = DBCenter.GetSingleResult<decimal>(
                    “SELECT ACTIVEVERSION FROM MES_CHIP_OPER_RECIPE WHERE DEVICE = #[STRING] AND ROUTE = #[STRING] AND ROUTEVER = #[DECIMAL]”
                    , TargetWorkOrderData.DeviceName, WorkOrderData.RouteName, WorkOrderData.RouteVersion);
                if (activeVersion <= 0)
                {
                    throw new CimesException(“目标工单: ” + WorkOrderData.WorkOrder + “没有加工明细设置!”);
                }
                ttbRecipeVersion.Text = activeVersion.Format();

                #region 帶出批號數量:於品號設定批號容量屬性,帶出預設值
                List<WpcItemInfo> lotSizes = WpcItemInfo.GetClassItems(“ChipDefaultLotSize”);
                if (lotSizes.Count == 0)
                {
                    throw new CimesException(Msg.Error.ItemMasterClassDataNotFound(“ChipDefaultLotSize”));
                }
                decimal tryDecimal;
                if (lotSizes[0].ItemName.IsNullOrTrimEmpty())
                {
                    throw new CimesException(Msg.Error.ItemMasterClassDataNotFound(“ChipDefaultLotSize”));
                }
                if (!decimal.TryParse(lotSizes[0].ItemName, out tryDecimal))
                {
                    throw new CimesException(Msg.Error.InputValueHasInvalidFormatPleaseInputInteger(“ChipDefaultLotSize”));
                }
                if (tryDecimal <= 0)
                {
                    throw new CimesException(Msg.Error.ContentMustBeLargeThanZero(“ChipDefaultLotSize”));
                }
                LotSize = tryDecimal;
                #endregion
                ttbWOQty.Text = WorkOrderData.Quantity.ToString();
                ttbRoute.Text = WorkOrderData.RouteName;
                ttbWOComment.Text = WorkOrderData.Description;
                ttbDeviceName.Text = WorkOrderData.DeviceName;
                ttbUnReleaseQty.Text = unReleaseQty.ToString();

                //var sourceSite = ddlSourceSite.GetText();
                //var waferID = ttbWafer.Text.Trim();

                StringBuilder sb = new StringBuilder();
                List<string> args = new List<string>();
                sb.Append(“SELECT * FROM MES_WMS_LOT WHERE ASSIGNWO = #[STRING] AND ISSUEWO = ASSIGNWO AND STATUS = “”Booking”” “);
                args.Add(sWO);
                //if (!sourceSite.IsNullOrTrimEmpty())
                //{
                //    sb.Append(” AND SOURCESITE = #[STRING] “);
                //    args.Add(sourceSite);
                //}

                if (!waferID.IsNullOrTrimEmpty())
                {
                    sb.Append(” AND (WAFERID LIKE #[STRING] OR EPILASERMARK LIKE #[STRING] ) “);
                    args.Add(“%” + waferID + “%”);
                    args.Add(“%” + waferID + “%”);
                    ttbWafer.Text = waferID;
                }

                sb.Append(” ORDER BY WAFERID “);

                //WaferList = InfoCenter.GetList<WMSLotInfo>(sb.ToString(), args.ToArray()).FindAll(p => p.WorkOrder.ToCimesString().IsIn(“”, “Empty”));
                WaferList = (from p in InfoCenter.GetList<WMSLotInfo>(sb.ToString(), args.ToArray())
                             where p.WorkOrder.IsNullOrTrimEmpty() || p.WorkOrder == “Empty”
                             select p).ToList();
                gvQuery.SetDataSource(SelectWaferList);
                gvQuery.DataBind();

                ttbWafer.ReadOnly = false;
                AjaxFocus(ttbWafer);
            }
            catch (Exception ex)
            {
                ttbWafer.ReadOnly = false;
                CimesException.Rethrow(ex);
            }
        }

        /// <summary>
        /// 查詢工單的資料
        /// </summary>
        /// <param name=”sender”></param>
        /// <param name=”e”></param>
        protected void btnQuery_Click(object sender, System.EventArgs e)
        {
            try
            {
                QueryData();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }

        /// <summary>
        /// 取消此動作,回到上一個查詢畫面
        /// </summary>
        /// <param name=”sender”></param>
        /// <param name=”e”></param>
        protected void btnCancel_Click(object sender, System.EventArgs e)
        {
            try
            {
                ReturnToPortal();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }

        /// <summary>
        /// 確定事件函式
        /// </summary>
        /// <param name=”sender”></param>
        /// <param name=”e”></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (SelectWaferList.Count == 0)
                {
                    throw new CimesException(Msg.Error.DataIsNotExist(lblWaferList.Text));
                }

                #region 檢查挑選片數不可大於未發放數量。
                if (Convert.ToDouble(ttbSelectedQty.Text) > Convert.ToDouble(ttbUnReleaseQty.Text))
                {
                    throw new CimesException(Msg.Error.CanNotBeGreaterThan(lblSelectQty.Text, lblUnReleaseQty.Text));
                }
                #endregion

                if (ttbRecipeVersion.Text.IsNullOrTrimEmpty())
                {
                    throw new CimesException(“参数: ” + lblRecipeVersion + “遗失!”);
                }

                
                List<string> lots = new List<string>();

    

// 接上面代码

            #region Transaction宣告
                var txnStamp = new TransactionStamp(this.User.Identity.Name, ProgramRight, ProgramRight, this.ApplicationName);
                using (var cts = CimesTransactionScope.Create())
                {
                    #region 覆寫工單主檔已下線量欄位與狀態
                    var updated = false;
                    int retry = 0;
                    WorkOrderInfoEx txnWorkOrderData = null;
                    do
                    {
                        txnWorkOrderData = WorkOrderInfo.GetWorkOrderByWorkOrder(WorkOrderData.WorkOrder).ChangeTo<WorkOrderInfoEx>(false); //(WorkOrderInfoEx)WorkOrderData.DeepCopy();
                        txnWorkOrderData.ReleaseQuantity += ttbSelectedQty.Text.ToDecimal();// +WorkOrderData.ReleaseQuantity;
                        if (txnWorkOrderData.Flag != “Created”) txnWorkOrderData.Flag = “Created”;
                        if (txnWorkOrderData.ReleaseQuantity > txnWorkOrderData.Quantity)
                        {
                            throw new CimesException(“批号创建数量不可大于工单原始数量!”);
                        }
                        try
                        {
                            if (txnWorkOrderData.UpdateToDB(txnStamp.UserID, txnStamp.RecordTime) != 1)
                                throw new CimesException(Msg.Error.AtomicityViolation(lblWO.Text));
                        }
                        catch (Exception ex)
                        {
                            ++retry;
                            Thread.Sleep(100);
                        }
                        updated = true;
                    } while (!updated && retry < 5);
                    if (!updated)
                    {
                        throw new CimesException(“已连续 5次尝试更新工单数据失败, 请稍后再次操作!”);
                    }
                    #endregion
                    int catchCount = 0;
                    int size = 25;
                    IEnumerable<WMSLotInfo> catchList = null;
                    while ((catchList = SelectWaferList.Skip(size * catchCount).Take(size)).Count() != 0)
                    {
                        ++catchCount;

                        #region 取得新Lot
                        var nextIDData = Naming.GenerateRunIDForCreate(WorkOrderData.LotType, User.Identity.Name);
                        string sLot = nextIDData.First;
                        if (nextIDData.Second != null)
                            nextIDData.Second.ForEach(p =>
                            {
                                if (DBCenter.ExecuteSQL(p) != 1)
                                    throw new CimesException(Msg.Error.AtomicityViolation(“Naming Sequence”));
                            });
                        lots.Add(sLot);
                        LotCreateInfo createNewLot = GetCreateLotData(sLot, 0, txnWorkOrderData, TargetWorkOrderData, ttbRecipeVersion.Text.ToDecimal());
                        #endregion

                        List<ComponentInfo> lstCreate = new List<ComponentInfo>();
                        catchList.LoopDo((item, i) =>
                        {
                            #region 产生新的Component
                            var comp = ComponentInfo.CreateLotNormalComponent(item.WAFERID, item.Quantity).ChangeTo<ComponentInfoEx>();
                            comp.Status = “Normal”;
                            comp.WorkOrder = createNewLot.WorkOrder;
                            comp.Unit = createNewLot.Unit;
                            comp.SecondUnit = “PCS”;
                            comp.SecondQuantity = comp.ComponentQuantity;
                            comp.LotSequence = createNewLot.Lot + “-” + (i + 1).ToString().PadLeft(2, “”0″”);
                            comp.ErpDevice = WorkOrderData.ErpDevice;
                            comp.TopGrade = “1100”;
                            comp.InternalDevice = WorkOrderData.ErpDevice;
                            comp.DeviceName = WorkOrderData.DeviceName;
                            comp.ProdType = “Wafer”;
                            comp.LaserMark = item.EPILASERMARK;
                            comp[“WAFER_TYPE”] = item.WAFER_TYPE;
                            comp[“LIFE_GRADE”] = item.LIFE_GRADE;
                            lstCreate.Add(comp);
                            #endregion

                            #region WMS 处理
                            item.WorkOrder = txnWorkOrderData.WorkOrder;
                            item.Status = WMSLotStatus.Created;
                            var history = item.InsertToHistory(txnStamp);
                            history.Lot = sLot;
                            history.UpdateToDB();

                            var nonactive = item.Fill<WMSLotNonactiveInfo>(true);
                            nonactive.InsertImmediately(txnStamp.UserID, txnStamp.RecordTime);
                            if (item.DeleteFromDB() != 1) throw new CimesException(Msg.Error.AtomicityViolation(“DELETE MES_WMS_LOT”));
                            #endregion
                        });

                        createNewLot[“QUANTITY”] = lstCreate.Sum(p => p.ComponentQuantity);
                        createNewLot[“STARTQUANTITY”] = createNewLot[“QUANTITY”].ToDecimal();
                        createNewLot[“SQUANTITY”] = lstCreate.Count;
                        createNewLot[“STARTCOMPQTY”] = lstCreate.Count;
                        WIPTransaction.CreateLots(new List<LotCreateInfo> { createNewLot }, txnStamp);
                        WIPTransaction.SetLotComponent(createNewLot, lstCreate, txnStamp);
                        WIPTransaction.StartLot(createNewLot, “Wait”, txnStamp);

                        #region 处理MES_WIP_COMP_NONACTIVE
                        var nonactiveData = DBCenter.GetDataTable(“SELECT * FROM MES_WIP_COMP_NONACTIVE WHERE COMPONENTID IN (#[INSTRING])”, new object[] { catchList.Select(p => p.WAFERID).ToArray() });
                        nonactiveData.AsEnumerable().LoopDo((row, i) =>
                        {
                            var di = DBInsert.Mix(“MES_WIP_COMP_LOG”);
                            foreach (DataColumn column in nonactiveData.Columns)
                            {
                                di[column.ColumnName] = row[column.ColumnName];
                            }
                            di.InsertToDB();
                            if (DBCenter.ExecuteParse(“DELETE FROM MES_WIP_COMP_NONACTIVE WHERE WIP_COMP_SID = #[STRING]”, row[“WIP_COMP_SID”].ToString()) != 1)
                            {
                                throw new CimesException(“处理MES_WIP_COMP_NONACTIVE资讯发生错误!”);// 理论上不会发生
                            }
                            DBInsert<object> dbi = DBInsert.Mix(“MES_CHIP_COMP_UNDO”);
                            dbi[“CHIP_COMP_UNDO_SID”] = DBCenter.GetSystemID();
                            dbi[“COMPONENTID”] = row[“COMPONENTID”].ToString();
                            dbi[“LOT”] = createNewLot.Lot;
                            dbi[“LINKSID”] = txnStamp.LinkSID;
                            dbi[“USERID”] = txnStamp.UserID;
                            dbi[“UPDATETIME”] = txnStamp.RecordTime;
                            dbi.InsertToDB();
                        });
                        #endregion
                    }

                    cts.Complete();
                }
                #endregion
                Js.OpenNewPage(UpdatePanel1, “RunCardLot.aspx?Type=Proc&Lots=” + lots.Concat(p => p, “^”, null).ToString());

                ReSetButton();
                ttbSelectedQty.Text = “0”;
                QueryData();

                ProgramInformationBlock1.ShowMessage(Msg.Hint.ExecuteSuccessfully(ProgramInformationBlock1.Caption));
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }

        LotCreateInfo GetCreateLotData(string sLot, decimal quantity, WorkOrderInfoEx WoData, WorkOrderInfo targerWO, decimal recipeVersion)
        {
            MES_WIP_LOT_CREATE.Singleton.SyncColumnsFromDB();
            MES_WIP_LOT.Singleton.SyncColumnsFromDB();
            var lotCreateData = LotCreateInfo.CreateLotInfo(WoData, sLot, quantity, 0);
            lotCreateData[“CUSTNO”] = WoData.CUSTNO;
            lotCreateData[“SITE”] = WoData.Factory;
            lotCreateData[“SECTION”] = WoData.Section;
            lotCreateData[“DESCR”] = WoData.Description;
            lotCreateData[“ERPDEVICE”] = WoData.ErpDevice;
            lotCreateData[“LOTCANCELFLAG”] = “Y”;
            lotCreateData[“TARGETWO”] = targerWO.WorkOrder;
            lotCreateData[“RECIPEVERSION”] = recipeVersion;
            lotCreateData[“DEVICE”] = targerWO.DeviceName;
            return lotCreateData;
        }

  

//  接上面代码

      protected void ttbWafer_TextChanged(object sender, EventArgs e)
        {
            try
            {
                ttbWafer.Text = ttbWafer.Text.Trim();
                string strWaferID = ttbWafer.Must(lblWaferID);
                //檢查是否已刷入
                var wms = SelectWaferList.FirstOrDefault(p => p.WAFERID == strWaferID || p.EPILASERMARK == strWaferID);
                if (wms != null)
                {
                    throw new CimesException(Msg.Error.DataIsAlreadyExist(strWaferID));
                }

                var findData = WaferList.FirstOrDefault(p => p.WAFERID == strWaferID || p.EPILASERMARK == strWaferID);
                if (findData == null)
                {
                    throw new CimesException(Msg.Error.DataIsNotExist(strWaferID));
                }

                //刷入的Wafer數量不可超過批號數量
                int iLotSize = ttbLotSize.Text.ToInt();
                if (iLotSize < SelectWaferList.Count + 1)
                {
                    //[12141] 每盒數量不可大於{0}!
                    throw new CimesException(Msg.Error.EachBoxQtyCanNotOverThen(ttbLotSize.Text));
                }
                SelectWaferList.Add((WMSLotInfo)findData.DeepCopy());
                gvQuery.SetDataSource(SelectWaferList, true);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
            finally
            {
                ttbWafer.Text = “”;
                AjaxFocus(ttbWafer);
            }
        }

        protected void gvQuery_DataBound(object sender, EventArgs e)
        {
            try
            {
                ttbSelectedQty.Text = SelectWaferList.Count.ToString();

                btnOK.Enabled = (SelectWaferList.Count > 0);
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }

        protected void gvQuery_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                WMSLotInfo WaferInfo = SelectWaferList[e.RowIndex];

                //從清單中刪除此Wafer
                SelectWaferList.Remove(WaferInfo);

                gvQuery.SetDataSource(SelectWaferList);
                gvQuery.DataBind();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }

        protected void ddlSourceSite_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                QueryData();
            }
            catch (Exception ex)
            {
                HandleError(ex);
            }
        }
    }
}

在开始查询数据库以及获取返回值的两条代码那里设置断点,然后开始调试执行。扫描条码之后,你会在两个断点出中断,估计一下分别所用的时间的数量级(比如说分别是“半秒钟,14秒钟,1秒钟”)就能知道下面该去重新分析哪一段程序了。
100分
分析一个程序的运行效率,需要反复执行程序7、8遍甚至十几遍,每一次都缩小范围。

有些人在第一条语句设置断点,然后逐行执行,我的天(!),这样的人说是在调试和分析程序流程,其实是在瞎找一些自己认识的字眼儿而已,根本不能理解程序流程。

真正理解程序流程的人,可以在5分钟内迅速地对程序重复分析10次,而不是花20分钟去把程序仅仅罗列一次。

你贴出这么一大堆代码来,估计也就是向人家给你猜测一下。

不要做我说的那种“逐行执行调试”的人。你应该自己分析程序来确定哪一两条语句花费了15秒,然后拿出真正的问题来讨论。

一个人最要学习的不是编程语句,而是调试、开发的方法。

不好意思,忘记说了,里面好多商业控件,代码无法调试……
你做还是我做啊?工资给我吧
引用 8 楼 nonocast 的回复:

你做还是我做啊?工资给我吧

只是把所有代码贴出来,以供查看方便,不是让你们写代码的。只是分析哪里可能慢!代码无法调试!Oracle 不懂

没有高手吗?
就想知道从哪里下手,找出慢的SQL 语句,谢谢!
十有八九是 数据库引起的。存储,视图等等,用的这个系统有没有日志输出?如果有就好办了。先从c#代码中找到调用的方法,看里面有没有执行数据库的存储,视图的东西。
引用 11 楼 kongwei521 的回复:

十有八九是 数据库引起的。存储,视图等等,用的这个系统有没有日志输出?如果有就好办了。先从c#代码中找到调用的方法,看里面有没有执行数据库的存储,视图的东西。

我认为也是这样,数据库的SQL 语句引起的。现在我就想找到这些有问题的语句,可是Oracle第一次接触,束手无策。代码也没有看出来有哪些语句。

请高手们出来,告诉我哪里可以追踪到速度慢?谢谢
代码不能运行,只能编译通过;Oracle数据库,我是第一次接触,谢谢!

代码不能运行,只能编译通过;

———————-
第一次听说阿。
如果这样的话,那你也只能先编译一部分代码试验,然后一部分一部分的增加代码来编译试着看了。

引用 14 楼 a3212b12 的回复:

代码不能运行,只能编译通过;

———————-
第一次听说阿。
如果这样的话,那你也只能先编译一部分代码试验,然后一部分一部分的增加代码来编译试着看了。

编译的话,也看不出哪里慢的吧?只有按F5 调试才行吧
这个是商业软件,很大的一坨,不能逐页面一步步调试,真是晕倒了

我的意思是,
先编译一部分,运行,快,ok.
再增加一部分,运行,快,ok

再增加一部分,运行,慢,哦,问题再这部分。

对出问题的代码再用上面的办法循环。

也许很罗嗦,但总比没有办法的好。

BS 架构,Oracle数据库 扫入条码速度很慢,如何追踪哪里慢?如何解决,谢谢大家!

报错信息,我百度了,好像是多国语言问题,但是代码中也没有看到问题。
难道这个问题就这么难吗?高手们快来围观!

这么长代码谁会用心看啊。:(
你用stopwatch,监控这个操作各个部分的用时,看看哪里执行的时间比较长,一般优先考虑的是代码出现问题。
我知道问题出在哪.
因为是从textchange事件里做的判断,而这是个后台方法,每改变一次值,页面就会回发一次,当然慢了
而扫条码是模拟的键盘,是一下子从键盘录入了10几个字符进去
那么页面需要刷新10几次,能不慢吗

你需要做JS或JQ脚本,从前台验证是否输入完毕,然后再调后台方法存数据库
而不是每改变一个字符都走一遍后台方法

我大概知道问题出在哪.
可能是sql查询语法有问题
这部分可能要找原厂
条码枪的原理是扫出二维码然后加一个回车
ttbWafer_TextChanged为啥要更改一次查询一次呢?

ttbWafer_TextChanged 跟資料有關的變數有兩個
WaferList ,  SelectedWaferList
這兩個是由在this[“XXXX”]取出來的裡面 
依照邏輯 變數WaferList是由QueryData填入
而QueryData只有在btnQuery_Click的時候才執行
而SelectedWaferList應該依照刷入的資料判斷是否存在
如果存在則報錯,不存再則加進去, 看起來根本沒有去查詢資料庫的樣子

以上兩個變數都不存在 程式會不斷的存取資料庫的問題 

往別的方向查一下吧 老大

加log看看是不是一个字符查询一次
23樓有懂Text_Change的原理?
有懂條碼槍的原理?

懂了再提意見吧 大哥

亲, 你知道神马是asp.net吗
亲, 你知道神马是asp.net吗
show出处理时间 慢慢缩小范围
谢谢大家的激烈讨论,如果有办法调试代码,我也能看出大概问题。
现在两个问题:
1) 扫入WaferID 很慢, 我看代码也没有发送什么SQL 语句,请大家继续讨论。
2) 代码报错,好像是多国语言。我将25行 <asp:Label ID=”lblProgress” runat=”server” Text=”<%$ Resources:Auto|RuleFace, DataProcessing %>” 改成不用资源对象: <asp:Label ID=”lblProgress” runat=”server” Text=”Test”

但是,一按F5运行,那个用户控件就又被自动改回去,代码就还报那个错误,这个有办法解决没?再次感谢大家捧场!

VS2013中的性能诊断可以监控耗时和调用次数较多的函数。
不过楼主应该从数据库写入次数,文件载入速度,多重循环这几个方面先看看
问题没有解决,决定联系开发的人了,谢谢大家!
兄弟,一看就知道,是LED 的MES ,WIP模块。这个问题太简单了,哈哈,

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明BS 架构,Oracle数据库 扫入条码速度很慢,如何追踪哪里慢?如何解决,谢谢大家!
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!