public ActionResult _Destroy([DataSourceRequest]DataSourceRequest request, TempExt model) { string Msg = ""; try { TempRepository modelRepo = new TempRepository(); if (modelRepo.Delete(model, ref Msg, this) == false) { return this.Json(new DataSourceResult { Errors = Msg }); } } catch (Exception ex) { string hostName1 = Dns.GetHostName(); string GetUserIPAddress = Dns.GetHostByName(hostName1).AddressList[0].ToString(); string PageName = Convert.ToString(Session["PageName"]); //string GetUserIPAddress = GetUserIPAddress1(); using (BaseRepository baseRepo = new BaseRepository()) { //BizContext BizContext1 = new BizContext(); BizApplication.AddError(baseRepo.BizDB, PageName, ex.Message, ex.StackTrace, DateTime.Now, GetUserIPAddress); } Session["PageName"] = ""; string error = ErrorHandling.HandleException(ex); return this.Json(new DataSourceResult { Errors = error }); } return Json(request); }
public static TestSetup Create() { var tempDir = TempDir.Create(); var repository = TempRepository.Create(tempDir); return(new TestSetup(repository, tempDir)); }
//view all the student on the system public IActionResult view(string searchString) { TempRepository.RemoveAll(); var StudentData = _dbContext.InfoTable.OrderBy(s => s.Id); var StudentGpa = _dbContext.StudnetGpa.OrderBy(s => s.StuId); var ResultList = from data in StudentData join Gpa in StudentGpa on data.Id equals Gpa.StuId select new { data.Id, data.Name, Gpa.StuGpa }; var FinalData = ResultList.Select(s => new { s.Id, s.Name, s.StuGpa }); if (!string.IsNullOrEmpty(searchString)) { FinalData = FinalData.Where(s => s.Id.Contains(searchString) || s.Name.Contains(searchString)); } foreach (var f in FinalData) { TempRepository.AddStudent(new NewStudentInsert { Id = f.Id, Name = f.Name, StudentGPA = f.StuGpa }); } return(View(TempRepository.Inserted)); }
public static void TestRepositoryPattern() { var storeName = "TestRepositoryPattern" + DateTime.Now.Ticks; string id; using ( var context = new MyEntityContext()) { var uow = new TempUnitOfWork(context); var repo = new TempRepository<IPerson>(uow); var derived = repo.Create(); derived.FirstName = "Danny"; derived.FirstName = "Mayers"; context.SaveChanges(); id = derived.Id; } using ( var context = new MyEntityContext()) { var uow = new TempUnitOfWork(context); var repo = new TempRepository<IPerson>(uow); var derived = repo.GetById(id); } }
public IHttpActionResult VehiclStatus(string status) { var vs = new TempRepository().AddUpdate(new DomainModel.TempStatus() { CreatedDate = DateTime.Now, DataStr = status }); return(Ok(new { ss = vs.ResponseIdStr })); }
public async Task <IActionResult> Upload(IFormFile file) { TempRepository.RemoveAll(); var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot", file.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } //Load the the data from the uploaded file IEnumerable <NewStudentInsert> ToAdd = DataLoader.Load(@"wwwroot\" + file.FileName); foreach (NewStudentInsert s in ToAdd) { s.Id = s.Id.Trim(); s.Name = s.Name.Trim(); s.Pass = s.Pass.Trim(); s.RepeatPass = s.RepeatPass.Trim(); var targetUser = _dbContext.InfoTable.SingleOrDefault(i => i.Id.Equals(s.Id, StringComparison.CurrentCulture)); var targetGPA = _dbContext.InfoTable.SingleOrDefault(i => i.Id.Equals(s.Id, StringComparison.CurrentCulture)); if (targetUser != null) { TempRepository.AddStudent(new NewStudentInsert { Id = s.Id, Name = s.Name, StudentGPA = s.StudentGPA, ADD = false }); continue; } var hasher = new PasswordHasher <InfoTable>(); targetUser = new InfoTable { Id = s.Id, Name = s.Name, RoleId = 2 }; targetUser.Pass = hasher.HashPassword(targetUser, s.Pass); //targetGPA = new StudnetGpa { StuId = student.Id, StuGpa = student.StudentGPA }; await _dbContext.InfoTable.AddAsync(targetUser); await _dbContext.SaveChangesAsync(); if (s.StudentGPA != double.NaN) { await GpaSet(s); } ViewBag.templist = true; TempRepository.AddStudent(s); } ViewBag.inserted = true; return(View(TempRepository.Inserted)); }
public void UpdateRequestSubstituteOfOrganicInfo(List <decimal> personIds) { try { string Description = string.Empty; string SQLCommand = string.Empty; if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { Description = "N'رد درخواست به دلیل تغییر مشخصات پرسنل درخواست کننده یا پرسنل جانشین درخواست'"; } else { Description = "N'Request Reject because Personel Specifications Change'"; } if (personIds.Count < operationBatchSizeValue && operationBatchSizeValue < 2100) { SQLCommand = "update rSubstitute " + "set requestSubstitute_Confirmed = 0 , " + "requestSubstitute_Description = " + Description + " " + "from TA_RequestSubstitute rSubstitute " + "INNER JOIN TA_Request request " + "ON rSubstitute.requestSubstitute_RequestID = request.request_ID " + "where rSubstitute.requestSubstitute_SubstituteID IN (:personIds) or " + "request.request_PersonID IN (:personIds) "; NHibernateSessionManager.Instance.GetSession().CreateSQLQuery(SQLCommand) .SetParameterList("personIds", personIds.ToArray()) .ExecuteUpdate(); } else { TempRepository tempRep = new TempRepository(false); string operationGUID = tempRep.InsertTempList(personIds); SQLCommand = " update rSubstitute " + " set requestSubstitute_Confirmed = 0 , " + " requestSubstitute_Description = " + Description + " " + " from TA_RequestSubstitute rSubstitute " + " INNER JOIN TA_Request request " + " ON rSubstitute.requestSubstitute_RequestID = request.request_ID " + " INNER JOIN TA_Temp temp " + " ON rSubstitute.requestSubstitute_SubstituteID = temp.temp_ObjectID OR request.request_PersonID = temp.temp_ObjectID " + " where temp_OperationGUID =:operationGUID "; NHibernateSessionManager.Instance.GetSession().CreateSQLQuery(SQLCommand) .SetParameter("operationGUID", operationGUID) .ExecuteUpdate(); tempRep.DeleteTempList(operationGUID); } } catch (Exception ex) { LogException(ex, "BRequestSubstitute", "UpdateRequestSubstituteOfOrganicInfo"); throw ex; } }
public ViewResult AddRecipe(Recipe recipe) { if (ModelState.IsValid) { TempRepository.RecipeAdd(recipe); return(View()); } else { return(View()); } }
private Repository SetupRepositoryWithRemote(string remoteName, string pushUrl) { var workingDirectory = TempDir.Create(); var repo = TempRepository.Create(workingDirectory); foreach (var existingRemoteName in repo.Network.Remotes.Select(remote => remote.Name)) { repo.Network.Remotes.Remove(existingRemoteName); } repo.Network.Remotes.Add(remoteName, pushUrl); return(repo); }
public void Empty_Repository() { using (var temp = new TempRepository()) { var path = temp.Directory.FullName; var target = new GitService(new RepositoryFacade()); var model = target.CreateLocalRepositoryModel(path); Assert.That(model, Is.Not.Null); Assert.That(model.LocalPath, Is.EqualTo(path)); Assert.That(model.Name, Is.EqualTo(temp.Directory.Name)); } }
public async Task Can_Handle_Renames(string oldPath, string oldContent, string newPath, string newContent, int expectLinesAdded) { using (var temp = new TempRepository()) { var commit1 = AddCommit(temp.Repository, oldPath, oldContent.Replace('.', '\n')); var commit2 = AddCommit(temp.Repository, newPath, newContent.Replace('.', '\n')); var contentBytes = new UTF8Encoding(false).GetBytes(newContent.Replace('.', '\n')); var target = new GitService(new RepositoryFacade()); var changes = await target.CompareWith(temp.Repository, commit1.Sha, commit2.Sha, newPath, contentBytes); Assert.That(changes?.LinesAdded, Is.EqualTo(expectLinesAdded)); } }
public void ShouldExitIfWorkingCopyContainsNoProjects() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); var workingCopy = WorkingCopy.Discover(workingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages[0].ShouldBe($"Could not find any projects files in {workingDirectory} that have a <Version> defined in their csproj file."); Cleanup.DeleteDirectory(workingDirectory); }
[TestCase("1.2.a..b.3.4", "1.2.a..b.a..b.3.4", "+b.+a.+.")] // This would be "+a.+.+b." without Indent-heuristic public async Task Indent_Heuristic_Is_Enabled(string content1, string content2, string expectPatch) { using (var temp = new TempRepository()) { var path = "foo.txt"; var commit1 = AddCommit(temp.Repository, path, content1.Replace('.', '\n')); var commit2 = AddCommit(temp.Repository, path, content2.Replace('.', '\n')); var target = new GitService(new RepositoryFacade()); var patch = await target.Compare(temp.Repository, commit1.Sha, commit2.Sha, path); Assert.That(patch.Content.Replace('\n', '.'), Contains.Substring(expectPatch)); } }
public async Task One_File_Is_Modified(string content1, string content2) { using (var temp = new TempRepository()) { var path = "foo.txt"; var commit1 = AddCommit(temp.Repository, path, content1.Replace('.', '\n')); var commit2 = AddCommit(temp.Repository, path, content2.Replace('.', '\n')); var target = new GitService(new RepositoryFacade()); var treeChanges = await target.Compare(temp.Repository, commit1.Sha, commit2.Sha, false); Assert.That(treeChanges.Modified.FirstOrDefault()?.Path, Is.EqualTo(path)); } }
public async Task Simple_Diff(string content1, string content2, string expectPatch) { using (var temp = new TempRepository()) { var path = "foo.txt"; var commit1 = AddCommit(temp.Repository, path, content1.Replace('.', '\n')); var commit2 = AddCommit(temp.Repository, path, content2.Replace('.', '\n')); var contentBytes = new UTF8Encoding(false).GetBytes(content2.Replace('.', '\n')); var target = new GitService(new RepositoryFacade()); var changes = await target.CompareWith(temp.Repository, commit1.Sha, commit2.Sha, path, contentBytes); Assert.That(changes.Patch.Replace('\n', '.'), Contains.Substring(expectPatch)); } }
public void Path_Must_Not_Use_Windows_Directory_Separator() { using (var temp = new TempRepository()) { var path = @"dir\foo.txt"; var oldContent = "oldContent"; var newContent = "newContent"; var commit1 = AddCommit(temp.Repository, path, oldContent); var commit2 = AddCommit(temp.Repository, path, newContent); var target = new GitService(new RepositoryFacade()); Assert.ThrowsAsync <ArgumentException>(() => target.Compare(temp.Repository, commit1.Sha, commit2.Sha, path)); } }
public void Check_HasRemotesButNoOrigin(string remoteName, string remoteUrl, bool noOrigin) { using (var temp = new TempRepository()) { if (remoteName != null) { temp.Repository.Network.Remotes.Add(remoteName, remoteUrl); } var path = temp.Directory.FullName; var target = new GitService(new RepositoryFacade()); var model = target.CreateLocalRepositoryModel(path); Assert.That(model.HasRemotesButNoOrigin, Is.EqualTo(noOrigin)); } }
public async Task <IActionResult> ManualRegister(AllInfo student) { if (!ModelState.IsValid) { return(View()); } else { //Remove any spaces in the first student.newStudnet.Id = student.newStudnet.Id.Trim(); student.newStudnet.Name = student.newStudnet.Name.Trim(); student.newStudnet.Pass = student.newStudnet.Pass.Trim(); student.newStudnet.RepeatPass = student.newStudnet.RepeatPass.Trim(); //check if the target user is used before or not var targetUser = _dbContext.InfoTable.SingleOrDefault(i => i.Id.Equals(student.newStudnet.Id, StringComparison.CurrentCulture)); var targetGPA = _dbContext.InfoTable.SingleOrDefault(i => i.Id.Equals(student.newStudnet.Id, StringComparison.CurrentCulture)); if (targetUser != null) { ViewBag.IdTarget = "This ID is already used"; return(View()); } //hash password var hasher = new PasswordHasher <InfoTable>(); targetUser = new InfoTable { Id = student.newStudnet.Id, Name = student.newStudnet.Name, RoleId = 2 }; targetUser.Pass = hasher.HashPassword(targetUser, student.newStudnet.Pass); //chech the GPA if (student.newStudnet.StudentGPA != double.NaN) { await GpaSet(student.newStudnet); } await _dbContext.InfoTable.AddAsync(targetUser); await _dbContext.SaveChangesAsync(); ViewBag.templist = true; TempRepository.AddStudent(student.newStudnet); ViewBag.inserted = true; return(View(new AllInfo { Studentslist = TempRepository.Inserted })); } }
/// <summary> /// تغییر مشخصات سازمانی پرسنل تحت مدیریت /// </summary> /// <param name="personList">لیست پرسنل</param> /// <param name="infoProxy">پروکسی مشخصات سازمانی</param> private void UpdateUnderManagement(IList <Person> personList, OrganicInfoProxy infoProxy) { try { if (infoProxy.DepartmentID != 0) { IQuery query = null; List <decimal> personIdList = new List <decimal>(); string operationGUID = string.Empty; string SQLCommand = string.Empty; operationGUID = string.Empty; foreach (Person person in personList) { personIdList.Add(person.ID); } if (personList.Count < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100) { SQLCommand = @"Update TA_UnderManagment SET underMng_DepartmentID =:DepartmentId WHERE underMng_PersonID in (:PersonList)"; query = NHibernateSessionManager.Instance.GetSession().CreateSQLQuery(SQLCommand); query.SetParameter("DepartmentId", infoProxy.DepartmentID); query.SetParameterList("PersonList", personIdList); query.ExecuteUpdate(); } else { TempRepository temprepository = new TempRepository(false); operationGUID = temprepository.InsertTempList(personIdList); // SQLCommand = @"Update TA_UnderManagment SET underMng_DepartmentID =:DepartmentId WHERE underMng_PersonId in // (select prs_Id from TA_Person Inner join TA_Temp on prs_Id = temp_ObjectID WHERE temp_OperationGUID =:operationGUID)"; SQLCommand = @"Update underMng SET underMng_DepartmentID =:DepartmentId from TA_UnderManagment underMng inner join TA_Person person on underMng.underMng_PersonId = person.prs_Id inner join TA_Temp temp on person.prs_Id = temp.temp_ObjectID and temp.temp_OperationGUID =:operationGUID"; query = NHibernateSessionManager.Instance.GetSession().CreateSQLQuery(SQLCommand); query.SetParameter("DepartmentId", infoProxy.DepartmentID); query.SetParameter("operationGUID", operationGUID); query.ExecuteUpdate(); temprepository.DeleteTempList(operationGUID); } } } catch (Exception ex) { BaseBusiness <Entity> .LogException(ex, "BChangeOrganicInfo", "UpdateUnderManagement"); throw ex; } }
public async Task Path_Can_Use_Windows_Directory_Separator() { using (var temp = new TempRepository()) { var path = @"dir\foo.txt"; var oldContent = "oldContent"; var newContent = "newContent"; var commit1 = AddCommit(temp.Repository, path, oldContent); var commit2 = AddCommit(temp.Repository, path, newContent); var target = new GitService(new RepositoryFacade()); var patch = await target.Compare(temp.Repository, commit1.Sha, commit2.Sha, path); var gitPath = Paths.ToGitPath(path); Assert.That(patch.Count(c => c.Path == gitPath), Is.EqualTo(1)); } }
public void ShouldExitIfWorkingCopyIsDirty() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); TempCsProject.Create(workingDirectory); var workingCopy = WorkingCopy.Discover(workingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages.ShouldHaveSingleItem(); _testPlatformAbstractions.Messages[0].ShouldBe($"Repository {workingDirectory} is dirty. Please commit your changes."); Cleanup.DeleteDirectory(workingDirectory); }
public void ShouldExitIfProjectsUseInconsistentNaming() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); TempCsProject.Create(Path.Join(workingDirectory, "project1"), "1.1.0"); TempCsProject.Create(Path.Join(workingDirectory, "project2"), "2.0.0"); CommitAll(tempRepository); var workingCopy = WorkingCopy.Discover(workingDirectory); Should.Throw <CommandLineExitException>(() => workingCopy.Versionize()); _testPlatformAbstractions.Messages[0].ShouldBe($"Some projects in {workingDirectory} have an inconsistent <Version> defined in their csproj file. Please update all versions to be consistent or remove the <Version> elements from projects that should not be versioned"); Cleanup.DeleteDirectory(workingDirectory); }
public async Task Path_Can_Use_Windows_Directory_Separator() { using (var temp = new TempRepository()) { var path = @"dir\foo.txt"; var oldContent = "oldContent"; var newContent = "newContent"; var commit1 = AddCommit(temp.Repository, path, oldContent); var commit2 = AddCommit(temp.Repository, path, newContent); var contentBytes = new UTF8Encoding(false).GetBytes(newContent); var target = new GitService(new RepositoryFacade()); var contentChanges = await target.CompareWith(temp.Repository, commit1.Sha, commit2.Sha, path, contentBytes); Assert.That(contentChanges.LinesAdded, Is.EqualTo(1)); Assert.That(contentChanges.LinesDeleted, Is.EqualTo(1)); } }
// GET: Payment public ActionResult Index(bool success, int order) { string ff = ""; foreach (string key in Request.Form.AllKeys) { ff += Request.Form[key]; } using (TempRepository bb = new TempRepository()) { bb.AddUpdate(new DomainModel.TempStatus() { DataStr = ff, CreatedDate = DateTime.Now }); } var bodyStream = new StreamReader(Request.InputStream); bodyStream.BaseStream.Seek(0, SeekOrigin.Begin); var bodyText = bodyStream.ReadToEnd(); using (TempRepository bb = new TempRepository()) { bb.AddUpdate(new DomainModel.TempStatus() { DataStr = bodyText, CreatedDate = DateTime.Now }); } ViewBag.IsSuccess = false; if (success) { using (TripRepository tripRepo = new TripRepository()) { tripRepo.TripPaymentDone(order); } ViewBag.IsSuccess = true; } return(View()); }
public void ShouldIgnoreInsignificantCommits() { var workingDirectory = TempDir.Create(); using var tempRepository = TempRepository.Create(workingDirectory); TempCsProject.Create(workingDirectory); var workingFilePath = Path.Join(workingDirectory, "hello.txt"); // Create and commit a test file File.WriteAllText(workingFilePath, "First line of text"); CommitAll(tempRepository); // Run versionize var workingCopy = WorkingCopy.Discover(workingDirectory); workingCopy.Versionize(); // Add insignificant change File.AppendAllText(workingFilePath, "This is another line of text"); CommitAll(tempRepository, "chore: Added line of text"); // Get last commit var lastCommit = tempRepository.Head.Tip; // Run versionize, ignoring insignificant commits try { workingCopy.Versionize(ignoreInsignificant: true); throw new InvalidOperationException("Expected to throw in Versionize call"); } catch (CommandLineExitException ex) { ex.ExitCode.ShouldBe(0); } lastCommit.ShouldBe(tempRepository.Head.Tip); // Cleanup Cleanup.DeleteDirectory(workingDirectory); }
public void Master_Branch() { using (var temp = new TempRepository()) { var signature = new Signature("Me", "*****@*****.**", DateTimeOffset.Now); temp.Repository.Commit("First", signature, signature); var expectSha = temp.Repository.Head.Tip.Sha; var path = temp.Directory.FullName; var target = new GitService(new RepositoryFacade()); var localRepository = target.CreateLocalRepositoryModel(path); var branch = target.GetBranch(localRepository); Assert.That(branch.Name, Is.EqualTo("master")); Assert.That(branch.DisplayName, Is.EqualTo("master")); Assert.That(branch.Id, Is.EqualTo("/master")); // We don't know owner Assert.That(branch.IsTracking, Is.EqualTo(false)); Assert.That(branch.TrackedSha, Is.EqualTo(null)); Assert.That(branch.Sha, Is.EqualTo(expectSha)); } }
public void Branch_With_Remote() { using (var temp = new TempRepository()) { var repository = temp.Repository; var owner = "owner"; var remoteName = "remoteName"; var remote = repository.Network.Remotes.Add(remoteName, $"https://github.com/{owner}/VisualStudio"); var localBranch = repository.Head; repository.Branches.Update(temp.Repository.Head, b => b.Remote = remote.Name, b => b.UpstreamBranch = localBranch.CanonicalName); var path = temp.Directory.FullName; var target = new GitService(new RepositoryFacade()); var localRepository = target.CreateLocalRepositoryModel(path); var branch = target.GetBranch(localRepository); Assert.That(branch.TrackedRemoteName, Is.EqualTo(remoteName)); } }
public IHttpActionResult PeymentGet() { try { // logger.Info("start 2 "); var bodyStream = new StreamReader(HttpContext.Current.Request.InputStream); bodyStream.BaseStream.Seek(0, SeekOrigin.Begin); var bodyText = bodyStream.ReadToEnd(); // logger.Info("Body 2:" + bodyText); if (!string.IsNullOrEmpty(bodyText)) { using (TempRepository bb = new TempRepository()) { bb.AddUpdate(new DomainModel.TempStatus() { DataStr = "Get " + bodyText, CreatedDate = DateTime.Now }); } WeAcceptTockenModelContainer returnObj = JsonConvert.DeserializeObject <WeAcceptTockenModelContainer>(bodyText); if (returnObj.obj != null) { if (!string.IsNullOrEmpty(returnObj.obj.token)) { using (SecurityUserRepository secRepo = new SecurityUserRepository()) { secRepo.UpdatePaymentTocken(returnObj.obj.token, returnObj.obj.order_id); } } } WeAcceptRootObject returnMainObj = JsonConvert.DeserializeObject <WeAcceptRootObject>(bodyText); if (returnMainObj.obj != null) { if (returnMainObj.obj.order != null) { logger.Info("obj.order.id : " + returnMainObj.obj.order.id.ToString()); logger.Info("obj.success : " + returnMainObj.obj.success); logger.Info("obj.id : " + returnMainObj.obj.id.ToString()); using (SecurityUserRepository secRepo = new SecurityUserRepository()) { if (returnMainObj.obj.success == true) { secRepo.UpdatePaymentDone(returnMainObj.obj.order.id.ToString()); secRepo.UpdateRefundOrderId(returnMainObj.obj.id.ToString(), returnMainObj.obj.order.id.ToString()); } } } } return(Ok("1 EGP has been successfully deducted from your card, please return to rabbit.")); } else { return(Ok("1 EGP has been successfully deducted from your card, please return to rabbit.")); } } catch (Exception ex) { logger.Error(ex.Message + " > " + ex.InnerException?.Message + " > " + ex.StackTrace); return(Ok("Pending payment, Please try again if not success")); } }
public ActionResult _Read([DataSourceRequest]DataSourceRequest request) { TempRepository modelRepo = new TempRepository(); DataSourceResult result = modelRepo.ReadAll().ToDataSourceResult(request); return Json(result); }