public User Insert(User newUser, Cred newCred) { if (newUser == null) { throw new ArgumentNullException(nameof(newUser)); } if (string.IsNullOrEmpty(newCred.UserPassword) || string.IsNullOrEmpty(newCred.UserEmail)) { throw new ArgumentNullException(nameof(newCred)); } Entities.Add(newUser); SaveChanges(); newCred.UserId = newUser.Id; if (CredRepository.Create(newCred) == null) { throw new ArgumentNullException(nameof(newCred)); } return(Entities.Include(i => i.Role).FirstOrDefault(f => f.Id == newUser.Id)); }
public void init() { cred = new Cred(@"D:\__kpi\kpi\bin\Debug"); con = new SqlConnection(cred.connectionString()); con.Open(); /// delegate AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args) { string name = args.Name; using (SqlCommand cmd = con.CreateCommand()) { cmd.CommandText = @"SELECT dll FROM docscript WHERE name = @name"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@name", name); object o = cmd.ExecuteScalar(); byte[] bytes = o as byte[]; if (bytes != null) { Assembly assm = System.Reflection.Assembly.Load(bytes); return(assm); } else { return(null); } } }; }
public User GetByEmailAndPassword(string userEmail, string userPassword) { Cred cred = Entities. FirstOrDefault(f => (f.UserEmail == userEmail) && (f.UserPassword == userPassword)); User user = null; if (cred != null) { user = Context.Users.Include(i => i.Role).FirstOrDefault(f => f.Id == cred.UserId); } return(user); }
public static ICred CreateCred(CredPOCO poco) { var cred = new Cred { Login = poco.Login, Pass = poco.Pass, Cookie = poco.Cookie, Expired = poco.Expired, Autorization = poco.Autorization, Site = EnumHelper.GetValueFromDescription <SiteType>(poco.Site) }; return(cred); }
public bool RemoveByUserId(int userId) { Cred cred = GetByUserId(userId); if (cred == null) { throw new Exception("Cred was not found."); } Entities.Remove(cred); SaveChanges(); return(true); }
/// <summary> /// Runs before the run() function runs /// </summary> #region before protected override void BeforeRun() { #region IOHelper_Before var fs = new Sys.FileSystem.CosmosVFS(); Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs); #endregion loadingscreen.loadScreen(); Console.Clear(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Cred.authentication(); Console.WriteLine("Welcome To DogeDOS 1.0"); user = ReadText("creduser"); }
public bool UpdateUserCred(int userId, User user) { Cred dbCred = GetByUserId(userId); if (dbCred == null) { throw new ArgumentException(nameof(dbCred)); } dbCred.UserEmail = user.Email; dbCred.UserPassword = user.Password; SaveChanges(); return(true); }
public async Task GetKey() { Cred creds = null; string result = string.Empty; try { creds = _db.Cred.FirstOrDefault(); _sessionCheckUrl = $"{_baseUrl}/?s={_apiKey};callsign=kf7ign"; using (var client = new HttpClient()) { var fullUrl = $"{_baseUrl}/?username={creds.User};password={creds.Pass};agent=q5.0"; var response = await client.GetAsync(fullUrl); result = await response.Content.ReadAsStringAsync(); } _logger.LogInformation($"{result}"); } catch { _logger.LogError("Error updating QRZ Api key!"); } finally { creds = null; } var qrzApi = ConvertResultToXml(result); if (!string.IsNullOrEmpty(qrzApi.Session.Key)) { _qrzApiData.ApiKey = qrzApi.Session.Key; await _db.SaveChangesAsync(); _apiKey = _qrzApiData.ApiKey; _logger.LogInformation("Updated QRZ Api Key!"); } else { if (!string.IsNullOrEmpty(qrzApi.Session.Error)) { _logger.LogError($"{qrzApi.Session.Error}"); } } }
public IActionResult Get2(Cred cred) { var rng = new Random(); var list = Enumerable.Range(1, 5).Select(index => new WeatherForecast { //Date = DateTime.Now.AddDays(index), TemperatureC = rng.Next(-20, 55), Summary = Summaries[rng.Next(Summaries.Length)] }).ToList(); var result = new RequestResult <List <WeatherForecast> >() { Data = list, Success = true, Message = "Success" }; return(Ok(result)); }
static void Main(string[] args) { try { string cwd = Environment.CurrentDirectory; if (args.Length > 0) { string cmd = args[0]; // заставит создавать файлы если их еще нет , ну или как-то иначе bool force = args.Length > 1 && args[1].ToLower() == "-f"; // todo set -f пишет весь проект не смотря на hg log -v -r tip Cred cred = new Cred(cwd); switch (cmd) { case "get": Core.get(cred, force); break; case "compile": Core.compile(cred); break; case "commit": // commit; Core.commit(cred); break; case "inject": Core.inject(cred); break; case "eject": Core.eject(cred); break; case "export": if (args.Length > 1) { string exportDll = args[1].Trim(); Core.export(cred, exportDll); } else { throw new IncorrectUsageEx(); } break; } } else { throw new IncorrectUsageEx(); } } catch (IncorrectUsageEx) { Console.WriteLine("incorrect usaget. hook { get [-f] | set | compile | inject | eject }"); Environment.Exit(1); } catch (HgrcException) { Console.WriteLine(".hg/hgrc file problem. Exist ? Config ? RTFM."); Environment.Exit(2); } catch (NothingToDoEx) { Console.WriteLine("nothing to do"); Environment.Exit(0); } catch (CompileExcexption ex) { Console.WriteLine("compile exception. check complieError.txt in project root"); foreach (string s in ex.compilerResults.Output) { Console.WriteLine(s); } Environment.Exit(3); } catch (DuplicateScriptNameException ex) { Console.WriteLine("duplicative script name, rename one script"); Console.WriteLine(ex.name); Environment.Exit(4); } catch (DllNotFoundException ex) { Console.WriteLine("file not found :" + ex.Message); Environment.Exit(5); } catch (IpcException ex) { Console.WriteLine("check ipc config at " + ex.Message); Environment.Exit(6); } catch (RemotingException ex) { Console.WriteLine("check ipc config at " + ex.Message); Environment.Exit(7); } catch (SecurityException ex) { Console.WriteLine("check ipc config at " + ex.Message); Environment.Exit(8); } catch (InjectEx ex) { Console.WriteLine("inject ex. call support"); Environment.Exit(9); } catch (InjectOcuped ex) { Console.WriteLine("event already used. do it by hand"); Environment.Exit(9); } catch (Exception ex) { Console.WriteLine(ex.Message); Environment.Exit(-1); } }
public Cred Create(Cred cred) { Entities.Add(cred); SaveChanges(); return(cred); }