public void ImportFormName(ExcelWorksheet sheet, IOrganizationService service) { var rowsCount = sheet.Dimension.Rows; for (var rowI = 1; rowI < rowsCount; rowI++) { var currentFormId = new Guid(ZeroBasedSheet.Cell(sheet, rowI, 1).Value.ToString()); var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("systemform", currentFormId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 2).Value.ToString() == "Name" ? "name" : "description" }; var labels = new List <LocalizedLabel>(); var columnIndex = 3; while (ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value != null) { var currentLcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); labels.Add(new LocalizedLabel(ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value.ToString(), currentLcid)); columnIndex++; } request.Labels = labels.ToArray(); service.Execute(request); } }
public void Import(ExcelWorksheet sheet, IOrganizationService service) { var views = new List <Tuple <int, Entity> >(); foreach (var row in sheet.Rows.Where(r => r.Index != 0).OrderBy(r => r.Index)) { var currentViewId = new Guid(row.Cells[0].Value.ToString()); var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("savedquery", currentViewId), AttributeName = row.Cells[3].Value.ToString() == "Name" ? "name" : "description" }; var labels = new List <LocalizedLabel>(); var columnIndex = 4; while (row.Cells[columnIndex].Value != null) { var currentLcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); labels.Add(new LocalizedLabel(row.Cells[columnIndex].Value.ToString(), currentLcid)); columnIndex++; } request.Labels = labels.ToArray(); service.Execute(request); } }
public void ImportFormName(ExcelWorksheet sheet, IOrganizationService service, BackgroundWorker worker) { OnLog(new LogEventArgs($"Reading {sheet.Name}")); var rowsCount = sheet.Dimension.Rows; var cellsCount = sheet.Dimension.Columns; var requests = new List <SetLocLabelsRequest>(); for (var rowI = 1; rowI < rowsCount; rowI++) { var currentFormId = new Guid(ZeroBasedSheet.Cell(sheet, rowI, 1).Value.ToString()); var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("systemform", currentFormId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 3).Value.ToString() == "Name" ? "name" : "description" }; var labels = new List <LocalizedLabel>(); var columnIndex = 4; while (columnIndex < cellsCount) { if (ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value != null) { var lcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); var label = ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value.ToString(); labels.Add(new LocalizedLabel(label, lcid)); } columnIndex++; } request.Labels = labels.ToArray(); requests.Add(request); } OnLog(new LogEventArgs($"Importing {sheet.Name} translations")); var arg = new TranslationProgressEventArgs { SheetName = sheet.Name }; foreach (var request in requests) { AddRequest(request); ExecuteMultiple(service, arg, requests.Count); } ExecuteMultiple(service, arg, requests.Count, true); }
public void Import(ExcelWorksheet sheet, IOrganizationService service) { var views = new List <Tuple <int, Entity> >(); var rowsCount = sheet.Dimension.Rows; var cellsCount = sheet.Dimension.Columns; for (var rowI = 1; rowI < rowsCount; rowI++) { var currentViewId = new Guid(ZeroBasedSheet.Cell(sheet, rowI, 0).Value.ToString()); var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("savedquery", currentViewId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 3).Value.ToString() == "Name" ? "name" : "description" }; var labels = new List <LocalizedLabel>(); var columnIndex = 4; while (columnIndex < cellsCount) { if (ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value != null) { var lcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); var label = ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value.ToString(); labels.Add(new LocalizedLabel(label, lcid)); } columnIndex++; } request.Labels = labels.ToArray(); service.Execute(request); } }
public void Import(ExcelWorksheet sheet, IOrganizationService service, BackgroundWorker worker) { var rowsCount = sheet.Dimension.Rows; var cellsCount = sheet.Dimension.Columns; var requests = new List <SetLocLabelsRequest>(); for (var rowI = 1; rowI < rowsCount; rowI++) { var currentViewId = new Guid(ZeroBasedSheet.Cell(sheet, rowI, 0).Value.ToString()); var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("savedquery", currentViewId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 3).Value.ToString() == "Name" ? "name" : "description" }; var labels = new List <LocalizedLabel>(); var columnIndex = 4; while (columnIndex < cellsCount) { if (ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value != null) { var lcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); var label = ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value.ToString(); labels.Add(new LocalizedLabel(label, lcid)); } columnIndex++; } request.Labels = labels.ToArray(); requests.Add(request); } int i = 0; foreach (var request in requests) { try { service.Execute(request); OnResult(new TranslationResultEventArgs { Success = true, SheetName = sheet.Name }); } catch (Exception error) { OnResult(new TranslationResultEventArgs { Success = false, SheetName = sheet.Name, Message = $"{request.EntityMoniker.Id}/{request.AttributeName}: {error.Message}" }); } i++; worker.ReportProgressIfPossible(0, new ProgressInfo { Item = i * 100 / requests.Count }); } }
public void Import(ExcelWorksheet sheet, IOrganizationService service, BackgroundWorker worker) { OnLog(new LogEventArgs($"Reading {sheet.Name}")); var rowsCount = sheet.Dimension.Rows; var cellsCount = sheet.Dimension.Columns; var requests = new List <SetLocLabelsRequest>(); for (var rowI = 1; rowI < rowsCount; rowI++) { if (HasEmptyCells(sheet, rowI, 2)) { continue; } var currentVisualizationId = new Guid(ZeroBasedSheet.Cell(sheet, rowI, 0).Value.ToString()); var locLabel = ((RetrieveLocLabelsResponse)service.Execute(new RetrieveLocLabelsRequest { EntityMoniker = new EntityReference("savedqueryvisualization", currentVisualizationId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 2).Value.ToString() == "Name" ? "name" : "description" })).Label; var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("savedqueryvisualization", currentVisualizationId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 2).Value.ToString() == "Name" ? "name" : "description" }; var labels = locLabel.LocalizedLabels.ToList(); var columnIndex = 3; while (columnIndex < cellsCount) { if (ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value != null) { var lcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); var label = ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value.ToString(); var translatedLabel = labels.FirstOrDefault(x => x.LanguageCode == lcid); if (translatedLabel == null) { translatedLabel = new LocalizedLabel(label, lcid); labels.Add(translatedLabel); } else { translatedLabel.Label = label; } } columnIndex++; } request.Labels = labels.ToArray(); requests.Add(request); } OnLog(new LogEventArgs($"Importing {sheet.Name} translations")); var arg = new TranslationProgressEventArgs { SheetName = sheet.Name }; foreach (var request in requests) { AddRequest(request); ExecuteMultiple(service, arg, requests.Count); } ExecuteMultiple(service, arg, requests.Count, true); }
public void Import(ExcelWorksheet sheet, IOrganizationService service) { var views = new List<Tuple<int, Entity>>(); var rowsCount = sheet.Dimension.Rows; var cellsCount = sheet.Dimension.Columns; for (var rowI = 1; rowI < rowsCount; rowI++) { var currentViewId = new Guid(ZeroBasedSheet.Cell(sheet, rowI, 0).Value.ToString()); var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("savedquery", currentViewId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 3).Value.ToString() == "Name" ? "name" : "description" }; var labels = new List<LocalizedLabel>(); var columnIndex = 4; while (columnIndex < cellsCount) { if (ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value != null) { var lcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); var label = ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value.ToString(); labels.Add(new LocalizedLabel(label, lcid)); } columnIndex++; } request.Labels = labels.ToArray(); service.Execute(request); } }
public void ImportFormName(ExcelWorksheet sheet, IOrganizationService service) { var rowsCount = sheet.Dimension.Rows; for (var rowI = 1; rowI < rowsCount; rowI++) { var currentFormId = new Guid(ZeroBasedSheet.Cell(sheet, rowI, 1).Value.ToString()); var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("systemform", currentFormId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 2).Value.ToString() == "Name" ? "name" : "description" }; var labels = new List<LocalizedLabel>(); var columnIndex = 3; while (ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value != null) { var currentLcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); labels.Add(new LocalizedLabel(ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value.ToString(), currentLcid)); columnIndex++; } request.Labels = labels.ToArray(); service.Execute(request); } }
public void Import(ExcelWorksheet sheet, IOrganizationService service) { var views = new List<Tuple<int, Entity>>(); foreach (var row in sheet.Rows.Where(r => r.Index != 0).OrderBy(r => r.Index)) { var currentViewId = new Guid(row.Cells[0].Value.ToString()); var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("savedquery", currentViewId), AttributeName = row.Cells[3].Value.ToString() == "Name" ? "name" : "description" }; var labels = new List<LocalizedLabel>(); var columnIndex = 4; while (row.Cells[columnIndex].Value != null) { var currentLcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); labels.Add(new LocalizedLabel(row.Cells[columnIndex].Value.ToString(),currentLcid)); columnIndex++; } request.Labels = labels.ToArray(); service.Execute(request); } }
public void ImportFormName(ExcelWorksheet sheet, IOrganizationService service, BackgroundWorker worker) { OnLog(new LogEventArgs($"Reading {sheet.Name}")); var rowsCount = sheet.Dimension.Rows; var cellsCount = sheet.Dimension.Columns; var requests = new List <SetLocLabelsRequest>(); for (var rowI = 1; rowI < rowsCount; rowI++) { var currentFormId = new Guid(ZeroBasedSheet.Cell(sheet, rowI, 1).Value.ToString()); var locLabel = ((RetrieveLocLabelsResponse)service.Execute(new RetrieveLocLabelsRequest { EntityMoniker = new EntityReference("systemform", currentFormId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 3).Value.ToString() == "Name" ? "name" : "description" })).Label; var labels = locLabel.LocalizedLabels.ToList(); var request = new SetLocLabelsRequest { EntityMoniker = new EntityReference("systemform", currentFormId), AttributeName = ZeroBasedSheet.Cell(sheet, rowI, 3).Value.ToString() == "Name" ? "name" : "description", Labels = locLabel.LocalizedLabels.ToArray() }; var columnIndex = 4; while (columnIndex < cellsCount) { if (ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value != null) { var lcid = int.Parse(ZeroBasedSheet.Cell(sheet, 0, columnIndex).Value.ToString()); var label = ZeroBasedSheet.Cell(sheet, rowI, columnIndex).Value.ToString(); var translatedLabel = labels.FirstOrDefault(x => x.LanguageCode == lcid); if (translatedLabel == null) { translatedLabel = new LocalizedLabel(label, lcid); labels.Add(translatedLabel); } else { translatedLabel.Label = label; } } columnIndex++; } request.Labels = labels.ToArray(); requests.Add(request); } OnLog(new LogEventArgs($"Importing {sheet.Name} translations")); var setting = GetCurrentUserSettings(service); var userSettingLcid = setting.GetAttributeValue <int>("uilanguageid"); var currentSetting = userSettingLcid; int orgLcid = GetCurrentOrgBaseLanguage(service); if (currentSetting != orgLcid) { setting["localeid"] = orgLcid; setting["uilanguageid"] = orgLcid; setting["helplanguageid"] = orgLcid; service.Update(setting); currentSetting = orgLcid; Thread.Sleep(2000); } var arg = new TranslationProgressEventArgs { SheetName = sheet.Name }; foreach (var request in requests) { AddRequest(request); ExecuteMultiple(service, arg, requests.Count); } ExecuteMultiple(service, arg, requests.Count, true); if (currentSetting != userSettingLcid) { setting["localeid"] = userSettingLcid; setting["uilanguageid"] = userSettingLcid; setting["helplanguageid"] = userSettingLcid; service.Update(setting); Thread.Sleep(2000); } }