public List <QAQCSearchResultDTO> GetQAQCByUserID(int userID, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; List <QAQCSearchResultDTO> data = new List <QAQCSearchResultDTO>(); try { using (QAQCMngEntities context = CreateContext()) { var result = context.QAQCMng_function_SearchQAQC(userID).ToList(); data = converter.DB2DTO_QAQCSearchResultDTOs(result); foreach (var item in data) { item.ModelCheckListGroupDTOs = converter.DB2DTO_ModelCheckListGroupDTOs(context.QAQCMng_ModelCheckListGroup_View.Where(s => s.ModelID == item.ModelID).ToList()); } //write log //context.QAQCMng_function_InsertLogInspector(userID); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public CategoryDTO GetCategory(out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; CategoryDTO data = new CategoryDTO(); data.CheckListDTOs = new List <CheckListDTO>(); data.DefectDTOs = new List <DefectDTO>(); try { using (QAQCMngEntities context = CreateContext()) { data.CheckListDTOs = converter.DB2DTO_CheckListDTOs(context.QAQCMng_CheckList_View.ToList()); data.DefectDTOs = converter.DB2DTO_DefectDTOs(context.QAQCMng_Defects_View.ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }
public bool UpdateReportFromMobile(int userID, object dtoItem, out Library.DTO.Notification notification) { ReportMobileInputDTO temp = (ReportMobileInputDTO)dtoItem; notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; try { using (QAQCMngEntities context = CreateContext()) { foreach (var item in temp.ReportQAQCDTOs) { int?reportQAQCID = context.QAQCMng_function_UpdateReportQAQC(item.QAQCID, item.TypeOfInspectionID, item.FinishedDate.ConvertStringToDateTime(), item.Remark, item.ReadyQty, item.StatusID, item.ManagementStringID, item.IsSynced, item.SyncedDate.ConvertStringToDateTime(), item.CreatedDate.ConvertStringToDateTime(), item.CheckedQty, userID, userID, CreateImageFromName(item.ImageName), item.LatitudeC, item.LongitudeC, item.LatitudeF, item.LongitudeF).FirstOrDefault(); if (reportQAQCID.HasValue) { if (item.ReportCheckListDTOs != null) { foreach (var reportCheckListDTO in item.ReportCheckListDTOs) { int?reportCheckListID = context.QAQCMng_function_UpdateReportCheckList(reportQAQCID, reportCheckListDTO.CheckListID, reportCheckListDTO.Remark, reportCheckListDTO.StatusID, reportCheckListDTO.CheckListMobileStringID, userID, userID).FirstOrDefault(); if (reportCheckListID != null && reportCheckListID.HasValue) { foreach (var reportCheckListImageDTO in reportCheckListDTO.ReportCheckListImageDTOs) { int?reportCheckListImageID = context.QAQCMng_function_UpdateReportCheckListImage(reportCheckListID, CreateImageFromName(reportCheckListImageDTO.ImageBase64), reportCheckListImageDTO.CheckListImageStringID, userID, userID).FirstOrDefault(); } } } } if (item.ReportDefectDTOs != null) { foreach (var reportDefectDTO in item.ReportDefectDTOs) { int?reportDefectID = context.QAQCMng_function_UpdateReportDefect(reportQAQCID, reportDefectDTO.DefectID, reportDefectDTO.DefectAQty, reportDefectDTO.DefectBQty, reportDefectDTO.DefectCQty, reportDefectDTO.DefectMobileStringID, userID, userID).FirstOrDefault(); if (reportDefectID != null && reportDefectID.HasValue) { foreach (var reportDefectImage in reportDefectDTO.ReportDefectImageDTOs) { int?reportDefectImageID = context.QAQCMng_function_UpdateReportDefectImage(reportDefectID, CreateImageFromName(reportDefectImage.ImageBase64), reportDefectImage.DefectImageMobileStringID, userID, userID).FirstOrDefault(); } } } } } } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; return(false); } return(true); }
public override DTO.SearchFormData GetDataWithFilter(System.Collections.Hashtable filters, int pageSize, int pageIndex, string orderBy, string orderDirection, out int totalRows, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; DTO.SearchFormData data = new DTO.SearchFormData(); data.QAQCSearchResultDTOs = new List <DTO.QAQCSearchResultDTO>(); totalRows = 0; int? statusID = null; string clientUD = null; string factoryOrderUD = null; string articleCode = null; string description = null; string factoryUD = null; string statusNM = null; if (filters.ContainsKey("statusID") && filters["statusID"] != null && !string.IsNullOrEmpty(filters["statusID"].ToString())) { statusID = Convert.ToInt32(filters["statusID"].ToString()); } if (filters.ContainsKey("clientUD") && !string.IsNullOrEmpty(filters["clientUD"].ToString())) { clientUD = filters["clientUD"].ToString().Replace("'", "''"); } if (filters.ContainsKey("factoryOrderUD") && !string.IsNullOrEmpty(filters["factoryOrderUD"].ToString())) { factoryOrderUD = filters["factoryOrderUD"].ToString().Replace("'", "''"); } if (filters.ContainsKey("articleCode") && !string.IsNullOrEmpty(filters["articleCode"].ToString())) { articleCode = filters["articleCode"].ToString().Replace("'", "''"); } if (filters.ContainsKey("description") && !string.IsNullOrEmpty(filters["description"].ToString())) { description = filters["description"].ToString().Replace("'", "''"); } if (filters.ContainsKey("factoryUD") && !string.IsNullOrEmpty(filters["factoryUD"].ToString())) { factoryUD = filters["factoryUD"].ToString().Replace("'", "''"); } if (filters.ContainsKey("statusNM") && !string.IsNullOrEmpty(filters["statusNM"].ToString())) { statusNM = filters["statusNM"].ToString().Replace("'", "''"); } //try to get data try { using (QAQCMngEntities context = CreateContext()) { totalRows = context.QAQCMng_Function_SearchResult(statusID, clientUD, factoryOrderUD, articleCode, description, factoryUD, statusNM, orderBy, orderDirection).Count(); var result = context.QAQCMng_Function_SearchResult(statusID, clientUD, factoryOrderUD, articleCode, description, factoryUD, statusNM, orderBy, orderDirection).ToList(); data.QAQCSearchResultDTOs = converter.DB2DTO_QAQCSearch(result.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList()); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; } return(data); }