static void changeAmount(int delta) { if (delta == 0 || currentCraftAmount == 0) { return; } if ((currentCraftAmount == 1 && delta == -1) || (currentCraftAmount == currentCraftAmountMax && delta == 1)) { return; } currentCraftAmount += delta; TechInfo.Ing[] ingsCurrent = originalTechInfo.ingredients.Select(ing => new TechInfo.Ing(ing.techType, ing.amount * currentCraftAmount)).ToArray(); currentTechInfo = new (ingsCurrent) { craftAmount = originalCraftAmount * currentCraftAmount, linkedItems = new (originalTechInfo.linkedItems) }; TechInfoUtils.setTechInfo(currentTechType, currentTechInfo); } }
public static void Dodaj(Dictionary <string, string> podaci, Kategorija kategorija) { long maxNivo = long.Parse(podaci["MAX_LVL"]); List <Preduvjet> preduvjeti = Preduvjet.NaciniPreduvjete(podaci["PREDUVJETI"]); foreach (Preduvjet pred in preduvjeti) { pred.nivo.preimenujVarijablu("LVL", podaci["KOD"] + "_LVL"); } List <TechInfo> popis; if (kategorija == Kategorija.RAZVOJ) { popis = tehnologijeRazvoj; } else { popis = tehnologijeIstrazivanje; } TechInfo techInfo = new TechInfo( popis.Count, podaci["IME"], podaci["OPIS"], podaci["KOD"], Formula.IzStringa(podaci["CIJENA"]), maxNivo, preduvjeti, Image.FromFile(podaci["SLIKA"]), kategorija); popis.Add(techInfo); }
public ActionResult Create([Bind(Include = "TechInfoID,SID,TQ,AO,Name,OrderTime,Address,TeNOSScomment,PIC,AreaCode,Metro,GPON,SN,VLAN,SurveyTime,CustTag,SurveyTech,ODPTag,PT1Com,PT1End,PT1Tech,JTTime,JTEnd,comment,ClosedTime,status")] TechInfo techInfo) { if (ModelState.IsValid) { // mengisi beberapa input menjadi "- jika tidak diisi oleh user techInfo.Address = (String.IsNullOrEmpty(techInfo.Address)) ? "-" : techInfo.Address; techInfo.TeNOSScomment = (String.IsNullOrEmpty(techInfo.TeNOSScomment)) ? "-" : techInfo.TeNOSScomment; techInfo.PIC = (String.IsNullOrEmpty(techInfo.PIC)) ? "-" : techInfo.PIC; techInfo.AreaCode = (String.IsNullOrEmpty(techInfo.AreaCode)) ? "-" : techInfo.AreaCode; techInfo.Metro = (String.IsNullOrEmpty(techInfo.Metro)) ? "-" : techInfo.Metro; techInfo.GPON = (String.IsNullOrEmpty(techInfo.GPON)) ? "-" : techInfo.GPON; techInfo.SN = (String.IsNullOrEmpty(techInfo.SN)) ? "-" : techInfo.SN; techInfo.VLAN = (String.IsNullOrEmpty(techInfo.VLAN)) ? "-" : techInfo.VLAN; techInfo.CustTag = (String.IsNullOrEmpty(techInfo.CustTag)) ? "-" : techInfo.CustTag; techInfo.SurveyTech = (String.IsNullOrEmpty(techInfo.SurveyTech)) ? "-" : techInfo.SurveyTech; techInfo.ODPTag = (String.IsNullOrEmpty(techInfo.ODPTag)) ? "-" : techInfo.ODPTag; techInfo.PT1Tech = (String.IsNullOrEmpty(techInfo.PT1Tech)) ? "-" : techInfo.PT1Tech; techInfo.comment = (String.IsNullOrEmpty(techInfo.comment)) ? "-" : techInfo.comment; techInfo.status = (String.IsNullOrEmpty(techInfo.status)) ? "-" : techInfo.status; db.TechInfoes.Add(techInfo); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(techInfo)); }
public static void setTechInfo(TechType techType, TechInfo techInfo) { #if GAME_SN CraftData.techData[techType] = techInfo; #elif GAME_BZ // for BZ we using TechDataPatches below #endif }
public ActionResult DeleteConfirmed(int id) { TechInfo techInfo = db.TechInfoes.Find(id); db.TechInfoes.Remove(techInfo); db.SaveChanges(); return(RedirectToAction("Index")); }
static void reset() { if (originalTechInfo != null) { TechInfoUtils.setTechInfo(currentTechType, originalTechInfo); } currentTechType = TechType.None; originalTechInfo = currentTechInfo = null; }
public ActionResult Edit([Bind(Include = "TechInfoID,SID,TQ,AO,Name,OrderTime,Address,TeNOSScomment,PIC,AreaCode,Metro,GPON,SN,VLAN,SurveyTime,CustTag,SurveyTech,ODPTag,PT1Com,PT1End,PT1Tech,JTTime,JTEnd,comment,ClosedTime,status")] TechInfo techInfo) { if (ModelState.IsValid) { db.Entry(techInfo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(techInfo)); }
public ActionResult _ArticleListForChannelIndex(string title, int catId, TechInfo techInfo) { var articleList = ArticleService.ListWithoutPage(3, new int[] { catId }, new int[] { techInfo.Id }); ViewBag.Title = title; ViewBag.CatId = catId; ViewBag.TechInfo = techInfo; ViewBag.ArticleList = articleList; return(View()); }
// // GET: /Category/Tech/ public ActionResult List() { var list = TechService.List(); ViewBag.List = list; int id = Controleng.Common.CECRequest.GetQueryInt("id", 0); TechInfo techInfo = null; if (id > 0) { techInfo = TechService.GetById(id); } return(View(techInfo)); }
public static TechInfo Create(TechInfo model) { if (model.Id == 0) { //Add int id = CategoryManage.AddTechInfo(model); model.Id = id; } else { CategoryManage.UpdateTechInfo(model); } return(model); }
public TechInfo GetTechInfo(string Name) { TechInfo Result = null; foreach (var Info in TechInfoList) { if (Info.Name == Name) { Result = Info; } } return(Result); }
// GET: Home/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TechInfo techInfo = db.TechInfoes.Find(id); if (techInfo == null) { return(HttpNotFound()); } return(View(techInfo)); }
/// <summary> /// 根据DataRow获得技术分类信息 /// </summary> /// <param name="dr"></param> /// <returns></returns> private static TechInfo GetTechInfoByDataRow(DataRow dr) { var model = new TechInfo(); if (dr == null) { return(model); } model.Alias = dr.Field <string>("Alias").ToLower(); model.Id = dr.Field <int>("Id"); model.IsDeleted = dr.Field <bool>("IsDeleted"); model.Name = dr.Field <string>("Name"); model.Sort = dr.Field <int>("Sort"); return(model); }
static void init(TechType techType) { currentCraftAmount = 0; TechInfo techInfo = TechInfoUtils.getTechInfo(techType); currentCraftAmountMax = getMaxAmount(techInfo); if (currentCraftAmountMax == 0) { return; } currentCraftAmount = 1; currentTechType = techType; originalTechInfo = techInfo; currentTechInfo = new TechInfo(techInfo); }
public ActionResult List(TechInfo model) { //检查 //如果添加,判断别名是否存在 bool isAdd = true; var list = TechService.List(); if (model.Id > 0) { isAdd = false; } if (isAdd) { //判断是否别名存在 if (!string.IsNullOrEmpty(model.Alias)) { if (list.Where(m => m.Alias == model.Alias).Count() > 0) { ModelState.AddModelError("ALIASEXISTS", "别名存在,请选择其他别名"); } } } else { //编辑,除了自身之外,判断是否存在 if (!string.IsNullOrEmpty(model.Alias)) { if (list.Where(m => (m.Alias == model.Alias && m.Id != model.Id)).Count() > 0) { ModelState.AddModelError("ALIASEXISTS", "别名存在,请选择其他别名"); } } } if (ModelState.IsValid) { TechService.Create(model); ViewBag.Msg = "保存成功"; } list = TechService.List(); ViewBag.List = list; return(View()); }
protected void SaveBtn1_Click(object sender, EventArgs e) { TechInfo obj = new TechInfo(); obj.Techadv = TechAdv1.Text; obj.Techdesc = TechDesc1.Text; obj.Rid = int.Parse(Rid1.Value); obj.Techitem = TechItem1.Value; obj.Techname = TechName1.Value; obj.Techother = TechOther1.Value; obj.Wasteitem = WasteItem1.Value; obj.Wastename = WasteName1.Value; obj.Wasteother = WasteOther1.Value; obj.Reusename = ReuseName1.Value; obj.Type = Type1.Value; obj.Username = Request.QueryString["username"].ToString(); obj.Isapproved = true; //mgr.Save(obj); String sqlRT = ""; sqlRT = sqlRT + " insert into TechInfo (Rid,Username,Techitem,Techname, Techother,Wasteitem,Wastename,Wasteother,Reusename,Techadv,Techdesc,[Type],Isapproved) "; sqlRT = sqlRT + " values( @Rid,@Username,@Techitem,@Techname, @Techother,@Wasteitem,@Wastename,@Wasteother,@Reusename,@Techadv,@Techdesc,@Type,@Isapproved) "; OleDbCommand cmdRT = new OleDbCommand(sqlRT); cmdRT.Parameters.Add("@Techadv", OleDbType.VarChar).Value = TechAdv1.Text; cmdRT.Parameters.Add("@Techdesc", OleDbType.VarChar).Value = TechDesc1.Text; cmdRT.Parameters.Add("@Rid", OleDbType.Integer).Value = int.Parse(Rid1.Value); cmdRT.Parameters.Add("@Techitem", OleDbType.VarChar).Value = TechItem1.Value; cmdRT.Parameters.Add("@Techname", OleDbType.VarChar).Value = TechName1.Value; cmdRT.Parameters.Add("@Techother", OleDbType.VarChar).Value = TechOther1.Value; cmdRT.Parameters.Add("@Wasteitem", OleDbType.VarChar).Value = WasteItem1.Value; cmdRT.Parameters.Add("@Wastename", OleDbType.VarChar).Value = WasteName1.Value; cmdRT.Parameters.Add("@Wasteother", OleDbType.VarChar).Value = WasteOther1.Value; cmdRT.Parameters.Add("@Reusename", OleDbType.VarChar).Value = ReuseName1.Value; cmdRT.Parameters.Add("@Type", OleDbType.VarChar).Value = Type1.Value; cmdRT.Parameters.Add("@Username", OleDbType.VarChar).Value = Request.QueryString["username"].ToString(); cmdRT.Parameters.Add("@Isapproved", OleDbType.Boolean).Value = true; SQLUtil.ExecuteSql(cmdRT); Response.Write("<script language='javascript'> { window.close();}</script>"); }
static int getMaxAmount(TechInfo techInfo) { int maxAmount = int.MaxValue; if (GameModeUtils.RequiresIngredients()) { foreach (var ing in techInfo.ingredients) { maxAmount = Math.Min(maxAmount, getCountAvailable(ing.techType) / ing.amount); } if (currentPowerRelay?.GetPower() > 5f) { maxAmount = Math.Min(maxAmount, (int)(currentPowerRelay.GetPower() / 5f - 1f)); } } return(maxAmount); }
public static int UpdateTechInfo(TechInfo model) { string strSQL = "UPDATE Categories SET Name = @Name,Alias = @Alias,Sort = @Sort,IsDeleted = @IsDeleted WHERE Id = @Id AND [Type] = 'tech'"; SqlParameter[] parms = { new SqlParameter("Id", SqlDbType.Int), new SqlParameter("Name", SqlDbType.NVarChar), new SqlParameter("Alias", SqlDbType.NVarChar), new SqlParameter("Sort", SqlDbType.Int), new SqlParameter("IsDeleted", SqlDbType.Bit), }; parms[0].Value = model.Id; parms[1].Value = model.Name; parms[2].Value = model.Alias; parms[3].Value = model.Sort; parms[4].Value = model.IsDeleted; return(SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms)); }
/// <summary> /// 添加技术分类 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int AddTechInfo(TechInfo model) { string strSQL = "INSERT INTO Categories(ParentId,RootId,ParentIds,Name,Alias,Sort,IsDeleted,[Type],CreateDateTime) VALUES(0,0,'0',@Name,@Alias,@Sort,@IsDeleted,@Type,GETDATE());SELECT @@IDENTITY;"; SqlParameter[] param = { new SqlParameter("Name", SqlDbType.NVarChar), new SqlParameter("Alias", SqlDbType.VarChar), new SqlParameter("Sort", SqlDbType.Int), new SqlParameter("IsDeleted", SqlDbType.Bit), new SqlParameter("Type", SqlDbType.VarChar) }; param[0].Value = model.Name; param[1].Value = model.Alias.ToLower(); param[2].Value = model.Sort; param[3].Value = model.IsDeleted; param[4].Value = CatType.Tech.ToString().ToLower(); return(Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, strSQL, param))); }
public static Tehnologija Ucitaj(PodaciCitac ulaz) { Kategorija kategorija = (Kategorija)ulaz.podatakInt(PohKategorija); TechInfo info = null; int id = ulaz.podatakInt(PohId); if (kategorija == Kategorija.ISTRAZIVANJE) { info = TechInfo.tehnologijeIstrazivanje[id]; } else { info = TechInfo.tehnologijeRazvoj[id]; } long nivo = ulaz.podatakLong(PohNivo); long ulozeno = ulaz.podatakLong(PohUlozeno); return(new Tehnologija(info, nivo, ulozeno)); }
public Tehnologija(TechInfo techInfo) { tip = techInfo; nivo = 0; ulozenoPoena = 0; }
protected void Page_Load(object sender, EventArgs e) { techtestResponse res = new techtestResponse(); techtestRequest req; res.error = String.Empty; // Need passed in store id and number of requested results. // 1. Deserialize the incoming Json. try { req = GetRequestInfo(); } catch (Exception ex) { res.error = ex.Message.ToString(); // Return the results as Json. SendResultInfoAsJson(res); return; } SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); try { connection.Open(); // seaches for a specific un and pw string sql = String.Format("select * from techtest where un='{0}' and pw='{1}'", req.un, req.pw); SqlCommand command = new SqlCommand(sql, connection); SqlDataReader reader = command.ExecuteReader(); List <TechInfo> list = new List <TechInfo>(); // may only need the reader to read the pw bc nothing else matters? while (reader.Read()) { // res.pw = Convert.ToString( reader["Model"] ); // list.Add( Convert.ToString( reader["Model"] ) ); TechInfo ti = new TechInfo(); ti.un = Convert.ToString(reader["un"]); ti.pw = Convert.ToString(reader["pw"]); // ti.year = Convert.ToInt32( reader["Year"] ); list.Add(ti); } reader.Close(); // instead of adding it to a list, compare it to the pw passed in // res.loginFound = list.ToArray(); if (list.ToArray().Length == 1) { res.login = true; } else { res.login = false; } } catch (Exception ex) { res.error = ex.Message.ToString(); } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } // Return the results as Json. SendResultInfoAsJson(res); // SendResultInfoAsJson(login); }
public void Delete(TechInfo obj) { HibernateTemplate.Delete(obj);; }
void InitializingArray() { string[] FieldName; List <string[]> DataList; TechInfoList = new List <TechInfo>(); FieldName = new string[] { "Name", "UnlockFacility", "UnlockActor", "UpgradeType", "UpgradeAmount", "RequiredIndex", "RequiredValue", "WorkLoad" }; DataList = new List <string[]>(); xmlReader.xmlReaderAccess.ReadXml("Data/Tech/XML/TechInfo", "TechInfo/Tech", FieldName, DataList); foreach (string[] Data in DataList) { TechInfo newRecipe = new TechInfo(); newRecipe.Name = Data[0]; newRecipe.UnlockFacility = Data[1].Split(','); newRecipe.UnlockActor = Data[2].Split(','); newRecipe.UpgradeValueType = Data[3]; newRecipe.UpgradeValueAmount = System.Convert.ToSingle(Data[4]); string[] RequiredIndex = Data[5].Split(','); newRecipe.RequiredTech = new int[RequiredIndex.Length]; for (int i = 0; i < RequiredIndex.Length; i++) { newRecipe.RequiredTech[i] = System.Convert.ToInt32(RequiredIndex[i]); } newRecipe.RequiredValue = System.Convert.ToInt32(Data[6]); newRecipe.RequiredWorkLoad = System.Convert.ToInt32(Data[7]); TechInfoList.Add(newRecipe); } FacilityList = new List <FacilityInfo>(); FieldName = new string[] { "Type", "Name", "Price", "UpkeepPrice", "UpkeepMonthTerm", "ElectricConsum", "LaborRequirement" }; DataList = new List <string[]>(); xmlReader.xmlReaderAccess.ReadXml("Data/Tech/XML/FacilityInfo", "FacilityInfo/Facility", FieldName, DataList); foreach (string[] Data in DataList) { FacilityInfo newFacility = new FacilityInfo(); newFacility.Type = Data[0]; newFacility.Name = Data[1]; newFacility.Price = System.Convert.ToInt32(Data[2]); newFacility.UpkeepPrice = System.Convert.ToInt32(Data[3]); newFacility.UpkeepMonthTerm = System.Convert.ToInt32(Data[4]); newFacility.ElectricConsum = System.Convert.ToSingle(Data[5]); newFacility.LaborRequirement = System.Convert.ToSingle(Data[6]); newFacility.Object = Resources.Load <GameObject>("GameSystem/InstallableObject/Object/" + newFacility.Name); FacilityList.Add(newFacility); } ProcessorList = new List <ProcessorInfo>(); FieldName = new string[] { "Type", "Name", "PerformanceQuality", "PerformanceSpeed", "ActorList" }; DataList = new List <string[]>(); xmlReader.xmlReaderAccess.ReadXml("Data/Tech/XML/ProcessorInfo", "ProcessorInfo/Processor", FieldName, DataList); foreach (string[] Data in DataList) { ProcessorInfo newProcessor = new ProcessorInfo(); newProcessor.Type = Data[0]; newProcessor.Name = Data[1]; newProcessor.PerformanceQuality = System.Convert.ToSingle(Data[2]); newProcessor.PerformanceSpeed = System.Convert.ToSingle(Data[3]); newProcessor.ActorList = Data[4].Split(','); ProcessorList.Add(newProcessor); } ActorList = new List <ProcessActorInfo>(); FieldName = new string[] { "Name", "TechPoint", "Cost" }; DataList = new List <string[]>(); xmlReader.xmlReaderAccess.ReadXml("Data/Tech/XML/ActorInfo", "ActorInfo/Actor", FieldName, DataList); foreach (string[] Data in DataList) { ProcessActorInfo newActor = new ProcessActorInfo(); newActor.Name = Data[0]; newActor.TechPoint = System.Convert.ToSingle(Data[1]); newActor.Cost = System.Convert.ToInt32(Data[2]); ActorList.Add(newActor); } }
public void Save(TechInfo obj) { HibernateTemplate.SaveOrUpdate(obj); }
protected void Page_Load(object sender, EventArgs e) { TechLoginResponse res = new TechLoginResponse(); TechLoginRequest req; res.error = String.Empty; // Need passed in store id and number of requested results. // 1. Deserialize the incoming Json. try { req = GetRequestInfo(); } catch (Exception ex) { res.error = ex.Message.ToString(); // Return the results as Json. SendResultInfoAsJson(res); return; } SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); try { connection.Open(); // seaches for a specific username and password string sql = String.Format("select * from TechInfo where Username='******' and Password='******'", req.username, req.password); SqlCommand command = new SqlCommand(sql, connection); SqlDataReader reader = command.ExecuteReader(); List <TechInfo> list = new List <TechInfo>(); // while (reader.Read()) { TechInfo ti = new TechInfo(); ti.username = Convert.ToString(reader["Username"]); ti.password = Convert.ToString(reader["Password"]); list.Add(ti); } reader.Close(); // make sure there's exactly one instance of the username and password given if (list.ToArray().Length == 1) { res.login = true; } else { res.login = false; } } catch (Exception ex) { res.error = ex.Message.ToString(); } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } // Return the results as Json. SendResultInfoAsJson(res); }
public void Save(TechInfo obj) { dao.Save(obj); }
public void Delete(TechInfo obj) { dao.Delete(obj); }
private Tehnologija(TechInfo techInfo, long nivo, long ulozenoPoena) { tip = techInfo; this.nivo = nivo; this.ulozenoPoena = ulozenoPoena; }