Exemple #1
0
        public IBLL.DTO.LabelDTO GetLabelById(string labeidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            IBLL.DTO.LabelDTO labe = null;

            try
            {
                IDAL.VO.LabelVO labe_ = this.dal.GetLabelById(labeidid);
                labe = LabelMapper.LabeMapper(labe_);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(labe), LibString.TypeName(labe_), LibString.TypeName(labe)));
            }
            catch (Exception ex)
            {
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(labe);
        }
Exemple #2
0
        public IBLL.DTO.LabelDTO AddLabel(IBLL.DTO.LabelDTO data)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            IBLL.DTO.LabelDTO toReturn = null;

            try
            {
                data.labeidid = null;
                IDAL.VO.LabelVO data_ = LabelMapper.LabeMapper(data);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_)));
                IDAL.VO.LabelVO stored = dal.NewLabel(data_);
                log.Info(string.Format("{0} {1} items added and got back!", LibString.ItemsNumber(stored), LibString.TypeName(stored)));
                toReturn = LabelMapper.LabeMapper(stored);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(toReturn), LibString.TypeName(stored), LibString.TypeName(toReturn)));
            }
            catch (Exception ex)
            {
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(toReturn);
        }
Exemple #3
0
        public static List <IBLL.DTO.LabelDTO> LabeMapper(string raw)
        {
            List <IBLL.DTO.LabelDTO> data = null;

            if (raw != null)
            {
                try
                {
                    data = new List <IBLL.DTO.LabelDTO>();

                    /*
                     * int st = raw.IndexOf("ZET");
                     * string ZETsubstring = raw.Substring(st);
                     *
                     * string[] tmp = ZETsubstring.Split(new string[] { "ZET" }, StringSplitOptions.RemoveEmptyEntries);
                     */

                    List <string> res = GeneralPurposeLib.LibString.GetAllValuesSegments(raw, "ZET");
                    //res = new List<string>(tmp);
                    //res = res.Select(str => str.Replace(Environment.NewLine, "")).ToList();

                    foreach (string r in res)
                    {
                        object[]          tmp2 = r.Split('|');
                        IBLL.DTO.LabelDTO tmp3 = LabeMapper(tmp2);
                        data.Add(tmp3);
                    }
                }
                catch (Exception)
                {
                }
            }
            return(data);
        }
Exemple #4
0
        public static IBLL.DTO.LabelDTO LabeMapper(object[] data)
        {
            IBLL.DTO.LabelDTO labe = new IBLL.DTO.LabelDTO();

            try
            {
                labe.labeesam = long.Parse((string)data[0]);
            }
            catch (Exception)
            {
                labe.labeesam = null;
            }
            labe.labebarcode = data[1] != null ? (string)data[1] : null;
            labe.labedesc    = data[2] != null ? (string)data[2] : null;
            labe.labeidcont  = data[3] != null ? (string)data[3] : null;
            labe.labeidlab   = data[6] != null ? (string)data[6] : null;
            //labe.idReq = (string)data[7];
            try
            {
                labe.labeesamacce = DateTime.ParseExact(((string)data[8]), "yyyyMMddHHmm", null);
            }
            catch (Exception)
            {
                labe.labeesamacce = null;
            }
            try
            {
                labe.labereri = int.Parse((string)data[17]);
            }
            catch (Exception)
            {
                labe.labereri = null;
            }
            labe.labrerinome  = data[18] != null ? (string)data[18] : null;
            labe.labeacceid   = data[19] != null ? (string)data[19] : null;
            labe.labemateid   = data[20] != null ? (string)data[20] : null;
            labe.labeelenanal = data[22] != null ? (string)data[22] : null;
            labe.labesectid   = data[23] != null ? (string)data[23] : null;
            labe.labesectnome = data[24] != null ? (string)data[24] : null;
            try
            {
                labe.labedaorprel = DateTime.ParseExact(((string)data[25]), "yyyyMMddHHmm", null);
            }
            catch (Exception)
            {
                labe.labedaorprel = null;
            }

            return(labe);
        }
Exemple #5
0
        public static IDAL.VO.LabelVO LabeMapper(IBLL.DTO.LabelDTO data)
        {
            IDAL.VO.LabelVO labe = null;
            try
            {
                Mapper.Initialize(cfg => cfg.CreateMap <IBLL.DTO.LabelDTO, IDAL.VO.LabelVO>());
                Mapper.AssertConfigurationIsValid();
                labe = Mapper.Map <IDAL.VO.LabelVO>(data);
            }
            catch (AutoMapperConfigurationException ex)
            {
                log.Error(string.Format("AutoMapper Configuration Error!\n{0}", ex.Message));
            }
            catch (AutoMapperMappingException ex)
            {
                log.Error(string.Format("AutoMapper Mapping Error!\n{0}", ex.Message));
            }

            return(labe);
        }
Exemple #6
0
        public IBLL.DTO.LabelDTO UpdatLabel(IBLL.DTO.LabelDTO data)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

            log.Info(string.Format("Starting ..."));

            int stored = 0;

            IBLL.DTO.LabelDTO toReturn = null;
            string            id       = data.labeidid.ToString();

            try
            {
                if (id == null || GetLabelById(id) == null)
                {
                    string msg = string.Format("No record found with the id {0}! Updating is impossible!", id);
                    log.Info(msg);
                    log.Error(msg);
                    return(null);
                }
                IDAL.VO.LabelVO data_ = LabelMapper.LabeMapper(data);
                log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_)));
                stored   = dal.SetLabel(data_);
                toReturn = GetLabelById(data.labeidid.ToString());
                log.Info(string.Format("{0} {1} items added and {2} {3} retrieved back!", stored, LibString.TypeName(data_), LibString.ItemsNumber(toReturn), LibString.TypeName(toReturn)));
            }
            catch (Exception ex)
            {
                string msg = "An Error occured! Exception detected!";
                log.Info(msg);
                log.Error(msg + "\n" + ex.Message);
            }

            tw.Stop();
            log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed)));

            return(toReturn);
        }