Im trying to set Language for System.Windows.Control.RichTextBox as "es-PE", but I found some issues, for example in some computers, works perfectly and SpellChecker is enabled with "es-PE" language, but in others it just works with "en-US", so I Dont know whats the matter with that control, I was using the following code in XAML and C# :
this is code when users select row from GridView and then shows the screenshot attached
private void dlstInformes_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (!dlstInformes.SelectedItem.ToString().Equals(""))
{
var source_ = dlstInformes.SelectedItems;
InformeMedico demo = new InformeMedico(); //New Window
foreach (informeMedico item in source_)
{
numeroinforme = item.numeroinforme.ToString();
nombreinforme = item.nombreinforme;
fechainforme = item.fechainforme.ToString();
nombreMedico = item.medicoCompleto.ToString();
turnoMedico = item.turno.ToString();
nombrePaciente = item.pacienteCompleto.ToString();
nombreExamen = item.nombreinforme.ToString();
}
demo.Language = XmlLanguage.GetLanguage("es-PE");
demo.txtNombreExamen.Text = nombreinforme;
demo.lblNroInforme.Content = numeroinforme;
demo.lblMedicoNombre.Content = nombreMedico;
demo.lblNombrePac.Content = nombrePaciente;
demo.lblTurnoMedico.Content = turnoMedico;
using (DB db = new DB())
{
var lstTM = (from ea in db.EXAMENXATENCIONs where ea.turnomedico.Trim() != " " select ea.turnomedico).Distinct().ToList();
string tm = (from ea in db.EXAMENXATENCIONs where ea.codigo == Convert.ToInt32(numeroinforme) select ea.turnomedico).FirstOrDefault();
demo.cboTurnoMed.ItemsSource = lstTM;
demo.cboTurnoMed.SelectedItem = tm;
demo.cboTurnoMed.SelectedValue = tm;
demo.cboTurnoMed.Text = tm;
if (tm.Equals("RE/ES") || tm.Equals("RE/HS") || tm.Equals("RE/HT") || tm.Equals("RE/KV") || tm.Equals("HH/CS") || tm.Equals("HH/ES") || tm.Equals("HH/HS") || tm.Equals("HH/HT") || tm.Equals("HH/KV"))
{
demo.FirmaUnoDefault.Content = "DEN51";
demo.FirmaDosDefault.Content = tm;
}
else if (tm.Equals("HH/AO") || tm.Equals("IU/AO") || tm.Equals("RE/AO") || tm.Equals("HH/JA") || tm.Equals("RR/JA") || tm.Equals("IU/JA"))
{
demo.FirmaUnoDefault.Content = "DEN51";
demo.FirmaDosDefault.Content = "AOY20";
}
else if (tm.Equals("IU/CS") || tm.Equals("IU/ES") || tm.Equals("IU/HT") || tm.Equals("IU/KV"))
{
demo.FirmaUnoDefault.Content = "IUU17";
demo.FirmaDosDefault.Content = tm;
}
else if (tm.Equals("RD/DE"))
{
demo.FirmaUnoDefault.Content = "REE";
demo.FirmaDosDefault.Content = "DEN51";
}
else if (tm.Equals("RE/JC"))
{
demo.FirmaUnoDefault.Content = "REE";
demo.FirmaDosDefault.Content = "JCCH25";
}
else if (tm.Equals("RE/CS"))
{
demo.FirmaUnoDefault.Content = "DEN51";
demo.FirmaDosDefault.Content = "REE";
}
}
demo.lblCodigoClase.Visibility = Visibility.Hidden;
demo.lblCodigoEstudio.Visibility = Visibility.Hidden;
demo.lblCodigoPaciente.Visibility = Visibility.Hidden;
demo.FirmaUnoDefault.Visibility = Visibility.Hidden;
demo.FirmaDosDefault.Visibility = Visibility.Hidden;
demo.rtbHallazgo.Language = XmlLanguage.GetLanguage("es-PE");
demo.rtbConclusion.Language = XmlLanguage.GetLanguage("es-PE");
demo.rtbTecnica.Language = XmlLanguage.GetLanguage("es-PE");
demo.rtbHallazgo.SpellCheck.IsEnabled = true;
demo.rtbTecnica.SpellCheck.IsEnabled = true;
demo.rtbConclusion.SpellCheck.IsEnabled = true;
demo.rtbConclusion.SpellCheck.SpellingReform = SpellingReform.PreAndPostreform;
demo.ResizeMode = ResizeMode.NoResize;
demo.Closing += new System.ComponentModel.CancelEventHandler(notClosing_CancelEventArgs);
demo.ShowDialog();
}
else
{
MessageBox.Show("Seleccione un item", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);
}
}
I also trying configurate and removing "en-US" language from SO, when it happens spellchecker stop completly and when I Re-Add that language for keyboard, it SpellChecker reappears.
Stills not working with "es-PE" or just Spanish as Parent
Thanks in Advance!
I'm not sure if this will help, but it might be worth a shot.
In the Application.StartUp event add the following code
FrameworkElement.LanguageProperty.OverrideMetadata(
typeof(FrameworkElement),
new FrameworkPropertyMetadata(
XmlLanguage.GetLanguage(
CultureInfo.CurrentCulture.IetfLanguageTag)));
Or you can modify it to specify es-PE instead of the current culture.
This post might provide more in-depth details: Getting a WPF application to pick up the correct regional settings
Related
enter image description hereThe trigger is working completely fine, but Its not giving 100% code coverage. The main issue with Test class, its not covering the if condition of Role__c.
Trigger:
trigger DrawingSharing on Drawing__c (after insert) {
if(trigger.isInsert){
for (Drawing__c draw : Trigger.new){
System.debug('draw: '+draw);
List<Installation__c> ListInstalltionList = new List <Installation__c>();
for(String installationActivityList :draw.Installation_Activity__c.split(';')){
Installation__c inst = new Installation__c();
inst.Drawing_ID__c = draw.Id;
inst.Installation_Activity__c=installationActivityList;
inst.Execution__c=draw.Execution_ID__c;
inst.Floor__c=draw.Floors__c;
ListInstalltionList.add(inst);
}
system.debug('ListInstalltionList==>'+ListInstalltionList);
insert ListInstalltionList;
List<Drawing__c> newList = new List<Drawing__c>();
newList.add(draw);
Map <Id,Id> DrawingProjectMap = new Map<Id,Id>();
Map<Id,Drawing__c> drawingIdObjMap = new Map<Id,Drawing__c>([select id, name,Approver__c, Execution_ID__r.Project__c from Drawing__c where id in :newList limit 1]);
for(Drawing__c Drawing : drawingIdObjMap.values())
{
DrawingProjectMap.put(Drawing.Id,Drawing.Execution_ID__r.Project__c);
}
system.debug(DrawingProjectMap);
Map<Id,RoleObjectSharing__mdt> roleobjaccessmap = new Map<Id,RoleObjectSharing__mdt>([select id,Object__c,role__c,Accesslevel__c from RoleObjectSharing__mdt where Object__c='Drawing']);
Map<String,String> RoleAccessmap = new Map<String,String>();
for(RoleObjectSharing__mdt Robj : roleobjaccessmap.values()){
RoleAccessmap.put(Robj.role__c,Robj.Accesslevel__c);
}
system.debug(RoleAccessmap.keySet());
system.debug(DrawingProjectMap.values());
Map<Id,Projects__c> teamrolemap = new Map<Id,Projects__c>([select Id,(select id, User_Lookup__c,Role__c from TeamRoles__r where Role__c in:RoleAccessmap.keySet()) from Projects__c where Id in :DrawingProjectMap.values()]);
system.debug('teamrolemap'+teamrolemap);
List <Drawing__Share> DrawShareList = new List<Drawing__Share>();
List <Drawing__c> DrawList = new List<Drawing__c>();
INTEGER countFound = 0;
for(Drawing__c drawobj : newList){
Projects__c proj = teamrolemap.get(DrawingProjectMap.get(drawobj.id));
system.debug(proj.teamroles__r);
***for(teamroles__c tr : proj.teamroles__r){
system.debug(tr);
if(tr.Role__c == 'PlanningEngineer' || tr.Role__c == 'AssistantPlanningEngineer' || tr.Role__c == 'PlanningManager' || tr.Role__c == 'AssistantPlanningManager' && countFound <=0) {
countFound = countFound + 1;
Drawing__c ddd = drawingIdObjMap.values();
ddd.Approver__c = tr.User_Lookup__c;
DrawList.add(ddd);
}
Drawing__Share recruiterShr = new Drawing__Share();
recruiterShr.ParentId = drawobj.Id;
recruiterShr.UserOrGroupId = tr.User_Lookup__c;
recruiterShr.AccessLevel = RoleAccessmap.get(tr.role__c);
recruiterShr.RowCause = tr.role__c+'__c';
DrawShareList.add(recruiterShr);***
}
system.debug(DrawShareList);
}
upsert DrawList;
Database.SaveResult[] lsr = Database.insert(DrawShareList,false);
Integer i=0;
for(Database.SaveResult sr : lsr){
if(!sr.isSuccess()){
}
i++;
}
}
}
}
Test Class:
static testMethod void Test4(){
System.debug('TestSharing = Test4');
Test.startTest();
Projects__c proj = new Projects__c();
proj.Name = 'Hello';
proj.LL_Location__c='Mumbai';
insert proj;
TeamRoles__c tr1 = new TeamRoles__c();
tr1.User_Lookup__c = UserInfo.getUserId();
tr1.Role__c = 'PlanningEngineer';
tr1.Project_Name__c = proj.Id;
insert tr1;
TeamRoles__c tr2 = new TeamRoles__c();
tr2.User_Lookup__c = UserInfo.getUserId();
tr2.Role__c = 'PlanningManager';
tr2.Project_Name__c = proj.Id;
insert tr2;
Execution__c ex = new Execution__c();
ex.Project__c = proj.Id;
insert ex;
Item_Master__c ItemeMaster = new Item_Master__c();
ItemeMaster.Item_Description__c = 'testing';
ItemeMaster.Item_Code__c = 'testing';
insert ItemeMaster;
Project_Items__c projItems = new Project_Items__c();
projItems.Total_PO_Quantity__c = 0;
projItems.ItemMaster__c = ItemeMaster.Id;
projItems.Execution__c = ex.Id;
insert projItems;
List<TeamRoles__c> lstTR = new List<TeamRoles__c>();
TeamRoles__c tr7 = new TeamRoles__c();
tr7.User_Lookup__c = UserInfo.getUserId();
tr7.Role__c = 'PlanningEngineer';
tr7.Project_Name__c = proj.Id;
lstTR.add(tr7);
List<Drawing__c> d= new List<Drawing__c>();
Drawing__c draw = new Drawing__c();
draw.Execution_Id__c = ex.Id;
draw.Floors__c='5F';
draw.Installation_Activity__c='Cable Tray';
draw.Drawing_Line_Items_Count__c = 0;
d.add(draw);
insert d;
//insert draw;
Installation__c inst = new Installation__c();
inst.Drawing_ID__c=draw.Id;
inst.Floor__c= draw.Floors__c;
inst.Installation_Activity__c='Cable Tray';
inst.As_built_Marked_Drawing_Prepared_by_Site__c =False;
inst.Execution__c = ex.Id;
insert inst;
SharingUtilityClass suc = new SharingUtilityClass();
suc.initObjSharing(lstTR);
Drawing_Line_Items__c dll = new Drawing_Line_Items__c();
dll.Drawing_Number__c = draw.Id;
dll.Project_Items__c = projItems.Id;
dll.Project_Name__c = proj.Id;
dll.Installation_Activity__c='Cable Tray';
dll.GFC_Quantity__c = 15;
dll.Shop_Drawing_Quantity__c = 20;
dll.GFC_Drawing_Line_Item_Done__c = true;
dll.Shop_Drawing_Line_Item_Done__c=true;
insert dll;
Installation_Line_Items__c instline = new Installation_Line_Items__c();
instline.Installation__c = inst.Id;
instline.Project_Items__c = projItems.Id;
instline.Installation_Activity__c='Cable Tray';
instline.Total_installed_quantity_DPR_Quantity__c = 100.00;
insert instline;
List<Drawing_Line_Items__c> listProj2 = CircularProgressController.getDrawingLineItem(dll.Id);
List<Drawing_Line_Items__c> listProj3 = CircularProgressController.getDrawingLineItemShop(dll.Id);
List<Drawing__c> listProj4 = Drawing.getDrawing(draw.Id);
List<Project_Items__c> listProj5 = Drawing.getProjectItems(ex.Id);
Test.stopTest();
}
If there are team roles being debugged from this line
for(teamroles__c tr : proj.teamroles__r){
system.debug(tr);
I would then check to see if this is evaluating to true within the test context:
if(tr.Role__c == 'PlanningEngineer' || tr.Role__c == 'AssistantPlanningEngineer' || tr.Role__c == 'PlanningManager' || tr.Role__c == 'AssistantPlanningManager' && countFound <=0)
This is the case, for example, if a user now creates a page. So the next day I need Azure Logic apps to send an email after 1 day.
The problem is: right now, it is by no means sending any email to me if I sign up yesterday. But it sends me an email that now it has gone through with succe.
I would like to know what goes wrong since it by no means email me as I set up yesterday.
My Logic app (From Azure) - Images
However, be aware that the code can be made short but I just need to find out if Logic apps are making mistakes or if thus my code previously works without problems.
[Route("/api/cronjob")]
[HttpGet]
public async Task<IActionResult> NewSletterUserEmail()
{
await Newsletter();
return Ok("Godkendt!");
}
public async Task<IActionResult> Newsletter()
{
var m = new Settings.ArdklarMail();
var dtt = DateTime.Now;
var days = _dbContext.OfferUser.Max(i => i.Days);
var MaxDays = DateTime.Now.AddDays(-days);
var userlist = _dbContext.Users.Where(i => i.Opretdate >= MaxDays && i.TilmeldtNyhedsbrev == true).ToList();
if (userlist != null)
{
foreach (var item in userlist)
{
string mail = item.Brugernavn;
string fullname = item.Navn;
var memberData = _dbContext.MemberShipValue.FirstOrDefault(r => r.UserId == item.UserId);
if (memberData == null)
{
//alm bruger
var result = _dbContext.OfferUser.Where(x => x.Value == 1).ToList();
if (result != null)
{
foreach (var itemValue in result)
{
int itemValueDays = itemValue.Days;//hvis den ingen antal har så giver den 0.
var daysValue = DateTime.Now.AddDays(-itemValueDays);
if (item.Opretdate.Date == daysValue)
{
var title = itemValue.Title;
var viewModel = new EmailModel
{
getUrl = m.RemoveLinkUrl(),
Title = title,
FullName = fullname,
Text = itemValue.Text.ToHtmlString()
};
var resultMail = await _viewRenderService.RenderToStringAsync("~/Views/Templates/OfferToUsers.cshtml", viewModel);//return Null here
MailMessageControl mailA = new MailMessageControl();
mailA.SetCredentials(m.azureName(), m.password());
mailA.SetSender(m.mailFrom());
mailA.AddAddressSee(item.Brugernavn);
mailA.SetSubject(title);
mailA.SetBody(resultMail);
mailA.SendEmail();
await Task.Delay(2200);
}
}
}
}
else
{
var result = _dbContext.OfferUser.Where(x => x.Value == 2).ToList();
if (result != null)
{
foreach (var itemValue in result)
{
int itemValueDays = itemValue.Days;//hvis den ingen antal har så giver den 0.
var daysValue = DateTime.Now.AddDays(-itemValueDays);
if (item.Opretdate.Date == daysValue)
{
var title = itemValue.Title;
var viewModel = new EmailModel
{
getUrl = m.RemoveLinkUrl(),
Title = title,
FullName = fullname,
Text = itemValue.Text.ToHtmlString()
};
var resultMail = await _viewRenderService.RenderToStringAsync("~/Views/Templates/OfferToUsers.cshtml", viewModel);//return Null here
MailMessageControl mailA = new MailMessageControl();
mailA.SetCredentials(m.azureName(), m.password());
mailA.SetSender(m.mailFrom());
mailA.AddAddressSee(item.Brugernavn);
mailA.SetSubject(title);
mailA.SetBody(resultMail);
mailA.SendEmail();
await Task.Delay(2200);
}
}
}
}
}
}
//Det er til dem fra nyhedsbrevet som få tilsendt nyhedsbrev omkring div ting.
var newsletterlist = _dbContext.NewsletterList.Where(i => i.Tilmeldtdato >= MaxDays).ToList();
if (newsletterlist != null)
{
foreach (var item in newsletterlist)
{
string mail = item.Email;
string fullname = item.Email;
//til de nyhedsbrevet område
var result = _dbContext.OfferUser.Where(x => x.Value == 3).ToList();
if (result != null)
{
foreach (var itemValue in result)
{
int itemValueDays = itemValue.Days;
var daysValue = DateTime.Now.AddDays(-itemValueDays);
if (item.Tilmeldtdato.Date == daysValue)
{
var title = itemValue.Title;
var viewModel = new EmailModel
{
getUrl = m.RemoveLinkUrl(),
Title = title,
FullName = fullname,
Text = itemValue.Text.ToHtmlString()
};
var resultMail = await _viewRenderService.RenderToStringAsync("~/Views/Templates/OfferToUsers.cshtml", viewModel);
MailMessageControl mailA = new MailMessageControl();
mailA.SetCredentials(m.azureName(), m.password());
mailA.SetSender(m.mailFrom());
mailA.AddAddressSee(mail);
mailA.SetSubject(title);
mailA.SetBody(resultMail);
mailA.SendEmail();
await Task.Delay(3500);
}
}
}
}
}
return Ok("Godkendt!");
}
No, I don't see mistake in Azure Logic Apps. Since the Logic App uses a recurrence trigger, it triggers the Logic App at the defined interval of time.
As there was send email action both side on the parallel branch, it will somehow send you an email by no means.
I have migrated my application to Dev Express 15.2.After migration data is not exporting in GridView style.Like alternate row color,Font ..etc.Do we have any option to export the data same as like in grid.
Designer:
this.gridView1.Appearance.EvenRow.BackColor = System.Drawing.Color.Khaki;
this.gridView1.Appearance.EvenRow.Options.UseBackColor = true;
this.gridView1.Appearance.GroupPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(74)))), ((int)(((byte)(74)))));
this.gridView1.Appearance.GroupPanel.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold);
this.gridView1.Appearance.GroupPanel.Options.UseBackColor = true;
this.gridView1.Appearance.GroupPanel.Options.UseFont = true;
this.gridView1.Appearance.HeaderPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
this.gridView1.Appearance.HeaderPanel.Options.UseBackColor = true;
this.gridView1.AppearancePrint.EvenRow.BackColor = System.Drawing.Color.Khaki;
this.gridView1.AppearancePrint.EvenRow.Options.UseBackColor = true;
this.gridView1.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
this.gridColumn1,
this.gridColumn2,
this.gridColumn3,
this.gridColumn4,
this.gridColumn5});
this.gridView1.GridControl = this.gridControl1;
this.gridView1.GroupSummary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] {
new DevExpress.XtraGrid.GridGroupSummaryItem(DevExpress.Data.SummaryItemType.Count, "OrderID", null, "")});
this.gridView1.Name = "gridView1";
this.gridView1.OptionsView.EnableAppearanceEvenRow = true;
Code in cs file
if(ext == "xlsx")
{
XlsxExportOptionsEx options = new XlsxExportOptionsEx();
options.ShowGridLines = false;
options.AllowSortingAndFiltering = DevExpress.Utils.DefaultBoolean.False;
options.ExportType = DevExpress.Export.ExportType.WYSIWYG;
exportView.ExportToXlsx(filename, options);
}
By setting following properties issue is solved.
((DevExpress.XtraGrid.Views.Grid.GridView)gridControl1.MainView).OptionsPrint.EnableAppearanceEvenRow = true;
((DevExpress.XtraGrid.Views.Grid.GridView)gridControl1.MainView).OptionsPrint.UsePrintStyles = false;
I am creating a WPF application to create digital catalog using kinect v1.8. I am trying to track only a single skeleton using following code:-
private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs skeletonFrameReadyEventArgs)
{
// Even though we un-register all our event handlers when the sensor
// changes, there may still be an event for the old sensor in the queue
// due to the way the KinectSensor delivers events. So check again here.
if (this.KinectSensor != sender)
{
return;
}
SkeletonFrame skeletonFrame = skeletonFrameReadyEventArgs.OpenSkeletonFrame();
if (skeletonFrame == null)
return;
Skeleton[] skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
skeletonFrame.CopySkeletonDataTo(skeletons);
Skeleton skeleton = (from skl in skeletons
where skl.TrackingState == SkeletonTrackingState.Tracked
select skl).FirstOrDefault();
if (skeleton == null)
return;
Skeleton[] s = new Skeleton[1];
s[0] = skeleton;
if (SkeletonTrackingState.Tracked == s[0].TrackingState)
{
//s1.SkeletonStream.ChooseSkeletons(s[0].TrackingId);
var accelerometerReading = this.KinectSensor.AccelerometerGetCurrentReading();
this.interactionStream.ProcessSkeleton(s, accelerometerReading, skeletonFrame.Timestamp);
}
}
I am getting an exception when I run the code and skeleton gets detected as follows:-
on the line "this.interactionStream.ProcessSkeleton(s, accelerometerReading, skeletonFrame.Timestamp);"
I need to detect only one skeleton and use it for further processing like to access the digital catalog applications.
Thanks in advance.
I have Faced Same Problem By using below code I have track only one skeleton Which is closer to the sensor.and directly assign the closest skeleton to the main skeleton stream.
private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs skeletonFrameReadyEventArgs)
{
Skeleton[] skeletons = new Skeleton[0];
using (SkeletonFrame skeletonFrame = skeletonFrameReadyEventArgs.OpenSkeletonFrame())
{
if (skeletonFrame != null && this.skeletons != null)
{
//Console.WriteLine(skeletonFrame.SkeletonArrayLength);
skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
// Set skeleton datas from skeletonFrame
skeletonFrame.CopySkeletonDataTo(this.skeletons);
TrackClosestSkeleton();
Skeleton[] singleSkeleton = new Skeleton[6];
Skeleton skl=(from mno in this.skeletons where mno.TrackingState==SkeletonTrackingState.Tracked && mno.TrackingId==globalClosestID select mno).FirstOrDefault();
if (skl == null)
return;
//Creating an empty skkeleton
Skeleton emptySkeleton = new Skeleton();
singleSkeleton[0] = skl; //Pass the Tracked skeleton with closestID
singleSkeleton[1] = emptySkeleton; //Passing Empty Skeleton
singleSkeleton[2] = emptySkeleton; //Passing Empty Skeleton
singleSkeleton[3] = emptySkeleton; //Passing Empty Skeleton
singleSkeleton[4] = emptySkeleton; //Passing Empty Skeleton
singleSkeleton[5] = emptySkeleton; //Passing Empty Skeleton
this.snew.SkeletonStream.ChooseSkeletons(globalClosestID);
var accelerometerReading = this.KinectSensor.AccelerometerGetCurrentReading();
this.interactionStream.ProcessSkeleton(singleSkeleton, accelerometerReading, skeletonFrame.Timestamp);
}
}
}
int globalClosestID = 0;
private void TrackClosestSkeleton()
{
if (this.snew != null && this.snew.SkeletonStream != null)
{
if (!this.snew.SkeletonStream.AppChoosesSkeletons)
{
this.snew.SkeletonStream.AppChoosesSkeletons = true; // Ensure AppChoosesSkeletons is set
}
float closestDistance = 10000f; // Start with a far enough distance
int closestID = 0;
foreach (Skeleton skeleton in this.skeletons.Where(s => s.TrackingState != SkeletonTrackingState.NotTracked))
{
if (skeleton.Position.Z < closestDistance)
{
closestID = skeleton.TrackingId;
closestDistance = skeleton.Position.Z;
}
}
if (closestID > 0)
{
this.snew.SkeletonStream.ChooseSkeletons(closestID); // Track this skeleton
globalClosestID = closestID;
}
}
}
check the above code it works for me.It may helpful to you.Here snew is the Kinectsensor.
You should try to track the closest skeleton using this method from MSDN
private void TrackClosestSkeleton()
{
if (this.kinect != null && this.kinect.SkeletonStream != null)
{
if (!this.kinect.SkeletonStream.AppChoosesSkeletons)
{
this.kinect.SkeletonStream.AppChoosesSkeletons = true; // Ensure AppChoosesSkeletons is set
}
float closestDistance = 10000f; // Start with a far enough distance
int closestID = 0;
foreach (Skeleton skeleton in this.skeletonData.Where(s => s.TrackingState != SkeletonTrackingState.NotTracked))
{
if (skeleton.Position.Z < closestDistance)
{
closestID = skeleton.TrackingId;
closestDistance = skeleton.Position.Z;
}
}
if (closestID > 0)
{
this.kinect.SkeletonStream.ChooseSkeletons(closestID); // Track this skeleton
}
}
}
And then in your SkeletonFrameReady
private void SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
Skeleton[] skeletons = new Skeleton[0];
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame != null && this.skeletonData != null)
{
skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
// Set skeleton datas from skeletonFrame
skeletonFrame.CopySkeletonDataTo(this.skeletonData);
TrackClosestSkeleton();
}
}
//Do some stuff here
}
I need some performance for doing some of my things. I'm trying to import excel data to my SQL Server database here is my code for doing that work but it really takes too much time for that. Could you give me some advice for that
[WebMethod]
public static string VerileriAktar(string alanlar, string gruplar, string shit)
{
ArtiDBEntities entity = new ArtiDBEntities();
string[] eslesmeler = alanlar.Split(',');
string[] grplar = gruplar.Split(',');
DataSet ds = (DataSet)HttpContext.Current.Session["ExcelVerileri"];
DataTable dt = ds.Tables["" + shit + ""];
MembershipUser gelen = (MembershipUser)HttpContext.Current.Session["kimo"];
Guid aa = (Guid)gelen.ProviderUserKey;
List<tbl_AltMusteriler> bulkliste = new List<tbl_AltMusteriler>();
List<tbl_AltMusteriler> ilkkontrol = entity.tbl_AltMusteriler.Where(o => o.UserId == aa).ToList();
List<tbl_AltMusteriler> grupicin = new List<tbl_AltMusteriler>();
List<tbl_OzelAlanlar> ensonatilacakalan = new List<tbl_OzelAlanlar>();
List<tbl_OzelTarihler> ensonalicaktarih = new List<tbl_OzelTarihler>();
// Datatable mın Kolon isimlerini değiştirdim.
foreach (string item_col_name in eslesmeler)
{
string alan = item_col_name.Split('=')[0].Split('_')[1];
string degisecek = item_col_name.Split('=')[1];
if (degisecek == "")
continue;
dt.Columns[degisecek].ColumnName = alan;
}
#region verilerde
foreach (DataRow dr in dt.Rows)
{
tbl_AltMusteriler yeni = new tbl_AltMusteriler();
foreach (DataColumn dtclm in dt.Columns)
{
string gsm1 = "";
if (dtclm.ColumnName == "gsm1")
gsm1 = dr["gsm1"].ToString();
string gsm2 = "";
if (dtclm.ColumnName == "gsm2")
gsm2 = dr["gsm2"].ToString();
string ad = "";
if (dtclm.ColumnName == "ad")
ad = dr["ad"].ToString();
string soyad = "";
if (dtclm.ColumnName == "soyad")
soyad = dr["soyad"].ToString();
if (gsm1 != "")
{
if (Tools.isNumber(gsm1) == false)
continue;
else
{
if (gsm1.Length > 10)
gsm1 = gsm1.Substring(1, 10);
yeni.Gsm1 = gsm1;
}
}
if (gsm2 != "")
{
if (Tools.isNumber(gsm2) == false)
continue;
else
{
if (gsm2.Length > 10)
gsm2 = gsm2.Substring(1, 10);
yeni.Gsm2 = gsm2;
}
}
if (ad != "")
yeni.Ad = ad;
if (soyad != "")
yeni.Soyad = soyad;
}
yeni.UserId = new Guid(aa.ToString());
if (yeni.Gsm1 != "")
grupicin.Add(yeni);
}
#endregion
bulkliste = grupicin.GroupBy(cust => cust.Gsm1).Select(grp => grp.First()).ToList();
List<tbl_AltMusteriler> yokartikin = bulkliste.Where(o => !ilkkontrol.Any(p => o.Gsm1 == p.Gsm1)).ToList();
int saybakim = yokartikin.Count();
DataTable bulkdt = new DataTable();
if (yokartikin.Count > 0)
{
Type listType = yokartikin.ElementAt(0).GetType();
PropertyInfo[] properties = listType.GetProperties();
foreach (PropertyInfo property in properties)
if (property.Name == "UserId")
bulkdt.Columns.Add(new DataColumn() { ColumnName = property.Name, DataType = typeof(Guid) });
else
bulkdt.Columns.Add(new DataColumn() { ColumnName = property.Name });
foreach (object itembulk in yokartikin)
{
DataRow drbk = bulkdt.NewRow();
foreach (DataColumn col in bulkdt.Columns)
drbk[col] = listType.GetProperty(col.ColumnName).GetValue(itembulk, null);
bulkdt.Rows.Add(drbk);
}
}
//var rowsOnlyInDt1 = bulkdt.AsEnumerable().Where(r => !bulkdt44.AsEnumerable()
// .Any(r2 => r["gsm1"].ToString() == r2["gsm1"].ToString()));
//DataTable result = rowsOnlyInDt1.CopyToDataTable();//The third table
if (bulkdt.Rows.Count > 0)
{
using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ArtiDBMemberShip"].ConnectionString))
{
SqlTransaction transaction = null;
connection.Open();
try
{
transaction = connection.BeginTransaction();
using (var sqlBulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.TableLock, transaction))
{
sqlBulkCopy.BulkCopyTimeout = 240;
sqlBulkCopy.DestinationTableName = "tbl_AltMusteriler";
sqlBulkCopy.ColumnMappings.Add("UserId", "UserId");
sqlBulkCopy.ColumnMappings.Add("Ad", "Ad");
sqlBulkCopy.ColumnMappings.Add("Soyad", "Soyad");
sqlBulkCopy.ColumnMappings.Add("Adres", "Adres");
sqlBulkCopy.ColumnMappings.Add("Gsm1", "Gsm1");
sqlBulkCopy.ColumnMappings.Add("Gsm2", "Gsm2");
sqlBulkCopy.ColumnMappings.Add("Faks", "Faks");
sqlBulkCopy.ColumnMappings.Add("Telefonis", "Telefonis");
sqlBulkCopy.ColumnMappings.Add("Telefonev", "Telefonev");
sqlBulkCopy.ColumnMappings.Add("Eposta", "Eposta");
sqlBulkCopy.ColumnMappings.Add("DogumTarihi", "DogumTarihi");
sqlBulkCopy.ColumnMappings.Add("EvlilikTar", "EvlilikTar");
sqlBulkCopy.ColumnMappings.Add("TcNo", "TcNo");
//sqlBulkCopy.ColumnMappings.Add("Deleted", "Deleted");
sqlBulkCopy.WriteToServer(bulkdt);
}
transaction.Commit();
}
catch (Exception)
{
transaction.Rollback();
}
}
entity.SaveChanges();
}
if (grplar.Length > 0)
{
List<tbl_AltMusteriler> guncelliste = entity.tbl_AltMusteriler.Where(o => o.UserId == aa).ToList();
List<tbl_KisiGrup> kisigruplari = new List<tbl_KisiGrup>();
foreach (tbl_AltMusteriler itemblkliste in bulkliste)
{
long AltMusteriIDsi = guncelliste.Where(o => o.Gsm1 == itemblkliste.Gsm1).FirstOrDefault().AltMusteriID;
// Seçili Gruplara kişileri ekleme
#region Gruplara ekleme
if (grplar.Length > 0)
{
foreach (string item_gruplar in grplar)
{
if (item_gruplar == "chkall")
continue;
if (item_gruplar == "")
continue;
if (item_gruplar == null)
continue;
tbl_KisiGrup yeni_kisi_grup = new tbl_KisiGrup()
{
AltMusteriID = AltMusteriIDsi,
GrupID = int.Parse(item_gruplar)
};
kisigruplari.Add(yeni_kisi_grup);
}
}
#endregion
}
List<tbl_KisiGrup> guncel_grup = entity.tbl_KisiGrup.Where(o => o.tbl_AltMusteriler.UserId == aa).ToList();
List<tbl_KisiGrup> kisi_grup_kaydet = kisigruplari.Where(o => !guncel_grup.Any(p => o.AltMusteriID == p.AltMusteriID && o.GrupID == p.GrupID)).ToList();
// Grupları Datatable çevirme
#region Grupları Datatable le çevirme
DataTable bulkdt2 = new DataTable();
if (kisi_grup_kaydet.Count > 0)
{
Type listType = kisi_grup_kaydet.ElementAt(0).GetType();
//Get element properties and add datatable columns
PropertyInfo[] properties = listType.GetProperties();
foreach (PropertyInfo property in properties)
bulkdt2.Columns.Add(new DataColumn() { ColumnName = property.Name });
foreach (object itembulk in kisi_grup_kaydet)
{
DataRow drbk = bulkdt2.NewRow();
foreach (DataColumn col in bulkdt2.Columns)
drbk[col] = listType.GetProperty(col.ColumnName).GetValue(itembulk, null);
bulkdt2.Rows.Add(drbk);
}
}
#endregion
//Burada bulk insert işlemini gerçekleştiriyoruz...
#region Grup Verileri BulkCopy ile birkerede yazdık
using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ArtiDBMemberShip"].ConnectionString))
{
SqlTransaction transaction = null;
connection.Open();
try
{
transaction = connection.BeginTransaction();
using (var sqlBulkCopy = new SqlBulkCopy(connection, SqlBulkCopyOptions.TableLock, transaction))
{
sqlBulkCopy.BulkCopyTimeout = 240;
sqlBulkCopy.DestinationTableName = "tbl_KisiGrup";
sqlBulkCopy.ColumnMappings.Add("AltMusteriID", "AltMusteriID");
sqlBulkCopy.ColumnMappings.Add("GrupID", "GrupID");
sqlBulkCopy.WriteToServer(bulkdt2);
}
transaction.Commit();
}
catch (Exception)
{
transaction.Rollback();
}
}
entity.SaveChanges();
#endregion
}
return "ok";
}
EDIT
actually that codeblock takes time when if there is 70.000 or more rows data
List<tbl_AltMusteriler> yokartikin = bulkliste.Where(o => !ilkkontrol.Any(p => o.Gsm1 == p.Gsm1)).ToList();
I think the my main problem is while I'm just inserting data with sqlbulkcopy. After that I couldn't get the identity ids, for that reason I get data to a generic list and try to find that new ids and creating a new list of group. and sqlbulkcopy again. these are takes lots of time about 10 minutes to import 65.000 rows is there another way to do those things
Your question is very broad. I would recomment reading performance considerations for EF. Also keep in mind that EF is not really meant for bulk operations since it brings all data from the database to the client. This adds a lot of overhead if you want to do this for a lot of entities if you don't need to/want to process them on the client. (Note I have not really looked into your code - it's too much)