I am trying to create subscriptions for reports via C# code using Web Reference CreateSubscription method. I have tried:
Using Web Reference and Service Reference. Both give error that is below.
Connecting to 2 different SSRS servers (localbox and on another server on the network)
On the local machine I tweaked permission of the user account to have admin level access.
Tried different parameters in web.config from examples on internet
The error that I get is:
"System.Web.Services.Protocols.SoapException: The report server
cannot open a connection to the report server database".
I am a bit stuck at this point. I am not sure if the SSRS is not configured correctly or I need to pass in a certain credentials via C# when I make the call. Any ideas?
Resources Used:
https://ssrstutorials.blogspot.com/2012/10/lesson-12-using-ssrs-web-services.html
https://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.createsubscription.aspx
https://jaliyaudagedara.blogspot.com/2012/05/accessing-report-server-using-report.html
Web Reference URL:
http://localhost:80/ReportServer/ReportService2005.asmx
Code:
ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
string report = "/Demo/DemoReport";
string desc = "Send email";
string eventType = "TimedSubscription";
string scheduleXml = #"<ScheduleDefinition><StartDateTime>2017-11-
24T09:00:00-08:00</StartDateTime><WeeklyRecurrence>
<WeeksInterval>1</WeeksInterval><DaysOfWeek><Monday>True</Monday>
</DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>";
ParameterValue[] extensionParams = new ParameterValue[8];
extensionParams[0] = new ParameterValue();
extensionParams[0].Name = "TO";
extensionParams[0].Value = "demo#demo.com";
extensionParams[1] = new ParameterValue();
extensionParams[1].Name = "ReplyTo";
extensionParams[1].Value = "demo#demo.com";
extensionParams[2] = new ParameterValue();
extensionParams[2].Name = "IncludeReport";
extensionParams[2].Value = "True";
extensionParams[3] = new ParameterValue();
extensionParams[3].Name = "RenderFormat";
extensionParams[3].Value = "MHTML";
extensionParams[4] = new ParameterValue();
extensionParams[4].Name = "Subject";
extensionParams[4].Value = "#ReportName was executed at
#ExecutionTime";
extensionParams[5] = new ParameterValue();
extensionParams[5].Name = "Comment";
extensionParams[5].Value = "Demo";
extensionParams[6] = new ParameterValue();
extensionParams[6].Name = "IncludeLink";
extensionParams[6].Value = "True";
extensionParams[7] = new ParameterValue();
extensionParams[7].Name = "Priority";
extensionParams[7].Value = "NORMAL";
ParameterValue parameter = new ParameterValue();
parameter.Name = "";
parameter.Value = "";
ParameterValue[] parameters = new ParameterValue[1];
parameters[0] = parameter;
string matchData = scheduleXml;
ExtensionSettings extSettings = new ExtensionSettings();
extSettings.ParameterValues = extensionParams;
extSettings.Extension = "Report Server Email";
try
{
rs.CreateSubscription(report, extSettings, desc, eventType,
matchData, parameters);
}
catch (SoapException e)
{
Console.WriteLine(e.Detail.InnerXml.ToString());
}
Error:
System.Web.Services.Protocols.SoapException: The report server cannot
open a connection to the report server database. A connection to the
database is required for all requests and processing. --->
Microsoft.ReportingServices.Library.ReportServerDatabaseUnavailableException:
The report server cannot open a connection to the report server
database. A connection to the database is required for all requests
and processing. at
Microsoft.ReportingServices.Library.Global.EnsureModeFromCatalog()
at Microsoft.ReportingServices.Library.Global.EnsureRSNativeMode()
at Microsoft.ReportingServices.WebServer.ReportingService2005..ctor()
Related
I want to select the user "test" so I can create a contact into his mailbox.
My actual problem is that it will create Contacts into my user "c-sharp".
"c-sharp" has full access on "test" mailbox
I changed the IP and the contact infos users are also only for testing.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
service.EnableScpLookup = false;
service.Credentials = new WebCredentials("c-sharp", "c-sharp", "domain");
service.UseDefaultCredentials = false;
IgnoreBadCertificates();
service.Url = new Uri("https://192.000.000.000/EWS/Exchange.asmx");
Contact contact = new Contact(service);
// Specify the name and how the contact should be filed.
contact.GivenName = "n.a.";
contact.FileAsMapping = FileAsMapping.SurnameCommaGivenName;
contact.DisplayName = "bau gmbh";
// Specify the company name.
contact.CompanyName = "bau";
// Specify the business, home, and car phone numbers.
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone] = "00000 00000";
contact.PhoneNumbers[PhoneNumberKey.MobilePhone] = "n.a.";
contact.PhoneNumbers[PhoneNumberKey.BusinessFax] = "00000 00000";
// Specify two email addresses.
contact.EmailAddresses[EmailAddressKey.EmailAddress1] = new EmailAddress("e#mail.de");
//homepage
contact.BusinessHomePage = "n.a.";
// Specify the home address.
PhysicalAddressEntry paEntry1 = new PhysicalAddressEntry();
paEntry1.Street = "straße";
paEntry1.City = "stadt";
paEntry1.State = "D";
paEntry1.PostalCode = "88890";
paEntry1.CountryOrRegion = "Deutschland";
contact.PhysicalAddresses[PhysicalAddressKey.Home] = paEntry1;
contact.Save();
Already tried this:
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.PrincipalName, "test");
I tested it with "test" and "test#domain" and "test#domain.de"
And get back this error:
"Der Name des Identitätsprinzipals ist ungültig."
Own translation: "The name of the identity principal is unvailed"
You can use Impersonation like this
ExchangeUserData exchangeUserData = new ExchangeUserData();
exchangeUserData.Username = "c-sharp";
exchangeUserData.Password = "c-sharp"; // c-sharp's Password
ExchangeService service = Service.ConnectToServiceWithImpersonation(exchangeUserData, impersonatedUserPrincipal);
Contact contact = new Contact(service);
// Specify the name and how the contact should be filed.
contact.GivenName = "n.a.";
contact.FileAsMapping = FileAsMapping.SurnameCommaGivenName;
contact.DisplayName = "bau gmbh";
// Specify the company name.
contact.CompanyName = "bau";
// Specify the business, home, and car phone numbers.
contact.PhoneNumbers[PhoneNumberKey.BusinessPhone] = "00000 00000";
contact.PhoneNumbers[PhoneNumberKey.MobilePhone] = "n.a.";
contact.PhoneNumbers[PhoneNumberKey.BusinessFax] = "00000 00000";
// Specify two email addresses.
contact.EmailAddresses[EmailAddressKey.EmailAddress1] = new EmailAddress("e#mail.de");
//homepage
contact.BusinessHomePage = "n.a.";
// Specify the home address.
PhysicalAddressEntry paEntry1 = new PhysicalAddressEntry();
paEntry1.Street = "straße";
paEntry1.City = "stadt";
paEntry1.State = "D";
paEntry1.PostalCode = "88890";
paEntry1.CountryOrRegion = "Deutschland";
contact.PhysicalAddresses[PhysicalAddressKey.Home] = paEntry1;
contact.Save();
If your c-sharp user has the proper rights in Exchange, you should be able to do:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013);
service.Credentials = new WebCredentials("c-sharp", "c-sharp", "domain");
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.PrincipalName, "test");
If this doesn't work for you, please comment below or update your question (there's an "edit" link under it) with the exact behavior you are seeing including any error messages.
Problem sloved.
I found the bug... both of you are right just change:
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.PrincipalName, "test");
Into:
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "test#domain.de");
Thats all ...
Great thanks to you
I want to consume SAP web service into my c# application. For that i wrote one block of code given below.
NetworkCredential ntobj = new NetworkCredential();
ZWEBSERVICE_INTERNAL_ORDER2 zClassobj = new ZWEBSERVICE_INTERNAL_ORDER2();
ZbapiFiCreateInternalOrder zMethodObj = new ZbapiFiCreateInternalOrder();
ZbapiFiCreateInternalOrderResponse zMethodResobj = new ZbapiFiCreateInternalOrderResponse();
ntobj.UserName = "alpldev";
ntobj.Password = "alpl123";
zClassobj.PreAuthenticate = true;
zClassobj.Credentials = ntobj;
zMethodObj.IDriverNo = "KD00000014";
zMethodObj.IPlant = "1001";
zMethodObj.ITripNo = "1001201406140027";
zMethodObj.IVhclNo = "AP29Q8639";
zMethodResobj = zClassobj.ZbapiFiCreateInternalOrder(zMethodObj);
but at last line i got "underlying connection established was closed. unexpected format was send" error.
please help me...
I'm actually using a soap service for a SAP WebService and I think I know what the problem is. You have to do first a Request including the QaaWsHeader and the ReportBlock configuration, then create the Request and finally with help with the ServicesSoapClient make the method to send your result.
Use this as an example, I hope this will help, good luck
Sellers.QaaWSHeader qaawsHeaderDatos = new Sellers.QaaWSHeader();
Sellers.GetReportBlock_WBS_Sellers getReportBlock = new Sellers.GetReportBlock_WBS_Sellers();
getReportBlock.login = userWS;
getReportBlock.password = passWS;
getReportBlock.refresh = true;
getReportBlock.startRow = 0;
getReportBlock.startRowSpecified = true;
getReportBlock.endRow = 1000;
getReportBlock.endRowSpecified = true;
Sellers.GetReportBlock_WBS_Sellers_Request WSRequest = new Sellers.GetReportBlock_WBS_Sellers_Request(qaawsHeaderDatos, getReportBlock);
Sellers.BIServicesSoap BiService = new Sellers.BIServicesSoapClient();
Sellers.GetReportBlock_WBS_Sellers_Response FinalResponse = BiService.GetReportBlock_WBS_Sellers(WSRequest);
object[][] yourTable = FinalResponse.table;
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"
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");
I am trying to consume some of these services in .Net/C#. Some of the Service could be easily consumed but with others i have got a misleading error.
this a part of the code:
input.AcademicProgramOfStudySelectionByName = new AcademicProgramOfStudyByNameQueryMessage_syncAcademicProgramOfStudySelectionByName();
input.AcademicProgramOfStudySelectionByName.AcademicProgramOfStudyName.languageCode = "DE";
I am getting at the second line the error "Object reference not set to an object instance."
but i have create the object in the first line!
The same code works in some other service!
you created the object
input.AcademicProgramOfStudySelectionByName, but you did not create its member input.AcademicProgramOfStudySelectionByName.AcademicProgramOfStudyName. As it seems, the constructor of class AcademicProgramOfStudyByNameQueryMessage_syncAcademicProgramOfStudySelectionByName does not populate its member AcademicProgramOfStudyName. So when you try to assign a value to a member of AcademicProgramOfStudyName and that instance is NULL, you get an exception.
Example code:
AcademicProgramOfStudyByNameQueryResponse_InClient client =
new AcademicProgramOfStudyByNameQueryResponse_InClient();
client.ClientCredentials.UserName.UserName = "XX";
client.ClientCredentials.UserName.Password = "YY";
AcademicProgramOfStudyByNameQueryMessage_sync input =
new AcademicProgramOfStudyByNameQueryMessage_sync();
input.AcademicProgramOfStudySelectionByName = new AcademicProgramOfStudyByNameQueryMessage_syncAcademicProgramOfStudySelectionByName();
// this is the member that currently is still NULL and has to be created:
input.AcademicProgramOfStudySelectionByName.AcademicProgramOfStudyName = new <insert whatever class is needed here>
// now this should work without throwing an exception
input.AcademicProgramOfStudySelectionByName.AcademicProgramOfStudyName.languageCode = "DE";
AcademicProgramOfStudyByNameResponseMessage_sync output =
new AcademicProgramOfStudyByNameResponseMessage_sync();
output = client.AcademicProgramOfStudyByNameQueryResponse_In(input);
it is really strange. see this compare:
In this code i get the error
AcademicProgramOfStudyByNameQueryResponse_InClient client =
new AcademicProgramOfStudyByNameQueryResponse_InClient();
client.ClientCredentials.UserName.UserName = "XX";
client.ClientCredentials.UserName.Password = "YY";
AcademicProgramOfStudyByNameQueryMessage_sync input =
new AcademicProgramOfStudyByNameQueryMessage_sync();
input.AcademicProgramOfStudySelectionByName = new AcademicProgramOfStudyByNameQueryMessage_syncAcademicProgramOfStudySelectionByName();
input.AcademicProgramOfStudySelectionByName.AcademicProgramOfStudyName.languageCode = "DE";
AcademicProgramOfStudyByNameResponseMessage_sync output =
new AcademicProgramOfStudyByNameResponseMessage_sync();
output = client.AcademicProgramOfStudyByNameQueryResponse_In(input);
and in this code i dont!!
CustomerSimpleByNameAndAddressQueryResponse_InClient client =
new CustomerSimpleByNameAndAddressQueryResponse_InClient();
client.ClientCredentials.UserName.UserName = "XX";
client.ClientCredentials.UserName.Password = "YY";
CustomerSimpleByNameAndAddressQueryMessage_sync input = new CustomerSimpleByNameAndAddressQueryMessage_sync();
input.CustomerSimpleSelectionByNameAndAddress = new CustomerSimpleByNameAndAddressQueryMessage_syncCustomerSimpleSelectionByNameAndAddress();
input.CustomerSimpleSelectionByNameAndAddress.CustomerAddressCityName = "Berlin";
CustomerSimpleByNameAndAddressResponseMessage_sync output = new CustomerSimpleByNameAndAddressResponseMessage_sync();
output = client.CustomerSimpleByNameAndAddressQueryResponse_In(input);