Value is never used in function(JS) - javascript

I have function for filtering results
Here is code
filtered = markers.filter(function (marker) {
var getDate = marker.date.match(/\d/g).join('');
var markerDate = new Date(parseFloat(getDate));
return (markerDate => valDateStart && markerDate <= valDateEnd && (marker.imei === imei || imei === null));
});
It was refactored from this
$.each(markers, function (i,marker) {
var getDate = marker.date.match(/\d/g).join('');
var markerDate = new Date(parseFloat(getDate));
// var valDate = new Date(startValue[2], startValue[1] - 1, startValue[0]);
if (markerDate => valDateStart && markerDate <= valDateEnd && (marker.imei === imei || imei === null)) {
filtered.push(marker);
}
});
But now in this row var markerDate = new Date(parseFloat(getDate)); I have markerDate is never used
Where is problem?

Related

Count the Calls group by months

Data: you can See in below image:
i want display this data like this:(how many calls are there in particular months)
Name Jan Feb March April May
Staff 0 1 1 0 0
Account 0 0 1 0 3
and i want to do this the same for all the months.
for Graph i wrote a function like this:(but i tried using same logic for table also, but that doesn't seem to work.)
Anyone can help me how to do the same thing in table
getGraphData2( data,config) {
var year = new Date().getUTCFullYear()-1;
var month = new Date().getMonth()+10;
var fullMonths = config.Filter.filter(f => f.type === "Monthly");
var monthsThisYear = config.Filter.filter(f => f.type === "Monthly" && f.key <= month && f.key > (month - 12));
var monthsLastYear = config.Filter.filter(f => f.type === "Monthly" && f.key > (12 - (12 - monthsThisYear.length)));
var months = [];
months.push(...monthsThisYear);
months.push(...monthsLastYear);
var labels = months.map(m => m.value);
var targetTypes = this.state.resultsGraph.map(m => ({Name: m.Name}));
var fData = {};
targetTypes.forEach(f => {
fData[f.Name] = { label: f.Name, data: fullMonths.map(m => 0) };
});
if (this.state.results !== null) {
for (var c = 0; c < this.state.resultsGraph.length; c++) {
var call = this.state.resultsGraph[c];
if (call !== undefined && call !== null) {
var cDate = new Date(call.Call_Date_vod__c); //ConvertToDate(call.call_Date_vod__c);
if (cDate != null && ((cDate.getMonth() + 1) <= month && cDate.getFullYear() === year) || (month < (cDate.getMonth() + 1) && cDate.getFullYear() === (year - 1))) {
var targetType = call.Name;
if (targetType !== undefined && targetType !== null) {
var actData = fData[targetType];
if (actData !== undefined && actData !== null)
actData.data[cDate.getMonth()] = actData.data[cDate.getMonth()] + 1;
else {
actData = fData["NoTarget"];
actData.data[cDate.getMonth()] = actData.data[cDate.getMonth()] + 1;
}
}
else {
var actData = fData["NoTarget"];
actData.data[cDate.getMonth()] = actData.data[cDate.getMonth()] + 1;
}
}
}
}
}
fData = Object.keys(fData).map(k => fData[k]);
fData = fData.filter(f => f.data.filter(d => d > 0).length > 0);
for (var i = 0; i < fData.length; i++) {
var fdat = fData[i];
var data = fdat.data;
fdat.data = months.map(m => data[(m.key - 1)]);
}
var ds = fData.map((m, index) => ({
label: m.label,
data: m.data,
stack: "stack1",
backgroundColor: labels.map(l => (this.props.selectGraphFilter === l) ? getCanvasPattern(config.BackgroundColor[index]) : config.BackgroundColor[index]),
hoverBackgroundColor: labels.map(l => (this.props.selectGraphFilter === l) ? getCanvasPattern(config.HoverBackgroundColor[index]) : config.HoverBackgroundColor[index]),
}));
var graphData = {
labels: labels,
datasets: ds,
};
return graphData;
}
How about to aggregate it like this?
const data = this.state.resultsGraph.reduce(
(actData, call) => {
if (actData) {
actData[call.Name][
`${call.Call_Date_vod__c.getMonth()} ${call.Call_Date_vod__c.getFullYear()}`
] =
(actData[call.Name][
`${call.Call_Date_vod__c.getMonth()} ${call.Call_Date_vod__c.getFullYear()}`
] || 0) + call.Call;
}
return actData;
},
{
Staff: {},
Account: {}
}
);

prototype function in javascript returns NaN

I have this code right here that returns NaN for some reason, but when I console.log parts of the return it returns an actual number. I tried Math.floor,parseInt`, I don't know what to do...
nouveauVoyage.prototype.prixGlobalParPersonne = function(){
var frais=0;
if (this.voiturePlaces == 0 && this.hotelPlaces == 0){
frais=0;
}else if(this.voiturePlaces != 0 && this.hotelPlaces != 0){
frais=40;
}else if((this.voiturePlaces != 0 && this.hotelPlaces == 0) || (this.voiturePlaces == 0 && this.hotelPlaces != 0)){
frais=20;
}
return ((this.nbrAdultes * this.prixParPersonne) + ((this.prixParPersonne * this.nbEnfants) * 0,8) + frais) / (this.nbAdultes + this.nbEnfants);
};
for more details here's my constructor
function nouveauVoyage(type,destination,nbrAdultes,nbrEnfants,prixParPersonne,prixParGroupe,placesVoitures,placesHotel){
this.id = (new Date().valueOf() + " ").substring(6, 13);
this.type = type;
this.destination = destination;
this.nbrAdultes = parseInt(nbrAdultes);
this.nbrEnfants = parseInt(nbrEnfants);
this.prixParPersonne = parseInt(prixParPersonne);
this.prixParGroupe = parseInt(prixParGroupe);
this.voiturePlaces = parseInt(placesVoitures);
this.hotelPlaces = parseInt(placesHotel);
}
and what I pass to it
var type = $("select").first().val();
var destination = $("input:radio:checked").val();
var nbAdultes = $("input[type=number]").eq(1).val();
var nbEnfants = $("input[type=number]").eq(2).val();
var prixParPersonne = $("input[type=text]").first().val();
var prixParGroupe = $("input[type=text]").last().val()
prixParPersonne = prixParPersonne.substring(0, prixParPersonne.length-1);
prixParGroupe = prixParGroupe.substring(0, prixParGroupe.length-1);
var placesVoiture = $("input[type=number").eq(-2).val();
var placesHotel = $("input[type=number]").last().val();
var voyage = new nouveauVoyage(type,destination,nbAdultes,nbEnfants,prixParPersonne,prixParGroupe,placesVoiture,placesHotel);

Electron process in multithread doesn't close after error

Situation:
I want to create a multithread script where I load a list of IPs + account information with a CSV.
I load the data and call a function where I open electron and run my nightmare script in combination with Vo. Inside the script I go to a site, loop through a list of links and check if someone lives in Australia.
When I have an error, for example Timeout, the browser stops working.
Error Example ->
{ message: 'navigation error',
code: -7,
details: 'Navigation timed out after 30000 ms',
url: 'https://facebook.com/login' }
Here is my Code
var fs = require('fs');
var csv = require('fast-csv');
var vo = require('vo');
var Nightmare = require('nightmare');
var count = 0;
var urls = fs.readFileSync('uniqueIds.csv').toString().split("\n");
var arrayUrls = Object.keys(urls).map(function (key) {return urls[key]});
var bloqNumber = 0;
function *run(proxy, user, pass, urlsID) {
var nightmare = new Nightmare({
webPreferences: { partition: 'your-custom-partition'},
switches:{
'proxy-server': proxy,
'ignore-certificate-errors': true
}, show: true });
yield nightmare
.goto('https://facebook.com/login')
.wait(".inputtext._55r1.inputtext._1kbt.inputtext._1kbt")
.type('input[name="email"]', user)
.type('input[name="pass"]', pass)
.click('button[name=login]')
.wait(29000);
var range = urlsID * 2000;
var rangeStart = range - 2000;
var urlsarray = arrayUrls.slice(rangeStart, range);
for (var i = 0; i < urlsarray.length; i++) {
count++;
console.log(count + " -> " + proxy);
if (count > 150){
yield nightmare.end();
}
yield nightmare
.goto("https://www.facebook.com/profile.php?id=" + urlsarray[i] + "&sk=about&section=living&pnref=about")
.wait(1000);
var seqCheck = yield nightmare.exists(".captcha_interstitial");
var bloqCheck = yield nightmare.exists(".mvl.ptm.uiInterstitial.uiInterstitialLarge.uiBoxWhite");
if (seqCheck == true) {
console.log("Seqcheck");
yield nightmare.wait(29000);
}
if (bloqCheck == true) {
console.log("Blocked for a week" + user + proxy);
bloqNumber++;
console.log(bloqNumber);
if (bloqNumber > 6) {
yield nightmare.end();
}
continue;
}
var location = yield nightmare.exists("._3pw9._2pi4._2ge8");
bloqNumber = 0;
console.log(location);
if (location == true) {
var getLocation = yield nightmare.evaluate(function() {
var jsonObject = new Array();
var links = document.getElementsByClassName('_3pw9 _2pi4 _2ge8');
var numProfiles = links.length;
for(var i = 0; i< numProfiles; i++){
var elem;
try {
elem = links[0].querySelector("._50f5._50f7 a").text;
} catch (err) {
var arrr = new Array('Hello', 'world');
return arrr;
}
jsonObject.push(elem);
}
return jsonObject;
});
var locationString = getLocation.join(" + ");
console.log(locationString + " -> " + urlsarray[i]);
if (locationString.indexOf("Australia") !== -1 ||
locationString.indexOf("Queensland") !== -1 ||
locationString.indexOf("New South Wales") !== -1 ||
locationString.indexOf("Victoria") !== -1 ||
locationString.indexOf("Northern Territory") !== -1 ||
locationString.indexOf("South Australia") !== -1||
locationString.indexOf("Tasmania") !== -1 ||
locationString.indexOf("Sydney") !== -1 ||
locationString.indexOf("Adelaide") !== -1 ||
locationString.indexOf("Cairns") !== -1 ||
locationString.indexOf("Perth") !== -1 ||
locationString.indexOf("Melbourne") !== -1 ||
locationString.indexOf("Brisbane") !== -1 ||
locationString.indexOf("Bundaberg") !== -1 ||
locationString.indexOf("Canberra") !== -1 ||
locationString.indexOf("Newcastle") !== -1 ||
locationString.indexOf("Western Australia") !== -1 ) {
console.log("Im in australia");
var stringToPrint = urlsarray[i] + ", " + locationString + "\n";
fs.appendFile('pages.csv', stringToPrint.replace(/(\r\n|\n|\r)/gm,"") + "\n", function (err) {
console.log("a new entry");
});
}
} else {
console.log("It was false");
}
}
yield nightmare.end();
}
fs.createReadStream('proxies.csv')
.pipe(csv())
.on('data', function (data) {
var proxy = data[0];
var user = data[1];
var pass = data[2];
var urlsID = data[3];
console.log(urlsID);
console.log(user);
console.log(pass);
vo(run(proxy, user, pass, urlsID)).then(out => console.log('out', out)).catch(error => console.log(error));
}).on('end', function (data) {
console.log('CSV reading finished.')
});
Desired Outcome:
I want every time i get some kind of error that my thread is closing.
Solved. Just append .catch like in the example below.
yield nightmare
.goto('https://facebook.com/login')
.wait(".inputtext._55r1.inputtext._1kbt.inputtext._1kbt")
.type('input[name="email"]', user)
.type('input[name="pass"]', pass)
.click('button[name=login]')
.wait(29000).catch(function(err){
console.dir(err);
nightmare.end();
});

Duplicating incident entity - MS CRM 2011 Incident entity

I'm trying to duplicate incident entity when click on a custom ribbon button. Everything is ok but i'm having problem with some fields. I'll share the code below.
When i remove the fields that made problem everything works fine, my web resource opens a new entity and populates fields. If i dont remove that fields im getting error. The odd situation is if i create another web resource with fields that i removed from my first Wresource it works fine too. Am i missing something or is there a field restriction ?
The code is working fine:
Comment outted section is making problem.
function test() {
if (Xrm.Page.data.entity.attributes.get("customerid").getValue() != null) {
var CustomerId = Xrm.Page.data.entity.attributes.get("customerid").getValue()[0].id;
var CustomerName = Xrm.Page.data.entity.attributes.get("customerid").getValue()[0].name;
var CustomerType = Xrm.Page.data.entity.attributes.get("customerid").getValue()[0].entityType;
}
if (Xrm.Page.data.entity.attributes.get("new_malzeme").getValue() != null) {
var MatNumbId = Xrm.Page.data.entity.attributes.get("new_malzeme").getValue()[0].id;
var MatNumbName = Xrm.Page.data.entity.attributes.get("new_malzeme").getValue()[0].name;
}
if (Xrm.Page.data.entity.attributes.get("new_satisburosu").getValue() != null) {
var SatBurId = Xrm.Page.data.entity.attributes.get("new_satisburosu").getValue()[0].id;
var SatBurName = Xrm.Page.data.entity.attributes.get("new_satisburosu").getValue()[0].name;
}
var Talep = Xrm.Page.data.entity.attributes.get("new_talep").getValue();
var ilgiliKisi = Xrm.Page.data.entity.attributes.get("new_ilgilikisi").getValue();
var UrunAdi = Xrm.Page.data.entity.attributes.get("new_urunadi").getValue();
var Zamanlama = Xrm.Page.data.entity.attributes.get("new_zamanlama").getValue();
var Email = Xrm.Page.data.entity.attributes.get("new_mail").getValue();
if (Xrm.Page.data.entity.attributes.get("new_siparis").getValue() != null) {
var SiparisId = Xrm.Page.data.entity.attributes.get("new_siparis").getValue()[0].id;
var SiparisName = Xrm.Page.data.entity.attributes.get("new_siparis").getValue()[0].name;
}
var Adet = Xrm.Page.data.entity.attributes.get("new_adet").getValue();
var Durumu = Xrm.Page.data.entity.attributes.get("incidentstagecode").getValue();
var telefon = Xrm.Page.data.entity.attributes.get("new_telefon").getValue();
var SrvOzt = Xrm.Page.data.entity.attributes.get("title").getValue();
if (Xrm.Page.data.entity.attributes.get("new_mhyetkilisi").getValue() != null) {
var MHyetkilisiId = Xrm.Page.data.entity.attributes.get("new_mhyetkilisi").getValue()[0].id;
var MHyetkilisiName = Xrm.Page.data.entity.attributes.get("new_mhyetkilisi").getValue()[0].name;
}
var islemBelgNo = Xrm.Page.data.entity.attributes.get("new_islembelgeno").getValue();
var Garanti = Xrm.Page.data.entity.attributes.get("new_garanti").getValue();
var SerTalTuru = Xrm.Page.data.entity.attributes.get("casetypecode").getValue();
var Sevkiyat = Xrm.Page.data.entity.attributes.get("new_sevkiyatsekli").getValue();
var SerAdrs = Xrm.Page.data.entity.attributes.get("new_servisadresi").getValue();
var Oncelik = Xrm.Page.data.entity.attributes.get("prioritycode").getValue();
var SemtIlce = Xrm.Page.data.entity.attributes.get("new_semt_ilce").getValue();
if (Xrm.Page.data.entity.attributes.get("new_sehir").getValue() != null) {
var SehirId = Xrm.Page.data.entity.attributes.get("new_sehir").getValue()[0].id;
var SehirName = Xrm.Page.data.entity.attributes.get("new_sehir").getValue()[0].name;
}
var TespitSnc = Xrm.Page.data.entity.attributes.get("new_tespitsonucu").getValue();
var HataKay = Xrm.Page.data.entity.attributes.get("new_mhhatakaynagi").getValue();
var HataAdi = Xrm.Page.data.entity.attributes.get("new_hatasebebi").getValue();
var HataliBrm = Xrm.Page.data.entity.attributes.get("new_hatalibirim").getValue();
var YplnHata = Xrm.Page.data.entity.attributes.get("new_hataadi").getValue();
var MHTop = Xrm.Page.data.entity.attributes.get("new_mhtoplanti").getValue();
var KapanisNdn = Xrm.Page.data.entity.attributes.get("new_kapansnedeni").getValue();
if (Xrm.Page.data.entity.attributes.get("new_satissor").getValue() != null) {
var SatSorId = Xrm.Page.data.entity.attributes.get("new_satissor").getValue()[0].id;
var SatSorName = Xrm.Page.data.entity.attributes.get("new_satissor").getValue()[0].name;
}
var Uygunsuzluk = Xrm.Page.data.entity.attributes.get("new_uygunsuzlukmaliyeti").getValue();
if (Xrm.Page.data.entity.attributes.get("new_departman").getValue() != null) {
var DepartmanId = Xrm.Page.data.entity.attributes.get("new_departman").getValue()[0].id;
var DepartmanName = Xrm.Page.data.entity.attributes.get("new_departman").getValue()[0].name;
}
var SerTalKay = Xrm.Page.data.entity.attributes.get("caseorigincode").getValue();
var SatFyt = Xrm.Page.data.entity.attributes.get("new_satisfiyati2").getValue();
if (Xrm.Page.data.entity.attributes.get("new_anketiyapan").getValue() != null) {
var AnketiYapanId = Xrm.Page.data.entity.attributes.get("new_anketiyapan").getValue()[0].id;
var AnketiYapanName = Xrm.Page.data.entity.attributes.get("new_anketiyapan").getValue()[0].name;
}
var AnketSonucu = Xrm.Page.data.entity.attributes.get("customersatisfactioncode").getValue();
var MusteriGors = Xrm.Page.data.entity.attributes.get("new_musterigorusleri").getValue();
var tekraronl = Xrm.Page.data.entity.attributes.get("new_tekraronleme").getValue();
var Aciklama = Xrm.Page.data.entity.attributes.get("description").getValue();
var parameters = {};
if (CustomerId != null && CustomerName != null) {
parameters["customerid"] = CustomerId;
parameters["customeridname"] = CustomerName;
parameters["customeridtype"] = CustomerType;
}
if (MatNumbId != null && MatNumbName != null) {
parameters["new_malzeme"] = MatNumbId;
parameters["new_malzemename"] = MatNumbName;
}
if (SatBurId != null && SatBurName != null) {
parameters["new_satisburosu"] = SatBurId;
parameters["new_satisburosuname"] = SatBurName;
}
if (Talep != null) {
parameters["new_talep"] = Talep;
}
if (ilgiliKisi != null) {
parameters["new_ilgilikisi"] = ilgiliKisi;
}
if (UrunAdi != null) {
parameters["new_urunadi"] = UrunAdi;
}
if (Zamanlama != null) {
parameters["new_zamanlama"] = Zamanlama;
}
if (Email != null) {
parameters["new_mail"] = Email;
}
if (SiparisId != null && SiparisName != null) {
parameters["new_siparis"] = SiparisId;
parameters["new_siparisname"] = SiparisName;
}
if (Adet != null) {
parameters["new_adet"] = Adet;
}
if (Durumu != null) {
parameters["incidentstagecode"] = Durumu;
}
if (telefon != null) {
parameters["new_telefon"] = telefon;
}
if (SrvOzt != null) {
parameters["title"] = SrvOzt;
}
if (MHyetkilisiId != null && MHyetkilisiName != null) {
parameters["new_mhyetkilisi"] = MHyetkilisiId;
parameters["new_mhyetkilisiname"] = MHyetkilisiName;
}
if (islemBelgNo != null) {
parameters["new_islembelgeno"] = islemBelgNo;
}
if (Garanti != null) {
parameters["new_garanti"] = Garanti;
}
if (SerTalTuru != null) {
parameters["casetypecode"] = SerTalTuru;
}
if (Sevkiyat != null) {
parameters["new_sevkiyatsekli"] = Sevkiyat;
}
if (SerAdrs != null) {
parameters["new_servisadresi"] = SerAdrs;
}
if (Oncelik != null) {
parameters["prioritycode"] = Oncelik;
}
if (SemtIlce != null) {
parameters["new_semt_ilce"] = SemtIlce;
}
if (TespitSnc != null) {
parameters["new_tespitsonucu"] = TespitSnc;
}
if (HataKay != null) {
parameters["new_mhhatakaynagi"] = HataKay;
}
if (HataAdi != null) {
parameters["new_hatasebebi"] = HataAdi;
}
if (HataliBrm != null) {
parameters["new_hatalibirim"] = HataliBrm;
}
if (YplnHata != null) {
parameters["new_hataadi"] = YplnHata;
}
if (MHTop != null) {
parameters["new_mhtoplanti"] = MHTop;
}
if (KapanisNdn != null) {
parameters["new_kapansnedeni"] = KapanisNdn;
}
/*if (SatSorId != null && SatSorName != null) {
parameters["new_satissor"] = SatSorId;
parameters["new_satissorname"] = SatSorName;
}*/
if (Uygunsuzluk != null) {
parameters["new_uygunsuzlukmaliyeti"] = Uygunsuzluk;
}
if (DepartmanId != null && DepartmanName != null) {
parameters["new_departman"] = DepartmanId;
parameters["new_departmanname"] = DepartmanName;
}
Xrm.Utility.openEntityForm("incident", null, parameters);
}

how to remove a row in kendo grid

can someone help me with this issue in my project..
i have workers that has different logins and have the same role. i have a customer page that worker can apply for a company's position(grid) with different shift(another grid inside the company's position). when a worker apply on that shift,the row will disappear in the grid.
my problem is.. i want to show the row again when another worker logs in.
how can i do this.. i did it only in one worker only.
here's what i have...
controller:
//to load the data of the grid
public JsonResult LoadCustomerPositionShiftWorkerList(int? clientCusPosId, int? clientId)
{
List<userWorkerCompare> workerDetails = new List<userWorkerCompare>();
GlobalVariables.SiteMapFile = "ClientSiteMapProvider";
MembershipUser membershipUser = Membership.GetUser();
string userId = membershipUser.ProviderUserKey.ToString();
var workerIdList = new List<Int32>();
var customerPositionShiftList = new List<Client_Customer_Position_Shift>();
List<ClientCustomerPositionShiftInfo> clientCustomerPositionShiftList = new List<ClientCustomerPositionShiftInfo>();
var filterList = (from a in db.Worker_Customer_Apply_Shift
where a.LogicalDelete == false && a.Client_Customer_PositionID == clientCusPosId
select a).ToList();
//this is to get workerId
if (Roles.IsUserInRole("Worker"))
{
var listWorker = (from a in db.Workers
where a.LogicalDelete == false
select new
{
a.ID,
a.userId,
a.FirstName,
a.LastName,
a.MiddleName,
a.BirthDate,
a.Gender_LookID,
a.LogicalDelete
}).ToList();
if (listWorker.Count() > 0)
{
foreach (var row in listWorker)
{
var cli = new userWorkerCompare
{
ID = row.ID,
FirstName = row.FirstName,
MiddleName = row.MiddleName,
LastName = row.LastName,
LogicalDelete = row.LogicalDelete,
userId = row.userId.ToString()
};
workerDetails.Add(cli);
}
var workerProfile = (from a in workerDetails
join b in db.Workers
on a.ID equals b.ID
where a.LogicalDelete == false && a.userId == userId
select b).SingleOrDefault();
ViewBag.WorkerProfile = workerProfile;
var workerAvail = (from a in db.Worker_Availability
where a.LogicalDelete == false
&& a.Worker_ID == workerProfile.ID
select a).ToList();
ViewBag.WorkerAvail = workerAvail;
var workerId = (from a in workerDetails
where a.LogicalDelete == false && a.userId == userId
select a.ID).SingleOrDefault();
ViewBag.WorkerId = workerId;
//this is to compare customer position shift from worker availability
if (clientCusPosId.HasValue)
{
customerPositionShiftList = (from a in db.Client_Customer_Position_Shift
where a.LogicalDelete == false && a.Client_Customer_PositionID == clientCusPosId
select a).ToList();
foreach (var row in customerPositionShiftList)
{
var workerList = (from a in db.Worker_Availability
where a.LogicalDelete == false && a.Worker_ID == workerProfile.ID
select a).ToList();
foreach (var Availability in workerList)
{
if (Availability.AvailableDay_LookID == row.Day_LookID || Availability.AvailableDay_LookID == 76 || row.Day_LookID == 76)
{
if (((Availability.StartTime == "Anytime" && Availability.EndTime == "Anytime") || (row.StartTime == "Anytime" && row.EndTime == "Anytime")) ||
(row.StartTime == "Anytime" || row.EndTime == "Anytime") || (Availability.StartTime == "Anytime" || Availability.EndTime == "Anytime"))
{
workerIdList.Add(row.ID);
}
else
{
DateTime availStartTime = Convert.ToDateTime(Availability.StartTime);
DateTime posStartTime = Convert.ToDateTime(row.StartTime);
DateTime availEndTime = Convert.ToDateTime(Availability.EndTime);
DateTime posEndTime = Convert.ToDateTime(row.EndTime);
if ((Availability.StartTime == row.StartTime &&
Availability.EndTime == row.EndTime) || (Availability.StartTime == row.StartTime ||
Availability.EndTime == row.EndTime) || (availStartTime < posStartTime && availEndTime > posEndTime))
{
workerIdList.Add(row.ID);
}
}
}
}
}
}
//to show compared list
var toBeList = (from a in customerPositionShiftList
where a.LogicalDelete == false
select a).ToList();
//after applying this one triggers to hide the row
var setToList =
toBeList.Select(x => x.ID).Except(filterList.Select(y => y.clientCusPosShiftId)).ToList();
var cusWorkList = (from a in db.Client_Customer_Position_Shift
where a.LogicalDelete == false
&& workerIdList.Contains(a.ID)
&& setToList.Contains(a.ID)
select new
{
a.ID,
a.Client_CustomerID,
a.Client_Customer_PositionID,
a.Day_LookID,
a.EndTime,
a.StartTime,
a.LogicalDelete
}).ToList();
if (cusWorkList.Count() > 0)
{
foreach (var row in cusWorkList)
{
ClientCustomerPositionShiftInfo ccpsi = new ClientCustomerPositionShiftInfo
{
ID = row.ID,
ClientID = clientId.HasValue ? clientId.Value : 0,
Client_Customer_PositionID = row.Client_Customer_PositionID,
Client_CustomerID = row.Client_CustomerID,
Day = GetLookupDisplayValById(row.Day_LookID),
StartTime = row.StartTime != "Anytime" ? Convert.ToDateTime(row.StartTime).ToString("hh:mm tt") : row.StartTime.Trim(),
EndTime = row.EndTime != "Anytime" ? Convert.ToDateTime(row.EndTime).ToString("hh:mm tt") : row.EndTime.Trim(),
DayID = (row.Day_LookID)
};
clientCustomerPositionShiftList.Add(ccpsi);
}
}
}
}
return Json(clientCustomerPositionShiftList.ToList().OrderBy(p => p.DayID), JsonRequestBehavior.AllowGet);
}
view/script:
<script type="text/javascript">
$(document).ready(function () {
var comparegrid = $("#positionShiftWorkerComparedGrid").kendoGrid({
scrollable: false,
sortable: true,
pageable: true,
dataSource: {
transport: {
read: {
url: '/Customer/LoadCustomerPositionShiftWorkerList?clientCusId=' + clientCusId + '&clientId=' + clientId + '&clientCusPosId=' + clientCusPosId,
dataType: "json",
type: "POST"
}
},
pageSize: 10
},
rowTemplate: kendo.template($("#positionShiftWorkerComparedTemplate").html().replace('k-alt', '')),
altRowTemplate: kendo.template($("#positionShiftWorkerComparedTemplate").html())
});
});
</script>
thanks!

Categories