public static string CreateLocalizationSrc(DAL.ServiceContext dbcontext, string filePath) { var litems = dbcontext.Localization.ToList(); Console.WriteLine("\nBuilding LocalizationSeedingFile ...(" + litems.Count + " items) "); XmlSerializer xsSubmit = new XmlSerializer(typeof(List <Models.LocalizationModel>)); var xml = ""; using (var sww = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sww)) { writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\""); xsSubmit.Serialize(writer, litems); xml = sww.ToString(); } } // write to file using (var writer = File.CreateText(filePath)) { writer.WriteLine(xml); writer.Flush(); writer.Close(); } return(filePath); }
public static object GetSettingValue(Enums.EnumGeneralSetting setting) { DAL.ServiceContext db = new DAL.ServiceContext(); var dbsetting = db.GeneralSettings.FirstOrDefault(ln => ln.GeneralSetting == setting); if (dbsetting != null) { switch (dbsetting.Type) { case Enums.EnumSettingType.Bool: return(bool.Parse(dbsetting.Value)); case Enums.EnumSettingType.Decimal: return(decimal.Parse(dbsetting.Value, System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))); case Enums.EnumSettingType.Float: return(float.Parse(dbsetting.Value)); case Enums.EnumSettingType.Int: return(int.Parse(dbsetting.Value)); case Enums.EnumSettingType.String: return(dbsetting.Value.ToString()); default: return(null); } } throw new Exceptions.SettingNotFoundException("Setting not found: " + setting.ToString()); }
protected override bool OnBeforeIncoming(IHubIncomingInvokerContext context) { DAL.ServiceContext db = new DAL.ServiceContext(); var dbCon = db.SignalRConnections.FirstOrDefault(ln => ln.SignalRConnectionId == context.Hub.Context.ConnectionId); if (dbCon == null) { // SimpleLogger logger = new SimpleLogger(); // logger.Info("added connection on BeForeIncoming"); db.AddConnection(context.Hub.Context.ConnectionId, context.Hub.Context.Request.GetRefererUrl(), context.Hub.Context.Request.GetClientIp()); } //if (Enum.TryParse(context.MethodDescriptor.Name, out Enums.EnumServiceHubMethods res)) //{ // var dbCon = db.SignalRConnections.FirstOrDefault(ln => ln.SignalRConnectionId == context.Hub.Context.ConnectionId); // switch (res) // { // case Enums.EnumServiceHubMethods.JoinGroup: // if (!dbCon.Groups.Contains(context.Args[0].ToString())) // dbCon.Groups.Add(context.Args[0].ToString()); // break; // case Enums.EnumServiceHubMethods.LeaveGroup: // var rm = dbCon.Groups.Remove(context.Args[0].ToString()); // break; // default: // break; // } // db.SaveChanges(); //} return(true); }
public ProductImportGoogleMerchantXML() { _db = new DAL.ServiceContext(); productRepository = new Repositories.ProductRepository(_db); userRepository = new Repositories.UserRepository(_db); userContext = new Repositories.UserContext(_db); }
public ServiceConfigurationController() { db = new DAL.ServiceContext(); coinIMPMinerContext = new Repositories.CoinIMPMinerContext(db); jseCoinMinerContext = new Repositories.JSECoinMinerContext(db); serviceSettingRepo = new Repositories.ServiceSettingRepositorie(db); }
public static void SendUserTotalMoneyUpdate(int UserId, double amount) { var db = new DAL.ServiceContext(); var userRepository = new Repositories.UserRepository(db); var user = userRepository.GetUser(UserId); GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Clients(user.SignalRConnections).updateUserTotal(amount); }
public OrderProcessDefault() { db = new DAL.ServiceContext(); orderRepository = new Repositories.OrderRepository(db); productRepository = new Repositories.ProductRepository(db); serviceRepository = new Repositories.ServiceSettingRepositorie(db); userRepository = new Repositories.UserRepository(db); }
public static void WinningRulesUpdate(string group) { var db = new DAL.ServiceContext(); var service = db.ServiceSettings.FirstOrDefault(ln => ln.ServiceUrl == group); var gs = service.LuckyGameSettings.FirstOrDefault(); var data = gs.WinningRules.ToList().ToWinningRuleViewModels(); GlobalHost.ConnectionManager.GetHubContext <ServiceHub>().Clients.Group(group.ToLower()).updateWinningRules(data); }
public static List <ViewModels.UserDataViewModel> getUsersList() { DAL.ServiceContext db = new DAL.ServiceContext(); List <ViewModels.UserDataViewModel> users = new List <ViewModels.UserDataViewModel>(); foreach (var item in db.UserData) { users.Add(item.ToUserDataViewModel()); } return(users); }
public ServiceSettingContext(DAL.ServiceContext db) { if (db == null) { _db = new DAL.ServiceContext(); } else { _db = db; } }
public MiningRoomCSECoin() { db = new DAL.ServiceContext(); apiUrl = (string)Utils.GeneralSettingsUtils.GetSettingValue(Enums.EnumGeneralSetting.JSECoinApiUrl); cmpPrivate = (string)Utils.GeneralSettingsUtils.GetSettingValue(Enums.EnumGeneralSetting.JSECoinPrivateKey); cmpPublic = (string)Utils.GeneralSettingsUtils.GetSettingValue(Enums.EnumGeneralSetting.JSECoinPublicKey); miningRoomRepo = new Repositories.MinerRoomRepository(db); userRepo = new Repositories.UserRepository(db); serviceRepo = new Repositories.ServiceSettingRepositorie(db); minerRepo = new Repositories.JSECoinMinerRepository(db); }
public static string GetXMRWalletAddressFor(string IdentityName) { DAL.ServiceContext db = new DAL.ServiceContext(); var dbuser = db.UserData.FirstOrDefault(ln => ln.IdentityName == IdentityName); if (dbuser == null) { return(null); } return(dbuser.XMRWalletAddress); }
public static float GetToals(string orderId) { DAL.ServiceContext db = new DAL.ServiceContext(); decimal sum = 0; var items = db.OrderItems.Where(ln => ln.Order.OrderIdentifier == orderId); foreach (var item in items) { sum = sum + item.Price; } return(float.Parse(sum.ToString())); }
public async Task<ActionResult> ChangeXMRWalletAddress(ChangeXMRWalletViewModel model) { DAL.ServiceContext db = new DAL.ServiceContext(); var dbuser = db.UserData.FirstOrDefault(ln => ln.IdentityName == User.Identity.Name); if (dbuser == null) return null; else { dbuser.XMRWalletAddress = model.XMRAddress; db.SaveChanges(); } return View(model); }
private static ProductModel _mapLuceneDocumentToData(Document doc) { DAL.ServiceContext db = new DAL.ServiceContext(); string srcId = doc.Get("SrcId"); var db_product = db.Products.FirstOrDefault(ln => ln.SrcIdentifier == srcId); if (db_product == null) { db_product = new ProductModel() { ID = 0, Name = "lucene_map_error" }; } return(db_product); }
public static int RemoveDeadConnections() { var db = new DAL.ServiceContext(); var heartBeat = GlobalHost.DependencyResolver.Resolve <ITransportHeartbeat>(); var conns = heartBeat.GetConnections().Select(x => x.ConnectionId).ToList(); var rmcnt = 0; var deadConnections = db.SignalRConnections.Where(x => !conns.Contains(x.SignalRConnectionId)).ToList(); rmcnt = deadConnections.Count; Repositories.SignalRConnectionContext sigContext = new Repositories.SignalRConnectionContext(db); sigContext.RemoveConnections(deadConnections); return(rmcnt); }
public static bool IsServiceOwner(int serviceId, string IdentityName) { DAL.ServiceContext db = new DAL.ServiceContext(); var service = db.ServiceSettings.FirstOrDefault(ln => ln.ID == serviceId); if (service == null) { return(false); } if (service.Owner.IdentityName == IdentityName) { return(true); } return(false); }
public ActionResult LogOff() { DAL.ServiceContext db = new DAL.ServiceContext(); Repositories.UserRepository userRepository = new Repositories.UserRepository(db); var user = userRepository.GetUser(User.Identity.Name); var toRemove = user.SignalRConnections.ToList(); foreach (var item in toRemove) { var rm = db.SignalRConnections.FirstOrDefault(ln => ln.SignalRConnectionId == item); var ms = rm.MinerStatus; db.MinerStatus.Remove(ms); db.SignalRConnections.Remove(rm); } db.SaveChanges(); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(RedirectToAction("Index", "Home")); }
public HttpResponseMessage Initialize([FromUri] RequestViewModel model) { //http://localhost/api/sc/initialize?ServiceUrl=test DAL.ServiceContext db = new DAL.ServiceContext(); var service = db.ServiceSettings.FirstOrDefault(ln => ln.ServiceUrl == model.ServiceUrl); if (service == null) { return(Request.CreateResponse( new ResponseViewModel() { ErrorMessage = "Service for: " + model.ServiceUrl + " not found", ErrorNumber = 1010 })); } var script = RenderViewToString("Fake", "Goto", service.ToServiceSettingViewModel()); return(Request.CreateResponse(new ResponseViewModel() { Script = script })); }
public string GetResourceValueFromDb(string sKey) { string resourceValue = string.Empty; string culture = Utils.CultureHelper.GetImplementedCulture(CultureInfo.CurrentCulture.Name); if (instance.cache.ContainsKey(buildCacheKey(sKey, culture))) { instance.cache.TryGetValue(buildCacheKey(sKey, culture), out resourceValue); } else { db = new DAL.ServiceContext(); Models.LocalizationModel localization = db.Localization.FirstOrDefault(l => l.Key == sKey && l.Culture == culture); resourceValue = localization != null ? localization.Value : string.Format("{0}(!!)", sKey); instance.cache.Add(buildCacheKey(sKey, culture), resourceValue); if (localization != null && localization.WasHit == false) { localization.WasHit = true; db.SaveChanges(); } } return(resourceValue); }
public JSECoinMinerRepository(DAL.ServiceContext db) { minerContext = new JSECoinMinerContext(db); _db = db; }
public GameSettingsContext(DAL.ServiceContext db) { _db = db; }
public UserContext(DAL.ServiceContext db) { _db = db; }
public CoinIMPMinerRepository(DAL.ServiceContext db) { minerContext = new CoinIMPMinerContext(db); _db = db; }
public GeneralSettingsRepository(DAL.ServiceContext _db) { db = _db; }
public PreDefinedMinerClientController() { db = new DAL.ServiceContext(); }
public ServiceSettingRepositorie(DAL.ServiceContext _db) { serviceContext = new ServiceSettingContext(db); db = _db; }
public OrderRepository(DAL.ServiceContext db) { orderContext = new OrderContext(db); userContext = new UserContext(db); productContext = new ProductContext(db); }
public UserRepository(DAL.ServiceContext db) { userContext = new UserContext(db); }
public UiResources() { cache = new Dictionary <string, string>(); db = db = new DAL.ServiceContext(); }