I am trying to implement scandit barcode scanner in my application.i downloaded its sample demo and its works fine.
same code i tried to implement in my app.but it shows black screen on scanning .
I gave camera access also. cant find any thing missing.
Please help if someone also faced same issue. any suggestion most appreciated.
thanks in advance
This is my code
using FormBot.ViewModels.Abstract;
using Scandit.BarcodePicker.Unified;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
namespace FormBot.ViewModels
{
public class SerialNumberViewModel: BaseViewModelDemo
{
private string _recognizedCode;
public ICommand StartScanningCommand => new Command(async () => await StartScanning());
public string RecognizedCode
{
get
{
return (_recognizedCode == null) ? "" : "Code scanned: " + _recognizedCode;
}
set
{
_recognizedCode = value;
}
}
public SerialNumberViewModel()
{
ScanditService.ScanditLicense.AppKey = "Key";
ScanditService.BarcodePicker.DidScan += BarcodePickerOnDidScan;
}
private async void BarcodePickerOnDidScan(ScanSession session)
{
RecognizedCode = session.NewlyRecognizedCodes.LastOrDefault()?.Data;
await ScanditService.BarcodePicker.StopScanningAsync();
}
private async Task StartScanning()
{
await ScanditService.BarcodePicker.StartScanningAsync(false);
}
}
}
in app.xaml.cs
private static string appKey = "key";
ScanditService.ScanditLicense.AppKey = appKey;
set android:hardwareAccelerated="true" in AndroidManifest.xml file worked for me.
Related
I wanted to easily turn some json schema files into classes. So googling I found NJsonSchema and I implemented this in a visual studio custom tool so I can set this on relevant json files and get my classes out. This al works and I pasted the code below. This code comes from this very answer. Though it does need a little updating for VS2022.
I find that documentation on how to do this is rather rare and the thing I am missing is how I can add something like configuration options for the custom tool.
Take for example the line "ClassStyle = CSharpClassStyle.Record," that is something one might want configurable for the user. But I cannot find anything on how to do that. Anyone have a good pointer/answer on this?
Preferably a way to add take the config from some custom properties in the file its properties that are available when the custom tool is configured on a project file.
using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System.Text;
using NJsonSchema.CodeGeneration.CSharp;
using NJsonSchema;
namespace ClassGeneratorForJsonSchema
{
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("GenerateClassesFromJsonSchema", "Use NJsonSchema to generate code from a json schema.", "1.0")]
[Guid("202E7E8B-557E-46CB-8A1D-3024AD68F44A")]
[ComVisible(true)]
[ProvideObject(typeof(ClassGeneratorForJsonSchema))]
[CodeGeneratorRegistration(typeof(ClassGeneratorForJsonSchema), "ClassGeneratorForJsonSchema", "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}", GeneratesDesignTimeSource = true)]
public sealed class ClassGeneratorForJsonSchema : IVsSingleFileGenerator
{
#region IVsSingleFileGenerator Members
public int DefaultExtension(out string pbstrDefaultExtension)
{
pbstrDefaultExtension = ".cs";
return pbstrDefaultExtension.Length;
}
public int Generate(string wszInputFilePath, string bstrInputFileContents,
string wszDefaultNamespace, IntPtr[] rgbOutputFileContents,
out uint pcbOutput, IVsGeneratorProgress pGenerateProgress)
{
try
{
var schema = JsonSchema.FromJsonAsync(bstrInputFileContents).Result;
var generator = new CSharpGenerator(schema, new CSharpGeneratorSettings()
{
JsonLibrary = CSharpJsonLibrary.SystemTextJson,
ClassStyle = CSharpClassStyle.Record,
Namespace = wszDefaultNamespace
});
byte[] bytes = Encoding.UTF8.GetBytes(generator.GenerateFile());
int length = bytes.Length;
rgbOutputFileContents[0] = Marshal.AllocCoTaskMem(length);
Marshal.Copy(bytes, 0, rgbOutputFileContents[0], length);
pcbOutput = (uint)length;
}
catch (Exception ex)
{
pcbOutput = 0;
}
return VSConstants.S_OK;
}
#endregion
}
}
I tried making an addon using the existing selenium addon codes and resources.
I was able to make an addon with just one command (for testing) to open Flipkart.
I used the selenium.open command code and edited it slightly by entering default value of URL argument as (flipkart.com).
I was successfully able to build my solution (I made sure to add all the nuget packages and other necessities)
Now when I try to load the addon in my studio, I'm getting an error mentioning that it expected command postfix for the FlipkartOpen command.
Can anyone please let me know the reason for this error and maybe a possible solution to fix it?
Here's the error image: G1ANT Studio Error for New Addon.
And here's my code sample:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Linq;
using System.Text;
using G1ANT.Language;
using OpenQA.Selenium;
namespace G1ANT.Addon.Flipkart.Commands
{
[Command(Name = "Flipkart.Open", Tooltip = "This command opens flipkart in a web browser provided in the Argument.")]
public class FlipkartOpen : Command
{
public FlipkartOpen(AbstractScripter scripter) : base(scripter)
{
}
public class Arguments : CommandArguments
{
// Enter all arguments you need
[Argument(Required = true, Tooltip = "Name of a web browser")]
public TextStructure Type { get; set; } = new TextStructure(string.Empty);
[Argument(DefaultVariable ="Url", Tooltip = "Website Url")]
public TextStructure Url { get; set; } = new TextStructure("www.flipkart.com");
[Argument(DefaultVariable = "timeoutselenium", Tooltip = "Specifies time in milliseconds for G1ANT.Robot to wait for the command to be executed")]
public override TimeSpanStructure Timeout { get; set; } = new TimeSpanStructure(SeleniumSettings.SeleniumTimeout);
[Argument(Tooltip = "By default, waits until the webpage fully loads")]
public BooleanStructure NoWait { get; set; } = new BooleanStructure(false);
[Argument(Tooltip = "Result variable")]
public VariableStructure Result { get; set; } = new VariableStructure("result");
}
// Implement this method
public void Execute(Arguments arguments)
{
try
{
SeleniumWrapper wrapper = SeleniumManager.CreateWrapper(
arguments.Type.Value,
arguments.Url?.Value,
arguments.Timeout.Value,
arguments.NoWait.Value,
Scripter.Log,
Scripter.Settings.UserDocsAddonFolder.FullName);
int wrapperId = wrapper.Id;
OnScriptEnd = () =>
{
SeleniumManager.DisposeAllOpenedDrivers();
SeleniumManager.RemoveWrapper(wrapperId);
SeleniumManager.CleanUp();
};
Scripter.Variables.SetVariableValue(arguments.Result.Value, new IntegerStructure(wrapper.Id));
}
catch (DriverServiceNotFoundException ex)
{
throw new ApplicationException("Driver not found", ex);
}
catch (Exception ex)
{
throw new ApplicationException($"Error occured while opening new selenium instance. Url '{arguments.Url.Value}'. Message: {ex.Message}", ex);
}
}
}
}
To remove this error, when you add new class, write Command.cs at the end while adding. Try FlipkartopenCommand.cs
This should remove your error.
I am trying to scrape an economic calendar from a specific website. Actually, I tried many times without any success, I don't know where I am wrong. Can you help me, pls?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HtmlAgilityPack;
using ScrapySharp.Extensions;
using ScrapySharp.Network;
namespace Calendar
{
class Program
{
static void Main(string[] args)
{
var url = "https://www.fxstreet.com/economic-calendar";
var webGet = new HtmlWeb();
if (webGet.Load(url) is HtmlDocument document)
{
var nodes = document.DocumentNode.CssSelect("#fxst-calendartable tbody").ToList();
foreach (var node in nodes)
{
// event_time
Debug.Print(node.CssSelect("div div").Single().InnerText);
// event-title
Debug.Print(node.CssSelect("div a").Single().InnerText);
}
}
Console.WriteLine("");
Console.ReadLine()
}
}
}
What error are you getting?
If you want to publish the event names and times from the website, I am assuming you need to read the table.
You can do so using
HtmlNode tablebody = doc.DocumentNode.SelectSingleNode("//table[#class='fxs_c_table']/tbody");
foreach(HtmlNode tr in tablebody.SelectNodes("./tr[#class='fxs_c_row']"))
{
Console.WriteLine("\nTableRow: ");
foreach(HtmlNode td in tr.SelectNodes("./td"))
{
Console.WriteLine(td.SelectSingleNode("./span").InnerText);
}
}
Get hold of the table with the class attribute and then use relevant XPATH to traverse the elements. Please post the error you are getting with your code.
Just starting messing with repository/interfaces and the like and I have an error when selecting a single record which I can't work out.
My controller has:
public ViewResult Detail(int ID)
{
var Details = (from x in repo.GetBreakdown(ID) select new BreakdownDetailViewModel { }).SingleOrDefault();
return View(Details);
}
The statement repo.GetBreakdown(ID) is underlined with the following error:
Could not find an implementation of the query pattern for source type ''. 'Select' not found.
My Interface is showing:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Entities;
namespace Domain.Abstract
{
public interface IBreakdownRepository
{
tblBreakdown_Log GetBreakdown(int ID);
IQueryable<tblBreakdown_Log> GetAllBreakdowns { get; }
}
}
And the repository itself has:
public tblBreakdown_Log GetBreakdown(int ID)
{
return (from x in db.tblBreakdown_Logs where x.MB_ID == ID select x).SingleOrDefault();
}
Any ideas on what the issue is here?
Thanks,
Chris
Based on the comment by #Evan
Changed my repository access to:
public IEnumerable<tblBreakdown_Log> GetBreakdown(int ID)
{
return (from x in db.tblBreakdown_Logs where x.MB_ID == ID select x);
}
The interface to the repository now has:
IEnumerable<tblBreakdown_Log> GetBreakdown(int ID);
And my controller access is:
public ViewResult Detail(int ID)
{
var Details = (from x in repo.GetBreakdown(ID) select new BreakdownDetailViewModel {Machine_Status=x.tblMachine_Status.Machine_Status, MB_ID=x.MB_ID});
return View(Details);
}
All working as needed now =]
How do you update records in CRM 2011 using OrganizationServiceContext? Can anyone provide a simple example? Thanks!
This is my code:
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Description;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Linq;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Client.Services;
using System.Data.Services;
using System.Text.RegularExpressions;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.Web.Security;
using System.Data;
using System.Collections.Specialized;
using System.Web.SessionState;
using System;
using System.Web.Profile;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Collections;
using System.Web.UI.WebControls.WebParts;
using System.Web;
using System.Web.UI;
using System.Drawing;
using System.Text;
using System.Web.Caching;
using Telerik.Web.UI;
using Microsoft.Xrm.Sdk.Discovery;
using Microsoft.Data.Entity;
using System.Data.Entity;
public partial class LeadShareEditPanel : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void imgBtnSaveNote_Click(object sender, ImageClickEventArgs e)
{
Uri organizationUri = new Uri("http://server/CRMT/XRMServices/2011/Organization.svc");
Uri homeRealmUri = null;
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = new System.Net.NetworkCredential("user", "password", "domain");
OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
// Get the IOrganizationService
//Get OrganizationServiceContext -the organization service context class implements the IQueryable interface and
//a .NET Language-Integrated Query (LINQ) query provider so we can write LINQ queries against Microsoft Dynamics CRM data.
using (var service = new OrganizationService(orgProxy))
using (var context = new CrmOrganizationServiceContext(service))
{
var contact = context.CreateQuery<Contact>().First(c => c.FirstName == "Bob");
contact.JobTitle = "Developer";
context.UpdateObject(contact);
context.SaveChanges();
contact.EMailAddress1 = "bob#contoso.com";
context.UpdateObject(contact);
context.SaveChanges();
}
}
}
This is an example from the 5.05 SDK help file
using (var service = new OrganizationService(connection))
using (var context = new CrmOrganizationServiceContext(service))
{
var contact = context.CreateQuery<Contact>().First(c => c.FirstName == "Bob");
contact.JobTitle = "Developer";
context.UpdateObject(contact);
context.SaveChanges();
contact.EMailAddress1 = "bob#contoso.com";
context.UpdateObject(contact);
context.SaveChanges();
}
If you haven't already you can download the SDK from here crm 2011 sdk . I would highly reccomend it as it has lots of great samples. The current version is 5.06.
Hope that helps.