Example #1
0
        public ActionResult Edit(component model)
        {
            if (string.IsNullOrEmpty(model.com_module_name))
            {
                ModelState.AddModelError("com_module_name", "Module Name is required.");
            }

            else if (string.IsNullOrEmpty(model.com_page_url))
            {
                ModelState.AddModelError("com_page_url", "page Url is required.");
            }
            if (ModelState.IsValid)
            {
                if (model.com_key > 0)
                {
                    if (_menuService.IsAlreadyExists(model))
                    {
                        ModelState.AddModelError("com_module_name", $" {model.com_module_name} already exists");
                    }
                }

                else
                {
                    model.com_modifiedby = User.Identity.GetUserId();
                    model.com_modifiedon = DateTime.Now.ToEST();


                    _menuService.Edit(model);

                    return(GetSuccessResult(Url.Action("Index", new { @id = model.com_key })));
                }
            }
            return(GetErrorResult(model));
        }
        public ActionResult AddComponent(component model, HttpPostedFileBase Image1)
        {
            var db = new ShopBridgeEntities();

            if (model.Discription != null && model.Name != null && model.Price != 0 && Image1 != null)
            {
                byte[] bytes;
                using (BinaryReader br = new BinaryReader(Image1.InputStream))
                {
                    bytes = br.ReadBytes(Image1.ContentLength);
                }


                db.components.Add(new component
                {
                    Name        = model.Name,
                    Price       = model.Price,
                    Image       = bytes,
                    Discription = model.Discription
                });
                db.SaveChanges();
                return(RedirectToAction("CoponentHomePage"));
            }
            return(View());
        }
        public void TestAddComponentPostMethod()
        {
            Mock <ComponentViewModel> Mockrepo = new Mock <ComponentViewModel>();
            component newComp = new component()
            {
                Name        = "BMW",
                Price       = 252525,
                Discription = "Long Life Car",
                ID          = 1
            };

            var httpContextMock = new Mock <HttpContextBase>();
            var serverMock      = new Mock <HttpServerUtilityBase>();

            serverMock.Setup(x => x.MapPath("~/Images/NBAlogoImg/")).Returns("@c:/Users/jadha/source/repos/ShopBridge/ShopBridge/App_Data/");
            httpContextMock.Setup(x => x.Server).Returns(serverMock.Object);

            var fileMock = new Mock <HttpPostedFileBase>();

            fileMock.Setup(x => x.FileName).Returns("car3.jfif");


            HomeController controller = new HomeController();

            controller.ControllerContext = new ControllerContext(httpContextMock.Object, new RouteData(), controller);


            //Act
            ActionResult result = controller.AddComponent(newComp, fileMock.Object);

            //assert
            fileMock.Verify(x => x.SaveAs("@c:/Users/jadha/source/repos/ShopBridge/ShopBridge/App_Data/car3.jfif"));
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
        }
Example #4
0
        /// <summary>
        /// Converts this instance of <see cref="component"/> to an instance of <see cref="componentDto"/>.
        /// </summary>
        /// <param name="entity"><see cref="component"/> to convert.</param>
        public static componentDto ToDTO(this component entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new componentDto();

            dto.v_ComponentId     = entity.v_ComponentId;
            dto.v_Name            = entity.v_Name;
            dto.i_CategoryId      = entity.i_CategoryId;
            dto.r_BasePrice       = entity.r_BasePrice;
            dto.i_DiagnosableId   = entity.i_DiagnosableId;
            dto.i_IsApprovedId    = entity.i_IsApprovedId;
            dto.i_ComponentTypeId = entity.i_ComponentTypeId;
            dto.i_UIIsVisibleId   = entity.i_UIIsVisibleId;
            dto.i_UIIndex         = entity.i_UIIndex;
            dto.i_ValidInDays     = entity.i_ValidInDays;
            dto.i_IsDeleted       = entity.i_IsDeleted;
            dto.i_InsertUserId    = entity.i_InsertUserId;
            dto.d_InsertDate      = entity.d_InsertDate;
            dto.i_UpdateUserId    = entity.i_UpdateUserId;
            dto.d_UpdateDate      = entity.d_UpdateDate;

            entity.OnDTO(dto);

            return(dto);
        }
Example #5
0
        /// <summary>
        /// Converts this instance of <see cref="componentDto"/> to an instance of <see cref="component"/>.
        /// </summary>
        /// <param name="dto"><see cref="componentDto"/> to convert.</param>
        public static component ToEntity(this componentDto dto)
        {
            if (dto == null)
            {
                return(null);
            }

            var entity = new component();

            entity.v_ComponentId     = dto.v_ComponentId;
            entity.v_Name            = dto.v_Name;
            entity.i_CategoryId      = dto.i_CategoryId;
            entity.r_BasePrice       = dto.r_BasePrice;
            entity.i_DiagnosableId   = dto.i_DiagnosableId;
            entity.i_IsApprovedId    = dto.i_IsApprovedId;
            entity.i_ComponentTypeId = dto.i_ComponentTypeId;
            entity.i_UIIsVisibleId   = dto.i_UIIsVisibleId;
            entity.i_UIIndex         = dto.i_UIIndex;
            entity.i_ValidInDays     = dto.i_ValidInDays;
            entity.i_IsDeleted       = dto.i_IsDeleted;
            entity.i_InsertUserId    = dto.i_InsertUserId;
            entity.d_InsertDate      = dto.d_InsertDate;
            entity.i_UpdateUserId    = dto.i_UpdateUserId;
            entity.d_UpdateDate      = dto.d_UpdateDate;

            dto.OnEntity(entity);

            return(entity);
        }
        public byte[] GetAssemblyBytesFromGuid(Guid guid)
        {
            component cp = _listComponent.Find(c => Guid.Parse(c.guid) == guid);

            if (null == cp)
            {
                throw new Exception($"Failed to retrieve component with guid = {guid}");
            }

            string   filePath = Path.Combine(LibraryPath, cp.fileName.Replace('-', '_'));
            FileInfo file     = new FileInfo(filePath);

            // Preliminary check
            // must exist
            if (!file.Exists)
            {
                throw new PluginException(string.Format("File {0} does not exist. Cannot load Component.", filePath));
            }
            // must be a dll file
            if (!file.Extension.Equals(".dll"))
            {
                throw new PluginException(string.Format("File {0} is not a dll file. Cannot load Component.", filePath));
            }

            return(File.ReadAllBytes(filePath));
        }
Example #7
0
        //[TestMethod]
        public void FirstTest()
        {
            Iformatter chosenFormatter = new FormatterImplementationsV1();
            var        _component      = new component <Iadapter>(chosenFormatter);
            Iadapter   ada             = _component.passAdapter();

            //Assert.IsInstanceOfType(ada, typeof(adapterImplementationV2));
        }
Example #8
0
        //[TestMethod]
        public void FirstTest()
        {
            Iformatter chosenFormatter = new FormatterImplementationsV1();
            var _component = new component<Iadapter>(chosenFormatter);
            Iadapter ada = _component.passAdapter();

            //Assert.IsInstanceOfType(ada, typeof(adapterImplementationV2));
        }
Example #9
0
        public void Run()
        {
            Iformatter chosenFormatter= new FormatterImplementationsV1();
            var _component = new component<Iadapter>(chosenFormatter);

            Iadapter ada = _component.passAdapter();

            ada.connect();
            ada.disconnect();
        }
Example #10
0
        ComponentList FromDbComponentToViewComponent(component component)
        {
            var addableComponent = new ComponentList();

            addableComponent.Id = component.ComponentId;
            addableComponent.CriticalityLevel = component.criticality_level.CriticalityLevel;
            addableComponent.Name             = component.NameAndVersion;
            addableComponent.Vendor           = component.VendorLink;

            return(addableComponent);
        }
        public void UpdateMedicalExam(ref OperationResult pobjOperationResult, bool pbIsChangeName, componentDto pobjDtoEntity, List <string> ClientSession)
        {
            //mon.IsActive = true;

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();

                #region Validar Nombre de componente

                if (pobjDtoEntity != null && pbIsChangeName == true)
                {
                    OperationResult objOperationResult6  = new OperationResult();
                    string          strfilterExpression1 = string.Format("v_Name==\"{0}\"&&i_Isdeleted==0", pobjDtoEntity.v_Name);

                    var _recordCount1 = GetMedicalExamCount(ref objOperationResult6, strfilterExpression1);

                    if (_recordCount1 != 0)
                    {
                        pobjOperationResult.ErrorMessage = "El nombre del componente ya existe";
                        return;
                    }
                }
                #endregion
                // Obtener la entidad fuente
                var objEntitySource = (from a in dbContext.component
                                       where a.v_ComponentId == pobjDtoEntity.v_ComponentId
                                       select a).FirstOrDefault();

                // Crear la entidad con los datos actualizados
                pobjDtoEntity.d_UpdateDate   = DateTime.Now;
                pobjDtoEntity.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                component objEntity = componentAssembler.ToEntity(pobjDtoEntity);

                // Copiar los valores desde la entidad actualizada a la Entidad Fuente
                dbContext.component.ApplyCurrentValues(objEntity);

                // Guardar los cambios
                dbContext.SaveChanges();

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "EXAMEN MÉDICO", "v_MedicalExamId=" + objEntity.v_ComponentId.ToString(), Success.Ok, null);
                return;
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.ACTUALIZACION, "EXAMEN MÉDICO", "v_MedicalExamId=" + pobjDtoEntity.v_ComponentId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage);
                return;
            }
        }
Example #12
0
        public static void AddProperty(this component theComponent, property property)
        {
            if (theComponent.Items == null)
            {
                theComponent.Items = new object[0];
            }

            object[] items = theComponent.Items;
            Array.Resize(ref items, theComponent.Items.Length + 1);
            items[items.Length - 1] = property;
            theComponent.Items      = items;
        }
 public Guid GetGuidFromName(string name)
 {
     try
     {
         component cp = _listComponent.Find(c => c.name == name);
         return(Guid.Parse(cp.guid));
     }
     catch (Exception /*ex*/)
     {
         return(Guid.Empty);
     }
 }
Example #14
0
        public bool Delete(component entity)
        {
            bool CanDelete = true;


            if (CanDelete)
            {
                _unitOfWork.MenuRepository.Delete(entity.com_key);
                _unitOfWork.Save();
                _unitOfWork.Commit();
            }
            return(CanDelete);
        }
        public double GetDoubleParameterDefaultValue(Guid guid, string name)
        {
            component cp    = _listComponent.Find(c => Guid.Parse(c.guid) == guid);
            parameter param = cp.paramDefaults.Find(p => p.name == name);

            if (param is parameterDouble paramDouble)
            {
                return(paramDouble.value);
            }
            else
            {
                return(0.0);
            }
        }
        public void bulletTriggerTest()
        {
            component com = new component();
            int       y   = com.bulletTrigger();

            if (y > 0)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
        public int GetMultiParameterDefaultValue(Guid guid, string name)
        {
            component cp    = _listComponent.Find(c => Guid.Parse(c.guid) == guid);
            parameter param = cp.paramDefaults.Find(p => p.name == name);

            if (param is parameterInt paramInt)
            {
                return(paramInt.value);
            }
            else
            {
                return(0);
            }
        }
        public bool GetBoolParameterDefaultValue(Guid guid, string name)
        {
            component cp    = _listComponent.Find(c => Guid.Parse(c.guid) == guid);
            parameter param = cp.paramDefaults.Find(p => p.name == name);

            if (param is parameterBool paramBool)
            {
                return(paramBool.value);
            }
            else
            {
                return(false);
            }
        }
        static void Main(string[] args)
        {
            var c = new component {
                section = new section {
                    title = "Reason for Visit", text = new text {
                        content = new content {
                            ID = "ID3EZZKACA", text = "No Reason for Visit was given."
                        }
                    }
                }
            };

            string s = ToXmlString(c);
        }
Example #20
0
 public static IEnumerable <property> Properties(this component theComponent)
 {
     if (theComponent.Items == null)
     {
         yield break;
     }
     foreach (var item in theComponent.Items)
     {
         if (item is property)
         {
             yield return(item as property);
         }
     }
 }
        public void AddMedicalExam(ref OperationResult pobjOperationResult, componentDto pobjDtoEntity, List <string> ClientSession)
        {
            //mon.IsActive = true;
            string NewId = "(No generado)";

            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();
                component             objEntity = componentAssembler.ToEntity(pobjDtoEntity);

                //var query = from A in dbContext.component

                var Result = (from A in dbContext.component
                              where A.i_IsDeleted == 0 && A.v_Name == pobjDtoEntity.v_Name
                              select A).FirstOrDefault();
                if (Result != null)
                {
                    pobjOperationResult.ErrorMessage = "El nombre ya se encuentra registrado";
                    pobjOperationResult.Success      = 0;
                    return;
                }

                objEntity.d_InsertDate   = DateTime.Now;
                objEntity.i_InsertUserId = Int32.Parse(ClientSession[2]);
                objEntity.i_IsDeleted    = 0;
                // Autogeneramos el Pk de la tabla
                int intNodeId = int.Parse(ClientSession[0]);
                NewId = Common.Utils.GetNewId(intNodeId, Utils.GetNextSecuentialId(intNodeId, 17), "ME");
                objEntity.v_ComponentId = NewId;


                dbContext.AddTocomponent(objEntity);
                dbContext.SaveChanges();

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EXAMEN MÉDICO", "v_MedicalExamId=" + NewId.ToString(), Success.Ok, null);
                return;
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "EXAMEN MÉDICO", "v_MedicalExamId=" + NewId.ToString(), Success.Failed, pobjOperationResult.ExceptionMessage);
                return;
            }
        }
Example #22
0
        component GetComponent(MemberInfo mi, string columnPrefix = "")
        {
            if (!_identificationRules.Any(rule => rule(mi)))
            {
                return(null);
            }

            var fields = mi.DeclaringType.GetSettableFieldsAndProperties();

            if (fields.Any(mi.IsBackingFieldFor))
            {
                return(null);                                  //we don't want to map the wrapping properties
            }
            var component = new component()
            {
                name = mi.Name, access = mi.Access()
            };
            var prefix = columnPrefix + component.name.Sanitise() + "_";
            var fieldsAndProperties = mi.ReturnType().GetSettableFieldsAndProperties().ToList();
            var parent = fieldsAndProperties.SingleOrDefault(p => p.Name.TrimStart('_').ToLower() == "parent");

            if (parent != null)
            {
                fieldsAndProperties.Remove(parent);
                component.parent = new parent()
                {
                    name = parent.Name,
                };
            }

            foreach (var memberInfo in fieldsAndProperties)
            {
                var subcomponent = GetComponent(memberInfo, prefix);
                if (subcomponent != null)
                {
                    component.component1.Add(component);
                    continue;
                }
                var property = CreateBasicProperties.GetProperty(memberInfo, prefix, propMi => false);
                if (property != null)
                {
                    component.property.Add(property);
                    continue;
                }
            }
            return(component);
        }
Example #23
0
        // load freebim data form webservice and store into XML
        private void button2_Click(object sender, EventArgs e)
        {
            library[] libraries = service.getAllLibraries(dbuser, dbpw);
            foreach (library l in libraries)
            {
                if (l.name == "freeBIM")
                {
                    orderedRel[] root = service.getChildsOf(dbuser, dbpw, l.freebimId);
                    foreach (orderedRel r in root)
                    {
                        getAllChildsOf(r);
                    }
                }
            }

            freeBimWebserviceTable           = new DataTable();
            freeBimWebserviceTable.TableName = "allComponents";
            freeBimWebserviceTable.Columns.Add("bsddGuid");
            freeBimWebserviceTable.Columns.Add("Code");
            freeBimWebserviceTable.Columns.Add("desc");
            freeBimWebserviceTable.Columns.Add("freebimId");
            freeBimWebserviceTable.Columns.Add("name");
            freeBimWebserviceTable.Columns.Add("children");

            component[] componentList = new component[guidList.Count];
            int         i             = 0;

            foreach (string s in guidList)
            {
                componentList[i++] = service.getComponent(dbuser, dbpw, s);
            }
            foreach (component c in componentList)
            {
                DataRow row = freeBimWebserviceTable.NewRow();
                row["bsddGuid"]  = c.bsddGuid;
                row["code"]      = c.code;
                row["desc"]      = c.desc;
                row["freebimId"] = c.freebimId;
                row["name"]      = c.name;
                row["children"]  = orderedRelToString(childsOf[c.freebimId]);

                freeBimWebserviceTable.Rows.Add(row);
                freebimName.Add(c.freebimId, c.name);
            }
            dataGridView7.DataSource = freeBimWebserviceTable;
            freeBimWebserviceTable.WriteXml("freeBIMData.xml");
        }
Example #24
0
        public ViewResult IndexComponent()
        {
            List <component> myComponents = new List <component>();
            var mComponent = db.Glasses.ToList();

            foreach (var c in mComponent)
            {
                component myComponent = new component();
                myComponent.Id   = c.Id;
                myComponent.Name = c.Name;
                myComponents.Add(myComponent);
                myComponent = null;
            }
            ViewBag.Title     = "Glass";
            ViewBag.myControl = "Glass";
            return(View(myComponents));
        }
Example #25
0
        public ComponentDetails FromDbComponentToComponentDetailed(component component)
        {
            var analogs = new List <ComponentList>();

            foreach (component com in component.component2)
            {
                analogs.Add(FromDbComponentToViewComponent(com));
            }

            ComponentDetails details = new ComponentDetails()
            {
                ComponentName    = component.NameAndVersion,
                CriticalityLevel = component.criticality_level.CriticalityLevel,
                Vendor           = component.VendorLink,
                Analogs          = analogs
            };

            return(details);
        }
Example #26
0
 public void SaveNewItem()
 {
     try {
         using (var db = new course_work_Entities())
         {
             var      s = from p in db.producers where p.name.Equals(producerField.Text) select p;
             producer producer;
             if (!s.Any())
             {
                 producer = new producer()
                 {
                     name = producerField.Text,
                 };
                 db.producers.Add(producer);
                 db.SaveChanges();
             }
             else
             {
                 producer = s.First();
             }
             var component = new component()
             {
                 name        = nameField.Text,
                 description = descriptionField.Text,
                 category1   = (from c in db.categories where c.name.Equals(categoryField.Text) select c).First(),
                 producer1   = producer,
                 price       = decimal.Parse(priceField.Text)
             };
             db.components.Add(component);
             db.SaveChanges();
             Init();
         }
         list.SelectedIndex = list.Items.Count - 1;
     }
     catch (FormatException)
     {
         MessageBox.Show("Очікується число", "Помилка введення");
     }
     catch (Exception)
     {
         MessageBox.Show("Щось пішло не так", "Помилка");
     }
 }
Example #27
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ViewBag.Menues = _menuService.GetAllMenues()
                             .Select(m => new { Value = m.com_key, Text = m.com_module_name })
                             .ToList()
                             .Select(m => new SelectListItem {
                Value = m.Value.ToString(), Text = m.Text
            });
            component com_data = _menuService.GetDetails(id.Value);

            if (com_data == null)
            {
                return(HttpNotFound());
            }
            return(GetViewResult(com_data));
        }
Example #28
0
        private IEnumerable <component> ProcessComponent(IEnumerable <Component> components)
        {
            foreach (var component in components.OrderBy(c => c.Name))
            {
                var componentNode = new component();
                componentNode.@class = component.Specification.Name;
                componentNode.name   = component.Name;

                foreach (var property in component.Properties.OrderBy(p => p.PropertyName))
                {
                    ComponentProperty representedProperty = property.RepresentedProperty;
                    var propertyNode = new property();
                    propertyNode.name    = representedProperty.Name;
                    propertyNode.type1   = representedProperty.Type;
                    propertyNode.column  = property.MappedColumn().Name.BackTick();
                    propertyNode.notnull = true;                     // This must be true for Component Properties.
                    componentNode.AddProperty(propertyNode);
                }
                yield return(componentNode);
            }
        }
 public Component(component _component)
 {
     InitializeComponent();
     this._component                  = _component;
     this.name_text.Content           = this._component.name.ToUpper();
     this.description_text.Content    = this._component.description;
     this.id_text.Content             = this._component.id.ToString();
     this.mode_value_button.IsChecked = this._component.mode == 1 ? true : false;
     this.value_slider.Value          = Convert.ToDouble(this._component.value);
     this.value_slider_text.Text      = this._component.value.ToString();
     this.name_edit_text.Text         = this._component.name;
     this.description_edit_text.Text  = this._component.description;
     try
     {
         this.type_text.Content = this._component.type.ToString();
     }
     catch (Exception e)
     {
         StatusBar.setConsoleTxt(e.Message);
     }
 }
Example #30
0
        public ViewResult IndexComponent()
        {
            List <component> myComponents = new List <component>();
            var mComponent = db.Processes.ToList();

            foreach (var c in mComponent)
            {
                if (!(c.Name.Contains("Pour") || c.Name.Contains("Stir")))
                {
                    //I need to exclude this process pour and stir.
                    component myComponent = new component();
                    myComponent.Id   = c.Id;
                    myComponent.Name = c.Name;
                    myComponents.Add(myComponent);
                    myComponent = null;
                }
            }
            ViewBag.Title     = "Ritual";
            ViewBag.myControl = "Process";
            return(View(myComponents));
        }
        public ActionResult Index()
        {
            ViewBag.Message = "Learn or Remember how to make basic Cocktails";
            //ViewBag.Message0 ="May your tip jar stay full";
            List <component> myCocktails = new List <component>();
            //var mCocktails = db.CockTails.ToList();
            var mCocktails = from cocks in db.CockTails select new { cocks.CocktailId, cocks.Name };

            mCocktails = mCocktails.OrderBy(c => c.Name);

            foreach (var c in mCocktails)
            {
                component myComponent = new component();
                myComponent.Id   = c.CocktailId;
                myComponent.Name = c.Name;
                myCocktails.Add(myComponent);
                myComponent = null;
            }
            ViewBag.Title     = "All Cocktails";
            ViewBag.myControl = "Cocktail";
            return(View(myCocktails));
        }
Example #32
0
    /// <summary>
    /// web 的 储存
    /// </summary>
    /// <param name="web"></param>
    public void InitData(string web)
    {
        componentWeb          = new component();
        componentWeb.pos      = new xyz();
        componentWeb.scale    = new xyz();
        componentWeb.rotation = new xyzw();
        componentWeb.name     = gameObject.name;
        componentWeb.id       = id;

        componentWeb.pos.x = transform.position.x;
        componentWeb.pos.y = transform.position.y;
        componentWeb.pos.z = transform.position.z;

        componentWeb.scale.x = transform.localScale.x;
        componentWeb.scale.y = transform.localScale.y;
        componentWeb.scale.z = transform.localScale.z;

        componentWeb.rotation.x = transform.rotation.x;
        componentWeb.rotation.y = transform.rotation.y;
        componentWeb.rotation.z = transform.rotation.z;
        componentWeb.rotation.w = transform.rotation.w;
    }