import users to ASP.NET membership from a file - asp.net

I have a site using ASP.NET membership. I also have an excel file with about 60 user records. How can I import the records into the membership database, without having to type all 60 into the ASP.NET Web Site Administration Tool.
Thank you

foreach (record in recordset) {
    if (!(Roles.RoleExists(record["Role"])) {
        Roles.CreateRole(record["Role"]);
    }
   
    if (Membership.GetUser(record["Username"]) == null) {
        System.Web.Security.MembershipCreateStatus status;
        Membership.CreateUser(record["Username"], record["Password"], record["Email"], record["RSecurityQuestion"], record["SecurityAnswer"], true, status);
        if (status == System.Web.Security.MembershipCreateStatus.Success) {
            Roles.AddUserToRole(record["Username"], record["Role"]);
        }
    }
}
I can't recall the code to create a recordset from an Excel file off the top of my head.
EDIT: Here is a good post on how to read/write excel files with ADO.NET

Here's three options for you
There may be an import data option in SQL Server Management Studio, you can use this (I just checked in SQL Server Express and it wasn't there but I'm certain it exists in the full version of Management Studio - can't check at the moment).
Use SSIS if you have it
You can do it old school and use Excel to build up a SQL string with references to the cells. Do this for the first row and then copy down. Copy all the statements into a query window and execute!

Choice 1
If you're lucky, Excel has a way to export the rows directly to your database (this depends on which Database you're using)
Choice 2
Write a program that iterates over each row in the excel table and inserts it manually into your database (again, process depends on which one)

Related

Close user sessions AXAPTA

im making a website who uses the Dynamics AX Business Connector to connect with AX, it´s working fine but sometimes the users don´t logout.
Here is my code:
Microsoft.Dynamics.BusinessConnectorNet.Axapta DynAx = new Microsoft.Dynamics.BusinessConnectorNet.Axapta();
try
{
DynAx.Logon(null, null, null, null);
//Execute some methods
DynAx.Logoff();
}
catch (Exception ex)
{
DynAx.Logoff();
}
and in ax i can see the users logged in. Again this happens sometimes, thats why i don´t know who may be.
Maybe Dispose() Method it's better?.
Thank you for taking your time to read this.
Logon/logoff works for me correctly, but if you're saying sometimes it doesn't, then the reason is most likely one of the following:
The business connector can be flaky. It's wasn't a Microsoft priority and eventually was depreciated.
Whatever is happening in your //Execute some methods section could be locking or preventing the logoff.
You may need to update your kernel to get an updated version of the business connector
In my AX2012R3 environment I can run the below PowerShell code over and over with success. This points me towards one of the above as a cause.
Add-Type -Path "C:\Program Files\Microsoft Dynamics AX\60\BusinessConnector\Bin\Microsoft.Dynamics.BusinessConnectorNet.dll"
$ax = new-object Microsoft.Dynamics.BusinessConnectorNet.Axapta
 
$ax.logon($null, $null, $null, $null)
$b = $ax.CreateAxaptaRecord("userinfo")
$array = New-Object System.Collections.ArrayList
 
$b.ExecuteStmt("select id from %1")
while($b.found){
$array.add($b.get_field("id")) | out-null
$b.next() | out-null
}
 
$array | Format-Table -AutoSize
$ax.Logoff()
$ax.Dispose()

Adding two seperate firebase projects for a single app

I want to implement e-commerce apps on IOS and Android. I can divide the apps into two parts less secured, more secured. I can say more secure is a case of accepting payments in the app.So for this purpose, I want to have separate login systems for entering into the app and making payments.I am using Firebase Authentication and in that Password Authentication.So at the start of the project if we want to use Firebase(for Authentication, Database)we need to add google-services.json for Android App and GoogleService-Info.plist for IOS App. But now I want to add two firebase projects for a single app. How is it possible?
Use multiple firebase projects in single application
Simply can access multiple projects through FirebaseApp configure.
Configuration
let secondaryOptions = FirebaseOptions(googleAppID: "your google app id",
                                           gcmSenderID: "your gcm id")
    secondaryOptions.apiKey = "your api key"
    secondaryOptions.projectID = "your projectid"
   
    secondaryOptions.bundleID = "your bundle id"
    secondaryOptions.databaseURL = "https://yourproject.firebaseio.com"
    secondaryOptions.storageBucket = "yourproject.appspot.com"
    secondaryOptions.androidClientID = "yourproject.apps.googleusercontent.com"
    secondaryOptions.deepLinkURLScheme = "myapp://"
    secondaryOptions.storageBucket = "yourprojectId.appspot.com"
    secondaryOptions.appGroupID = nil
FirebaseApp.configure(name: "secondary", options: secondaryOptions)
Usage
guard let secondary = FirebaseApp.app(name: "secondary")
else { assert(false, "Could not retrieve secondary app") }
let secondaryDb = Database.database(app: secondary)
in your firebase. open up a project and click on 'add another project'.
and then select app for IOS or Android. You are done.

While sending a service request (PHP Service) from Flex application, it is executing multiple service request to server. How can we avoid first call?

While sending a service request (PHP Service) from Adobe Flex application , it is calling multiple service request to server. How can we avoid first call ?
Please help me to resolve it.
First one is a blank service with operation => 5.
We can show blank service call via firebug (Browser -> Developer tool)
Sample Flex Code :
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:RemoteObject id="CustomerRo" destination="customerService" endpoint="<SERVER URL>"
showBusyCursor="false" source="customerService" concurrency="single" >
<s:method name="customerLogin" fault=""
result="method1_resultHandler(event)" />
</s:RemoteObject>
</fx:Declarations>
<s:Button click="button1_clickHandler(event)" label="Send" />
I believe the 5 is part of the AMF protocol and signals that a command operation is the next operation that should be expected by the server.
We need to do the following changes in flex application for avoid duplicate call from every request
    Add 'services-config.xml" to the application folder. (Ref : https://gist.github.com/hui/268372 )
    Add  configuration file path to Flex compiler, (Project->Properties->Flex Compiler)
       Example :  -locale en_US -services "C:\Location/services-config.xml"
    Change this attribute in code base of each modules
        
From : < s:RemoteObject id="CustomerRo" destination="customerService" endpoint="< SERVER URL >" showBusyCursor="false" source="customerService" concurrency="single" >
        
To : < s:RemoteObject id="CustomerRo" destination="amfora" showBusyCursor="false" source="customerService" concurrency="single" >
[Note : Destination should be equal to < destination id="amfora" > in 'services-config.xml" ]

Give Google Service Account access to all my Google Analytics Accounts

My work email has access to around 100 analytic accounts. Is there anyway give a google service account to all of the analytics I have access to with out needing to manually add it to every account?
Working off of Eike's comment, it seems to be possible from Google Apps Scripts:
function listAccounts() {
var accounts = Analytics.Management.Accounts.list();
if (accounts.items && accounts.items.length) {
for (var i = 0; i < accounts.items.length; i++) {
var account = accounts.items[i];
var body =
{
permissions:
{
local: ['READ_AND_ANALYZE'] //or whatever permissions you need
},
userRef:
{
email: 'theemailaddressyouneed'
}
};
Analytics.Management.AccountUserLinks.insert(body, account.id);
}
} else {
Logger.log('No accounts found.');
}
}
You will have to add the "Advanced Google Service" resource: Google Analytics API.
When you run it, you will also need to allow as a user who actually has permissions to add users to GA accounts.
Edit: I forgot to add, this seemed to create a new project for me in the developer console. I got an error message the first time about the project not having the API enabled. Click details or go to the dev console and find this project and enable the Google Analytics API.

Confused with load-on-startup value

When we mention any servlet as loadOnStartup in web.xml then its init method is called at applicaton startup.
<web-app xmlns="http://java.sun.com/xml/ns/javaee"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd     version="3.0">       
<servlet>         
<servlet-name>SimpleServlet</servlet-name>         
<servlet-class>app01c.SimpleServlet</servlet-class>         
<load-on-startup>10</load-on-startup>     
</servlet>      
 <servlet-mapping>         
<servlet-name>SimpleServlet</servlet-name>         
<url-pattern>/simple</url-pattern>     
</servlet-mapping>        
</web-app>
<load-on-startup>10</load-on-startup>
here, what does it mean for the value 10? if i change it to
5, what will happen? having less value will make it to load earlier? if so, if it is 0, is it the earliest? i am little confused with as i came across some googling that positive value in load-on-startup, make it to load at start up.
Does this positive is greater than than 0? Does 0 value is same as nothing in load-on-startup?
0 is the highest priority.
If you have only one servlet you can not see the difference
ServletName load-on-start-up_value
Servlet1 4(3)
Servlet2 6(4)
Servlet3 3(2)
Servlet4 2(1)
Servlet4 object will be created first then Servlet3 object will be created and then Servlet1 and Servlet2 objects will be created.
If you give -1 it will be ignored
By default, servlet object is created when you make the first request to servlet, but if you want to create the servlet object at the load time(or start up time), then you can provide <load-on-startup></load-on-startup> value in web.xml.
<load-on-startup></load-on-startup> is servlet wise. If there are 2 servlets in your application so you need to provide <load-on-startup></load-on-startup> value for each servlet.
<load-on-startup></load-on-startup> value either 0 or any positive integer. If you are putting <load-on-startup>10</load-on-startup> value 10, and you have only single servlet then it will not affect any thing, but you have more then 1 servlet then 0 value is highest priority and then so on.

Resources