public void Select(ParameterDTO parameterDTO)
        {
            var rowHandle = _gridViewBinder.RowHandleFor(parameterDTO);

            _gridView.FocusedRowHandle = rowHandle;
        }
示例#2
0
 private void onParameterValueSet(ParameterDTO parameter, PropertyValueSetEventArgs <double> e)
 {
     OnEvent(() => _presenter.OnParameterValueSet(parameter, e.NewValue));
 }
        public async Task <List <HISUploadErrorMessageDTO> > ValidateSPFileAsync(IFileListEntry fileEntry, HISUploadDataDTO HISfileOwner)
        {
            List <HISUploadErrorMessageDTO> ErrorMessage = new List <HISUploadErrorMessageDTO>();

            try
            {
                string              path = "";
                const bool          FIRSTROW_IS_HEADER = true;
                List <ParameterDTO> objParamList       = new List <ParameterDTO>();
                var searchModel = new ParameterDTO()
                {
                    prm_code_major = "UPLOAD_PATH"
                };

                objParamList = await _apiHelper.GetDataListByModelAsync <ParameterDTO, ParameterDTO>("dropdownlist_api/GetParameterList", searchModel);

                if (objParamList.FirstOrDefault(x => x.prm_code_minor == "PATH") != null)
                {
                    path = objParamList.FirstOrDefault(x => x.prm_code_minor == "PATH").prm_value;
                }
                else
                {
                    ErrorMessage.Add(new HISUploadErrorMessageDTO
                    {
                        hfu_status      = 'E',
                        hfu_Err_type    = "E",
                        hfu_Err_no      = 1,
                        hfu_Err_Column  = "",
                        hfu_Err_Message = "ไม่พบ Config PATH กรุณาติดต่อผู้ดูแลระบบ "
                    });

                    return(ErrorMessage);
                }

                string str_CurrentDate = DateTime.Now.ToString("yyyyMMdd");
                path = Path.Combine(path, str_CurrentDate, HISfileOwner.hfu_hos_code);
                bool exists = System.IO.Directory.Exists(path);

                if (!exists)
                {
                    System.IO.Directory.CreateDirectory(path);
                }

                path = Path.Combine(path, fileEntry.Name);

                using (FileStream file = new FileStream(path, FileMode.Create))
                {
                    try
                    {
                        await fileEntry.Data.CopyToAsync(file);
                    }
                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                        file.Flush();
                    }
                }

                //        WHONetMappingSearch searchWHONet = new WHONetMappingSearch();
                //        searchWHONet.wnm_mappingid = MappingTemplate.mp_id;
                //        searchWHONet.wnm_mst_code = MappingTemplate.mp_mst_code;

                //        List<WHONetMappingListsDTO> WHONetColumn = await _apiHelper.GetDataListByModelAsync<WHONetMappingListsDTO, WHONetMappingSearch>("mapping_api/Get_WHONetMappingListByModel", searchWHONet);
                //        var WHONetColumnMandatory = WHONetColumn.Where(x => x.wnm_mandatory == true);
                #region ReadExcel
                if (Path.GetExtension(fileEntry.Name) == ".xls" || Path.GetExtension(fileEntry.Name) == ".xlsx")
                {
                    ExcelDataSetConfiguration option = new ExcelDataSetConfiguration();
                    DataSet result = new DataSet();

                    using (var stream = File.Open(path, FileMode.Open, FileAccess.Read))
                    {
                        using (var reader = ExcelReaderFactory.CreateReader(stream))
                        {
                            if (FIRSTROW_IS_HEADER == true)
                            {
                                result = reader.AsDataSet(new ExcelDataSetConfiguration()
                                {
                                    ConfigureDataTable = (tableReader) => new ExcelDataTableConfiguration()
                                    {
                                        UseHeaderRow = true
                                    }
                                }
                                                          );
                            }
                            else
                            {
                                result = reader.AsDataSet();
                            }

                            ErrorMessage.Add(new HISUploadErrorMessageDTO
                            {
                                hfu_status      = 'I',
                                hfu_Err_type    = "I",
                                hfu_Err_no      = 1,
                                hfu_Err_Column  = "Total",
                                hfu_Err_Message = result.Tables[0].Rows.Count.ToString()
                            });
                        }
                    }
                    #endregion

                    //----------  Validate Data in File -------------
                    var       dataTable   = result.Tables[0];
                    const int colRefNo    = 0;
                    const int colHNNo     = 1;
                    const int colLabNo    = 2;
                    const int colSpecDate = 3;

                    const string COL_REF_NO = "Ref No";
                    const string COL_HN_NO  = "HN";
                    const string COL_LAB_NO = "Lab";
                    const string COL_DATE   = "Date";

                    // Check column Exist
                    Boolean columnExists = result.Tables[0].Columns.Contains(COL_REF_NO) &&
                                           result.Tables[0].Columns.Contains(COL_HN_NO) &&
                                           result.Tables[0].Columns.Contains(COL_LAB_NO) &&
                                           result.Tables[0].Columns.Contains(COL_DATE);
                    if (columnExists == false)
                    {
                        ErrorMessage.Add(new HISUploadErrorMessageDTO
                        {
                            hfu_status      = 'E',
                            hfu_Err_type    = "C",
                            hfu_Err_no      = 1,
                            hfu_Err_Column  = COL_REF_NO,
                            hfu_Err_Message = "ไม่พบ Column " + COL_REF_NO
                        });
                    }

                    for (var i = 0; i < dataTable.Rows.Count; i++)
                    {
                        for (var j = 0; j < dataTable.Columns.Count; j++)
                        {
                            //HISWithSP
                            if (HISfileOwner.hfu_file_type == "HIS" && j == 4)
                            {
                                break;
                            }

                            var data = dataTable.Rows[i][j];

                            // Check column not null
                            if (string.IsNullOrEmpty(data.ToString()))
                            {
                                string columnError = "";
                                if (j == colRefNo)
                                {
                                    columnError = "Ref No.";
                                }
                                else if (j == colHNNo)
                                {
                                    columnError = "HN No.";
                                }
                                else if (j == colLabNo)
                                {
                                    columnError = "Lab No.";
                                }
                                else if (j == colSpecDate)
                                {
                                    columnError = "Date";
                                }
                            }



                            // Check Date format incorrect
                            if (j == colSpecDate)
                            {
                                //string dateString = data.ToString();
                                //DateTime dtValue;
                                //DateTime dt;
                                //string[] formateDate = { "dd/MM/yyyy" };
                                //if (DateTime.TryParse(dateString, out dtValue))
                                //{
                                //    var dateonly = dtValue.Date;
                                //    if (!DateTime.TryParseExact(dateonly.ToString(), formateDate,
                                //                 new CultureInfo("en-US"),
                                //                 DateTimeStyles.None, out dt))
                                //    {
                                //        //your condition fail code goes here
                                //        ErrorMessage.Add(new HISUploadErrorMessageDTO
                                //        {
                                //            hfu_status = 'E',
                                //            hfu_Err_type = "E",
                                //            hfu_Err_no = 1,
                                //            hfu_Err_Column = "",
                                //            hfu_Err_Message = "Column Date ต้องอยู่ในรูปแบบ " + formateDate[0]
                                //        }); ;
                                //        return ErrorMessage;
                                //    }

                                //}
                                //else
                                //{
                                //    ErrorMessage.Add(new HISUploadErrorMessageDTO
                                //    {
                                //        hfu_status = 'E',
                                //        hfu_Err_type = "E",
                                //        hfu_Err_no = 1,
                                //        hfu_Err_Column = "",
                                //        hfu_Err_Message = "Column Date ต้องอยู่ในรูปแบบ " + formateDate[0]
                                //    }); ;
                                //    return ErrorMessage;
                                //}
                            }
                        }
                    }

                    var chkError = ErrorMessage.FirstOrDefault(x => x.hfu_status == 'E');
                    if (chkError != null)
                    {
                        File.Delete(path);
                    }
                    else
                    {
                        ErrorMessage.Add(new HISUploadErrorMessageDTO
                        {
                            hfu_status      = 'I',
                            hfu_Err_type    = "P",
                            hfu_Err_no      = 1,
                            hfu_Err_Column  = "path",
                            hfu_Err_Message = path
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                //create log
            }
            return(ErrorMessage);
        }
示例#4
0
 protected virtual SuperToolTip GetToolTipFor(ParameterDTO parameterDTO, GridHitInfo hi)
 {
     return(_toolTipCreator.ToolTipFor(parameterDTO));
 }
示例#5
0
 private void onSetDimension(ParameterDTO parameter, IDimension newValue)
 {
     _presenter.SetDimensionFor(parameter, newValue);
 }
示例#6
0
 private void setParameterValue(ParameterDTO parameterDTO, double newDisplayValue)
 {
     OnEvent(() => _presenter.SetParameterValue(parameterDTO, newDisplayValue));
 }
示例#7
0
 private void onIsPersistableSet(ParameterDTO parameterDTO, bool newValue)
 {
     _presenter.SetIsPersistable(parameterDTO, newValue);
 }
示例#8
0
 public void SetDescription(ParameterDTO parameterDTO, string newDescription)
 {
     AddCommand(_parameterTask.SetDescriptionForParameter(parameterDTO.Parameter, newDescription, BuildingBlock).Run(_interactionTaskContext.Context));
 }
示例#9
0
 public void SetName(ParameterDTO parameterDTO, string newName)
 {
     AddCommand(_parameterTask.SetNameForParameter(parameterDTO.Parameter, newName, BuildingBlock).Run(_interactionTaskContext.Context));
 }
 private void updateValueOrigin(ParameterDTO parameterDTO, ValueOrigin newValueOrigin)
 {
     OnEvent(() => _presenter.SetParameterValueOrigin(parameterDTO, newValueOrigin));
 }
        public async Task <List <HISUploadErrorMessageDTO> > ValidateAndUploadFileSPFileAsync(IFileListEntry fileEntry
                                                                                              , HISUploadDataDTO HISfileOwner
                                                                                              , HISFileTemplateDTO HISTemplateActive)
        {
            List <HISUploadErrorMessageDTO> ErrorMessage = new List <HISUploadErrorMessageDTO>();

            try
            {
                string path = "";
                List <ParameterDTO> objParamList = new List <ParameterDTO>();
                var searchModel = new ParameterDTO()
                {
                    prm_code_major = "UPLOAD_PATH"
                };

                const bool FIRSTROW_IS_HEADER = true;
                const int  colRefNo           = 0;
                const int  colHNNo            = 1;
                const int  colLabNo           = 2;
                const int  colSpecDate        = 3;
                var        formateDate        = HISTemplateActive.hft_date_format;
                var        COL_REF_NO         = HISTemplateActive.hft_field1; // "Ref No";
                var        COL_HN_NO          = HISTemplateActive.hft_field2; //"HN";
                var        COL_LAB_NO         = HISTemplateActive.hft_field3; // "Lab";
                var        COL_DATE           = HISTemplateActive.hft_field4; //"Date";

                objParamList = await _apiHelper.GetDataListByModelAsync <ParameterDTO, ParameterDTO>("dropdownlist_api/GetParameterList", searchModel);

                if (objParamList.FirstOrDefault(x => x.prm_code_minor == "PATH") != null)
                {
                    path = objParamList.FirstOrDefault(x => x.prm_code_minor == "PATH").prm_value;
                }
                else
                {
                    ErrorMessage.Add(new HISUploadErrorMessageDTO
                    {
                        hfu_status      = 'E',
                        hfu_Err_type    = "E",
                        hfu_Err_no      = 1,
                        hfu_Err_Column  = "",
                        hfu_Err_Message = "ไม่พบ Config PATH กรุณาติดต่อผู้ดูแลระบบ "
                    });

                    return(ErrorMessage);
                }

                string str_CurrentDate = DateTime.Now.ToString("yyyyMMdd");
                path = Path.Combine(path, str_CurrentDate, HISfileOwner.hfu_hos_code);
                bool exists = System.IO.Directory.Exists(path);

                if (!exists)
                {
                    System.IO.Directory.CreateDirectory(path);
                }

                path = Path.Combine(path, fileEntry.Name);

                using (FileStream file = new FileStream(path, FileMode.Create))
                {
                    try
                    {
                        await fileEntry.Data.CopyToAsync(file);
                    }
                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                        file.Flush();
                    }
                }

                #region ReadExcel
                if (Path.GetExtension(fileEntry.Name) == ".xls" || Path.GetExtension(fileEntry.Name) == ".xlsx")
                {
                    ExcelDataSetConfiguration option = new ExcelDataSetConfiguration();
                    DataSet result = new DataSet();

                    using (var stream = File.Open(path, FileMode.Open, FileAccess.Read))
                    {
                        using (var reader = ExcelReaderFactory.CreateReader(stream))
                        {
                            if (FIRSTROW_IS_HEADER == true)
                            {
                                result = reader.AsDataSet(new ExcelDataSetConfiguration()
                                {
                                    ConfigureDataTable = (tableReader) => new ExcelDataTableConfiguration()
                                    {
                                        UseHeaderRow = true
                                    }
                                }
                                                          );
                            }
                            else
                            {
                                result = reader.AsDataSet();
                            }


                            while (reader.Read())
                            {
                                var strFileFormatDate = reader.GetNumberFormatString(3);
                                if (strFileFormatDate.ToLower() != formateDate.ToLower())
                                {
                                    ErrorMessage.Add(new HISUploadErrorMessageDTO
                                    {
                                        hfu_status      = 'E',
                                        hfu_Err_type    = "E",
                                        hfu_Err_no      = 1,
                                        hfu_Err_Column  = "",
                                        hfu_Err_Message = "Column Date ต้องอยู่ในรูปแบบ " + formateDate
                                    });;
                                    return(ErrorMessage);
                                }
                            }

                            ErrorMessage.Add(new HISUploadErrorMessageDTO
                            {
                                hfu_status      = 'I',
                                hfu_Err_type    = "I",
                                hfu_Err_no      = 1,
                                hfu_Err_Column  = "Total",
                                hfu_Err_Message = result.Tables[0].Rows.Count.ToString()
                            });
                        }
                    }
                    #endregion

                    //----------  Validate Data in File -------------
                    var dataTable = result.Tables[0];

                    // Check column Exist
                    Boolean columnExists = result.Tables[0].Columns.Contains(COL_REF_NO) &&
                                           result.Tables[0].Columns.Contains(COL_HN_NO) &&
                                           result.Tables[0].Columns.Contains(COL_LAB_NO) &&
                                           result.Tables[0].Columns.Contains(COL_DATE);
                    if (columnExists == false)
                    {
                        ErrorMessage.Add(new HISUploadErrorMessageDTO
                        {
                            hfu_status      = 'E',
                            hfu_Err_type    = "C",
                            hfu_Err_no      = 1,
                            hfu_Err_Column  = COL_REF_NO,
                            hfu_Err_Message = "ไม่พบ Column " + COL_REF_NO
                        });
                    }

                    for (var i = 0; i < dataTable.Rows.Count; i++)
                    {
                        for (var j = 0; j < 4; j++)
                        {
                            var data = dataTable.Rows[i][j];

                            // Check column not null
                            if (string.IsNullOrEmpty(data.ToString()))
                            {
                                string columnError = "";
                                if (j == colRefNo)
                                {
                                    columnError = COL_REF_NO;
                                }
                                else if (j == colHNNo)
                                {
                                    columnError = COL_HN_NO;
                                }
                                else if (j == colLabNo)
                                {
                                    columnError = COL_LAB_NO;
                                }
                                else if (j == colSpecDate)
                                {
                                    columnError = COL_DATE;
                                }

                                var chkErrExist = ErrorMessage.FirstOrDefault(e => e.hfu_status == 'W' && e.hfu_Err_no == i + 2);

                                if (chkErrExist == null)
                                {
                                    ErrorMessage.Add(new HISUploadErrorMessageDTO
                                    {
                                        hfu_status      = 'W',
                                        hfu_Err_type    = columnError,
                                        hfu_Err_no      = i + 2,
                                        hfu_Err_Column  = "Required",
                                        hfu_Err_Message = "Field is required"
                                    });
                                }

                                else
                                {
                                    //ErrorMessage.Where(e => e.hfu_status == 'W' && e.hfu_Err_no == i + 1).
                                    //    Select(n => { n.hfu_Err_Message = ""; return n; }).ToList();
                                    chkErrExist.hfu_Err_type += ',' + columnError;
                                }
                            }

                            // Check Date format incorrect
                            //if (j == colSpecDate)
                            //{
                            //    string dateString = data.ToString();
                            //    DateTime dt;
                            //    //string[] formateDate = { HISTemplateActive.hft_date_format }; //  dd/MM/yyyy
                            //    // en-GB , en-US
                            //    //var formateDate = HISTemplateActive.hft_date_format;
                            //    try
                            //    {
                            //        dt = DateTime.Parse(dateString,new CultureInfo("en-US"));

                            //    }
                            //    catch (Exception ex)
                            //    {
                            //        ErrorMessage.Add(new HISUploadErrorMessageDTO
                            //        {
                            //            hfu_status = 'E',
                            //            hfu_Err_type = "E",
                            //            hfu_Err_no = 1,
                            //            hfu_Err_Column = "",
                            //            hfu_Err_Message = "Column Date ต้องอยู่ในรูปแบบ " + formateDate
                            //        }); ;
                            //        return ErrorMessage;
                            //    }
                            //}
                        }
                    }

                    var chkError = ErrorMessage.FirstOrDefault(x => x.hfu_status == 'E');
                    if (chkError != null)
                    {
                        File.Delete(path);
                    }
                    else
                    {
                        ErrorMessage.Add(new HISUploadErrorMessageDTO
                        {
                            hfu_status      = 'I',
                            hfu_Err_type    = "P",
                            hfu_Err_no      = 1,
                            hfu_Err_Column  = "path",
                            hfu_Err_Message = path
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                //create log
            }
            return(ErrorMessage);
        }
 protected virtual bool IsValueOriginEditable(ParameterDTO parameterDTO)
 {
     return(_presenter.CanEditValueOrigin(parameterDTO));
 }
示例#13
0
 private void updateListOfValues(ParameterDTO parameterDTO, IParameter parameter) => _parameterListOfValuesRetriever.UpdateLisOfValues(parameterDTO.ListOfValues, parameter);
示例#14
0
        public async Task <IQueryable <ProductDTO> > SortProducsByParameters(int TypeId, bool StateOrder = true)
        {
            string param           = "Стандарт";
            int    paramId         = 2; // тип штока
            int    paramDiameterId = 4;
            string diameter        = "60";

            var products = await _context.ProductParameters
                           .Include(p => p.Product)
                           .Where(p => p.Product.ProductTypeId == TypeId && p.Value == param && p.ParameterId == paramId)
                           .Select(p => p.Product)
                           .Include(p => p.ProductType)
                           .Include(p => p.ProductParameters)
                           .ToListAsync();

            if (StateOrder == true)
            {
                products = products.OrderBy(v => v.ProductParameters.Where(g => g.ParameterId == paramDiameterId)
                                            .OrderBy(t => Convert.ToInt32(t.Product.Amount)).FirstOrDefault().Product.Amount).ToList();
            }
            else
            {
                products = products.OrderByDescending(v => v.ProductParameters.Where(g => g.ParameterId == paramDiameterId)
                                                      .OrderByDescending(t => t.Product.Amount).FirstOrDefault().Product.Amount).ToList();
            }

            var items = new List <ProductDTO>();

            foreach (var product in products)
            {
                var foundParam = product.ProductParameters.Where(pp => pp.ParameterId == paramDiameterId && pp.Value == diameter)
                                 .FirstOrDefault();
                if (foundParam == null)
                {
                    continue;
                }

                var productDTO = new ProductDTO()
                {
                    ProductId     = product.Id,
                    Number        = product.Number,
                    Manufacturer  = product.Manufacturer,
                    Amount        = product.Amount,
                    PrimeCostEUR  = product.PrimeCostEUR,
                    ProductTypeId = product.ProductTypeId,
                    NameType      = product.ProductType.NameType
                };

                foreach (var typeParam in product.ProductParameters)
                {
                    var paramDTO = new ParameterDTO();
                    var value    = product.ProductParameters.FirstOrDefault(t => t.ParameterId == typeParam.Id);
                    if (value != null)
                    {
                        paramDTO.Id    = value.Id;
                        paramDTO.Value = value.Value;
                    }
                    paramDTO.Id          = typeParam.Id;
                    paramDTO.Name        = typeParam.Product.ProductType.NameType;
                    paramDTO.ParameterId = typeParam.ParameterId;
                    paramDTO.Value       = typeParam.Value;

                    productDTO.Parameters.Add(paramDTO);
                }

                items.Add(productDTO);
            }

            return(items.AsQueryable());
        }
 private void onIsFavoriteSet(ParameterDTO parameterDTO, bool newValue)
 {
     _presenter.SetIsFavorite(parameterDTO, newValue);
 }
 protected override void Context()
 {
     base.Context();
     _parameter    = new PKSimParameter();
     _parameterDTO = new ParameterDTO(_parameter);
 }
 private void configureRepository(BaseEdit activeEditor, ParameterDTO parameter)
 {
     _unitControl.UpdateUnitsFor(activeEditor, parameter);
 }
示例#18
0
 private void setParameterUnit(ParameterDTO parameterDTO, Unit unit)
 {
     OnEvent(() => _presenter.SetParameterUnit(parameterDTO, unit));
 }