public void ReceiveRequest(string globalId, string receivedNotes) { var rows = _tpr.TechnologyProblemsTable.AsEnumerable().Where(r => r.Field <string>("GlobalID") == globalId); if (!rows.Any()) { return; } var techProblem = rows.First(); var techProblemId = Convert.ToInt32(techProblem["TechnologyProblemID"]); var receivedDate = App.BaseClass.GetDateFromSqlServer(); var receiverWorkerId = AdministrationClass.CurrentWorkerId; _tpr.FillReceivedInfo(techProblemId, receivedDate, receiverWorkerId, receivedNotes); AdministrationClass.AddNewAction(18); var requestDate = Convert.ToDateTime(techProblem["RequestDate"]); var requestWorkerId = Convert.ToInt32(techProblem["RequestWorkerID"]); var workerName = new IdToNameConverter().Convert(receiverWorkerId, typeof(string), "ShortName", new CultureInfo("ru-RU")) .ToString(); var newsText = string.Format(ReceivedText, workerName, receivedDate); NewsHelper.AddTextToNews(requestDate, requestWorkerId, newsText); }
private void UploadFiles(IEnumerable <string> filePaths, int workerId) { if (_ftpClient.IsBusy) { MessageBox.Show("В данный момент невозможно выполнить загрузку. Попробуйте позже"); return; } var workerPath = GetWorkerPath(workerId); // Worker directory doesnt exist if (workerPath == null) { var workerName = new IdToNameConverter().Convert(workerId, typeof(string), "FullName", new CultureInfo("ru-RU")) .ToString(); // Get right name of worker directory var renamedWorkerName = GetRenamedFileName(workerName); workerPath = string.Format("{0}_[id]{1}", renamedWorkerName, workerId); // Create worker directory _ftpClient.MakeDirectory(string.Concat(_ftpClient.CurrentPath, workerPath, "/")); } foreach (var filePath in filePaths) { var fileName = Path.GetFileName(filePath); var adress = string.Concat(_ftpClient.CurrentPath, workerPath, "/", fileName); if (!_ftpClient.FileExist(adress)) { _sc.AddFileToWorker(Convert.ToInt32(StaffListBox.SelectedValue), fileName, AdministrationClass.CurrentWorkerId, App.BaseClass.GetDateFromSqlServer()); } else { if (MetroMessageBox.Show("Файл '" + fileName + "' уже существует в данном каталоге. \n\n" + "Заменить существующий файл?", string.Empty, MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes) { return; } } var uri = new Uri(adress); if (_processWindow != null) { _processWindow.Close(true); } _processWindow = new WaitWindow { Text = "Загрузка файла..." }; _processWindow.Show(Window.GetWindow(this), true); _ftpClient.UploadFileCompleted += OnFtpClientUploadFileCompleted; _ftpClient.UploadFileAsync(uri, "STOR", filePath); } }
public ServiceEquipmentInfo(DataRowView rowView, int currentWorkerId) { InitializeComponent(); App.BaseClass.GetServiceEquipmentClass(ref _sec); _rowView = rowView; _curWorkerId = currentWorkerId; _workerNameConverter = new IdToNameConverter(); DataContext = rowView; SetRowsHeight(); FillBlank(); scrollViewer.ScrollToEnd(); }
public WorkerStimulation(DataRowView workerView, DataRowView dataRowView, int curWorkerId, int selectedStimId, bool promotion = true) { InitializeComponent(); App.BaseClass.GetStimulationClass(ref _stc); _idToNameConverter = new IdToNameConverter(); FillBindings(); _workerView = workerView; _currentWorkerId = curWorkerId; _selectedWorkerStimId = selectedStimId; SetChangingWorkerStimSettings(dataRowView, promotion); OkWorkerStimButton.Visibility = Visibility.Hidden; SaveWorkerStimButton.Visibility = Visibility.Visible; }
public TechnologyProblemInfo(DataRowView techProblemView, int curWorkerId) { InitializeComponent(); App.BaseClass.GetTechnologyProblemClass(ref _tpr); _curWorkerId = curWorkerId; Height = 450; Width = 600; RequestInfoGrid.Visibility = Visibility.Visible; RequestInfoGrid.IsEnabled = true; _workerNameConverter = new IdToNameConverter(); _techProblemView = techProblemView; DataContext = techProblemView; SetRowsHeight(); FillBlank(); ScrollViewer.ScrollToEnd(); }
private static void ReplaceWorkerRequestText() { #region Variables initializing App.BaseClass.GetWorkerRequestsClass(ref _workerRequestsClass); var factoryName = _workerRequestReportStruct.FactoryId == 1 ? "СООО «ЗОВ-ПРОФИЛЬ»" : _workerRequestReportStruct.FactoryId == 2 ? "СООО «ЗОВ-ТермоПрофильСистемы»" : string.Empty; var directoryName = _workerRequestReportStruct.DirectoryName; var professionName = new IdToProfessionConverter(). Convert(_workerRequestReportStruct.ProfessionId, typeof(string), null, CultureInfo.InvariantCulture).ToString().ToLower(); var workerName = new IdToNameConverter().Convert(_workerRequestReportStruct.WorkerId, "FullName"); var salarySaveType = string.Empty; var rows = _workerRequestsClass.SalatySaveTypesTable.Select(string.Format("SalarySaveTypeID = {0}", (int)_workerRequestReportStruct.SalarySaveType)); if (rows.Any()) { salarySaveType = rows.First()["SalarySaveTypeName"].ToString().ToLower(); } var requestDate = string.Empty; switch (_workerRequestReportStruct.IntervalType) { case IntervalType.DurringSomeHours: requestDate = string.Format("на {0:dd.MM.yyyy} с {0:HH:mm} по {1:HH:mm}", _workerRequestReportStruct.RequestDate, _workerRequestReportStruct.RequestFinishDate); break; case IntervalType.DurringWorkingDay: requestDate = string.Format("на {0:dd.MM.yyyy}", _workerRequestReportStruct.RequestDate); break; case IntervalType.DurringSomeDays: requestDate = _workerRequestReportStruct.RequestDate.Year == _workerRequestReportStruct.RequestFinishDate.Year ? string.Format("с {0:dd.MM} по {1:dd.MM.yyyy}", _workerRequestReportStruct.RequestDate, _workerRequestReportStruct.RequestFinishDate) : string.Format("с {0:dd.MM.yyyy} по {1:dd.MM.yyyy}", _workerRequestReportStruct.RequestDate, _workerRequestReportStruct.RequestFinishDate); break; } var workingOffType = string.Empty; var workingOffRows = _workerRequestsClass.WorkingOffTypesTable. Select(string.Format("WorkingOffTypeID = {0}", (int)_workerRequestReportStruct.WorkingOffType)); if (rows.Any()) { workingOffType = workingOffRows.First()["WorkingOffTypeName"].ToString().ToLower(); } var workerNotes = _workerRequestReportStruct.WorkerNotes; var mainWorkerName = new IdToNameConverter().Convert(_workerRequestReportStruct.MainWorkerId, "FullName"); var mainWorkerProfession = new IdToProfessionConverter(). Convert(_workerRequestReportStruct.MainWorkerProfessionId, typeof(string), null, CultureInfo.InvariantCulture).ToString().ToLower(); #endregion try { // create missing object object missing = Missing.Value; // create Word application object Word.Application wordApp = new Word.Application(); // create Word document object Word.Document aDoc = null; // if temp.doc available if (File.Exists(_tempWorkerRequestDocumentPath)) { object readOnly = false; object isVisible = true; wordApp.Visible = false; object filePath = _tempWorkerRequestDocumentPath; //aDoc = wordApp.Documents.Open(ref filePath, ref missing, // ref readOnly, ref missing, ref missing, ref missing, // ref missing, ref missing, ref missing, ref missing, // ref missing, ref isVisible, ref missing, ref missing, // ref missing, ref missing); aDoc = wordApp.Documents.Add(ref filePath, ref missing, ref missing, ref isVisible); aDoc.Activate(); FindAndReplace(wordApp, "<CompanyName/>", factoryName); FindAndReplace(wordApp, "<Director/>", directoryName); FindAndReplace(wordApp, "<WorkerProfession/>", professionName); FindAndReplace(wordApp, "<WorkerName/>", workerName); FindAndReplace(wordApp, "<SalarySaveType/>", salarySaveType); FindAndReplace(wordApp, "<RequestDate/>", requestDate); //FindAndReplace(wordApp, "<WorkingOffType/>", workingOffType); FindAndReplace(wordApp, "<RequestNotes/>", workerNotes); FindAndReplace(wordApp, "<MainWorkerName/>", mainWorkerName); FindAndReplace(wordApp, "<MainWorkerProfession/>", mainWorkerProfession); wordApp.Visible = true; } else { MessageBox.Show("Не удаётся найти файл-шаблон.", "Файл отсутствует", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception exp) { MessageBox.Show("Ошибка в процессе." + "\n" + exp.Message + "\nПопробуйте закрыть открытые Word документы.", "Internal Error", MessageBoxButton.OK, MessageBoxImage.Error); } }