static void Main(string[] args) { //Set Aspose Lisence SetLicense(); args = new string[1]; args[0] = "-replace"; if (args.Count() == 0 || (args[0].ToLower() != "-report") || (args[0].ToLower() != "-replace")) { //-report will only output potential matches to a excel file, -replace will update file Console.WriteLine("must include -report or -replace"); } else { var reportOnly = args[0].ToLower() == "-report"; var rootFolder = AppDomain.CurrentDomain.BaseDirectory; //get replace target from targets.txt and populate into a List<string> var targetList = ReadTarget(); var stringList = new List <string>(); var output = SearchAllFiles(ReplaceModel.Convert(targetList), reportOnly, stringList, rootFolder); File.WriteAllLines("output.csv", stringList.ToArray()); } }
public bool Validate() { bool status = false; try { var xDoc = XDocument.Load(EnhanceLog.Set(Hashtable, "SubKeys", true)); replaceModel = xDoc.Descendants("Replacer").Select(x => new ReplaceModel { DirectoryPath = x.Attribute("Directory").Value, Pattern = x.Attribute("Pattern").Value, Contains = x.Attribute("Contains").Value }).FirstOrDefault(); replaceModels = xDoc.Element("Replacer").Elements("Line").Select(x => new ReplaceModel { DirectoryPath = x.Attribute("Directory") == null ? replaceModel.DirectoryPath : x.Attribute("Directory").Value, Pattern = x.Attribute("Pattern") == null ? replaceModel.DirectoryPath : x.Attribute("Pattern").Value, Contains = x.Attribute("Contains") == null ? replaceModel.DirectoryPath : x.Attribute("Contains").Value, MatchValue = x.Attribute("Match").Value, ReplaceValue = x.Attribute("Replace").Value }).ToList(); status = true; } catch (Exception ex) { logger.Error(ex); } return(status); }
static void Init() { Rect wr = new Rect(100, 100, 450, 600); ReplaceModel window = (ReplaceModel)EditorWindow.GetWindowWithRect(typeof(ReplaceModel), wr, true, "ReplaceGameObjectBatching"); window.Show(); }
public ReplaceViewModel(ReplaceModel replace, DocumentModel document) { Replace = replace; _document = document; ChangeVisiblilityOfReplaceWindowCommand = new RelayCommand(ChangeVisiblilityOfReplaceWindow); ReplaceTextCommand = new RelayCommand(ReplaceText, () => !string.IsNullOrEmpty(Replace.TextToReplace) && !string.IsNullOrEmpty(Replace.TextAfterReplace) && !string.IsNullOrEmpty(_document.Text)); }
public bool SaveReplacementInfo(ReplaceModel model) { int maxSl = _iProductReplaceGateway.GetMaxReplaceSerialNoByYear(DateTime.Now.Year); model.ReplaceNo = maxSl + 1; model.ReplaceRef = GenerateOrderRefNo(maxSl); model.TransactionRef = GenerateOrderRefNo(maxSl); int rowAffected = _iProductReplaceGateway.SaveReplacementInfo(model); return(rowAffected > 0); }
public ActionResult Replace(ReplaceModel model) { if (!_orchardServices.Authorizer.Authorize(Permissions.AccessFindReplace, T("Unable to access Find/Replace"))) { return(new HttpUnauthorizedResult()); } _findReplaceService.Replace(model.ItemIds, model.Find, model.Replace); _orchardServices.Notifier.Add(NotifyType.Information, T("Successfully updated {0} content item(s).", model.ItemIds.Count)); return(RedirectToAction("Index")); }
public Replace() { SettingsOrig = Settings = ReplaceModel.LoadSettings(); InitializeComponent(); replaceSearch.OnSearch += itemNo => { if (string.IsNullOrWhiteSpace(itemNo)) { Settings = SettingsOrig; } else { Settings = SettingsOrig.Where(x => x.ItemNo.Equals( SettingsOrig.FirstOrDefault(y => y.ReplaceNo.Equals(itemNo, StringComparison.CurrentCultureIgnoreCase))?.ItemNo ?? itemNo, StringComparison.CurrentCultureIgnoreCase)).ToList(); } RefreshTableBinding(); }; replaceEdit.OnEdit += (oldVal, newVal) => { var setting = SettingsOrig.FirstOrDefault(x => x.ItemNo.Equals(oldVal.ItemNo, StringComparison.CurrentCultureIgnoreCase) && x.ReplaceNo.Equals(oldVal.ReplaceNo, StringComparison.CurrentCultureIgnoreCase)); if (setting == null) { return; } setting.ItemNo = newVal.ItemNo.ToUpperInvariant(); setting.ReplaceNo = newVal.ReplaceNo.ToUpperInvariant(); replaceSearch.Filter(null, null); RefreshTableBinding(); }; replaceEdit.OnAdd += s => { SettingsOrig.Add(s); SettingsOrig = SettingsOrig.OrderBy(x => x.ItemNo).ToList(); replaceSearch.Filter(null, null); RefreshTableBinding(); }; replaceEdit.OnDelete += s => { SettingsOrig.Remove(s); replaceSearch.Filter(null, null); RefreshTableBinding(); }; RefreshTableBinding(); }
public IActionResult ReplaceTradeUnion(ReplaceModel model) { var usedResistances = db.Resistance.Where(s => s.TradeUnionId == model.Id).ToList(); foreach (var item in usedResistances) { item.TradeUnionId = model.NewId; db.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } var tradeUnion = db.TradeUnion.Find(model.Id); db.TradeUnion.Remove(tradeUnion); db.SaveChanges(); return(Ok()); }
public void ReplaceText_ShouldNotBeAbleToExecute_WhenDocumentTextAndTextToReplaceAndReplacementAreNullOrEmpty() { DocumentModel documentModel = new DocumentModel(); documentModel.Text = string.Empty; ReplaceModel replaceModel = new ReplaceModel(); replaceModel.TextToReplace = string.Empty; replaceModel.TextAfterReplace = string.Empty; ReplaceViewModel replaceViewModel = new ReplaceViewModel(replaceModel, documentModel); Assert.IsFalse(replaceViewModel.ReplaceTextCommand.CanExecute(null)); }
public IActionResult ReplaceCompany(ReplaceModel model) { var usedResistances = db.Resistance.Where(s => s.CompanyId == model.Id).ToList(); foreach (var item in usedResistances) { item.CompanyId = model.NewId; db.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } var company = db.Company.Find(model.Id); company.Deleted = true; db.SaveChanges(); return(Ok()); }
public void ReplaceText_ShouldBeAbleToExecute_WhenDocumentTextAndTextToReplaceAndReplacementAreNotNullOrEmpty() { DocumentModel documentModel = new DocumentModel(); documentModel.Text = "test"; ReplaceModel replaceModel = new ReplaceModel(); replaceModel.TextToReplace = "test"; replaceModel.TextAfterReplace = "test"; ReplaceViewModel replaceViewModel = new ReplaceViewModel(replaceModel, documentModel); Assert.IsTrue(replaceViewModel.ReplaceTextCommand.CanExecute(null)); }
public int SaveReplacementInfo(ReplaceModel model) { ConnectionObj.Open(); SqlTransaction sqlTransaction = ConnectionObj.BeginTransaction(); try { CommandObj.Transaction = sqlTransaction; CommandObj.CommandText = "UDSP_SaveReplacementInfo"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@ClientId", model.ClientId); CommandObj.Parameters.AddWithValue("@ReplaceRef", model.ReplaceRef); CommandObj.Parameters.AddWithValue("@ReplaceNo", model.ReplaceNo); CommandObj.Parameters.AddWithValue("@TransactionRef", model.ReplaceRef); CommandObj.Parameters.AddWithValue("@BranchId", model.BranchId); CommandObj.Parameters.AddWithValue("@DistributionPointId", model.DistributionPointId); CommandObj.Parameters.AddWithValue("@Remarks", model.Remarks); CommandObj.Parameters.AddWithValue("@CompanyId", model.CompanyId); CommandObj.Parameters.AddWithValue("@UserId", model.UserId); CommandObj.Parameters.Add("@ReplaceMasterId", SqlDbType.BigInt); CommandObj.Parameters["@ReplaceMasterId"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); var masterId = Convert.ToInt64(CommandObj.Parameters["@ReplaceMasterId"].Value); var rowAffected = SaveReplacementDetails(model, masterId); if (rowAffected > 0) { sqlTransaction.Commit(); } return(rowAffected); } catch (Exception exception) { Log.WriteErrorLog(exception); sqlTransaction.Rollback(); throw new Exception("Could not save Replace Info", exception); } finally { CommandObj.Dispose(); ConnectionObj.Close(); CommandObj.Parameters.Clear(); } }
public void ReplaceText_ShouldReplaceText_WhenRegex() { var text = "test nontest word"; var expected = "testnannontestnanword"; ReplaceModel replaceModel = new ReplaceModel(); DocumentModel documentModel = new DocumentModel(); replaceModel.IsRegex = true; replaceModel.TextToReplace = @"\s+"; replaceModel.TextAfterReplace = "nan"; documentModel.Text = text; ReplaceViewModel replaceViewModel = new ReplaceViewModel(replaceModel, documentModel); replaceViewModel.ReplaceTextCommand.Execute(null); Assert.AreEqual(expected, documentModel.Text); }
private int SaveReplacementDetails(ReplaceModel model, long masterId) { int n = 0; foreach (var item in model.Products) { CommandObj.Parameters.Clear(); CommandObj.CommandText = "UDSP_SaveReplacementDetails"; CommandObj.CommandType = CommandType.StoredProcedure; CommandObj.Parameters.AddWithValue("@ProductId", item.ProductId); CommandObj.Parameters.AddWithValue("@ReplaceId", masterId); CommandObj.Parameters.AddWithValue("@Quantity", item.Quantity); CommandObj.Parameters.AddWithValue("@ExpiryDate", item.ExpiryDate); CommandObj.Parameters.Add("@RowAffected", SqlDbType.Int); CommandObj.Parameters["@RowAffected"].Direction = ParameterDirection.Output; CommandObj.ExecuteNonQuery(); n += Convert.ToInt32(CommandObj.Parameters["@RowAffected"].Value); } return(n); }
public void OpenEdit(ReplaceModel replaceModel) { if (Edit) { var res = !ReplaceModel.ItemNo.Equals(ItemNo.Text, StringComparison.CurrentCultureIgnoreCase) || !ReplaceModel.ReplaceNo.Equals(ReplaceNo.Text, StringComparison.CurrentCultureIgnoreCase) ? MessageBox.Show("Вы уже редактируете запись. Сохранить изменения предидущей?", "Сохранить изменения", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) : DialogResult.No; switch (res) { case DialogResult.Yes: OnEdit?.Invoke(ReplaceModel, new ReplaceModel() { ItemNo = ItemNo.Text.ToUpperInvariant(), ReplaceNo = ReplaceNo.Text.ToUpperInvariant() }); break; case DialogResult.No: ReplaceModel = replaceModel; ItemNo.Text = ReplaceModel.ItemNo.ToUpperInvariant(); ReplaceNo.Text = ReplaceModel.ReplaceNo.ToUpperInvariant(); break; case DialogResult.Cancel: break; } } else { ReplaceModel = replaceModel; ItemNo.Text = ReplaceModel.ItemNo.ToUpperInvariant(); ReplaceNo.Text = ReplaceModel.ReplaceNo.ToUpperInvariant(); } Edit = true; }
public MainViewModel() { _document = new DocumentModel(); _debuggerModel = new DebuggerModel(); _console = new ConsoleModel(); _debugDocumentModel = new DebugDocumentModel(); _replaceModel = new ReplaceModel(); _compilerFlags = new CompilerFlagsModel(); _debuggerFlags = new DebuggerFlagsModel(); _editorView = new EditorView(); _editorDebugView = new EditorDebugView(); _currentView = _editorView; Editor = new EditorViewModel(_document); File = new FileViewModel(_document); Help = new HelpViewModel(); Debugger = new DebuggerViewModel(_document, _debugDocumentModel, _console, _debuggerModel, _currentView, _editorView, _editorDebugView, _debuggerFlags); Compiler = new CompilerViewModel(_document, _console, _compilerFlags); MainWindow = new MainWindowViewModel(); Replace = new ReplaceViewModel(_replaceModel, _document); }
public ActionResult SaveReplacementInfo(FormCollection collection) { try { var products = GetProductFromXmalFile(GetTempReplaceProductXmlFilePath()); var r = collection["clientId1"]; bool result = false; if (products.Any() && r != "") { int branchId = Convert.ToInt32(Session["BranchId"]); int companyId = Convert.ToInt32(Session["CompanyId"]); var clientId = Convert.ToInt32(collection["clientId1"]); var user = (ViewUser)Session["user"]; var model = new ReplaceModel { ClientId = clientId, Products = products.ToList(), BranchId = branchId, UserId = user.UserId, CompanyId = companyId }; result = _iProductReplaceManager.SaveReplacementInfo(model); } if (result) { TempData["SaveReplaceMessage"] = "<p style='color:green'>Saved Successfully!</p>"; RemoveAll(); } return(RedirectToAction("Entry")); } catch (Exception exception) { Log.WriteErrorLog(exception); return(PartialView("_ErrorPartial", exception)); } }
public IActionResult ReplaceProtestoType(ReplaceModel model) { var anyResistanceProtestoType = db.ProtestoProtestoType.Any(s => s.ProtestoTypeId == model.NewId); var usedResistances = db.ProtestoProtestoType.Where(s => s.ProtestoTypeId == model.Id).ToList(); if (!anyResistanceProtestoType) { db.ProtestoProtestoType.RemoveRange(usedResistances); } else { foreach (var item in usedResistances) { item.ProtestoTypeId = model.NewId; db.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } } var protestoType = db.ProtestoType.Find(model.Id); db.ProtestoType.Remove(protestoType); db.SaveChanges(); return(Ok()); }
public IActionResult ReplaceCorporation(ReplaceModel model) { var anyResistanceCorporation = db.ResistanceCorporation.Any(s => s.CorporationId == model.NewId); var usedResistances = db.ResistanceCorporation.Where(s => s.CorporationId == model.Id).ToList(); if (!anyResistanceCorporation) { db.ResistanceCorporation.RemoveRange(usedResistances); } else { foreach (var item in usedResistances) { item.CorporationId = model.NewId; db.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } } var corporation = db.Corporation.Find(model.Id); db.Corporation.Remove(corporation); db.SaveChanges(); return(Ok()); }
public int Update(ReplaceModel model) { throw new NotImplementedException(); }
public bool Delete(ReplaceModel model) { throw new NotImplementedException(); }
public void SaveSettings() { ReplaceModel.SaveSettings(SettingsOrig); }
public ActionResult Entry(FormCollection collection, ReplaceModel model) { try { int branchId = Convert.ToInt32(Session["BranchId"]); int companyId = Convert.ToInt32(Session["CompanyId"]); var clientId = Convert.ToInt32(collection["clientId"]); var user = (ViewUser)Session["user"]; var productId = Convert.ToInt32(collection["ProductId"]); var qty = Convert.ToInt32(collection["Quantity"]); var aProduct = _iProductManager.GetProductByProductId(productId); aProduct.Quantity = qty; aProduct.ExpiryDate = model.ExpiryDate; aProduct.SaleDate = model.SaleDate; var products = new List <Product> { aProduct }; model.ClientId = clientId; model.Products = products.ToList(); model.BranchId = branchId; model.UserId = user.UserId; model.CompanyId = companyId; model.Remarks = collection["Remarks"]; //var result = _iProductReplaceManager.SaveReplacementInfo(model); var warrantyBatteryModel = new WarrantyBatteryModel { ReceiveDatetime = DateTime.Now, ClientId = clientId, ReceiveByBranchId = branchId, EntryByUserId = user.UserId, DelivaryRef = DateTime.Now.Year.ToString().Substring(2, 2) + "FAKE", TransactionRef = Guid.NewGuid().ToString().ToUpper().Substring(0, 8), ReportByEmployeeId = user.EmployeeId, ReceiveRemarks = model.Remarks, ProductId = productId, IsManualEntry = "Y", Status = 1, ExpiryDate = model.ExpiryDate, SaleDate = model.SaleDate }; if (collection["Barcode"] == "") { warrantyBatteryModel.Barcode = "FAKE" + Guid.NewGuid().ToString().ToUpper().Substring(0, 9); } else { warrantyBatteryModel.Barcode = collection["Barcode"]; } var resultTest = _iServiceManager.ReceiveServiceProductTemp(warrantyBatteryModel); if (resultTest) { ModelState.Clear(); ViewBag.DistributionPointId = new SelectList(_iBranchManager.GetAllBranches(), "BranchId", "BranchName", branchId); return(View()); } // AddProductToTempReplaceProductXmlFile(aProduct); ViewBag.DistributionPointId = new SelectList(_iBranchManager.GetAllBranches(), "BranchId", "BranchName", branchId); return(View()); } catch (Exception exception) { Log.WriteErrorLog(exception); return(PartialView("_ErrorPartial", exception)); } //return View(); }