SOAP Запрос структуры веб-службы Результат - PullRequest
0 голосов
/ 16 января 2020

Я хочу получить ожидаемый вывод, что при вводе идентификатора проекта результатом должны быть детали этапа. Внутри веха, есть детали задачи. А внутри Задачи есть детали требований задания. Смотрите фотографии:

Ввод:

enter image description here

Это то, что я хочу, чтобы ожидаемый результат: (Я просто набираю их, чтобы вы можете понять, что я сказал.)

enter image description here enter image description here

Фактический вывод с ошибкой.

enter image description here

Вот мой код:

Бизнес-уровень

 public class GetProjectDetails_Application_Layer
{
    public string UserMgmtDBConnString = DBConnections.SnapConnections.UserMgmtDBConnString;
    public string constr = DBConnections.SnapConnections.WorkFlowConnString;

    public List<Milestones_details> GetProjectDetails(int PROJECT_ID)
    {
        List<Milestones_details> Milestones = new List<Milestones_details>();
        try
        {

            using (OracleConnection conn = new OracleConnection(constr))
            {
                conn.Open();

                string qry = @"SELECT A.END_MILESTONE_FK as MILESTONE_FK FROM TBL_WORKFLOW_DEFINITION A
                                INNER JOIN TBL_PROJECTS B on B.WORKFLOW_FK = A.WORKFLOW_FK
                                INNER JOIN TBL_PROJECT_MS_DEFINITION C on C.PROJECT_FK = B.PROJECT_PK
                                WHERE PROJECT_FK = :PROJECTID
                                UNION
                                SELECT A.START_MILESTONE_FK as MILESTONE_FK FROM TBL_WORKFLOW_DEFINITION A
                                INNER JOIN TBL_PROJECTS B on B.WORKFLOW_FK = A.WORKFLOW_FK
                                INNER JOIN TBL_PROJECT_MS_DEFINITION C on C.PROJECT_FK = B.PROJECT_PK
                                WHERE PROJECT_FK = :PROJECTID";

                OracleCommand cmd = new OracleCommand(qry, conn);
                cmd.BindByName = true;

                OracleParameter param = new OracleParameter();
                param.ParameterName = ":PROJECTID";
                param.Value = PROJECT_ID;
                cmd.Parameters.Add(param);

                OracleDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Milestones_details Milestone = new Milestones_details();
                    Milestone.Milestone_PK = Convert.ToInt32(rdr[0]);
                    Milestones.Add(Milestone);
                }
                foreach (Milestones_details Milestone in Milestones)
                {
                    //select name
                    qry = @"SELECT MILESTONE_PK, MILESTONE_NAME FROM TBL_MILESTONE A
                                 INNER JOIN TBL_PROJECT_MILESTONE B on B.MILESTONE_FK = A.MILESTONE_PK
                                    WHERE PROJECT_FK = :MilestoneID";
                    cmd = new OracleCommand(qry, conn);

                    param = new OracleParameter();
                    param.ParameterName = ":MilestoneID";
                    param.Value = PROJECT_ID;
                    cmd.Parameters.Add(param);

                    Milestone.Link = new List<Link>();

                    rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        Milestone.Milestone_PK = Convert.ToInt32(rdr[0].ToString());
                        Milestone.Milestone_name = rdr[1].ToString();
                    }


                        //select all task from designed milestone
                        qry = @"select TASK_FK,task_name from tbl_task_for_milestone a
                                INNER JOIN TBL_TASK b ON a.TASK_FK = b.TASK_PK
                                where milestone_fk = :MilestoneID order by task_order";

                    cmd = new OracleCommand(qry, conn);

                    param = new OracleParameter();
                    param.ParameterName = ":MilestoneID";
                    param.Value = Milestone.Milestone_PK;
                    cmd.Parameters.Add(param);

                    rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        Tasks_details Task = new Tasks_details();
                        Task.TASK_FK = Convert.ToInt32(rdr[0].ToString());
                        Task.TASK_NAME = rdr[1].ToString();
                        Milestone.ListOfTask.Add(Task);
                    }

                    foreach (Tasks_details task in Milestone.ListOfTask)
                    {
                        task.ListOfTaskReq = new List<Task_Requirements_details>();

                        qry = @"SELECT TASK_REQUIREMENT_PK as TASK_REQUIREMENT_ID, FIELD_NAME, FIELD_ALIAS, FIELD_TYPE FROM TBL_REQ_FOR_TASK  A 
                             INNER JOIN TBL_TASK_REQUIREMENTS B ON B.TASK_REQUIREMENT_PK = A.TASK_REQUIREMENT_FK 
                             WHERE TASK_FK = :TASK_ID ORDER BY REQ_ORDER";

                        cmd = new OracleCommand(qry, conn);
                        //cmd.CommandType = CommandType.StoredProcedure;

                        param = new OracleParameter();
                        param.ParameterName = ":TASK_ID";
                        param.Value = task.TASK_FK;
                        cmd.Parameters.Add(param);

                        rdr = cmd.ExecuteReader();
                        while (rdr.Read())
                        {
                            Task_Requirements_details Taskreq = new Task_Requirements_details();
                            Taskreq.TASK_REQUIREMENT_PK = Convert.ToInt32(rdr[0].ToString());
                            Taskreq.FIELD_NAME = rdr[1].ToString();
                            Taskreq.FIELD_TYPE = rdr[2].ToString();
                            Taskreq.FIELD_ALIAS = rdr[3].ToString();
                            task.ListOfTaskReq.Add(Taskreq);
                        }
                    }   
                }
                conn.Close();
            }
        }
        catch (Exception e)
        {
            Milestones_details ml = new Milestones_details();
            ml.resp = e.ToString();
            Milestones.Add(ml);
            //return e.ToString();
        }
        return Milestones;

    }
}

Модель

 public class Milestones_details
{
    public int Milestone_PK { get; set; }
    public string Milestone_name { get; set; }
    public string resp { get; set; }
    public List<Link> Link { get; set; }
    public List<Tasks_details> ListOfTask { get; set; }
}

public class Tasks_details
{
    public int TASK_FK { get; set; }
    public string TASK_NAME { get; set; }
    public List<Task_Requirements_details> ListOfTaskReq { get; set; }


}

public class Task_Requirements_details
{
    public int TASK_REQUIREMENT_PK { get; set; }
    public string FIELD_NAME { get; set; }
    public string FIELD_TYPE { get; set; }
    public string FIELD_ALIAS { get; set; }

}

Сервис:

 [OperationContract]
    List<Milestones_details> GetProjectDetails(int PROJECT_ID);

Сервис:

 public List<Milestones_details> GetProjectDetails(int PROJECT_ID)
    {
        GetProjectDetails_Application_Layer milestonedetails = new GetProjectDetails_Application_Layer();
        return milestonedetails.GetProjectDetails(PROJECT_ID);

    }
...