Beispiel #1
0
        public WrapperViewEditProject GetViewForUpdateProject(int id)
        {
            WrapperViewEditProject wp = new WrapperViewEditProject();
            string msg = "";

            using (DatabaseContext db = new DatabaseContext())
            {
                try
                {
                    Project            project      = db.Projects.SingleOrDefault(a => a.id == id);
                    List <Gate>        gateList     = db.Gates.ToList();
                    List <GateVersion> gateVersions = db.GateVersions.Where(a => a.gvProjectId == id).ToList();

                    var result = gateVersions.Join(gateList, gv => gv.gvGateId, g => g.gateId, (a, b) => new
                    {
                        projectId = project.id,
                        gateId    = a.gvGateId,
                        gateDesc  = b.gateDesc,
                        gateLine  = a.gvLine
                    });

                    List <GateList> projectGateList = new List <GateList>();

                    foreach (var item in result)
                    {
                        GateList gl = new GateList();
                        gl.gateDesc  = item.gateDesc;
                        gl.gateId    = item.gateId;
                        gl.gateLine  = item.gateLine;
                        gl.projectId = item.projectId;

                        projectGateList.Add(gl);
                    }


                    List <ProjectStatus> statusList = db.ProjectStatuses.ToList();


                    wp.project         = project;
                    wp.statusList      = statusList;
                    wp.projectGateList = projectGateList;
                }
                catch (Exception ex)
                {
                    if (ex.InnerException is null)
                    {
                        msg = ex.Message;
                    }
                    else
                    {
                        msg = ex.InnerException.Message;
                    }

                    MyLogger.GetInstance().Error("Error  - Editing Project" + msg);
                }
                return(wp);
            }
        }
Beispiel #2
0
        public bool SaveProjectInfo(WrapperViewEditProject wvep)
        {
            string msg    = "";
            bool   output = false;

            using (DatabaseContext db = new DatabaseContext())
            {
                using (DbContextTransaction transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        Project prj = new Project();
                        prj = wvep.project;
                        db.Projects.Add(prj);
                        db.Entry(prj).State = EntityState.Modified;
                        db.SaveChanges();

                        msg = "Sucessfully updated";

                        transaction.Commit();
                        output = true;
                    }
                    catch (Exception ex)
                    {
                        if (ex.InnerException is null)
                        {
                            msg = ex.Message;
                        }
                        else
                        {
                            msg = ex.InnerException.Message;
                        }
                        MyLogger.GetInstance().Error("Error - Udating Project Info" + msg);


                        transaction.Rollback();
                    }
                }
                return(output);
            }
        }
Beispiel #3
0
 public bool SaveProjectInfo(WrapperViewEditProject wvep)
 {
     throw new NotImplementedException();
 }
Beispiel #4
0
        public WrapperViewEditProject GetViewForUpdateGate(int projectId, int gateId, int gateLine)
        {
            string msg = "";
            WrapperViewEditProject wp = new WrapperViewEditProject();

            Project     p  = new Project();
            GateVersion gv = new GateVersion();

            wp.project     = p;
            wp.gateversion = gv;
            using (DatabaseContext db = new DatabaseContext())
            {
                //  ArrayList dayslist = new ArrayList();
                List <GroupFunction> dayslist = new List <GroupFunction>();
                try
                {
                    List <DbViewClass> dbview = db.gridClasses.AsNoTracking()
                                                .Where(n => n.id == projectId && n.gvGateId == gateId && n.gvLine == gateLine)
                                                .OrderBy(n => n.ProjFuncId).
                                                ToList();

                    int           tempFuncId    = 0;
                    string        str           = "";
                    string        flag          = "X";
                    int           printflag     = 0;
                    int           idfunc        = 0;
                    int           idrel         = 0;
                    int           idapp         = 0;
                    int           estimateRecId = 0;
                    string        namefunc      = "";
                    int           totalDays     = 0;
                    int           projfuncid    = 0;
                    GroupFunction gf            = null;
                    foreach (var aa in dbview)
                    {
                        if (aa.FuncId != tempFuncId)
                        {
                            if (printflag == 1)
                            {
                                gf            = new GroupFunction();
                                gf.appid      = idapp;
                                gf.releaseId  = idrel;
                                gf.FuncId     = idfunc;
                                gf.FuncName   = namefunc;
                                gf.daysString = str;
                                gf.totalDays  = totalDays;
                                gf.ProjFuncId = projfuncid;
                                dayslist.Add(gf);
                                totalDays = 0;
                                str       = "";
                            }
                            printflag = 1;
                        }
                        if (str.Length == 0)
                        {
                            str = aa.estId.ToString() + "," + aa.phaseCode.ToString() + "," + aa.roleId.ToString() + "," + aa.estDays.ToString() + "," + flag;
                        }
                        else
                        {
                            str = str + "-" + aa.estId.ToString() + "," + aa.phaseCode.ToString() + "," + aa.roleId.ToString() + "," + aa.estDays.ToString() + "," + flag;
                        }

                        idfunc        = aa.FuncId;
                        idrel         = aa.RelId;
                        idapp         = aa.AppId;
                        namefunc      = aa.FuncName;
                        estimateRecId = aa.estId;
                        projfuncid    = aa.ProjFuncId;

                        totalDays  = totalDays + aa.estDays;
                        tempFuncId = aa.FuncId;
                    }
                    gf            = new GroupFunction();
                    gf.appid      = idapp;
                    gf.releaseId  = idrel;
                    gf.FuncId     = idfunc;
                    gf.FuncName   = namefunc;
                    gf.daysString = str;
                    gf.totalDays  = totalDays;
                    gf.ProjFuncId = projfuncid;
                    dayslist.Add(gf);
                    //foreach (GroupFunction i in dayslist)
                    //{
                    //    System.Diagnostics.Debug.WriteLine(i.FuncId);
                    //    System.Diagnostics.Debug.WriteLine(i.FuncName);
                    //    System.Diagnostics.Debug.WriteLine(i.appid);
                    //    System.Diagnostics.Debug.WriteLine(i.RelId);
                    //    System.Diagnostics.Debug.WriteLine(i.daysString);

                    //}

                    //List<GroupFunction> result = gridClassList.GroupBy(x => new { x.FuncId, x.FuncName, x.AppId, x.RelId })
                    //    .Select(o => o.First()).ToList().Select(o => new GroupFunction
                    //    {
                    //        FuncId = o.FuncId, FuncName = o.FuncName, appid = o.AppId, RelId = o.RelId
                    //    }).ToList();



                    //foreach (GroupFunction item in result)
                    //{
                    //    System.Diagnostics.Debug.WriteLine(item.appid);
                    //}


                    List <EstimateAttachment> attachments = db.EstimateAttachments.Where(x => x.projectId == projectId &&
                                                                                         x.gateId == gateId && x.lineNo == gateLine).ToList();

                    List <Phase>         phaseList    = db.Phases.ToList(); //int projectId, int gateId, int gateLine
                    List <Role>          roleList     = db.Roles.ToList();
                    List <Application>   appList      = db.Applications.ToList();
                    List <Release>       releaseList  = db.Releases.ToList();
                    List <Functionality> functionList = db.Functionalities.ToList();
                    List <ProjectStatus> statusList   = db.ProjectStatuses.ToList();
                    List <Gate>          gateList     = db.Gates.ToList();


                    //

                    wp.attachments          = attachments;
                    wp.groupFunction        = dayslist;
                    wp.project.impactType   = dbview[0].impactType;
                    wp.project.statusId     = dbview[0].statusId;
                    wp.gateversion.gvGateId = dbview[0].gvGateId;
                    wp.gateversion.gvStatus = dbview[0].gvStatus;
                    //wp.funcid= gridClassList[0].FuncId;

                    wp.dbview       = dbview;
                    wp.appList      = appList;
                    wp.relList      = releaseList;
                    wp.roleList     = roleList;
                    wp.phaselist    = phaseList;
                    wp.functionList = functionList;
                    wp.statusList   = statusList;
                    wp.gateList     = gateList;
                }
                catch (Exception ex)
                {
                    if (ex.InnerException is null)
                    {
                        msg = ex.Message;
                    }
                    else
                    {
                        msg = ex.InnerException.Message;
                    }


                    msg = msg + "\n" + "Error - getting gate details..Project Id = " + projectId + " Gate Id = " + gateId + " Line = " + gateLine;

                    MyLogger.GetInstance().Error(msg);
                }
            }
            return(wp);
        }