Jamaa SMPP Client working example - c#

I'm using Jamaa SMPP Client
Does anyone have a working example on sending SMS?
Here is my code :
var textMessage = new TextMessage() { DestinationAddress = "XXXXXXXXX", SourceAddress = "XXXXXXXXX", Text = "test" };
var client = new SmppClient();
client.Properties.SystemID = "xxxx";
client.Properties.Password = "YYYY";
client.Properties.Port = ZZZZ;
client.Properties.Host = "255.255.255.255";
client.Properties.DefaultEncoding = DataCoding.SMSCDefault;
client.Properties.AddressNpi = NumberingPlanIndicator.Unknown;
client.Properties.AddressTon = TypeOfNumber.Unknown;
client.ForceConnect();
client.Start();
client.SendMessage(textMessage);
client.Shutdown();
But my provider is saying that I'm lacking the bind info (Bind_transceiver, Bind_transmitter, Bind_receiver)

Have a look at the below sample code . I think you are missing the SystemType parameter. The send operation works fine with me .
// Initialize Connection
client = new SmppClient();
properties = client.Properties;
properties.SystemID = "BBBB";
properties.Password = "BBBB";
properties.Port = 1234; //IP port to use
properties.Host = "1.2.3.4"; //SMSC host name or IP Address
properties.SystemType = "EXT_SME";
properties.DefaultServiceType = "EXT_SME";
//Resume a lost connection after 30 seconds
client.AutoReconnectDelay = 3000;
TextMessage send_msg = new TextMessage();
send_msg.DestinationAddress = mobile_number; //Receipient number
send_msg.SourceAddress = "1234"; //Originating number
send_msg.Text = message;
send_msg.RegisterDeliveryNotification = true; /
client.SendMessage(send_msg);
general_obj.WriteLog(mobile_number +" "+message, "SendLog");

Related

ASP.NET PayPal Parallel Payments

I am needing some assistance with paypal Parallel payments C# I have tried the Classic API and the REST API that paypal has. I am running into cycles and don't know what else to do, I have tried to get chained payments working and I have google'd and there is a huge lack of support so Im now trying Parallel. Let you know i get an 500 internal Server error..
ReceiverList receiverList = new ReceiverList();
receiverList.receiver = new List<Receiver>();
Receiver secondaryReceiver = new Receiver((decimal?)2.00);
secondaryReceiver.email = "xxxxxxxxx#gmail.com";
secondaryReceiver.primary = false;
secondaryReceiver.paymentType = "GOODS";
receiverList.receiver.Add(secondaryReceiver);
Receiver primaryReceiver = new Receiver((decimal?)10.00);
primaryReceiver.email = "xxxxxxxxxxxxxxxxxx-facilitator#gmail.com ";
primaryReceiver.primary = true;
primaryReceiver.paymentType = "GOODS";
primaryReceiver.invoiceId = "123456789";
receiverList.receiver.Add(primaryReceiver);
RequestEnvelope requestEnvelope = new RequestEnvelope("en_US");
string actionType = "Pay";
string returnUrl = "https://devtools-paypal.com/guide/ap_chained_payment/dotnet?success=true";
string cancelUrl = "https://devtools-paypal.com/guide/ap_chained_payment/dotnet?cancel=true";
string currencyCode = "USD";
PayRequest payRequest = new PayRequest(requestEnvelope, actionType, cancelUrl, currencyCode, receiverList, returnUrl);
payRequest.ipnNotificationUrl = "http://replaceIpnUrl.com";
payRequest.feesPayer = "PRIMARYRECEIVER";
payRequest.trackingId = "123456789";
Dictionary<string, string> paypalConfig = new Dictionary<string, string>();
paypalConfig.Add("account1.apiUsername", "xxxxxxxxxxxxxxx-facilitator_api1.gmail.com");
paypalConfig.Add("account1.apiPassword", "xxxxxxxxxxxxxxxxxxx");
paypalConfig.Add("account1.apiSignature", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
paypalConfig.Add("account1.applicationId", "APP-80W284485P519543T");
paypalConfig.Add("IPNEndpoint", "https://www.paypal.com/cgi-bin/webscr");
paypalConfig.Add("url", "https://www.paypal.com/webscr&cmd=_express-checkout&token=");
paypalConfig.Add("endpoint", "https://api-3t.paypal.com/2.0/");
paypalConfig.Add("mode", "sandbox");
PayPal.AdaptivePayments.AdaptivePaymentsService service = new PayPal.AdaptivePayments.AdaptivePaymentsService(paypalConfig);
PayResponse response = service.Pay(payRequest);
string redirectUrl = null;
if (!response.responseEnvelope.ack.ToString().Trim().ToUpper().Equals(AckCode.FAILURE.ToString()) && !response.responseEnvelope.ack.ToString().Trim().ToUpper().Equals(AckCode.FAILUREWITHWARNING.ToString()))
{
redirectUrl = "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" + response.payKey;
}
Now as for the web.config I dont know exactly how to do it or really what to do. i Have found a few things but need of help.
Thanks

Why aren't I getting email notifications from eBay API?

I am trying to get an email when one of my items sell. However, no email ever comes. If I change it to notify me when an item is listed, that email arrives so I know my code is somewhat working. Here is my code:
ApiContext apiContext= GetApiContext();
SetNotificationPreferencesCall apiCall = new SetNotificationPreferencesCall(apiContext);
ApplicationDeliveryPreferencesType applicationDeliveryPreferences = new ApplicationDeliveryPreferencesType();
applicationDeliveryPreferences.ApplicationEnable = EnableCodeType.Enable;
applicationDeliveryPreferences.ApplicationEnableSpecified = true;
applicationDeliveryPreferences.ApplicationURL = "mailto://myemail#gmail.com";
applicationDeliveryPreferences.AlertEmail = "mailto://myemail#gmail.com";
applicationDeliveryPreferences.AlertEnable = EnableCodeType.Enable;
applicationDeliveryPreferences.AlertEnableSpecified = true;
NotificationEnableType notification =
new NotificationEnableType
{
EventEnable = EnableCodeType.Enable,
EventEnableSpecified = true,
EventType = NotificationEventTypeCodeType.ItemSold,
EventTypeSpecified = true
};
apiCall.UserDeliveryPreferenceList = new NotificationEnableTypeCollection(new[] { notification });
apiCall.ApplicationDeliveryPreferences = applicationDeliveryPreferences;
apiCall.UserDeliveryPreferenceList = new NotificationEnableTypeCollection(new[] { notification });
apiCall.Execute();

Perforce Api - How to command "get revision [changelist number]"

I would like to implement the Perforce command "Get Revision [Changelist Number]" using the Perforce .NET API (C#). I currently have code that will "Get Latest Revision", but I need to modify it to get a specific changelist.
To sync the data with a changelist number, what should I do?
Source
// --------Connenct----------------
Perforce.P4.Server server = new Perforce.P4.Server(
new Perforce.P4.ServerAddress("127.0.0.1:9999"));
Perforce.P4.Repository rep = new Perforce.P4.Repository(server);
Perforce.P4.Connection con = rep.Connection;
con.UserName = m_P4ID;
string password = m_P4PASS;
Perforce.P4.Options opconnect = new Perforce.P4.Options();
opconnect.Add("-p", password);
con.Connect(opconnect);
if (con.Credential == null)
con.Login(password);
//----------Download----------
string clientPath = #"C:\P4V\";
string ws_client = clientPath;
Perforce.P4.Client client = new Perforce.P4.Client();
client.Name = ws_client;
client.Initialize(con);
con.CommandTimeout = new TimeSpan(0);
IList<Perforce.P4.FileSpec> fileList = client.SyncFiles(new Perforce.P4.Options());
//----------Disconnect------------
con.Disconnect();
con.Dispose();
Edit: Attempt 1
Perforce.P4.DepotPath depot = new Perforce.P4.DepotPath("//P4V//");
Perforce.P4.LocalPath local = new Perforce.P4.LocalPath(ws_client);
Perforce.P4.FileSpec fs = new Perforce.P4.FileSpec(depot, null, local,
Perforce.P4.VersionSpec.Head);
IList<Perforce.P4.FileSpec> listFiles = new List<Perforce.P4.FileSpec>();
listFiles.Add(fs);
IList<Perforce.P4.FileSpec> foundFiles = rep.GetDepotFiles(listFiles,
new Perforce.P4.Options(1234)); // 1234 = Changelist number
client.SyncFiles(foundFiles, null);
Error Message
Usage: files/print [-o localFile -q] files...Invalid option: -c.
I do not know the problem of any argument.
Or there will not be related to this reference source?
Edit 2
I tried to solve this problem. However, it does not solve the problem yet.
Perforce.P4.Changelist changelist = rep.GetChangelist(1234);
IList<Perforce.P4.FileMetaData> fileMeta = changelist.Files;
In this case, I could get only the files in the changelist. I would like to synchronize all files of the client at the moment of changelist 1234.
SyncFiles takes an optional FileSpec arg. You can specify a file path and a revision specifier with that FileSpec arg. Here are the relevant docs:
FileSpec object docs
SyncFiles method docs
You don't need to run GetDepotFiles() to get the FileSpec object; you can just create one directly as shown in the FileSpec object docs. The error you are getting with GetDepotFiles() is because it expects the change number to be specified as part of the FileSpec object passed into as the first argument to GetDepotFiles().
To expand further, GetDepotFiles() calls the 'p4 files' command when it talks to Perforce. new Perforce.P4.Options(1234) generates an option of '-c 1234' which 'p4 files' doesn't accept. That's why the error message is 'Usage: files/print [-o localFile -q] files...Invalid option: -c.'
I struggled with the same problem as well. Finally based on Matt's answer I got it working. Please see simple example below.
using (Connection con = rep.Connection)
{
//setting up client object with viewmap
Client client = new Client();
client.Name = "p4apinet_solution_builder_sample_application_client";
client.OwnerName = "p4username";
client.Root = "c:\\clientRootPath";
client.Options = ClientOption.AllWrite;
client.LineEnd = LineEnd.Local;
client.SubmitOptions = new ClientSubmitOptions(false, SubmitType.RevertUnchanged);
client.ViewMap = new ViewMap();
client.ViewMap.Add("//depotpath/to/your/file.txt", "//" + client.Name + "/clientpath/to/your/file.txt", MapType.Include);
//connecting to p4 and creating client on p4 server
Options options = new Options();
options["Password"] = "p4password";
con.UserName = "p4username";
con.Client = new Client();
con.Connect(options);
con.Client = rep.CreateClient(client);
//syncing all files (in this case 1) defined in client's viewmap to the changelist level of 12345
Options syncFlags = new Options(SyncFilesCmdFlags.Force, 100);
VersionSpec changeListLevel = new ChangelistIdVersion(12345);
List<FileSpec> filesToBeSynced = con.Client.ViewMap.Select<MapEntry, FileSpec>(me => new FileSpec(me.Left, changeListLevel)).ToList();
IList<FileSpec> results = con.Client.SyncFiles(filesToBeSynced, syncFlags);
}
The following code should allow you to sync a depot to a particular revision (changelist number).
string uri = "...";
string user = "...";
string workspace = "...";
string pass = "...";
int id = 12345; // the actual changelist number
string depotPath = "//depot/foo/main/...";
int maxItemsToSync = 10000;
Server server = new Server(new ServerAddress(uri));
Repository rep = new Repository(server);
server = new Server(new ServerAddress(uri));
rep = new Repository(server);
Connection con = rep.Connection;
con.UserName = user;
con.Client = new Client();
con.Client.Name = workspace;
// connect
bool connected = con.Connect(null);
if (connected)
{
try
{
// attempt a login
Perforce.P4.Credential cred = con.Login(pass);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
con.Disconnect();
connected = false;
}
if (connected)
{
// get p4 info and show successful connection
ServerMetaData info = rep.GetServerMetaData(null);
Console.WriteLine("CONNECTED TO " + info.Address.Uri);
Console.WriteLine("");
try
{
Options opts = new Options();
// uncomment below lines to only get a preview of the sync w/o updating the workspace
//SyncFilesCmdOptions syncOpts = new SyncFilesCmdOptions(SyncFilesCmdFlags.Preview, maxItemsToSync);
SyncFilesCmdOptions syncOpts = new SyncFilesCmdOptions(SyncFilesCmdFlags.None, maxItemsToSync);
VersionSpec version = new ChangelistIdVersion(id);
PathSpec path = new DepotPath(depotPath);
FileSpec depotFile = new FileSpec(path, version);
IList<FileSpec> syncedFiles = rep.Connection.Client.SyncFiles(syncOpts, depotFile);
//foreach (var file in syncedFiles)
//{
// Console.WriteLine(file.ToString());
//}
Console.WriteLine($"{syncedFiles.Count} files got synced!");
}
catch (Exception ex)
{
Console.WriteLine("");
Console.WriteLine(ex.Message);
Console.WriteLine("");
}
finally
{
con.Disconnect();
}
}
}
If you are looking for other ways to build the file spec, like for example sync only a specific list of files to "head", etc, visit this link and search for "Building a FileSpec"

C# Error Binding Resource while Connecting to Openfire server using Jabber-Net

I am developing c# client to connect Openfire server
This is my code
User = txtUserName.Text;
Pwd = txtPassword.Text;
pnlCredentials.Enabled = false;
jabberClient1.User = User;
jabberClient1.Server = "61.182.225.189";
jabberClient1.Password = Pwd;
jabberClient1.AutoRoster = true;
jabberClient1.Port = 5222;
JID jid = new JID("kamal", "192,168,1,17", "123456");
jabberClient1.AutoLogin = true;
jabberClient1.Resource = jid.Resource;
jabberClient1.AutoStartTLS = true;
jabberClient1.NetworkHost = null;
jabberClient1.OnInvalidCertificate += new System.Net.Security.RemoteCertificateValidationCallback(jabberClient1_OnInvalidCertificate);
rm = new RosterManager();
rm.Stream = jabberClient1;
rm.AutoSubscribe = true;
rm.AutoAllow = jabber.client.AutoSubscriptionHanding.AllowAll;
rm.OnRosterBegin += new bedrock.ObjectHandler(rm_OnRosterBegin);
rm.OnRosterEnd += new bedrock.ObjectHandler(rm_OnRosterEnd);
rm.OnRosterItem += new RosterItemHandler(rm_OnRosterItem);
pm = new PresenceManager();
pm.Stream = jabberClient1;
rosterTree1.RosterManager = rm;
rosterTree1.PresenceManager = pm;
rosterTree1.DoubleClick += new EventHandler(rosterTree1_DoubleClick);
jabberClient1.OnAuthenticate += new bedrock.ObjectHandler(jabberClient1_OnAuthenticate);
lblUser.Text = jabberClient1.User;
jabberClient1.Connect();
I am not sure what I need to use in parameters for below
JID jid = new JID("kamal", "192,168,1,17", "123456");
I used user name , server IP and password for that
when I run this it returns error
Error binding resource error type="modify" code="400"bad-requestmlns="urn:ietf:params:xml:ns:xmpp-stanzas"
Could you please help me to solve this
Thank you in advance
I have edited the code using the latest Jabber.net DLL as bellows
JabberClient jabberClient = new JabberClient();
//Bind the JabberClient events to methods that handle those events.
jabberClient.OnAuthError += new IQHandler(jabberClient_OnAuthError);
jabberClient.OnError += new bedrock.ExceptionHandler(jabberClient_OnError);
jabberClient.OnConnect += new bedrock.ObjectHandler(jabberClient_OnConnect);
jabberClient.OnDisconnect += new bedrock.ObjectHandler(jabberClient_OnDisconnect);
//Set client settings
jabberClient.AutoReconnect = 3;
JID jid = new JID("kamal", "192.168,1,17", "123456");
jabberClient.User = jid.User;
jabberClient.Server = jid.Server;
jabberClient.Port =5222;
jabberClient.Resource = jid.Resource;
jabberClient.Password = "123456";
jabberClient.AutoPresence = false;
jabberClient.AutoLogin = true;
jabberClient.Connect();
Now when I try to connect it does fire disconnect event ?

GeoCodeRequest() constructor returns null

I'm trying to create a wcf service that consumes Bing's Geocoding soap service. But when ever i try to set init a new GeoCodeRequest using it's constructor it returns a null.
When I call request.Query = address; I get a null value error referring to request .
public string RequestLocation(string address)
{
const string key = "mybingapplicationId";
var request = new GeocodeRequest();
request.Credentials.ApplicationId = key;
request.Query = address;
var filters = new ConfidenceFilter[1];
filters[0] = new ConfidenceFilter { MinimumConfidence = Confidence.High };
var geocodeOptions = new GeocodeOptions { Filters = filters };
request.Options = geocodeOptions;
// Make the geocode request
var geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
var geocodeResponse = geocodeService.Geocode(request);
return geocodeResponse.Results[0].DisplayName;
}
[UnitTest]
[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\Development\\WcfService1\\WcfService1", "/")]
[UrlToTest("http://localhost:24842/")]
[DeploymentItem("WcfService1.dll")]
public void RequestLocationTest()
{
var target = new TestService.BingEngineClient();
var address = string.Format("1600 Pennsylvania Avenue, {0}, {1}","Washington", "DC");
var expected = string.Empty;
var actual = target.RequestLocation(address);
Assert.IsNotNull(actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
First the code is missing initialization of the Credentials.
request.Credentials = new GeocodeService.Credentials();
When you go through Creating a Bing Maps Account you have to use their application to
Create a Bing Maps Key for the specific application in question. Note that this is different from your account key.
public string RequestLocation(string address)
{
var request = new GeocodeRequest {Credentials = new Credentials {ApplicationId = _key}, Query = address};
var filters = new ConfidenceFilter[1];
filters[0] = new ConfidenceFilter { MinimumConfidence = Confidence.High };
var geocodeOptions = new GeocodeOptions { Filters = filters };
request.Options = geocodeOptions;
// Make the geocode request
var geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
var geocodeResponse = geocodeService.Geocode(request);
return string.Format("Longitude:{0},Latitude:{1}", geocodeResponse.Results[0].Locations[0].Longitude,
geocodeResponse.Results[0].Locations[0].Latitude);
}

Categories

Resources