Esempio n. 1
0
        public void PropertyService_GetPropertyInfoADO_Test()
        {
            try
            {
                PropertiesDTO property = new PropertiesDTO();

                using (SqlConnection con = new SqlConnection(connectionString))
                {
                    var userId     = Guid.Parse("10445DB1-C5B0-478A-89F6-613450414ED4");
                    var propertyId = Guid.Parse("76589131-9FF7-40CE-A4FD-F5F1C78AD18B");

                    SqlCommand cmd = new SqlCommand("sp_GetPropertyInfo", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter[] qparams =
                    {
                        new SqlParameter("@UserId",     userId),
                        new SqlParameter("@PropertyId", propertyId)
                    };

                    cmd.Parameters.AddRange(qparams);

                    con.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        property.Id         = Guid.Parse(rdr["Id"].ToString());
                        property.UserId     = Guid.Parse(rdr["UserId"].ToString());
                        property.Name       = rdr["Name"].ToString();
                        property.Address    = rdr["Address"].ToString();
                        property.City       = rdr["City"].ToString();
                        property.ContactNo  = rdr["ContactNo"].ToString();
                        property.Owner      = rdr["Owner"].ToString();
                        property.TotalRooms = Convert.ToInt16(rdr["TotalRooms"]);
                    }

                    Assert.IsNotNull(property);
                }
            }
            catch (Exception ex)
            {
                logService.Log("Get Property Info", ex.InnerException.Message, ex.Message, ex.StackTrace);
                Assert.Fail();
            }
        }
Esempio n. 2
0
        public void PropertyService_GetPropertiesADO_Test()
        {
            try
            {
                List <PropertiesDTO> properties = new List <PropertiesDTO>();

                using (SqlConnection con = new SqlConnection(connectionString))
                {
                    var userId = Guid.Parse("10445DB1-C5B0-478A-89F6-613450414ED4");

                    SqlCommand cmd = new SqlCommand("sp_GetOwnerProperties", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@UserId", userId);

                    con.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();

                    while (rdr.Read())
                    {
                        PropertiesDTO property = new PropertiesDTO();

                        property.Id         = Guid.Parse(rdr["Id"].ToString());
                        property.UserId     = Guid.Parse(rdr["UserId"].ToString());
                        property.Name       = rdr["Name"].ToString();
                        property.Address    = rdr["Address"].ToString();
                        property.City       = rdr["City"].ToString();
                        property.ContactNo  = rdr["ContactNo"].ToString();
                        property.Owner      = rdr["Owner"].ToString();
                        property.TotalRooms = Convert.ToInt16(rdr["TotalRooms"]);

                        properties.Add(property);
                    }
                    con.Close();

                    Assert.IsTrue(properties.Count > 0);
                }
            }
            catch (Exception ex)
            {
                logService.Log("Get Owner Properties", ex.InnerException.Message, ex.Message, ex.StackTrace);
                Assert.Fail();
            }
        }
Esempio n. 3
0
        private static int AddNextMultipleValues(PropertiesDTO dto, string[] arr,
                                                 int currentIndex)
        {
            bool   toContinue = true;
            string peekedValue;

            while (toContinue)
            {
                peekedValue = PeekNextInArray(arr, currentIndex);
                if ((peekedValue.Contains("[[[") && peekedValue.Contains("]]]")) ||
                    (arr.Length == (currentIndex + 1)))
                {
                    toContinue = false;
                }
                else
                {
                    dto.Value.Add(peekedValue.Replace("\"", string.Empty));
                    currentIndex++;
                }
            }
            return(currentIndex);
        }
Esempio n. 4
0
        public static List <PropertiesDTO> ReadShortProperties(string properties)
        {
            List <PropertiesDTO> props = new List <PropertiesDTO>();

            string[] splited = properties.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

            for (int i = 0; i <= splited.Length; i++)
            {
                if ((i + 1) >= splited.Length)
                {
                    return(props);
                }

                if (splited[i].Contains("[[[") && splited[i].Contains("]]]"))
                {
                    PropertiesDTO dto = new PropertiesDTO();

                    //dto.Key = splited[i].Replace("[[[", string.Empty).Replace("]]]", string.Empty);
                    dto.Key = splited[i].Substring(3, splited[i].Length - 6);


                    if (PeekNextInArray(splited, i).Contains("[[[") &&
                        PeekNextInArray(splited, i).Contains("]]]"))
                    {
                        continue;
                    }
                    else
                    {
                        int add = AddNextMultipleValues(dto, splited, i);
                        i = add - 1;
                    }
                    props.Add(dto);
                }
            }

            return(props);
        }
Esempio n. 5
0
 public ActionResult Update_Point_Properties(PropertiesDTO propertyModel)
 {
     objElementRepository.Update_Element_Properties(propertyModel);
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Esempio n. 6
0
        public void Update_Element_Properties(PropertiesDTO element_properties)
        {
            IEnumerable <long>       element_ids  = element_properties.elementDto.Select(e => e.ID);
            IEnumerable <tblElement> list_element = _dbcontext.tblElements.Where(t => element_ids.Contains(t.ID));



            foreach (tblElement tbl_element in list_element)
            {
                TagType element_tag_type;

                if (Enum.TryParse(tbl_element.Element_Tag_Type, out element_tag_type))
                {
                    if (element_properties.Point_Name != null && element_properties.Point_Name.Length > 0 && tbl_element.Element_Name.ToLower().Contains(element_properties.Point_Name.ToLower()))
                    {
                        tbl_element.Element_Name = tbl_element.Element_Name.ToLower().Replace(element_properties.Point_Name.ToLower(), element_properties.Point_Name_New);
                    }

                    switch (element_tag_type)
                    {
                    case TagType.site:
                        break;

                    case TagType.equip:
                        break;

                    case TagType.point:

                        if (element_properties.Unit > 0)
                        {
                            tbl_element.Unit_ID = element_properties.Unit;
                        }

                        if (element_properties.Min_Value != null)
                        {
                            tbl_element.Min_Value = element_properties.Min_Value;
                        }
                        if (element_properties.Max_Value != null)
                        {
                            tbl_element.Max_Value = element_properties.Max_Value;
                        }
                        if (element_properties.Freq != null)
                        {
                            tbl_element.Freq      = (long)element_properties.Freq;
                            tbl_element.Freq_Unit = element_properties.Freq_Unit.ToString();
                        }


                        if (element_properties.Recorded_Freq != null)
                        {
                            tbl_element.Recorded_Freq      = (long)element_properties.Recorded_Freq;
                            tbl_element.Recorded_Freq_Unit = element_properties.Recorded_Freq_Unit.ToString();
                        }

                        if (Enum.IsDefined(typeof(Data_Formate), element_properties.Data_Type))
                        {
                            tbl_element.Data_Type = element_properties.Data_Type.ToString();
                        }

                        break;

                    default: throw new TagException(Resources.TagNullException);
                    }
                }
            }
            _dbcontext.SaveChanges();
        }