Cannot find function createEvent in object - calendar

I have no idea why I am getting this error... All of the other code in this script is commented out...
Any help would be appreciated!
error message: TypeError: Cannot find function createEvent in object . (line 16, file "Code")
function createEvent(test)
{
var cal = CalendarApp.getCalendarsByName(test);
var title = 'Script Demo Event';
var start = new Date("April 5, 2013 08:00:00 PDT");
var end = new Date("April 5, 2013 10:00:00 PDT");
var desc = "Created using Google Apps Script";
var loc = "Script Center";
var event = cal.createEvent(title, start, end, {description:desc, location:loc});
};

(friend figured it out)
These two do not play well together....
createEvent AND getCalendarsByName
createEvent must use getCalendarsByID

Related

How to Query By Firebase Timestamp (from - to)?

i want to query my data by time stamp
let date = new Date();
var today = new Date();
var yesterday = date.setDate(today.getDate() - 1);
console.log(date)
const dataTable = collection(db, 'sales')
let mquery = query(dataTable, where('createdDate', "<", yesterday))
const qSnap = await getDocs(mquery)
console.log(qSnap)
error : Uncaught (in promise) FirebaseError: Expected type 'mc', but it was: a custom xh object
The error that you encountered was produced by not using the query() method as pointed out by #AyseAsude. Now, after fixing the query, you should also convert the variable yesterday into a date format and iterate the items from the query. See code below:
let date = new Date();
var today = new Date();
var yesterday = new Date(date.setDate(today.getDate() - 1));
const dataTable = collection(db, 'sales')
let mquery = query(dataTable, where('createdDate', "<", yesterday))
const qSnap = await getDocs(mquery)
qSnap.forEach((doc) => {
// doc.data() is never undefined for query doc snapshots
console.log(doc.id, " => ", doc.data());
});
For more information, you check out this documentation.
You should use the query function and create Query instance.
import {query} from "firebase/firestore";
let mquery = query(dataTable, where('createdDate', "<", yesterday))
const qSnap = await getDocs(mquery)
Documentations to refer to:
https://firebase.google.com/docs/firestore/query-data/queries#simple_queries
https://firebase.google.com/docs/reference/js/firestore_#query

Programming c# code to create a SSRS data driven subscription

I have SSRS report with parameters under SQL Reporting service 2012 standard edition. I like to export to excel and send as an attachment in the email to different receipt and receipt comes from some SQL query that means it is dynamic.
Data-driven subscription can do this but I have SQL Server 2012 Standard edition which does not support data-driven subscription and I can not upgrade, so I am looking for any code which can do the similar job like a data-driven subscription.
I found this link which has the solution to my issue.
http://jaliyaudagedara.blogspot.com/2012/10/creating-data-driven-subscription.html
when I try this code under visual studio 2015 "Class Library" project by adding service reference "http://mylocalserver:81/reportserver/ReportService2010.asmx" I am getting an error on this line of code.
ReportingService2010SoapClient rs= new ReportingService2010SoapClient();
Additional information about the error: Could not find default endpoint element that references contract 'ReportService2010.ReportingService2010Soap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
After spending enough time to make it work with "Class Library" project, I decided to do the code under web service project by adding the web service reference. with some trial and error finally, I got the working code here under web service project. below code works on my local machine which has Sql server 2012 enterprise edition but it gives me the same error saying "Data-driven subscriptions to reports" is not supported in this edition of Reporting Services" on my company server which has SQL server 2012 standard edition.
public void DoWork()
{
ReportingService2010 rs = new ReportingService2010();
rs.Credentials = CredentialCache.DefaultCredentials;
// rs.Url = "http://mylocalserver:81/reportserver/ReportService2010.asmx";
rs.Url = "http://companyserver/reportserver/ReportService2010.asmx";
var reportPath = "/CYTYC Reports/";
string report = $"{reportPath}AllContactCIPPointsReport";
string description = "Programmatic Data Driven Subscription \"Report Server Email\" ";
//set extension as Windows File Share
ExtensionSettings settings = new ExtensionSettings();
settings.Extension = "Report Server Email";
// Set the extension parameter values.
var extensionParams = new ParameterValueOrFieldReference[8];
// var to = new ParameterFieldReference { ParameterName = "TO", FieldAlias = "PARAMS" }; // Data-driven.
var to = new ParameterValue { Name = "TO", Value = "example#gmail.com" }; // Data-driven.
extensionParams[0] = to;
var replyTo = new ParameterValue { Name = "ReplyTo", Value = "example#gmail.com" };
extensionParams[1] = replyTo;
var includeReport = new ParameterValue { Name = "IncludeReport", Value = "False" };
extensionParams[2] = includeReport;
var renderFormat = new ParameterValue { Name = "RenderFormat", Value = "HTML4.0" };
extensionParams[3] = renderFormat;
var priority = new ParameterValue { Name = "Priority", Value = "NORMAL" };
extensionParams[4] = priority;
var subject = new ParameterValue { Name = "Subject", Value = "Subsribed Report" };
extensionParams[5] = subject;
var comment = new ParameterValue { Name = "Comment", Value = "Here is the link to your report." };
extensionParams[6] = comment;
var includeLink = new ParameterValue { Name = "IncludeLink", Value = "True" };
extensionParams[7] = includeLink;
settings.ParameterValues = extensionParams;
// Create the data source for the delivery query.
var delivery = new DataSource { Name = "" };
var dataSourceDefinition = new DataSourceDefinition
{
ConnectString = "Data Source=CYTYC-LIVE;Initial Catalog=yourdatabasename",
CredentialRetrieval = CredentialRetrievalEnum.Store,
Enabled = true,
EnabledSpecified = true,
Extension = "SQL",
ImpersonateUserSpecified = false,
UserName = "username",
Password = "password"
};
delivery.Item = dataSourceDefinition;
// Create the data set for the delivery query.
var dataSetDefinition = new DataSetDefinition
{
AccentSensitivitySpecified = false,
CaseSensitivitySpecified = false,
KanatypeSensitivitySpecified = false,
WidthSensitivitySpecified = false
};
var queryDefinition = new QueryDefinition
{
CommandText = #"Your select * from Query",
CommandType = "Text",
Timeout = 45,
TimeoutSpecified = true
};
dataSetDefinition.Query = queryDefinition;
var results = new DataSetDefinition();
var oServerInfoHeader = new ServerInfoHeader();
var oTrustedUserHeader = new TrustedUserHeader();
bool changed;
string[] paramNames;
try
{
results = rs.PrepareQuery(delivery, dataSetDefinition, out changed, out paramNames);//.PrepareQuery(oTrustedUserHeader, delivery, dataSetDefinition, out results, out changed,out paramNames);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
var dataRetrieval = new DataRetrievalPlan { DataSet = results, Item = dataSourceDefinition };
// Set the event type and match data for the delivery.
const string eventType = "TimedSubscription";
const string matchData = "<ScheduleDefinition><StartDateTime>2018-06-01T14:00:00-07:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Monday>True</Monday><Tuesday>True</Tuesday><Wednesday>True</Wednesday><Thursday>True</Thursday><Friday>True</Friday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>";
//const string eventType = "SnapshotUpdated";
//const string matchData = null;
//// Set the report parameter values.
//var parameters = new ParameterValueOrFieldReference[1];
//// i am retrieving value EMAIL from database and I am passing that value as my report parameter value
//var reportparam = new ParameterFieldReference { ParameterName = "yourreportparametername", FieldAlias = "PARAMS" }; // Data-driven.
//parameters[0] = reportparam;
var parameters = new ParameterValue[1];
var reportparam = new ParameterValue {Name = "yourreportparametername", Value = "yourreportparametervalue"};
parameters[0] = reportparam;
string subscriptionId = "";
try
{
subscriptionId = rs.CreateDataDrivenSubscription(report, settings, dataRetrieval, description, eventType, matchData, parameters);
//(oTrustedUserHeader, report, settings, dataRetrieval,description, eventType, matchData, parameters,out subscriptionId);
}
catch (System.Web.Services.Protocols.SoapException ex)
{
Console.WriteLine(ex.Detail.InnerText.ToString(CultureInfo.InvariantCulture));
}
}
You don't say why you need the Data Driven subscriptions - a regular SSRS subscription can e-mail an Excel report with set or default parameters.
There aren't any third party tools that I know of that emulates the Data Driven subscriptions but there have been some users who have created their own.
If you just want to trigger a subscription based on criteria, you could just use an SSIS job to run the query to determine whether to send or not and trigger the subscription if so.
Something like Data Driven Subscriptions SSRS Standard Edition 2008
If you need something more complicated (like varying TO/CC recipients, changing parameter values...), you'll need to do a bit more programming. Here's a couple things to get started with the theory and code:
https://www.mssqltips.com/sqlservertip/4249/simulate-reporting-services-data-driven-subscriptions-on-unsupported-editions/
http://www.sqlservercentral.com/articles/Reporting+Services+(SSRS)/163119/

Find a specific Google Document in Drive

I am trying to write a script to get the URL of a specific yet dynamic Google Document in Drive. The Google Document is created every Tuesday with its date at the end of the title of the Google Document.
"TypeError: Cannot find function getUrl in object FileIterator." error shows on line var agendaURL = file.getUrl();. Not sure how to debug this.
var ssUrl = 'LINK BUFFERED';
var sheetName = 'SHEET1'; // name of sheet to use
var rangeName = 'C30'; // range of values to include
var dateRange = SpreadsheetApp.openByUrl(ssUrl)
.getSheetByName(sheetName)
.getRange(rangeName)
.getValues();
// NEED TO find how to find file by name below!
var file = DriveApp.getFilesByName("Weekly Agenda | " +dateRange);
var agendaURL = file.getUrl();
It is because you need to iterate through all of the files that meet the search criteria. The solution is here: https://developers.google.com/apps-script/reference/drive/drive-app
var files = DriveApp.getFilesByName("Weekly Agenda | " +dateRange);
while (files.hasNext()) {
var file = files.next();
var agendaURL = file.getUrl();
return agendaURL //for first one, or you can return each one, push to an array, etc...
}
The value which got by DriveApp.getFilesByName() is FileIterator. So it is necessary to retrieve the filename from the value as follows.
var filename = "Weekly Agenda | " + dateRange;
var file = DriveApp.getFilesByName(filename);
while (file.hasNext()) {
var file = files.next();
if (file.getName() == filename) {
var agendaURL = file.getUrl();
}
}

Find difference between 2 dates with AngularJS

I get 2 dates from MySQL something like this:
Start: 2015-11-01 22:56:59 End: 2015-11-03 00:00:00
Also I get dates from object array; here is what one object looks like:
Array[5]
0: Object
$$hashKey: "object:9"
created_at: "2015-10-23 03:36:11"
expiration_date: "2015-11-03 00:00:00"
id: 1
name: "TEST PROJECT"
I need to find how many days left with AngularJS...
Its simple. Use the function as:
$scope.calcDiff = function(firstDate, secondDate){
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));
}
Consider using moment.js for all your javascript date and time manipulations.
With the moment library it is as easy as:
moment(date1).diff(moment(date2), 'days')
You just need to write a js function, that do all calculation instead of you.
<label>{{diffDate(date1, date2) }} </label>
$scope.diffDate = function(date1, date2){
var dateOut1 = new Date(date1); // it will work if date1 is in ISO format
var dateOut2 = new Date(date2);
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
alert(diffDays);
return dateOut;
};
If your data is not in ISO format, you have to set it explicitly.
var dateString = "2015-01-16 22:15:00";
var date = Date.parse(dateString, "yyyy-MM-dd HH:mm:ss");
You can use amDifference filter. Don't forget to inject $filter
let dif = $filter('amDifference')(date1, date2, 'days');

Initializing a NotificationController in DNN 7

How do you initialize a NotificationController in DNN 7.1.2?
I've tried:
var nc = new DotNetNuke.Services.Social.Notifications.NotificationController();
However this is empty and has no methods to call... Am I initializing the wrong thing?
Surely there should be something in there other than ToString, GetType, Equals and GetHashCode
I need to be able to create NotificationTypes and create Notifications.
Thanks
You can use NotificationsController.Instance.SendNotification method to send notifications.
Here is the example:
var notificationType = NotificationsController.Instance.GetNotificationType("HtmlNotification");
var portalSettings = PortalController.GetCurrentPortalSettings();
var sender = UserController.GetUserById(portalSettings.PortalId, portalSettings.AdministratorId);
var notification = new Notification {NotificationTypeID = notificationType.NotificationTypeId, Subject = subject, Body = body, IncludeDismissAction = true, SenderUserID = sender.UserID};
NotificationsController.Instance.SendNotification(notification, portalSettings.PortalId, null, new List<UserInfo> { user });
This will send notification to a specific user.
If you need to create your own Notification type use the code below as a guide, it will create a NotificationType "GroupApprovedNotification". This is from core groups module.
type = new NotificationType { Name = "GroupApprovedNotification", Description = "Group Approved Notification", DesktopModuleId = deskModuleId };
if (NotificationsController.Instance.GetNotificationType(type.Name) == null)
{
NotificationsController.Instance.CreateNotificationType(type);
}

Resources