Beispiel #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);
        }
Beispiel #2
0
        public static List <IDAL.VO.LabelVO> LabeMapper(string raw)
        {
            List <IDAL.VO.LabelVO> data = null;

            if (raw != null)
            {
                try
                {
                    data = new List <IDAL.VO.LabelVO>();

                    int    st           = raw.IndexOf("ZET");
                    string ZETsubstring = raw.Substring(st);

                    string[] tmp = ZETsubstring.Split(new string[] { "ZET" }, StringSplitOptions.RemoveEmptyEntries);

                    List <string> res = null;
                    res = new List <string>(tmp);
                    res = res.Select(str => str.Replace(Environment.NewLine, "")).ToList();

                    foreach (string r in res)
                    {
                        object[]        tmp2 = r.Split('|');
                        IDAL.VO.LabelVO tmp3 = LabeMapper(tmp2);
                        data.Add(tmp3);
                    }
                }
                catch (Exception)
                {
                }
            }
            return(data);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public int SetLabel(IDAL.VO.LabelVO data)
        {
            int result = 0;

            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            string table = this.LabelTabName;

            try
            {
                string        connectionString = this.GRConnectionString;
                string        labeidid         = data.labeidid.HasValue ? data.labeidid.Value.ToString() : null;
                List <string> autoincrement    = new List <string>()
                {
                    "labeidid"
                };

                if (labeidid == null)
                {
                    // INSERT NUOVA
                    result = DBSQL.InsertOperation(connectionString, table, data, autoincrement);
                    log.Info(string.Format("Inserted {0} new records!", result));
                }
                else
                {
                    long labeidid_ = long.Parse(labeidid);
                    // UPDATE
                    Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>()
                    {
                        { "id",
                          new DBSQL.QueryCondition()
                          {
                              Key   = "labeidid",
                              Value = labeidid_,
                              Op    = DBSQL.Op.Equal,
                              Conj  = DBSQL.Conj.None,
                          } },
                    };
                    result = DBSQL.UpdateOperation(connectionString, table, data, conditions);
                    log.Info(string.Format("Updated {0} records!", result));
                }
            }
            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(result);
        }
Beispiel #5
0
        // NO ENTITYFRAMEWORK

        public IDAL.VO.LabelVO GetLabelById(string labeidid)
        {
            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            IDAL.VO.LabelVO labe = null;
            try
            {
                string connectionString = this.GRConnectionString;

                long   labelidid_ = long.Parse(labeidid);
                string table      = this.LabelTabName;

                Dictionary <string, DBSQL.QueryCondition> conditions = new Dictionary <string, DBSQL.QueryCondition>()
                {
                    {
                        "id",
                        new DBSQL.QueryCondition()
                        {
                            Key   = "labeidid",
                            Op    = DBSQL.Op.Equal,
                            Value = labelidid_,
                            Conj  = DBSQL.Conj.None
                        }
                    }
                };
                DataTable data = DBSQL.SelectOperation(connectionString, table, conditions);
                log.Info(string.Format("DBSQL Query Executed! Retrieved {0} record!", LibString.ItemsNumber(data)));
                if (data != null)
                {
                    if (data.Rows.Count == 1)
                    {
                        labe = LabelMapper.LabeMapper(data.Rows[0]);
                        log.Info(string.Format("{0} Records mapped to {1}", LibString.ItemsNumber(labe), LibString.TypeName(labe)));
                    }
                }
            }
            catch (Exception ex)
            {
                log.Info(string.Format("DBSQL Query Executed! Retrieved 0 record!"));
                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);
        }
Beispiel #6
0
        public static IDAL.VO.LabelVO LabeMapper(object[] data)
        {
            IDAL.VO.LabelVO labe = new IDAL.VO.LabelVO();

            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);
        }
Beispiel #7
0
        public IDAL.VO.LabelVO NewLabel(IDAL.VO.LabelVO data)
        {
            IDAL.VO.LabelVO result = null;

            Stopwatch tw = new Stopwatch();

            tw.Start();

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

            string table = this.LabelTabName;

            try
            {
                string connectionString = this.GRConnectionString;

                List <string> pk = new List <string>()
                {
                    "LABEIDID"
                };
                List <string> autoincrement = new List <string>()
                {
                    "labeIdiD"
                };
                // INSERT NUOVA
                DataTable res = DBSQL.InsertBackOperation(connectionString, table, data, pk, autoincrement);
                if (res != null)
                {
                    if (res.Rows.Count > 0)
                    {
                        result = LabelMapper.LabeMapper(res.Rows[0]);
                        log.Info(string.Format("Inserted new record with ID: {0}!", result.labeidid));
                    }
                }
            }
            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(result);
        }
Beispiel #8
0
        public static List <IDAL.VO.LabelVO> LabeMapper(DataTable rows)
        {
            List <IDAL.VO.LabelVO> data = new List <IDAL.VO.LabelVO>();

            if (rows != null)
            {
                if (rows.Rows.Count > 0)
                {
                    foreach (DataRow row in rows.Rows)
                    {
                        IDAL.VO.LabelVO tmp = LabeMapper(row);
                        data.Add(tmp);
                    }
                }
            }

            return(data);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
Beispiel #11
0
        public static IDAL.VO.LabelVO LabeMapper(DataRow row)
        {
            IDAL.VO.LabelVO labe = new IDAL.VO.LabelVO();

            labe.labeidid     = row["LABEIDID"] != DBNull.Value ? (long)row["LABEIDID"] : (long?)null;
            labe.labebarcode  = row["LABEBARCODE"] != DBNull.Value ? (string)row["LABEBARCODE"] : null;
            labe.labeidcont   = row["LABEIDCONT"] != DBNull.Value ? (string)row["LABEIDCONT"] : null;
            labe.labedesc     = row["LABEDESC"] != DBNull.Value ? (string)row["LABEDESC"] : null;
            labe.labeidlab    = row["LABEIDLAB"] != DBNull.Value ? (string)row["LABEIDLAB"] : null;
            labe.labeesam     = row["LABEESAM"] != DBNull.Value ? (long)row["LABEESAM"] : (long?)null;
            labe.labeesamacce = row["LABEESAMACCE"] != DBNull.Value ? (DateTime)row["LABEESAMACCE"] : (DateTime?)null;
            labe.labepaziid   = row["LABEPAZIID"] != DBNull.Value ? (long)row["LABEPAZIID"] : (long?)null;
            labe.labereri     = row["LABERERI"] != DBNull.Value ? (int)row["LABERERI"] : (int?)null;
            labe.labrerinome  = row["LABRERINOME"] != DBNull.Value ? (string)row["LABRERINOME"] : null;
            labe.labeacceid   = row["LABEACCEID"] != DBNull.Value ? (string)row["LABEACCEID"] : null;
            labe.labemateid   = row["LABEMATEID"] != DBNull.Value ? (string)row["LABEMATEID"] : null;
            labe.labeelenanal = row["LABEELENANAL"] != DBNull.Value ? (string)row["LABEELENANAL"] : null;
            labe.labesectid   = row["LABESECTID"] != DBNull.Value ? (string)row["LABESECTID"] : null;
            labe.labesectnome = row["LABESECTNOME"] != DBNull.Value ? (string)row["LABESECTNOME"] : null;
            labe.labedaorprel = row["LABEDAORPREL"] != DBNull.Value ? (DateTime)row["LABEDAORPREL"] : (DateTime?)null;

            return(labe);
        }