I created a program a while ago using C# that does some automation for a completely different program, but found that I need to access data from a Lotus Notes database. The only problem is, I can only seem to figure out how to open the database by the server's name (using session.GetDatabase())... I can't figure out how to open it by Replica ID. Does anyone know how I would go about that? (I don't want my program going down every time the server changes.)
public static string[] GetLotusNotesHelpTickets()
{
NotesSession session = new NotesSession();
session.Initialize(Password);
// 85256B45:000EE057 = NTNOTES1A Server Replica ID
NotesDatabase database = session.GetDatabase("NTNOTES1A", "is/gs/gshd.nsf", false);
string SearchFormula = string.Concat("Form = \"Call Ticket\""
, " & GroupAssignedTo = \"Business Systems\""
, " & CallStatus = \"Open\"");
NotesDocumentCollection collection = database.Search(SearchFormula, null, 0);
NotesDocument document = collection.GetFirstDocument();
string[] ticketList = new string[collection.Count];
for (int i = 0; i < collection.Count; ++i)
{
ticketList[i] = ((object[])(document.GetItemValue("TicketNumber")))[0].ToString();
document = collection.GetNextDocument(document);
}
document = null;
collection = null;
database = null;
session = null;
return ticketList;
}
This code is working fine, but if the server changed from NTNOTES1A, then nothing is going to work anymore.
you'll need to use the notesDbDirectory.OpenDatabaseByReplicaID(rid$) method. To get the NotesDbDirectory, you can use the getDbDirectory method of the session
Set notesDbDirectory = notesSession.GetDbDirectory( serverName$ )
So you can use the code below to get a database by replicaID.
public static string[] GetLotusNotesHelpTickets()
{
NotesSession session = new NotesSession();
session.Initialize(Password);
Set notesDBDirectory = session.GetDbDirectory("NTNOTES1A")
// 85256B45:000EE057 = NTNOTES1A Server Replica ID
NotesDatabase database = notesDBDirectory.OpenDatabaseByReplicaID("85256B45:000EE057")
string SearchFormula = string.Concat("Form = \"Call Ticket\""
, " & GroupAssignedTo = \"Business Systems\""
, " & CallStatus = \"Open\"");
NotesDocumentCollection collection = database.Search(SearchFormula, null, 0);
NotesDocument document = collection.GetFirstDocument();
string[] ticketList = new string[collection.Count];
for (int i = 0; i < collection.Count; ++i)
{
ticketList[i] = ((object[])(document.GetItemValue("TicketNumber")))[0].ToString();
document = collection.GetNextDocument(document);
}
document = null;
collection = null;
database = null;
session = null;
return ticketList;
}
Unfortunately, this only solves half of your problem. I know you'd rather just tell Notes to fetch the database with a particular replicaID from the server closest to the client, just like the Notes Client does when you click on a DBLink or Bookmark. However, there is (or appears to be) no way to do that using the Notes APIs.
My suggestion is to either loop through a hard-coded list of potential servers by name, and check to see if the database is found (the OpenDatabaseByReplicaID method returns ERR_SYS_FILE_NOT_FOUND (error 0FA3) if the database is not found). If that's not a good option, perhaps you can easily expose the servername in an admin menu of your app so it can be changed easily if the server name changes at some point.
set database = new NotesDatabase("")
call database.OpenByReplicaID("repid")
Related
I can't see the name of the tables already created. I'm working on a project in which I have access to the DynamoDB database through an IAM client, I create the AmazonClient using the credentials and configs that were made available to me, but I can't see the tables already created in the database.
I have already created the client and connected it to the database, I am trying to see the number of tables as follows, but the result is always 0
new code
List<string> currentTables = client.ListTablesAsync().Result.TableNames;
MessageBox.Show(currentTables.Count.ToString());
Try awaiting the API call:
List<string> currentTables = await client.ListTablesAsync().Result.TableNames;
MessageBox.Show(currentTables.Count.ToString());
Try this sync code instead:
AmazonDynamoDBClient client = new AmazonDynamoDBClient();
// Initial value for the first page of table names.
string lastEvaluatedTableName = null;
do
{
// Create a request object to specify optional parameters.
var request = new ListTablesRequest
{
Limit = 10, // Page size.
ExclusiveStartTableName = lastEvaluatedTableName
};
var response = client.ListTables(request);
ListTablesResult result = response.ListTablesResult;
foreach (string name in result.TableNames)
Console.WriteLine(name);
lastEvaluatedTableName = result.LastEvaluatedTableName;
} while (lastEvaluatedTableName != null);
Hi I have created a task using the QMS API and have had success populating all general, reload, and reduce tabs but I am now having trouble when working with the distribute category. I'm trying to "Distribute to QlikView Server " and add a view users to distribute to. Except whenever I include distribute in the DocumentTaskScope (DocumentTaskScope.Distribute), the task seems to lose reference to the SourceDocument and the reduce category gets wiped, along with options from general and reload being lost. This is indicated by this dialog appearing when I click manage users when on the distribute tab.
Also here is what my distribute panel actually looks like, as you can see it is missing the "Distribute to QlikView Server" area that should normally be there:
Here is my code for the distribute section, I am writing this program in c# and the program builds and executes with no errors, it just doesn't produce the intended result.
I was thinking if it had something to do with the server name syntax or if the ID member. The documentation indicated that this is meant to be the "The ID of the QlikView Server. ", so I used the id of the qlikview service but I am not certain this is what it is looking for.
//Distribute static ("Manually" in QV Management Console)
DocumentTask.TaskDistribute.TaskDistributeStatic tds = new DocumentTask.TaskDistribute.TaskDistributeStatic();
TaskDistributionDestination.TaskDistributionDestinationQlikViewServer tddqvs = new TaskDistributionDestination.TaskDistributionDestinationQlikViewServer();
tddqvs.Name = "QVS#qlikviewdev";
tddqvs.Mount = "Root Folder";
tddqvs.ID = qvsGuid;
TaskDistributionEntry newEntry = new TaskDistributionEntry();
newEntry.Destination = new TaskDistributionDestination();
TaskDistributionDestination tdd = new TaskDistributionDestination();
TaskDistributionDestinationType tddt = new TaskDistributionDestinationType();
tddt = TaskDistributionDestinationType.QlikViewServer;
newEntry.Destination.Type = tddt;
newEntry.Destination.QlikViewServer = tddqvs;
TaskDistributionDestination.TaskDistributionDestinationFolder tddf = new TaskDistributionDestination.TaskDistributionDestinationFolder();
tddf.Name = "N/A";
newEntry.Destination.Folder = tddf;
DirectoryServiceObject[] serviceObject = new DirectoryServiceObject[2];
DirectoryServiceObject dso1 = new DirectoryServiceObject();
DirectoryServiceObject dso2 = new DirectoryServiceObject();
dso1.Name = "QlikView_Admin";
dso1.Type = DirectoryServiceObjectType.Named;
dso1.OtherProperty = "N/A";
dso2.Name = "Qlikview_PowerUser";
dso2.Type = DirectoryServiceObjectType.Named;
dso2.OtherProperty = "N/A";
serviceObject[0] = dso1;
serviceObject[1] = dso2;
newEntry.Recipients = serviceObject;
TaskDistributionEntry[] tdeArray = new TaskDistributionEntry[1];
tdeArray[0] = newEntry;
tds.DistributionEntries = tdeArray;
docTask.Distribute = new DocumentTask.TaskDistribute();
docTask.Distribute.Static = tds;
DocumentTask.TaskDistribute.TaskDistributeDynamic taskDistributeDynamic = new DocumentTask.TaskDistribute.TaskDistributeDynamic();
taskDistributeDynamic.Destinations = new List<TaskDistributionDestination>().ToArray();
taskDistributeDynamic.FieldName = string.Empty;
taskDistributeDynamic.IdentityType = UserIdentityValueType.DisplayName;
docTask.Distribute.Dynamic = taskDistributeDynamic;
DocumentTask.TaskDistribute.TaskDistributeNotification tdn = new DocumentTask.TaskDistribute.TaskDistributeNotification();
tdn.SendNotificationEmail = false;
docTask.Distribute.Notification = tdn;
DocumentTask.TaskDistribute.TaskDistributeOutput tdo = new DocumentTask.TaskDistribute.TaskDistributeOutput();
tdo.Type = TaskDistributionOutputType.QlikViewDocument;
docTask.Distribute.Output = tdo;
Turns out I was using the wrong GUID for the TaskDistributionDestinationQlikViewServer Objects' ID field. Once I set it to be the ID of the QVS#(servername) service, it worked.
Is there a way by which I can trigger a SSRS subscription (Time based) whenever there is an event like file created in a shared folder? Can we do it with powershell or C#?
Is there a out of box feature available in SSRS (though I don't think there is any)?
I am using SQL Server 2008 R2.
Yes, we do something like this here. You can use the FireSubscription function of the Reporting Services web services to trigger a subscription. Here's a detailed explanation of how to set it up:
Firing a Reporting Services Subscription
You can use the FileSystemWatcher to tell when your file is dropped and then fire the subscription off. It's asynchronous though so you don't get notification if the report was sent successfully... only that it was successfully queued up. Also you first modify the parameters of the subscription before you fire it, so you have to make sure that you don't have more than one program to trigger the subscription or it might end up tripping over itself.
Another slightly more complicated way to do it is to use the Render function to generate a report and then have your program manage the emailing.
Render Function
This way you don't have to create a dummy subscription and you'll know immediately if it was sent successfully with the correct parameters.
One final note... if you have the Enterprise Edition (which you probably don't), it comes with Data Driven Report Subscriptions, which you could use to trigger a subscription:
Creating a Data-Driven Subscription
Here i have used timely subscription , i had requirement to generate report
on some button click, so i created subscription which will fire after one minute and generate PDF report.
And I got all help from this article :
http://odetocode.com/articles/114.aspx
You need to add webservice reference of webservice provided by SSRS
http://mymachine/ReportServer/ReportService2010.asmx
Here #"\MyMachineName\Share", is path where my pdf was stored
(PATH:The folder path or UNC file share path to which to save the report.
https://msdn.microsoft.com/en-us/library/ms154020.aspx)
So you can call generate subscription as per your need on file created.
using Test_WebProject.ReportService2010;
private static ExtensionSettings GetExtensionSettings()
{
ParameterValue[] extensionParams = new ParameterValue[7];
for (int i = 0; i < extensionParams.Length; i++)
extensionParams[i] = new ParameterValue();
extensionParams[0].Name = "FILENAME";
extensionParams[0].Value = "Test1#TimeStamp";
extensionParams[1].Name = "FILEEXTN";
extensionParams[1].Value = "true";
extensionParams[2].Name = "PATH";
extensionParams[2].Value = #"\\MyMachineName\Share";
extensionParams[3].Name = "RENDER_FORMAT";
extensionParams[3].Value = "PDF";
extensionParams[4].Name = "WRITEMODE";
extensionParams[4].Value = "None"; //"Overwrite ";// "AutoIncrement";
extensionParams[5].Name = "USERNAME";
extensionParams[5].Value = "gmd";
extensionParams[6].Name = "PASSWORD";
extensionParams[6].Value = "password123";
ExtensionSettings extensionSettings = new ExtensionSettings();
extensionSettings.Extension = "Report Server FileShare"; // EXTENSION_FILESHARE;
extensionSettings.ParameterValues = extensionParams;
return extensionSettings;
}
static void generateSubscription()
{
string report = #"/MyReports/TestSSRSSubscrptionReport";
string description = "My Test subscription2010";
string eventType = "TimedSubscription";
ExtensionSettings extSettings = GetExtensionSettings();
List<ReportService2010.ParameterValue> parameters = new List<ReportService2010.ParameterValue>();
parameters.Add(new ReportService2010.ParameterValue() { Name = "EmployeeKey", Value = "9" });
parameters.Add(new ReportService2010.ParameterValue() { Name = "SelectedColumn", Value = "EmployeeKey" });
parameters.Add(new ReportService2010.ParameterValue() { Name = "ParamSelectedColumns", Value = "FirstName" });
parameters.Add(new ReportService2010.ParameterValue() { Name = "ParamSelectedColumns", Value = "LastName" });
NetworkCredential credentials = new NetworkCredential("gmd", "password123");
ReportService2010.ReportingService2010 rs = new ReportService2010.ReportingService2010();
rs.Credentials = credentials; // System.Net.CredentialCache.DefaultCredentials;
DateTime topDatetime = DateTime.Now;
topDatetime = topDatetime.AddMinutes(1);
string scheduleXml = "<ScheduleDefinition><StartDateTime>";
scheduleXml += topDatetime.ToShortDateString() + " " + topDatetime.ToShortTimeString();
scheduleXml += "</StartDateTime></ScheduleDefinition>";
string sid = rs.CreateSubscription(report, extSettings, description, eventType, scheduleXml, parameters.ToArray());
}
You could create a windows service that uses FileSystemWatcher (https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher%28v=vs.110%29.aspx) and then just trigger your job on the changed event.
We are having an issue with searching a custom record through SuiteTalk. Below is a sample of what we are calling. The issue we are having is in trying to set up the search using the internalId of the record. The issue here lies in in our initial development account the internal id of this custom record is 482 but when we deployed it through the our bundle the record was assigned with the internal Id of 314. It would stand to reason that this internal id is not static in a site per site install so we wondered what property to set up to reference the custom record. When we made the record we assigned its “scriptId’ to be 'customrecord_myCustomRecord' but through suitetalk we do not have a “scriptId”. What is the best way for us to allow for this code to work in all environments and not a specific one? And if so, could you give an example of how it might be used.
Code (C#) that we are attempting to make the call from. We are using the 2013.2 endpoints at this time.
private SearchResult NetSuite_getPackageContentsCustomRecord(string sParentRef)
{
List<object> PackageSearchResults = new List<object>();
CustomRecord custRec = new CustomRecord();
CustomRecordSearch customRecordSearch = new CustomRecordSearch();
SearchMultiSelectCustomField searchFilter1 = new SearchMultiSelectCustomField();
searchFilter1.internalId = "customrecord_myCustomRecord_sublist";
searchFilter1.#operator = SearchMultiSelectFieldOperator.anyOf;
searchFilter1.operatorSpecified = true;
ListOrRecordRef lRecordRef = new ListOrRecordRef();
lRecordRef.internalId = sParentRef;
searchFilter1.searchValue = new ListOrRecordRef[] { lRecordRef };
CustomRecordSearchBasic customRecordBasic = new CustomRecordSearchBasic();
customRecordBasic.recType = new RecordRef();
customRecordBasic.recType.internalId = "314"; // "482"; //THIS LINE IS GIVING US THE TROUBLE
//customRecordBasic.recType.name = "customrecord_myCustomRecord";
customRecordBasic.customFieldList = new SearchCustomField[] { searchFilter1 };
customRecordSearch.basic = customRecordBasic;
// Search for the customer entity
SearchResult results = _service.search(customRecordSearch);
return results;
}
I searched all over for a solution to avoid hardcoding internalId's. Even NetSuite support failed to give me a solution. Finally I stumbled upon a solution in NetSuite's knowledgebase, getCustomizationId.
This returns the internalId, scriptId and name for all customRecord's (or customRecordType's in NetSuite terms! Which is what made it hard to find.)
public string GetCustomizationId(string scriptId)
{
// Perform getCustomizationId on custom record type
CustomizationType ct = new CustomizationType();
ct.getCustomizationTypeSpecified = true;
ct.getCustomizationType = GetCustomizationType.customRecordType;
// Retrieve active custom record type IDs. The includeInactives param is set to false.
GetCustomizationIdResult getCustIdResult = _service.getCustomizationId(ct, false);
foreach (var customizationRef in getCustIdResult.customizationRefList)
{
if (customizationRef.scriptId == scriptId) return customizationRef.internalId;
}
return null;
}
you can make the internalid as an external property so that you can change it according to environment.
The internalId will be changed only when you install first time into an environment. when you deploy it into that environment, the internalid will not change with the future deployments unless you choose Add/Rename option during deployment.
I'm using the Business Objects Web Services SDK to access our Business Objects data. I've successfully got a list of reports, and from that found the LastSuccessfulInstance of a report that has been previously run. However, I can't seem to get the LastRunTime to be populated. When I do a query with no attributes specified it comes back as not set, and I get the same result when I ask for that attribute in particular. I've looked at the report itself and the instance and they both don't have this information. Does anyone know where I can get it from?
Here's my code (hacked from one of SAP's demos):
var sessConnUrl = serviceUrl + "/session";
var boConnection = new BusinessObjects.DSWS.Connection(sessConnUrl);
var boSession = new Session(boConnection);
// Setup the Enterprise Credentials used to login to the Enterprise System
var boEnterpriseCredential = new EnterpriseCredential
{
Domain = cmsname,
Login = username,
Password = password,
AuthType = authType
};
// Login to the Enterprise System and retrieve the SessionInfo
boSession.Login(boEnterpriseCredential);
/************************** DISPLAY INBOX OBJECTS *************************/
// Retrieve the BIPlatform Service so it can be used to add the USER
var biPlatformUrl = boSession.GetAssociatedServicesURL("BIPlatform");
var boBiPlatform = BIPlatform.GetInstance(boSession, biPlatformUrl[0]);
// Specify the query used to retrieve the inbox objects
// NOTE: Adding a "/" at the end of the query indicates that we want to
// retrieve the all the objects located directly under the inbox.
// Without the "/" Path operator, the inbox itself would be returned.
const string query = "path://InfoObjects/Root Folder/Reports/";
// Execute the query and retrieve the reports objects
var boResponseHolder = boBiPlatform.Get(query, null);
var boInfoObjects = boResponseHolder.InfoObjects.InfoObject;
// If the reports contains a list of objects, loop through and display them
if (boInfoObjects != null)
{
// Go through and display the list of documents
foreach (var boInfoObject in boInfoObjects)
{
var report = boInfoObject as Webi;
if (report == null)
continue;
if (!string.IsNullOrEmpty(report.LastSuccessfulInstanceCUID))
{
var instanceQuery = "cuid://<" + report.LastSuccessfulInstanceCUID + ">";
var instanceResponseHolder = boBiPlatform.Get(instanceQuery, null);
var instance = instanceResponseHolder.InfoObjects.InfoObject[0];
}
}
}
Both report.LastRunTimeSpecified and instance.LastRunTimeSpecified are false and both LastRunTime are 01\01\0001, but I can see a last run time in the Web Intelligence UI.
With a little help from Ted Ueda at SAP support I figured it out. Not all the properties are populated by default you need to append #* to the query string to get everything, i.e. change the line:
const string query = "path://InfoObjects/Root Folder/Reports/";
to:
const string query = "path://InfoObjects/Root Folder/Reports/#*";