Exemplo n.º 1
0
        public int generateRptTest(int div, string userId)
        {
            byte[] bytes = null;
            rptProjectCwaIwpDTO rptInfo = GetProjectCwaIwpByIwp(1);

            UserInfoDTO userInfo = new UserInfoDTO();
            userInfo = (new TrueTask.Common()).GetUserInfo(userId);

            switch (div)
            {
                case 1:
                    bytes = GenerateReportForCover("", rptInfo);
                    break;
                case 2:
                    List<FiwpequipDTO> equips = new List<FiwpequipDTO>();
                    for (int i = 1; i < 10; i++)
                    {
                        FiwpequipDTO equip = new FiwpequipDTO();
                        equip.FiwpEquipID = i;
                        equip.EquipmentName = i.ToString();
                        equip.EquipDesc = i.ToString();
                        equip.StartUseDate = DateTime.Now;
                        equip.FinishUseDate = DateTime.Now;
                        equips.Add(equip);
                    }
                    bytes = GenerateReportForEquipment(equips, rptInfo);
                    break;
                case 3:
                    List<FiwpmaterialDTO> materials = new List<FiwpmaterialDTO>();
                    for (int i = 1; i < 10; i++)
                    {
                        FiwpmaterialDTO material = new FiwpmaterialDTO();
                        material.FIWPMaterialID = i;
                        material.PartNo = i.ToString();
                        material.Vendor = i.ToString();
                        material.Qty = Convert.ToDecimal(i);
                        materials.Add(material);
                    }
                    bytes = GenerateReportForMaterial(materials, rptInfo);
                    break;
                case 4:
                    List<ComboBoxDTO> combos = new List<ComboBoxDTO>();
                    for (int i = 1; i < 10; i++)
                    {
                        ComboBoxDTO combo = new ComboBoxDTO();
                        combo.DataID = i;
                        combo.DataName = i.ToString();
                        combo.ExtraValue1 = i.ToString();
                        combo.ExtraValue2 = i.ToString();
                        combo.ExtraValue3 = i.ToString();
                        combos.Add(combo);
                    }
                    bytes = GenerateReportForCombo(combos, rptInfo, "List");
                    break;
            }

            string rootPath = "/SigmaStorage/";
            string childPath = "SigmaDoc/" + userInfo.CompanyName + "/" + userInfo.CurrentProjectId + "/";

            int newRevision = 0;

            string uploadFolder = HttpContext.Current.Server.MapPath(rootPath + childPath + newRevision.ToString() + "/");
            if (!Directory.Exists(uploadFolder))
            {
                Directory.CreateDirectory(uploadFolder);
            }
            string filePath = Path.Combine(uploadFolder, "TEST.jpg");

            System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
            // Writes a block of bytes to this stream using data from
            // a byte array.
            fs.Write(bytes, 0, bytes.Length);

            fs.Close();

            return 1;
        }
Exemplo n.º 2
0
        public ProgressAssignment UpdateIWPComponentprogressAssignment(ProgressAssignment list, bool isUsingMpp)
        {
            //string userName = string.Empty;
            //string password = string.Empty;

            //if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            //{
            //    string[] P6LoginInfo = (new P6Manager()).GetP6Login();
            //    userName = P6LoginInfo[0];
            //    password = P6LoginInfo[1];
            //}

            if (isUsingMpp)
            {
                // project id, so get last project loaded in projectschedule.
                //MppHelper.Instance.GetProjectInstance(list.fiwp.ProjectID);
            }

            List<FiwpmaterialDTO> fiwpMaterial_new = new List<FiwpmaterialDTO>();
            List<FiwpmaterialDTO> fiwpMaterial_old = new List<FiwpmaterialDTO>();

            //first update all progresses.
            if (list.progress != null && list.progress.Count > 0 && list.fiwp != null)
            {
                //bool dochange = false;
                string updatedBy = list.progress[0].UpdatedBy;

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    try
                    {
                        list.progress = UpdateProgressAssignment(list.progress);

                        //현재시점에서는 Device에서 ScheduleLineItem의 공사기간을 넘지못하도록 막고있기때문에 쓰이지 않는코드 - 2014.04.12
                        /*
                        DoCheckProjectScheduleConstrain(dbname, list.fiwp, userName, password);
                        if (!string.IsNullOrEmpty(list.fiwp.ExceptionMessage))
                        {
                            if (list.fiwp.ExceptionMessage.Contains("Update ProjectSchedule"))
                                dochange = true;
                            else if (!string.IsNullOrEmpty(list.fiwp.ExceptionMessage))
                                throw new Exception(list.fiwp.ExceptionMessage);
                        }*/
                        scope.Complete();
                    }
                    catch (Exception ex)
                    {
                        if (scope != null) scope.Dispose();
                        throw new Exception("Fail to update ProgressAssignment", ex);
                    }
                }

                if (list.fiwp != null)
                {
                    #region "Update FIWP info to P6"
                    //Component를 Assign함으로써 TotalManhours와 EstimatedWorker가 변경된다.
                    //이 로직을 구현하기 위해 당 method리턴 후에
                    //Device에서 다른 UpdateIwpPeriod를 호출하고 있다.
                    //추후 당method에 삽입하는 형태로 통합이 필요하다. - 2014.04.12

                    //switch (list.fiwp.DTOStatus)
                    //{
                    //    //case (int)RowStatus.New:
                    //    //    DoProcessFIWPWBS(dbname, list.fiwp, userName, password);
                    //    //    break;
                    //    case (int)RowStatus.Update:
                    //        DoUpdateFIWPToP6(list.fiwp, userName, password);
                    //        break;
                    //    //case (int)RowStatus.Delete:
                    //    //    DoRemoveFIWPFromP6(dbname, list.fiwp, userName, password);
                    //    //    break;
                    //}

                    //List<FiwpDTO> fiwps = new List<FiwpDTO>();
                    //fiwps.Add(list.fiwp);
                    //fiwps = SaveIwp(fiwps);

                    //if (fiwps != null && fiwps.Count > 0)
                    //    list.fiwp = fiwps[0];

                    //현재시점에서는 Device에서 ScheduleLineItem의 공사기간을 넘지못하도록 막고있기때문에 쓰이지 않는코드 - 2014.04.12
                    //if (dochange)
                    //    UpdateFIWPOutcomeProjectScheduleAndP6(dbname, list.fiwp, userName, password);

                #endregion "Update FIWP info to P6"

                    #region "Insert/Update FIWP Material List"
                    try
                    {
                        List<FiwpmaterialDTO> fiwpMateriallist = new List<FiwpmaterialDTO>();
                        List<FiwpmaterialDTO> tempList = new List<FiwpmaterialDTO>();

                        tempList = GetFiwpMaterialByFIWP(list.fiwp.FiwpID, list.fiwp.ProjectID, list.fiwp.DisciplineCode);
                        if (tempList != null && tempList.Count() > 0)
                            fiwpMaterial_old = tempList;

                        tempList = GetMaterialForFiwpMaterialUpdating(list.fiwp.FiwpID, list.fiwp.ProjectID, list.fiwp.DisciplineCode);
                        if (tempList != null && tempList.Count() > 0)
                            fiwpMaterial_new = tempList;

                        foreach (FiwpmaterialDTO newRow in fiwpMaterial_new)
                        {
                            FiwpmaterialDTO fiwpmaterial = new FiwpmaterialDTO();
                            var result = fiwpMaterial_old.Where(x => newRow.EstMHLibID == x.EstMHLibID).FirstOrDefault();

                            if (result != null)
                            {
                                fiwpmaterial = result;
                                fiwpmaterial.Qty = newRow.Qty;
                                fiwpmaterial.UOMLUID = newRow.UOMLUID;
                                fiwpmaterial.DTOStatus = (int)RowStatusNo.Update;
                                fiwpmaterial.UpdatedBy = updatedBy;
                            }
                            else
                            {
                                fiwpmaterial = newRow;
                                fiwpmaterial.DTOStatus = (int)RowStatusNo.New;
                                fiwpmaterial.UpdatedBy = updatedBy;
                            }

                            fiwpmaterial.FIWPID = list.fiwp.FiwpID;

                            fiwpMateriallist.Add(fiwpmaterial);
                        }

                        if (fiwpMateriallist.Count > 0)
                            fiwpMateriallist = (new TrueTask.Assemble()).SaveFiwpMaterial(fiwpMateriallist); //SaveFiwpMaterial(fiwpMateriallist);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion "Insert/Update FIWP Material List"

                    #region useless
                    //#region "Insert/Update FIWP QAQC List"
                    //try
                    //{
                    //    List<FiwpqaqcDTO> fiwpqaqcs = new List<FiwpqaqcDTO>();
                    //    #region "Old"
                    //    /*
                    //    List<MTODTO> mtoList = (new DALC.ProgressDAL()).GetProgressByCwpFiwp(dbname, list.fiwp.ProjectID, list.fiwp.ModuleID, list.fiwp.CWPID, list.fiwp.FiwpID);
                    //    List<LibqaqcformtemplateDTO> libqaqcList = (new DALC.LibqaqcformtemplateDAL()).GetLibqaqcformtemplateByProject(dbname, list.fiwp.ProjectID);
                    //    List<QaqcformtemplateDTO> qaqctemplateList = (new DALC.QaqcformtemplateDAL()).GetQaqcformtemplateByFormtypeNameProject(dbname, QAQCFormType.IWP, string.Empty, list.fiwp.ProjectID);
                    //    List<FiwpqaqcDTO> fiwpqaqcList = (new DALC.FiwpqaqcDAL()).GetFiwpqaqcByFIWP(dbname, list.fiwp.FiwpID);

                    //    foreach (MTODTO progress in list.progress)
                    //    {
                    //        List<LibqaqcformtemplateDTO> libqaqcs = new List<LibqaqcformtemplateDTO>();
                    //        MTODTO mto = mtoList.Where(x => x.ProgressID == progress.ProgressID).FirstOrDefault();

                    //        libqaqcs = libqaqcList.Where(x => x.LibID == mto.LibEstManhrsID && x.TaskCategoryID == mto.TaskCategoryID).ToList();

                    //        foreach (LibqaqcformtemplateDTO libqaqc in libqaqcs)
                    //        {
                    //            int Qty = 1;
                    //            QaqcformtemplateDTO qaqctemplate = qaqctemplateList.Where(x => x.QAQCFormTemplateID == libqaqc.QAQCFormTemplateID).FirstOrDefault();
                    //            List<FiwpqaqcDTO> oldfiwpqaqcs = fiwpqaqcList.Where(x => x.QAQCFormTemplateID == libqaqc.QAQCFormTemplateID).ToList();

                    //            if (qaqctemplate.QAQCTypeLUID == QAQCType.Tag)
                    //            {
                    //                var mtos = mtoList.Where(x => x.LibEstManhrsID == libqaqc.LibID && x.TaskCategoryID == libqaqc.TaskCategoryID).GroupBy(y => y.EngTagNumber).Select(z => z.Key).ToList();
                    //                Qty = mtos.Count();
                    //            }

                    //            if (oldfiwpqaqcs.Count() > 0)
                    //            {
                    //                oldfiwpqaqcs.ForEach(x => { x.Qty = Qty; x.UpdatedBy = list.fiwp.UpdatedBy; x.UpdatedDate = DateTime.Now; x.DTOStatus = (int)RowStatus.Update; });

                    //                fiwpqaqcs.AddRange(oldfiwpqaqcs);
                    //            }
                    //            else
                    //            {
                    //                FiwpqaqcDTO newfiwpqaqc = new FiwpqaqcDTO();
                    //                newfiwpqaqc.FIWPID = list.fiwp.FiwpID;
                    //                newfiwpqaqc.CWPID = list.fiwp.CWPID;
                    //                newfiwpqaqc.ProjectID = list.fiwp.ProjectID;
                    //                newfiwpqaqc.ModuleID = list.fiwp.ModuleID;
                    //                newfiwpqaqc.Qty = Qty;
                    //                newfiwpqaqc.QAQCFormTemplateID = libqaqc.QAQCFormTemplateID;
                    //                newfiwpqaqc.QAQCFormTypeLUID = QAQCFormType.IWP;
                    //                newfiwpqaqc.UpdatedBy = list.fiwp.UpdatedBy;
                    //                newfiwpqaqc.UpdatedDate = DateTime.Now;
                    //                newfiwpqaqc.DTOStatus = (int)RowStatus.New;

                    //                fiwpqaqcs.Add(newfiwpqaqc);
                    //            }
                    //        }
                    //    }
                    //    */
                    //    #endregion
                    //    fiwpqaqcs = ProjectWriter.CreateFiwpQaqc(dbname, list.fiwp, list.progress);// (new Element.Reveal.Server.DALC.FiwpqaqcDAL()).SaveFiwpqaqc(dbname, fiwpqaqcs, RowStatus.None);
                    //}
                    //catch (Exception ex)
                    //{
                    //    throw ex;
                    //}

                    //#endregion "Insert/Update FIWP QAQC List"

                    //#region "Sync FIWP_ProjectSchedule Resource to P6"

                    //SyncScheduleFIWPResourceToP6(dbname, list.fiwp.FiwpID, list.fiwp.ProjectID, list.fiwp.ModuleID, userName, password);

                    //#endregion "Sync FIWP_ProjectSchedule Resource to P6"

                    #endregion
                }
            }

            return list;
        }