Ejemplo n.º 1
0
 private static List <CloudScanner> GetRegisteredScanners()
 {
     using (var context = new CloudContext())
     {
         return(context.Scanners.ToList());
     }
 }
Ejemplo n.º 2
0
        public async Task <IList <Adult> > GetAllAsync()
        {
            await using CloudContext _context = new CloudContext();
            IList <Adult> adultsToReturn = await _context.AdultTable.Include(a => a.JobTitle).ToListAsync();

            return(adultsToReturn);
        }
Ejemplo n.º 3
0
        public async Task <IList <Family> > GetAllAsync()
        {
            await using CloudContext _context = new CloudContext();
            IList <Family> familiesToReturn = await _context.FamilyTable.Include(a => a.Adults).ThenInclude(j => j.JobTitle).ToListAsync();

            return(familiesToReturn);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Start polling for tasks...
        /// </summary>
        /// <returns>true on success</returns>
        public async Task <bool> MonitorTasksStart()
        {
            bool blSuccess;

            CloudScanner cloudScanner = null;

            using (var context = new CloudContext())
            {
                cloudScanner = context.Scanners.First();
            }

            var cloudClient = new TwainCloudClient(CloudManager.GetCloudApiRoot(), new TwainCloudTokens(cloudScanner.AuthorizationToken, cloudScanner.RefreshToken));

            cloudClient.TokensRefreshed += (sender, args) =>
            {
                cloudScanner.AuthorizationToken = args.Tokens.AuthorizationToken;
                cloudScanner.RefreshToken       = args.Tokens.RefreshToken;
                SaveScannerRegistration(cloudScanner);
            };

            // Start monitoring for commands...
            blSuccess = await m_twainlocalscannerdevice.DeviceHttpServerStart(new DeviceSession(cloudClient, cloudScanner.Id));

            if (!blSuccess)
            {
                Log.Error("DeviceHttpServerStart failed...");
                return(false);
            }

            // All done...
            return(true);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads list of registered cloud devices.
        /// </summary>
        private void LoadRegisteredCloudDevices()
        {
            // Handle a chicken and egg problem...
            if (m_scanner == null)
            {
                return;
            }

            // We're good from this point on...
            m_CloudDevicesComboBox.Items.Clear();
            using (var context = new CloudContext())
            {
                // load registered scanners
                var scanners = context.Scanners.ToArray();
                m_CloudDevicesComboBox.Items.AddRange(scanners);

                // select the current one
                var currentScanner = m_scanner.GetCurrentCloudScanner();
                if (currentScanner != null)
                {
                    foreach (var s in scanners)
                    {
                        if (s.Id == currentScanner.Id)
                        {
                            m_CloudDevicesComboBox.SelectedItem = s;
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            using (IServiceScope serviceScope =
                       app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                CloudContext context = serviceScope.ServiceProvider.GetRequiredService <CloudContext>();
                context.Database.Migrate();
            }

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseMvc();
            app.UseSwagger();

            app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "FileStructure V1"); });
        }
Ejemplo n.º 7
0
        public static string SetCloudControlEntitiesJsScript(Dictionary <string, double> TagsAndFreqs,
                                                             CloudContext context = CloudContext.HomePage)
        {
            StringBuilder sbCloud = new StringBuilder();

            sbCloud.AppendLine("            var entries = [");
            if (context == CloudContext.HomePage)
            {
                foreach (var KeyValue in TagsAndFreqs)
                {
                    sbCloud.AppendLine(
                        string.Format("                {{ label: '{0}', url: '../Individual.aspx?id={0}', target: '_top' }},",
                                      KeyValue.Key));
                }
            }
            else
            {
                foreach (var KeyValue in TagsAndFreqs)
                {
                    sbCloud.AppendLine(
                        string.Format("                {{ label: '{0}', url: '#{0}', target: '_self' }},",
                                      KeyValue.Key));
                }
            }
            sbCloud.AppendLine("            ];");
            return(sbCloud.ToString());
        }
Ejemplo n.º 8
0
 public static void Main(string[] args)
 {
     using (CloudContext context = new CloudContext())
     {
     }
     CreateHostBuilder(args).Build().Run();
 }
Ejemplo n.º 9
0
 public ValuesController(IConfiguration configuration, CloudContext cloudContext, ISample sampleClient)
 {
     this.sampleClient  = sampleClient;
     this.cloudContext  = cloudContext;
     this.configuration = configuration;
     baseName           = $"{configuration.GetValue<string>("spring:application:name")}:{configuration.GetValue<string>("server:port")}";
 }
Ejemplo n.º 10
0
        public GenericRepository(CloudContext context)
        {
            this.context = context;
            this.dbSet   = context.Set <TEntity>();


            if (typeof(TEntity) == typeof(AdminRe))
            {
                foreach (var entity in dbSet)
                {
                    var    admin       = entity as AdminRe;
                    string decryptPass = AESThenHMAC.SimpleDecryptWithPassword(admin.Pass, "itcomma_luuductrung");
                    admin.DecryptedPass = decryptPass;
                }
            }
            else
            {
                if (typeof(TEntity) == typeof(Employee))
                {
                    foreach (var entity in dbSet)
                    {
                        var    emp         = entity as Employee;
                        string decryptPass = AESThenHMAC.SimpleDecryptWithPassword(emp.Pass, "itcomma_luuductrung");
                        string decryptCode = AESThenHMAC.SimpleDecryptWithPassword(emp.EmpCode, "itcomma_luuductrung");
                        emp.DecryptedPass = decryptPass;
                        emp.DecryptedCode = decryptCode;
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public void Refresh()
        {
            this.Save();
            var context = this._cloudContext;

            this._cloudContext = new CloudContext();
            context.Dispose();
        }
Ejemplo n.º 12
0
 public void Initialize(CloudContext context)
 {
     context.Hosts.Add(new Host
     {
         Name = HostOneName,
         UserPersonnelNumber = UserDataInitializer.UserOneLoginName
     });
 }
Ejemplo n.º 13
0
 private static void SaveScannerRegistration(CloudScanner scanner)
 {
     using (var context = new CloudContext())
     {
         context.Scanners.AddOrUpdate(scanner);
         context.SaveChanges();
     }
 }
Ejemplo n.º 14
0
 public void Initialize(CloudContext context)
 {
     context.User.Add(new User
     {
         LoginName       = UserOneLoginName,
         PersonnelNumber = UserOnePersonnelNumber
     });
 }
Ejemplo n.º 15
0
        public AccountController(UserManager <User> userManager, SignInManager <User> signInManager, CloudContext context, AccountRepository repository)
        {
            _userManager   = userManager;
            _signInManager = signInManager;

            Repository   = repository;
            CloudContext = context;
        }
Ejemplo n.º 16
0
        public PublisherViewModel(ConfigurationFile configurationFile) : base(configurationFile)
        {
            var functions = CloudContext.GetPublisherFunctions();

            foreach (var function in functions)
            {
                Functions.Add(function);
            }
        }
Ejemplo n.º 17
0
        public static void Initialize(CloudContext db)
        {
            var dis = AssemblyUtil.GetAllDefaultConstructableConstructed <IDataInitializer>();

            foreach (var dataInitializer in dis)
            {
                dataInitializer.Initialize(db);
            }
            db.SaveChanges();
        }
Ejemplo n.º 18
0
        public async Task RemoveAsync(int adultId)
        {
            await using CloudContext _context = new CloudContext();
            Adult adultToRemove = await _context.AdultTable.FirstOrDefaultAsync(a => a.Id == adultId);

            if (adultToRemove != null)
            {
                _context.AdultTable.Remove(adultToRemove);
                await _context.SaveChangesAsync();
            }
        }
Ejemplo n.º 19
0
        public async Task RemoveAsync(int userId)
        {
            await using CloudContext _context = new CloudContext();
            User userToRemove = await _context.UserTable.FirstOrDefaultAsync(u => u.UserId == userId);

            if (userToRemove != null)
            {
                _context.UserTable.Remove(userToRemove);
                await _context.SaveChangesAsync();
            }
        }
Ejemplo n.º 20
0
        public async Task RemoveAsync(int familyId)
        {
            await using CloudContext _context = new CloudContext();
            Family famToRemove = await _context.FamilyTable.FirstOrDefaultAsync(f => f.Id == familyId);

            if (famToRemove != null)
            {
                _context.FamilyTable.Remove(famToRemove);
                await _context.SaveChangesAsync();
            }
        }
Ejemplo n.º 21
0
        public async Task <User> ValidateUserAsync(string username, string password)
        {
            await using CloudContext _context = new CloudContext();
            User validateUser = await _context.UserTable.FirstOrDefaultAsync(u =>
                                                                             u.UserName.Equals(username) && u.Password.Equals(password));

            if (validateUser != null)
            {
                return(validateUser);
            }

            throw new Exception($"User not found!");
        }
Ejemplo n.º 22
0
        public async Task <Family> GetByIdAsync(int familyId)
        {
            await using CloudContext _context = new CloudContext();
            Family famToFind = await _context.FamilyTable.FirstOrDefaultAsync(f => f.Id == familyId);

            if (famToFind != null)
            {
                return(famToFind);
            }

            {
                throw new Exception($"Cannot find family with {familyId} id!");
            }
        }
Ejemplo n.º 23
0
        public async Task <Adult> GetByIdAsync(int adultId)
        {
            await using CloudContext _context = new CloudContext();
            Adult adultToFind = await _context.AdultTable.Include(a => a.JobTitle).FirstOrDefaultAsync(a => a.Id == adultId);

            if (adultToFind != null)
            {
                return(adultToFind);
            }

            {
                throw new Exception($"Cannot find adult with {adultId} id!");
            }
        }
Ejemplo n.º 24
0
        public async Task <User> GetByIdAsync(int userId)
        {
            await using CloudContext _context = new CloudContext();
            User userToFind = await _context.UserTable.FirstOrDefaultAsync(u => u.UserId == userId);

            if (userToFind != null)
            {
                return(userToFind);
            }

            {
                throw new Exception($"Cannot find user with {userId} id!");
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Action调用后。
 /// </summary>
 /// <param name="cloudContext">云调用上下文。</param>
 public virtual void ActionExecuteAfter(CloudContext cloudContext)
 {
     if (_list.Count == 0)
     {
         return;
     }
     for (int i = 0; i < _list.Count; i++)
     {
         try {
             _list[i].ActionExecuteAfter(cloudContext);
         } catch (Exception error) {
             cloudContext.SetError(error, -1);
         }
     }
 }
        public static StringBuilder GenerateWordCloud(string WordCloudId, List <string> Tags,
                                                      CloudContext context = CloudContext.HomePage)
        {
            StringBuilder sbCloud = new StringBuilder();

            sbCloud.AppendLine("<script type=text/javascript>");
            sbCloud.AppendLine("       $(document).ready(function () {");
            sbCloud.AppendLine("            var entries = [");
            foreach (string Tag in Tags)
            {
                if (context == CloudContext.HomePage)
                {
                    sbCloud.AppendLine(string.Format("                {{ label: '{0}', url: '../Individual.aspx?id={0}', target: '_top' }},", Tag));
                }
                else
                {
                    sbCloud.AppendLine(string.Format("                {{ label: '{0}', url: '#{0}', target: '_self' }},", Tag));
                }
            }
            sbCloud.AppendLine("            ];");
            sbCloud.AppendLine("            var settings = {");
            sbCloud.AppendLine("                entries: entries,");
            sbCloud.AppendLine("                width: 480,");
            sbCloud.AppendLine("                height: 480,");
            sbCloud.AppendLine("                radius: '65%',");
            sbCloud.AppendLine("                radiusMin: 75,");
            sbCloud.AppendLine("                bgDraw: true,");
            sbCloud.AppendLine("                bgColor: '#fff',");
            sbCloud.AppendLine("                opacityOver: 1.00,");
            sbCloud.AppendLine("                opacityOut: 0.05,");
            sbCloud.AppendLine("                opacitySpeed: 6,");
            sbCloud.AppendLine("                fov: 800,");
            sbCloud.AppendLine("                speed: 1,");
            sbCloud.AppendLine("                fontFamily: 'Oswald, Arial, sans-serif',");
            sbCloud.AppendLine("                fontSize: '15',");
            sbCloud.AppendLine("                fontColor: '#111',");
            sbCloud.AppendLine("                fontWeight: 'normal',//bold");
            sbCloud.AppendLine("                fontStyle: 'normal',//italic ");
            sbCloud.AppendLine("                fontStretch: 'normal',//wider, narrower, ultra-condensed, extra-condensed, condensed, semi-condensed, semi-expanded, expanded, extra-expanded, ultra-expanded");
            sbCloud.AppendLine("                fontToUpperCase: true");
            sbCloud.AppendLine("            };");
            sbCloud.AppendLine("            //var svg3DTagCloud = new SVG3DTagCloud( document.getElementById( 'holder'  ), settings );");
            sbCloud.AppendLine(string.Format("            $('#{0}').svg3DTagCloud(settings);", WordCloudId));
            sbCloud.AppendLine("        });");
            sbCloud.AppendLine("</script>");

            return(sbCloud);
        }
Ejemplo n.º 27
0
        public CloudScanner GetCurrentCloudScanner()
        {
            CloudScanner cloudScanner = null;

            var cloudConfigFileName = GetCloudConfigFileName();

            if (File.Exists(cloudConfigFileName))
            {
                var cloudScannerId = File.ReadAllText(GetCloudConfigFileName());

                using (var context = new CloudContext())
                    cloudScanner = context.Scanners.Find(cloudScannerId);
            }

            return(cloudScanner);
        }
Ejemplo n.º 28
0
        public static void RenderTagCloud(string id, Dictionary <string, double> TagsAndFreqs, System.Web.UI.Page page,
                                          CloudContext context, PoliticalLeaningContext leaning, double MaxFontSize = 15.0)
        {
            // Define the name and type of the client scripts on the page.
            String csname1 = "tagcloud" + id;
            Type   cstype  = page.GetType();

            // Get a ClientScriptManager reference from the Page class.
            ClientScriptManager cs = page.ClientScript;

            // Check to see if the startup script is already registered.
            if (!cs.IsStartupScriptRegistered(cstype, csname1))
            {
                cs.RegisterStartupScript(cstype, csname1, utilities.WordCloud.GenerateWordCloud(
                                             id, TagsAndFreqs, MaxFontSize, context, leaning).ToString());
            }
        }
Ejemplo n.º 29
0
        public async Task <Family> AddAsync(Family family)
        {
            try
            {
                await using CloudContext _context = new CloudContext();
                var newFamily = await _context.FamilyTable.AddAsync(family);

                await _context.SaveChangesAsync();

                return(newFamily.Entity);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                throw;
            }
        }
Ejemplo n.º 30
0
        public async Task <User> AddAsync(User user)
        {
            await using CloudContext _context = new CloudContext();
            try
            {
                var newAddedUser = await _context.UserTable.AddAsync(user);

                await _context.SaveChangesAsync();

                return(newAddedUser.Entity);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                throw;
            }
        }
Ejemplo n.º 31
0
 public FriendsController(CloudContext context, FriendshipRepository repository)
 {
     Repository = repository;
     CloudContext = context;
 }
Ejemplo n.º 32
0
 public UsersController(CloudContext context, UserRepository repository)
 {
     Repository = repository;
     CloudContext = context;
 }
 public MomentsController(CloudContext context, MomentRepository repository, MediaStorageRepository mediaStorage)
 {
     Repository = repository;
     CloudContext = context;
     MediaStorage = mediaStorage;
 }