public ResModel AddRepairItem(RepairItemDto repairItemDto, UserDto operationUser) { using (var db = new ModelContext()) { var repairItem = new RepairItem() { Id = Guid.NewGuid(), Name = repairItemDto.Name, Description = repairItemDto.Description, SerNum = repairItemDto.SerNum, WorkHour = repairItemDto.WorkHour, Price = repairItemDto.Price, IsHot = repairItemDto.IsHot, RepairItemTypeId = repairItemDto.RepairItemTypeId }; try { db.RepairItem.Add(repairItem); db.SaveChanges(); } catch (Exception e) { return(new ResModel() { Msg = "添加维修项目失败", Success = false }); } return(new ResModel() { Msg = "添加维修项目成功", Success = true }); } }
void HandleRepairItem(RepairItem packet) { Creature unit = GetPlayer().GetNPCIfCanInteractWith(packet.NpcGUID, NPCFlags.Repair); if (!unit) { Log.outDebug(LogFilter.Network, "WORLD: HandleRepairItemOpcode - {0} not found or you can not interact with him.", packet.NpcGUID.ToString()); return; } // remove fake death if (GetPlayer().HasUnitState(UnitState.Died)) { GetPlayer().RemoveAurasByType(AuraType.FeignDeath); } // reputation discount float discountMod = GetPlayer().GetReputationPriceDiscount(unit); if (!packet.ItemGUID.IsEmpty()) { Log.outDebug(LogFilter.Network, "ITEM: Repair {0}, at {1}", packet.ItemGUID.ToString(), packet.NpcGUID.ToString()); Item item = GetPlayer().GetItemByGuid(packet.ItemGUID); if (item) { GetPlayer().DurabilityRepair(item.GetPos(), true, discountMod, packet.UseGuildBank); } } else { Log.outDebug(LogFilter.Network, "ITEM: Repair all items at {0}", packet.NpcGUID.ToString()); GetPlayer().DurabilityRepairAll(true, discountMod, packet.UseGuildBank); } }
public JournalRepair(JObject evt) : base(evt, JournalTypeEnum.Repair) { if (evt["Items"] is JArray) { Items = new List <RepairItem>(); ItemLocalised = Item = ItemFD = ""; foreach (var jitem in evt["Items"]) { var itemfd = JournalFieldNaming.NormaliseFDItemName(jitem.Str()); var item = JournalFieldNaming.GetBetterItemName(itemfd); var repairitem = new RepairItem { ItemFD = itemfd, Item = item, ItemLocalised = item.SplitCapsWordFull() }; ItemLocalised = ItemLocalised.AppendPrePad(repairitem.ItemLocalised, ", "); // for the voice pack, keep this going Items.Add(repairitem); } } else { ItemFD = JournalFieldNaming.NormaliseFDItemName(evt["Item"].Str()); Item = JournalFieldNaming.GetBetterItemName(ItemFD); ItemLocalised = JournalFieldNaming.CheckLocalisation(evt["Item_Localised"].Str(), Item); } Cost = evt["Cost"].Long(); }
public override GameObject CreateGameObject(ReferenceData referenceData, Transform parent = null) { var gameObject = base.CreateGameObject(referenceData, parent); var ownerData = new OwnerData(referenceData.Owner, referenceData.Global, referenceData.Faction, referenceData.Rank); var uses = referenceData.Health == -1 ? data.MaxUses : referenceData.Health; RepairItem.Create(gameObject, this, referenceData); return(gameObject); }
private void FinishContainerAction() { ContainerPoint cp = goal.GetComponent <ContainerPoint>(); cp.Close(); if (null == cp) { Debug.LogError("not a ContainerPoint object!"); } if (cp.prefab == null) { return; } if (carriedItem != null) { DestroyImmediate(carriedItem.gameObject); carriedItem = null; } Waypoint wp = goal.GetComponent <Waypoint>(); switch (wp.damage) { case DamageType.REPAIR_MECHANIC: PlaySound(Speech.WERKZEUG_ERHALTEN); break; case DamageType.REPAIR_BATTERY: PlaySound(Speech.BATTERIE_ERHALTEN); break; case DamageType.REPAIR_BERYLLIUM: PlaySound(Speech.BERYLLIUMKUGEL_ERHALTEN); break; case DamageType.REPAIR_FLUX: PlaySound(Speech.FLUX_COMPENSATOR_ERHALTEN); break; default: case DamageType.REPAIR_WELD: case DamageType.REPAIR_NONE: break; } GameObject item = Instantiate(cp.prefab, this.transform); carriedItem = item.GetComponent <RepairItem>(); state = RobotState.MOVE_TO_DAMAGE; goal = null; }
public bool PickUpRepairItem(RepairItem item) { bool canPickUp = currentRepairItem == null; if (canPickUp) { currentRepairItem = item; repairImage.sprite = item.sprite; } return(canPickUp); }
public void DropRepairItem() { if (currentRepairItem != null) { currentRepairItem.transform.position = transform.position - transform.forward * 5; currentRepairItem.gameObject.SetActive(true); currentRepairItem.SetColliderActive(true); repairImage.sprite = null; currentRepairItem = null; } }
private void StartContainerAction() { ContainerPoint cp = goal.GetComponent <ContainerPoint>(); cp.Open(); if (null == cp) { Debug.LogError("not a ContainerPoint object!"); } if (cp.prefab == null) { return; } if (carriedItem != null) { DestroyImmediate(carriedItem.gameObject); carriedItem = null; } Waypoint wp = goal.GetComponent <Waypoint>(); switch (wp.damage) { case DamageType.REPAIR_MECHANIC: PlaySound(Speech.WERKZEUG); break; case DamageType.REPAIR_BATTERY: PlaySound(Speech.BATTERIE); break; case DamageType.REPAIR_BERYLLIUM: PlaySound(Speech.BERYLLIUMKUGEL); break; case DamageType.REPAIR_FLUX: PlaySound(Speech.FLUX_COMPENSATOR); break; default: case DamageType.REPAIR_WELD: case DamageType.REPAIR_NONE: break; } }
private void RepairDone(DamagePoint dp) { if (carriedItem != null) { DestroyImmediate(carriedItem.gameObject); carriedItem = null; } Waypoint wp = dp.GetComponent <Waypoint>(); switch (wp.damage) { case DamageType.REPAIR_WELD: PlaySound(Speech.SCHWEISSGERAET); break; case DamageType.REPAIR_MECHANIC: PlaySound(Speech.WERKZEUG_INSTALLIERT); break; case DamageType.REPAIR_BATTERY: PlaySound(Speech.BATTERIE_INSTALLIERT); break; case DamageType.REPAIR_BERYLLIUM: PlaySound(Speech.BERYLLIUMKUGEL_INSTALLIERT); break; case DamageType.REPAIR_FLUX: PlaySound(Speech.FLUX_COMPENSATOR_INSTALLIERT); break; default: case DamageType.REPAIR_NONE: break; } dp.Deactivate(); state = RobotState.IDLE; goal = null; }
void BeConfused() { //PlaySound(Speech.I_AM_CONFUSED); if (carriedItem != null) { SetAnimState(AnimState.THROW); carriedItem.FloatToSpace(); carriedItem = null; } DamagePoint p = FindUnusedDamagePoint(); if (null == p) { Debug.Log("no more damage points!"); return; } Waypoint wp = p.GetComponent <Waypoint>(); SetTarget(wp, true); }
public static void SeedRepairItems(DataContext dataContext) { if (!dataContext.RepairItems.Any()) { var repairs = dataContext.Repairs.ToList(); var items = dataContext.Items.ToList(); var repairIndex = 0; foreach (var item in items) { var repairItem = new RepairItem(); repairItem.Repair = repairs[repairIndex]; repairItem.Item = item; if (repairItem.Repair.DateCompleted.HasValue) { repairItem.DateRepaired = repairItem.Repair.DateCompleted; repairItem.DateShipped = repairItem.Repair.DateCompleted; repairItem.CourierTrackingID = random.Next(10000000, 99999999).ToString(); } dataContext.Add(repairItem); if (repairIndex < 19) { repairIndex++; } else { repairIndex = 0; } } dataContext.SaveChanges(); } }
public static RepairItem Load(List <string> values) { RepairItem item = new RepairItem(); item.iconGraphic = new Graphics(ref values, 23); item.prefireGraphic = new Graphics(ref values, 71); item.repairGraphic = new Graphics(ref values, 100); item.prefireSound = new Sound(ref values, 79); item.repairSound = new Sound(ref values, 108); ItemInfo.LoadGeneralSettings1((ItemInfo)item, values); item.useAmmoID = CSVReader.GetInt(values[31]); item.ammoUsedPerShot = CSVReader.GetInt(values[32]); item.ammoCapacity = CSVReader.GetInt(values[33]); item.requiredItem = CSVReader.GetInt(values[34]); item.requiredItemAmount = CSVReader.GetInt(values[35]); item.energyCostTerrain0 = CSVReader.GetInt(values[36]); item.energyCostTerrain1 = CSVReader.GetInt(values[37]); item.energyCostTerrain2 = CSVReader.GetInt(values[38]); item.energyCostTerrain3 = CSVReader.GetInt(values[39]); item.energyCostTerrain4 = CSVReader.GetInt(values[40]); item.energyCostTerrain5 = CSVReader.GetInt(values[41]); item.energyCostTerrain6 = CSVReader.GetInt(values[42]); item.energyCostTerrain7 = CSVReader.GetInt(values[43]); item.energyCostTerrain8 = CSVReader.GetInt(values[44]); item.energyCostTerrain9 = CSVReader.GetInt(values[45]); item.energyCostTerrain10 = CSVReader.GetInt(values[46]); item.energyCostTerrain11 = CSVReader.GetInt(values[47]); item.energyCostTerrain12 = CSVReader.GetInt(values[48]); item.energyCostTerrain13 = CSVReader.GetInt(values[49]); item.energyCostTerrain14 = CSVReader.GetInt(values[50]); item.energyCostTerrain15 = CSVReader.GetInt(values[51]); item.secondShotEnergy = CSVReader.GetInt(values[52]); item.secondShotTimeout = CSVReader.GetInt(values[53]); item.fireDelay = CSVReader.GetInt(values[54]); item.fireDelayOther = CSVReader.GetInt(values[55]); item.maxFireDelay = CSVReader.GetInt(values[56]); item.entryFireDelay = CSVReader.GetInt(values[57]); item.reloadDelayNormal = CSVReader.GetInt(values[58]); item.reloadDelayPartial = CSVReader.GetInt(values[59]); item.reloadDelayAsynchronous = CSVReader.GetInt(values[60]); item.reloadDelayAsynchronousPartial = CSVReader.GetInt(values[61]); item.routeRange = CSVReader.GetInt(values[62]); item.routeRotationalRange = CSVReader.GetInt(values[63]); item.routeFriendly = CSVReader.GetBool(values[65]); item.recoil = CSVReader.GetInt(values[66]); item.verticalRecoil = CSVReader.GetInt(values[67]); item.prefireDelay = CSVReader.GetInt(values[68]); item.reliability = CSVReader.GetInt(values[69]); item.reliabilityFireDelay = CSVReader.GetInt(values[70]); item.movementCancelsPrefire = CSVReader.GetBool(values[83]); item.notifyOthersOfPrefire = CSVReader.GetBool(values[84]); item.cashCost = CSVReader.GetInt(values[85]); item.useWhileCarryingBall = CSVReader.GetBool(values[86]); item.useWhileCarryingFlag = CSVReader.GetBool(values[87]); item.soccerThrow = CSVReader.GetInt(values[88]); item.soccerBallFriction = CSVReader.GetInt(values[89]); item.soccerBallSpeed = CSVReader.GetInt(values[90]); item.soccerLowFireAngle = CSVReader.GetInt(values[91]); item.soccerHighFireAngle = CSVReader.GetInt(values[92]); item.repairType = CSVReader.GetInt(values[93]); item.repairAmount = CSVReader.GetInt(values[94]); item.repairPercentage = CSVReader.GetInt(values[95]); item.repairTime = CSVReader.GetInt(values[96]); item.repairDistance = CSVReader.GetInt(values[97]); item.killPotential = CSVReader.GetInt(values[98]); item.repairSelf = CSVReader.GetBool(values[99]); return(item); }
public static void AddItem(RepairItem newItem) { allItems.Add(newItem); }
public void SpawnItem() { currentItem = Instantiate(repairItem, transform).GetComponent <RepairItem>(); }
public static List <ItemInfo> Load(string filename) { List <ItemInfo> itemInfo = new List <ItemInfo>(); TextReader reader = new StreamReader(filename); string line = ""; while ((line = reader.ReadLine()) != null) { List <string> values = CSVReader.Parse(line); switch (values[0]) { case "4": Ammo ammo = Ammo.Load(values); BlobsToLoad.Add(ammo.graphic.blobName); itemInfo.Add(ammo); break; case "1": MultiItem multiItem = MultiItem.Load(values); BlobsToLoad.Add(multiItem.graphic.blobName); itemInfo.Add(multiItem); break; case "6": Projectile projectile = Projectile.Load(values); BlobsToLoad.Add(projectile.iconGraphic.blobName); BlobsToLoad.Add(projectile.fireGraphic.blobName); BlobsToLoad.Add(projectile.projectileGraphic.blobName); BlobsToLoad.Add(projectile.shadowGraphic.blobName); BlobsToLoad.Add(projectile.trailGraphic.blobName); BlobsToLoad.Add(projectile.explosionGraphic.blobName); BlobsToLoad.Add(projectile.prefireGraphic.blobName); BlobsToLoad.Add(projectile.firingSound.blobName); BlobsToLoad.Add(projectile.explosionSound.blobName); BlobsToLoad.Add(projectile.bounceSound.blobName); BlobsToLoad.Add(projectile.prefireSound.blobName); itemInfo.Add(projectile); break; case "7": VehicleMaker vehicleMaker = VehicleMaker.Load(values); BlobsToLoad.Add(vehicleMaker.prefireSound.blobName); BlobsToLoad.Add(vehicleMaker.prefireGraphic.blobName); BlobsToLoad.Add(vehicleMaker.iconGraphic.blobName); itemInfo.Add(vehicleMaker); break; case "8": MultiUse multiUse = MultiUse.Load(values); BlobsToLoad.Add(multiUse.prefireGraphic.blobName); BlobsToLoad.Add(multiUse.firingSound.blobName); BlobsToLoad.Add(multiUse.prefireSound.blobName); BlobsToLoad.Add(multiUse.iconGraphic.blobName); itemInfo.Add(multiUse); break; case "11": RepairItem repair = RepairItem.Load(values); BlobsToLoad.Add(repair.iconGraphic.blobName); BlobsToLoad.Add(repair.prefireGraphic.blobName); BlobsToLoad.Add(repair.repairGraphic.blobName); BlobsToLoad.Add(repair.prefireSound.blobName); BlobsToLoad.Add(repair.repairSound.blobName); itemInfo.Add(repair); break; case "15": UpgradeItem upgrade = UpgradeItem.Load(values); BlobsToLoad.Add(upgrade.iconGraphic.blobName); itemInfo.Add(upgrade); break; case "12": ControlItem control = ControlItem.Load(values); BlobsToLoad.Add(control.iconGraphic.blobName); BlobsToLoad.Add(control.prefireGraphic.blobName); BlobsToLoad.Add(control.effectGraphic.blobName); BlobsToLoad.Add(control.prefireSound.blobName); BlobsToLoad.Add(control.firingSound.blobName); itemInfo.Add(control); break; case "13": UtilityItem utility = UtilityItem.Load(values); BlobsToLoad.Add(utility.iconGraphic.blobName); BlobsToLoad.Add(utility.activateSound.blobName); itemInfo.Add(utility); break; case "17": WarpItem warp = WarpItem.Load(values); BlobsToLoad.Add(warp.iconGraphic.blobName); BlobsToLoad.Add(warp.prefireGraphic.blobName); BlobsToLoad.Add(warp.warpGraphic.blobName); BlobsToLoad.Add(warp.prefireSound.blobName); BlobsToLoad.Add(warp.warpSound.blobName); itemInfo.Add(warp); break; case "16": SkillItem skill = SkillItem.Load(values); BlobsToLoad.Add(skill.iconGraphic.blobName); itemInfo.Add(skill); break; case "14": ItemMaker item = ItemMaker.Load(values); BlobsToLoad.Add(item.prefireGraphic.blobName); BlobsToLoad.Add(item.prefireSound.blobName); BlobsToLoad.Add(item.iconGraphic.blobName); itemInfo.Add(item); break; case "18": NestedItem nested = NestedItem.Load(values); FilesToLoad.Add(nested.location); itemInfo.Add(nested); break; case "default": //F**k you, you idiot. use Log.write //Console.WriteLine("If you see this Toriad f****d up"); break; } } return(itemInfo); }
public static void RunRepairer() { string thishost = System.Net.Dns.GetHostName(); Random rnd = new Random(unchecked (DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + 5757981)); System.Threading.Thread.Sleep(7000); if (!MySpace.DataMining.AELight.dfs.DfsConfigExists( MySpace.DataMining.AELight.dfs.DFSXMLNAME)) { _ThreadDisabled(); return; } MySpace.DataMining.AELight.dfs dc = MySpace.DataMining.AELight.dfs.ReadDfsConfig_unlocked( MySpace.DataMining.AELight.dfs.DFSXMLNAME); if (null == dc.FileDaemon || !dc.FileDaemon.Enabled) { dc = null; _ThreadDisabled(); return; } for (; ; System.Threading.Thread.Sleep(dc.FileDaemon.RepairSleep)) { List <RepairItem> repairs = new List <RepairItem>(dc.FileDaemon.MaxRepairs); { List <RepairItem> allrepairs = new List <RepairItem>(200); foreach (string host in dc.Slaves.SlaveList.Split(';')) { try { string netpath = MySpace.DataMining.AELight.Surrogate.NetworkPathForHost(host); string fp = netpath + @"\filescan.log"; string[] repairfiles = System.IO.File.ReadAllLines(fp); try { System.IO.File.Delete(fp); } catch { } foreach (string rf in repairfiles) { int i = rf.IndexOf("] "); if (-1 != i) { string s = rf.Substring(i + 2); i = IndexOfEndOfParam(s); string rfhost = s.Substring(0, i); s = s.Substring(i + 1); i = IndexOfEndOfParam(s); string spos = s.Substring(0, i); s = s.Substring(i + 1); string chunkname = s.Trim('"'); RepairItem ri = new RepairItem(); ri.chunkname = chunkname; ri.host = rfhost; try { ri.filepos = int.Parse(spos); // spos might be "<done>"; if so, don't add it. allrepairs.Add(ri); } catch { } } } } catch { } } allrepairs.Sort(new Comparison <RepairItem>( delegate(RepairItem ri1, RepairItem ri2) { return(string.Compare(ri1.chunkname, ri2.chunkname, true)); })); for (int i = 1; i < allrepairs.Count; i++) { if (0 == string.Compare(allrepairs[i - 1].chunkname, allrepairs[i].chunkname, true)) { allrepairs[i].hits += allrepairs[i - 1].hits; allrepairs[i - 1].hits = 0; } } allrepairs.Sort(new Comparison <RepairItem>( delegate(RepairItem ri1, RepairItem ri2) { return(ri2.hits - ri1.hits); })); for (int i = 0; i < 10 && i < allrepairs.Count && allrepairs[i].hits > 0; i++) { repairs.Add(allrepairs[i]); } } foreach (RepairItem ri in repairs) { bool found = false; foreach (MySpace.DataMining.AELight.dfs.DfsFile df in dc.Files) { foreach (MySpace.DataMining.AELight.dfs.DfsFile.FileNode fn in df.Nodes) { if (0 == string.Compare(fn.Name, ri.chunkname, true)) { found = true; string state = "no attempt"; string newhost = "N/A"; string[] ahosts = fn.Host.Split(';'); if (dc.FileDaemon.AutoRepair) { for (int itries = 0; itries < 5; itries++, System.Threading.Thread.Sleep(1000)) { try { System.IO.File.AppendAllText("filerepairlog.txt", "[" + DateTime.Now + "] NotReplacing \"" + ri.chunkpath + "\" with replicate chunk: AutoRepair is false" + Environment.NewLine); break; } catch { } } break; } else if (ahosts.Length < 2 || ahosts.Length < dc.Replication) { //state = "no attempt: file replicate count is " + ahosts.Length // + "; cluster replication factor is " + dc.Replication; break; } else { foreach (string ahost in ahosts) { if (0 != string.Compare(ahost, ri.host, true)) { try { string newchunkname = "zd.fdrepair." + Guid.NewGuid() + ".zd"; string newchunkpath = MySpace.DataMining.AELight.Surrogate.NetworkPathForHost(ri.host) + @"\" + newchunkname; System.IO.File.Copy( MySpace.DataMining.AELight.Surrogate.NetworkPathForHost(ahost) + @"\" + ri.chunkname, newchunkpath ); string chunkpath = ri.chunkpath; System.IO.File.Delete(chunkpath); System.IO.File.Move(newchunkpath, chunkpath); state = "success"; newhost = ahost; break; } catch (Exception e) { state = "failure: " + e.ToString(); } } } } for (int itries = 0; itries < 5; itries++, System.Threading.Thread.Sleep(1000)) { try { System.IO.File.AppendAllText("filerepairlog.txt", "[" + DateTime.Now + "] Replacing \"" + ri.chunkpath + "\" with chunk from " + newhost + ": " + state + Environment.NewLine); break; } catch { } } break; } } if (found) { break; } } } } }
public static void RunRepairer() { string thishost = System.Net.Dns.GetHostName(); Random rnd = new Random(unchecked(DateTime.Now.Millisecond + System.Diagnostics.Process.GetCurrentProcess().Id + 5757981)); System.Threading.Thread.Sleep(7000); if (!MySpace.DataMining.AELight.dfs.DfsConfigExists( MySpace.DataMining.AELight.dfs.DFSXMLNAME)) { _ThreadDisabled(); return; } MySpace.DataMining.AELight.dfs dc = MySpace.DataMining.AELight.dfs.ReadDfsConfig_unlocked( MySpace.DataMining.AELight.dfs.DFSXMLNAME); if (null == dc.FileDaemon || !dc.FileDaemon.Enabled) { dc = null; _ThreadDisabled(); return; } for (; ; System.Threading.Thread.Sleep(dc.FileDaemon.RepairSleep)) { List<RepairItem> repairs = new List<RepairItem>(dc.FileDaemon.MaxRepairs); { List<RepairItem> allrepairs = new List<RepairItem>(200); foreach (string host in dc.Slaves.SlaveList.Split(';')) { try { string netpath = MySpace.DataMining.AELight.Surrogate.NetworkPathForHost(host); string fp = netpath + @"\filescan.log"; string[] repairfiles = System.IO.File.ReadAllLines(fp); try { System.IO.File.Delete(fp); } catch { } foreach (string rf in repairfiles) { int i = rf.IndexOf("] "); if (-1 != i) { string s = rf.Substring(i + 2); i = IndexOfEndOfParam(s); string rfhost = s.Substring(0, i); s = s.Substring(i + 1); i = IndexOfEndOfParam(s); string spos = s.Substring(0, i); s = s.Substring(i + 1); string chunkname = s.Trim('"'); RepairItem ri = new RepairItem(); ri.chunkname = chunkname; ri.host = rfhost; try { ri.filepos = int.Parse(spos); // spos might be "<done>"; if so, don't add it. allrepairs.Add(ri); } catch { } } } } catch { } } allrepairs.Sort(new Comparison<RepairItem>( delegate(RepairItem ri1, RepairItem ri2) { return string.Compare(ri1.chunkname, ri2.chunkname, true); })); for (int i = 1; i < allrepairs.Count; i++) { if (0 == string.Compare(allrepairs[i - 1].chunkname, allrepairs[i].chunkname, true)) { allrepairs[i].hits += allrepairs[i - 1].hits; allrepairs[i - 1].hits = 0; } } allrepairs.Sort(new Comparison<RepairItem>( delegate(RepairItem ri1, RepairItem ri2) { return ri2.hits - ri1.hits; })); for (int i = 0; i < 10 && i < allrepairs.Count && allrepairs[i].hits > 0; i++) { repairs.Add(allrepairs[i]); } } foreach (RepairItem ri in repairs) { bool found = false; foreach (MySpace.DataMining.AELight.dfs.DfsFile df in dc.Files) { foreach (MySpace.DataMining.AELight.dfs.DfsFile.FileNode fn in df.Nodes) { if (0 == string.Compare(fn.Name, ri.chunkname, true)) { found = true; string state = "no attempt"; string newhost = "N/A"; string[] ahosts = fn.Host.Split(';'); if (dc.FileDaemon.AutoRepair) { for (int itries = 0; itries < 5; itries++, System.Threading.Thread.Sleep(1000)) { try { System.IO.File.AppendAllText("filerepairlog.txt", "[" + DateTime.Now + "] NotReplacing \"" + ri.chunkpath + "\" with replicate chunk: AutoRepair is false" + Environment.NewLine); break; } catch { } } break; } else if (ahosts.Length < 2 || ahosts.Length < dc.Replication) { //state = "no attempt: file replicate count is " + ahosts.Length // + "; cluster replication factor is " + dc.Replication; break; } else { foreach (string ahost in ahosts) { if (0 != string.Compare(ahost, ri.host, true)) { try { string newchunkname = "zd.fdrepair." + Guid.NewGuid() + ".zd"; string newchunkpath = MySpace.DataMining.AELight.Surrogate.NetworkPathForHost(ri.host) + @"\" + newchunkname; System.IO.File.Copy( MySpace.DataMining.AELight.Surrogate.NetworkPathForHost(ahost) + @"\" + ri.chunkname, newchunkpath ); string chunkpath = ri.chunkpath; System.IO.File.Delete(chunkpath); System.IO.File.Move(newchunkpath, chunkpath); state = "success"; newhost = ahost; break; } catch (Exception e) { state = "failure: " + e.ToString(); } } } } for (int itries = 0; itries < 5; itries++, System.Threading.Thread.Sleep(1000)) { try { System.IO.File.AppendAllText("filerepairlog.txt", "[" + DateTime.Now + "] Replacing \"" + ri.chunkpath + "\" with chunk from " + newhost + ": " + state + Environment.NewLine); break; } catch { } } break; } } if (found) { break; } } } } }
private void RepairExecuted(object _) { Item.Durability = (float)Item.MaxDurability; RepairItem.OnCanExecuteChanged(); }