填充数据来自对象列表中的存储过程

时间:2013-07-17 09:13:32

标签: c# asp.net performance stored-procedures refactoring

我应该如何重构这样的方法,即使被调用的存储过程get_inbox需要一点时间来返回相同的数据,也需要很长时间才能运行!!


 public static List<UserTransactionDTO> InboxTransactionList(int emp_num, int task_code)
        {
            List<UserTransactionDTO> Transactionlist = new List<UserTransactionDTO>();
            UserTransactionDTO UserTransactionOBJ = new UserTransactionDTO();
            SignedDTO signed = new SignedDTO();
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("@empnum", emp_num.ToString());
            param.Add("@taskcode", task_code.ToString());

            DBConnection DAL_Helper = new DBConnection(ConfigurationSettings.AppSettings["rom"].ToString(), false);
            DataTable result_dt = DAL_Helper.Return_DataTable("get_inbox", CommandType.StoredProcedure, param);
            DataRow result_dr;
            for (int i = 0; i < result_dt.Rows.Count; i++)
            {
                result_dr = result_dt.Rows[i];
                UserTransactionOBJ = new UserTransactionDTO();
                UserTransactionOBJ.PageView = result_dr[0].ToString();
                UserTransactionOBJ.TaskName = result_dr[1].ToString();
                UserTransactionOBJ.TaskCode = int.Parse(result_dr[2].ToString());
                UserTransactionOBJ.SpName = result_dr[3].ToString();
                UserTransactionOBJ.DbName = result_dr[4].ToString();
                UserTransactionOBJ.KeyName = result_dr[5].ToString();
                UserTransactionOBJ.TransSerial = int.Parse(result_dr[6].ToString());
                UserTransactionOBJ.TransDate = result_dr[7].ToString();
                UserTransactionOBJ.EmpName = result_dr[9].ToString();
                UserTransactionOBJ.ValuesKey = result_dr[10].ToString();
                UserTransactionOBJ.TransYear = int.Parse(result_dr[18].ToString());
                UserTransactionOBJ.BoxType = 2;
                if (result_dr[11].ToString() == "")
                    UserTransactionOBJ.OldStatusCode = -1;
                else
                    UserTransactionOBJ.OldStatusCode = int.Parse(result_dr[11].ToString());
                UserTransactionOBJ.NewStatusCode = int.Parse(result_dr[12].ToString());
                UserTransactionOBJ.MainCode = int.Parse(result_dr[13].ToString());
                UserTransactionOBJ.Year = int.Parse(result_dr[14].ToString());
                if (result_dr[15].ToString() != "")
                    UserTransactionOBJ.MailNumber = int.Parse(result_dr[15].ToString());
                else
                    UserTransactionOBJ.MailNumber = 0;
                UserTransactionOBJ.TaskType = int.Parse(result_dr[16].ToString());
                UserTransactionOBJ.ConfirmFlag = int.Parse(result_dr[17].ToString());

                UserTransactionOBJ.TransDesc = GetStoredProcedureResult1(UserTransactionOBJ.DbName, UserTransactionOBJ.SpName, UserTransactionOBJ.KeyName, UserTransactionOBJ.ValuesKey = result_dr[10].ToString());
                //--------------------------------------------------------------------------------------
                int flag;
                DF_Utilities.GetLastPDF(task_code, int.Parse(UserTransactionOBJ.ValuesKey.Split(',')[1]), int.Parse(UserTransactionOBJ.ValuesKey.Split(',')[0]), out flag);
                UserTransactionOBJ.Request_file = flag;


                Transactionlist.Add(UserTransactionOBJ);
            }

            return Transactionlist;
        }

0 个答案:

没有答案