public ResourceViewModel(resources res) { this.id = res.Id; this.path = res.path; this.type = res.type; this.article_id = res.article_id; }
public void reduceResources(resources availableResources) { availableResources.airResources -= airResources; availableResources.earthResources -= earthResources; availableResources.fireResources -= fireResources; availableResources.waterResources -= waterResources; }
public void editDownloadableResource(object sender, EventArgs e) { Model1 _db = new Model1(); int id = int.Parse(ViewState["ResID"].ToString()); resources res = (from resources in _db.resources where resources.ResourceID == id select resources).FirstOrDefault(); TextBox text = (TextBox)Page.FindControlRecursive("editDownloadResourceName"); FileUpload file = (FileUpload)Page.FindControlRecursive("editDownloadResourceFile"); if (file.HasFile) { string fileName = Path.GetFileName(file.FileName); string path = "~/Subjects/" + subjectID + "/Downloadables/"; file.SaveAs(Server.MapPath(path) + fileName); res.ResourceName = text.Text; res.ResourcePath = fileName; _db.SaveChanges(); } else { res.ResourceName = text.Text; _db.SaveChanges(); } Refresh(); }
public bool AddTaskResource(int blockID, string taskName, string taskText, DateTime deadline) { var myResource = new resources(); myResource.BlockID = blockID; myResource.ResourceName = taskName; myResource.ResourcePath = taskName; myResource.ResourceType = "task"; myResource.IsVisible = false; using (Model1 _db = new Model1()) { _db.resources.Add(myResource); _db.SaveChanges(); var myTask = new taskresources(); myTask.ResourceID = myResource.ResourceID; myTask.TaskName = taskName; myTask.Text = taskText; myTask.Deadline = deadline; _db.taskresources.Add(myTask); _db.SaveChanges(); int subjectID = (from blocks in _db.blocks where blocks.BlockID == blockID select blocks.SubjectID).First(); Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Subjects/" + subjectID) + "/Tasks/" + myResource.ResourceID); } return(true); }
public void saveResources(string path, string type, List <string> atr) { // save button string name, desc; using (Model1Container1 context = new Model1Container1()) { resources r = new resources() { path = path, added_at = DateTime.Now.ToString(), type = type }; context.resources.Add(r); for (var i = 0; i < atr.Count; i += 2) { name = atr[i]; desc = atr[i + 1]; atributes a = new atributes() { name = name, description = desc, resource = r }; context.atributes.Add(a); } context.SaveChanges(); } }
public bool AddRiddleResource(int blockId, string name, string audioName, string imageName, string ogtext, string trtext, string answer) { var myResource = new resources(); myResource.BlockID = blockId; myResource.ResourceName = name; myResource.ResourcePath = audioName; myResource.ResourceType = "riddle"; myResource.IsVisible = false; using (Model1 _db = new Model1()) { _db.resources.Add(myResource); _db.SaveChanges(); var myRiddle = new riddleresources(); myRiddle.ResourceID = myResource.ResourceID; myRiddle.AudioPath = audioName; myRiddle.ImagePath = imageName; myRiddle.RiddleName = name; myRiddle.Text = ogtext; myRiddle.TranslatedText = trtext; myRiddle.Answer = answer; _db.riddleresources.Add(myRiddle); _db.SaveChanges(); } return(true); }
public int Create(ResourceViewModel resourceRepository) { var res = new resources { article_id = resourceRepository.article_id, path = resourceRepository.path, type = resourceRepository.type }; return(_resourceRepository.Create(res)); }
public bool possibleToBuy(resources availableResources) { if (availableResources.airResources < airResources || availableResources.earthResources < earthResources || availableResources.waterResources < waterResources || availableResources.fireResources < fireResources) { return(false); } return(true); }
public void ChangeVisibility(object sender, CommandEventArgs e) { Model1 _db = new Model1(); int resID = int.Parse(e.CommandArgument.ToString()); resources res = (from resources in _db.resources where resources.ResourceID == resID select resources).FirstOrDefault(); if (res != null) { res.IsVisible = !res.IsVisible; _db.SaveChanges(); Refresh(); } }
public bool DeleteResource(int id) { using (Model1 _db = new Model1()) { resources res = (from resources in _db.resources where resources.ResourceID == id select resources).FirstOrDefault(); if (res != null) { _db.resources.Remove(res); _db.SaveChanges(); } } return(true); }
public void EditTextResource(object sender, EventArgs e) { Model1 _db = new Model1(); int id = int.Parse(ViewState["ResID"].ToString()); resources res = (from resources in _db.resources where resources.ResourceID == id select resources).FirstOrDefault(); TextBox text = (TextBox)Page.FindControlRecursive("editTextResource"); if (res != null) { res.ResourcePath = text.Text; _db.SaveChanges(); Refresh(); } }
public void ShowEditText(object sender, CommandEventArgs e) { ViewState["ResID"] = e.CommandArgument.ToString(); ModalPopupExtender modalPopupExtender = (ModalPopupExtender)Page.FindControlRecursive("EditTextPopup"); modalPopupExtender.Show(); Model1 _db = new Model1(); int id = int.Parse(ViewState["ResID"].ToString()); resources res = (from resources in _db.resources where resources.ResourceID == id select resources).FirstOrDefault(); TextBox text = (TextBox)Page.FindControlRecursive("editTextResource"); text.Text = res.ResourcePath; }
public bool AddResources(string resourceName, string resourcePath, int blockId, string resourceType) { var myResource = new resources(); myResource.BlockID = blockId; myResource.ResourceName = resourceName; myResource.ResourcePath = resourcePath; myResource.IsVisible = false; myResource.ResourceType = resourceType; using (Model1 _db = new Model1()) { _db.resources.Add(myResource); _db.SaveChanges(); } return(true); }
public int AddTestResource(int blockID, string testName, string zip) { var myResource = new resources(); myResource.BlockID = blockID; myResource.IsVisible = false; myResource.ResourceName = testName; myResource.ResourceType = "test"; myResource.ResourcePath = zip; using (Model1 _db = new Model1()) { _db.resources.Add(myResource); _db.SaveChanges(); } return(myResource.ResourceID); }
public void EditVideoResource(object sender, EventArgs e) { Model1 _db = new Model1(); int id = int.Parse(ViewState["ResID"].ToString()); resources res = (from resources in _db.resources where resources.ResourceID == id select resources).FirstOrDefault(); TextBox name = (TextBox)Page.FindControlRecursive("EditVideoResourceName"); TextBox path = (TextBox)Page.FindControlRecursive("EditVideoPath"); string link = path.Text.Replace("watch?v=", "embed/"); System.Diagnostics.Debug.WriteLine("hasta aqui"); res.ResourceName = name.Text; res.ResourcePath = link; _db.SaveChanges(); Refresh(); }
public void EditImageResource(object sender, EventArgs e) { FileUpload fileUpload = (FileUpload)Page.FindControlRecursive("EditImageResourceFile"); if (fileUpload.HasFile) { string fileName = Path.GetFileName(fileUpload.FileName); string path = "~/Subjects/" + subjectID + "/Images/"; fileUpload.SaveAs(Server.MapPath(path) + fileName); Model1 _db = new Model1(); int id = int.Parse(ViewState["ResID"].ToString()); resources res = (from resources in _db.resources where resources.ResourceID == id select resources).FirstOrDefault(); res.ResourcePath = fileName; _db.SaveChanges(); Refresh(); } }
protected void Page_Load(object sender, EventArgs e) { var _db = new Model1(); resID = Convert.ToInt32(Request.QueryString["ResourceID"]); id = resID; resources res = (from resources in _db.resources where resources.ResourceID == resID select resources).First(); int subjectID = (from blocks in _db.blocks where blocks.BlockID == res.BlockID select blocks.SubjectID).First(); frame.Src = "~/Subjects/" + subjectID + "/Tests/" + res.ResourceID + "/index.html"; string userIDtmp = User.Identity.GetUserId(); userID = userIDtmp; string nametmp = User.Identity.GetName() + " " + User.Identity.GetSurname1() + " " + User.Identity.GetSurname2(); userName = nametmp; subID = subjectID; }
protected bindingTemplate createWADLBinding(QName serviceQName, String portName, Uri serviceUrl, resources res) { bindingTemplate bindingTemplate = new bindingTemplate(); // Set BusinessService Key bindingTemplate.serviceKey = (UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart())); List <tModelInstanceInfo> items = new List <tModelInstanceInfo>(); if (serviceUrl != null) { // Set AccessPoint accessPoint accessPoint = new accessPoint(); accessPoint.useType = (AccessPointType.endPoint.ToString()); accessPoint.Value = ((serviceUrl.ToString())); bindingTemplate.Item = (accessPoint); // Set Binding Key String bindingKey = UDDIKeyConvention.getBindingKey(properties, serviceQName, portName, serviceUrl); bindingTemplate.bindingKey = (bindingKey); bindingTemplate.description = Common2UDDI.mapdescription(getDescription(res.doc), lang).ToArray(); // reference wsdl:binding tModel tModelInstanceInfo tModelInstanceInfoBinding = new tModelInstanceInfo(); tModelInstanceInfoBinding.tModelKey = (keyDomainURI + "binding"); instanceDetails id = new instanceDetails(); id.instanceParms = portName; tModelInstanceInfoBinding.instanceDetails = (id); tModelInstanceInfoBinding.description = Common2UDDI.mapdescription("The binding that this endpoint implements. " + bindingTemplate.description[0].Value + " The instanceParms specifies the port local name.", lang).ToArray(); items.Add(tModelInstanceInfoBinding); tModelInstanceInfo tModelInstanceInfoPortType = new tModelInstanceInfo(); tModelInstanceInfoPortType.tModelKey = (keyDomainURI + "rest"); tModelInstanceInfoPortType.description = Common2UDDI.mapdescription("The wadl:Resource:base implements.", lang).ToArray(); items.Add(tModelInstanceInfoPortType); } bindingTemplate.tModelInstanceDetails = items.ToArray(); return(bindingTemplate); }
private string GetGuerrillaDTO(string name) { //load guerrilla var guerrilla = (from guerrillaDB in _context.Guerrilla where guerrillaDB.Name.Equals(name) select new guerrilla() { guerrillaName = guerrillaDB.Name, name = guerrillaDB.Name, email = guerrillaDB.Email, faction = guerrillaDB.Faction, rank = guerrillaDB.Rank, timestamp = guerrillaDB.Timestamp }).Single(); //load resources resources resources = new resources(); List <GuerrillaResources> resourcesDB = _context.GuerrillaResources.Where(r => r.Guerrilla.Equals(name)).ToList(); foreach (GuerrillaResources guerrillaResources in resourcesDB) { if (guerrillaResources.Resource.Equals(_oil)) { resources.oil = guerrillaResources.Quantity; } if (guerrillaResources.Resource.Equals(_money)) { resources.money = guerrillaResources.Quantity; } if (guerrillaResources.Resource.Equals(_people)) { resources.people = guerrillaResources.Quantity; } } guerrilla.resources = resources; //load units buildings buildings = new buildings(); army army = new army(); List <GuerrillaUnits> unitsDB = _context.GuerrillaUnits.Where(u => u.Guerrilla.Equals(name)).ToList(); foreach (GuerrillaUnits guerrillaUnits in unitsDB) { if (guerrillaUnits.Unit.Equals(_bunker)) { buildings.bunker = guerrillaUnits.Quantity; } if (guerrillaUnits.Unit.Equals(_assault)) { army.assault = guerrillaUnits.Quantity; } if (guerrillaUnits.Unit.Equals(_engineer)) { army.engineer = guerrillaUnits.Quantity; } if (guerrillaUnits.Unit.Equals(_tank)) { army.tank = guerrillaUnits.Quantity; } } guerrilla.resources = resources; guerrilla.buildings = buildings; guerrilla.army = army; return(JsonConvert.SerializeObject(guerrilla)); }
public string Modify(string valueToModify, CustomizationContextData context) { Logger.DebugLine("Enumeration Started for " + context.UserIdentity.Name); string GatewayName = AGCheck.ISAGEE(context); #if DEBUG GatewayName = "c.mac.org.il"; #endif Logger.DebugLine("SDK in debug mode. Gateway always set to true."); resources AllApps = Helpers.Deserialize <resources>(valueToModify, resourcesSerializer); if (GatewayName != "") { try { List <string> UserGroups = Helpers.GetGroups(context.UserIdentity.Name); Logger.DebugLine("Detected " + UserGroups.Count + " AD groups."); List <resourceType> AppMod = new List <resourceType>(); Logger.DebugLine(string.Join(",", UserGroups.ToArray())); try { Logger.DebugLine("Match result employees:" + UserGroups.Contains("agee-employees")); if (UserGroups.Contains("agee-employees")) { UserGroups.Clear(); UserGroups = null; Logger.DebugLine("Adding only employees apps."); foreach (resourceType App in AllApps.resource) { if (App.title == "Outlook2010" || App.title == "Outlook2016" || App.title == "מכבי ידע" || App.title == "מקוונים אישית אליך-פורטל סאפ") { Logger.DebugLine("Matched " + App.title + ". Adding to Mod Group"); AppMod.Add(App); } } AllApps.resource = AppMod.ToArray(); string CustomApps = Helpers.Serialize(AllApps, resourcesSerializer); return(CustomApps); } } catch (Exception rdx) { Logger.DebugLine("Could not do something in employees:" + rdx.Message); } try { Logger.DebugLine("match result noclicks:" + UserGroups.Contains("agee-full-without-clicks")); if (UserGroups.Contains("agee-full-without-clicks")) { UserGroups.Clear(); UserGroups = null; #if DEBUG Logger.DebugLine("Removing Clicks from app list."); #endif foreach (resourceType App in AllApps.resource) { if (!App.title.Contains("ניהול תיק רפואי")) { AppMod.Add(App); } } AllApps.resource = AppMod.ToArray(); AppMod.Clear(); AppMod = null; return(Helpers.Serialize(AllApps, resourcesSerializer)); } } catch (Exception rdx) { Logger.DebugLine("Could not do something in no-clicks:" + rdx.Message); } } catch (Exception rdx) { Logger.DebugLine("Customization error:" + rdx.Message); return(valueToModify); } } return(valueToModify); }
public static String MontaSalaTerapeuta(String cod_filial, String cod_terapeuta) { List <resources> resources = new List <resources>(); String conexao = ConfigurationManager.ConnectionStrings["conexao"].ConnectionString; SqlConnection con = new SqlConnection(); con.ConnectionString = conexao.ToString(); SqlCommand cmd = new SqlCommand(); String ssql = ""; ssql = @" select ds_sala,cod_sala,fil.ds_filial from tb_sala s inner join tb_filial fil on fil.cod_filial = s.cod_filial where 1=1"; if (cod_filial != "0") { ssql += " and fil.cod_filial =" + cod_filial; } ssql += " order by fil.ds_filial,s.ds_sala "; cmd.CommandText = ssql; cmd.Connection = con; con.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { resources r = new resources(); r.id = Convert.ToInt32(dr["cod_sala"]); r.title = "SALA " + dr["ds_sala"].ToString(); r.building = dr["ds_filial"].ToString(); List <children> childrens = new List <children>(); SqlConnection conTerapeuta = new SqlConnection(); conTerapeuta.ConnectionString = conexao.ToString(); SqlCommand cmdTerapeuta = new SqlCommand(); String ssqlTerepeuta = ""; ssqlTerepeuta = @"select cod_terapeuta, nm_terapeuta from tb_terapeuta where 1=1 "; if (cod_terapeuta != "0") { ssqlTerepeuta += " and cod_terapeuta=" + cod_terapeuta; } cmdTerapeuta.CommandText = ssqlTerepeuta; cmdTerapeuta.Connection = conTerapeuta; conTerapeuta.Open(); SqlDataReader drTerapeuta = cmdTerapeuta.ExecuteReader(); while (drTerapeuta.Read()) { children c = new children(); c.id = Convert.ToInt32(drTerapeuta["cod_terapeuta"]); c.title = drTerapeuta["nm_terapeuta"].ToString(); childrens.Add(c); } drTerapeuta.Close(); conTerapeuta.Close(); r.children = childrens; resources.Add(r); } con.Close(); return(Newtonsoft.Json.JsonConvert.SerializeObject(resources)); }