Beispiel #1
0
    public string UpdatePosition(string titleId, string title)
    {
        if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(titleId))
        {
            //logger.Info(string.Format(base.LogEmptyInfo, "Title, TitleId"));
            return(string.Format(LogEmptyInfo, "Title, TitleId"));
        }

        CardData    refStaffData    = Session.CardManager.GetDictionaryData(RefStaff.ID);
        SectionData positionSection = refStaffData.Sections[RefStaff.Positions.ID];

        //im RowData position = GetExistObject(RefStaff.Positions.ID, RefStaff.Positions.Name, title);
        RowDataCollection positionColl = GetExistObject(RefStaff.Positions.ID, RefStaff.Positions.Name, title);
        RowData           position     = positionColl[0];

        if (position == null)
        {
            return(AddPosition(titleId, title));
        }

        refStaffData.BeginUpdate();
        //position[RefStaff.Positions.Name] = title;
        position[RefStaff.Positions.SyncTag] = titleId;
        refStaffData.EndUpdate();

        return("Должность обновлена");
    }
Beispiel #2
0
    //Должности

    public string AddPosition(string titleId, string title)
    {
        if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(titleId))
        {
            //logger.Info(string.Format(base.LogEmptyInfo, "Title, TitleId"));
            return(string.Format(LogEmptyInfo, "Title, TitleId"));
        }

        CardData    refStaffData    = Session.CardManager.GetDictionaryData(RefStaff.ID);
        SectionData positionSection = refStaffData.Sections[RefStaff.Positions.ID];

        refStaffData.BeginUpdate();

        var newRowDepartment = positionSection.Rows.AddNew();

        newRowDepartment[RefStaff.Positions.Name]    = title;
        newRowDepartment[RefStaff.Positions.SyncTag] = titleId;

        refStaffData.EndUpdate();

        return("Должность добавлена");
    }
Beispiel #3
0
    public string DeletePosition(string titleId)
    {
        if (string.IsNullOrEmpty(titleId))
        {
            //logger.Info(string.Format(base.LogEmptyInfo, "TitleId"));
            return(string.Format(LogEmptyInfo, "TitleId"));
        }

        CardData    refStaffData = Session.CardManager.GetDictionaryData(RefStaff.ID);
        SectionData unitsSection = refStaffData.Sections[RefStaff.Positions.ID];
        //im RowData position = GetExistObject(RefStaff.Positions.ID, RefStaff.Positions.SyncTag, titleId);
        RowDataCollection positionColl = GetExistObject(RefStaff.Positions.ID, RefStaff.Positions.SyncTag, titleId);
        RowData           position     = positionColl[0];

        if (position != null)
        {
            refStaffData.BeginUpdate();
            unitsSection.DeleteRow(position.Id);
            refStaffData.EndUpdate();
        }

        return("Должность удалена");
    }
Beispiel #4
0
        public static Boolean RegisterProtocol(UserSession Session, String CardID, String TempFolder, Guid EmployeeId)
        {
            logger.Info("cardId='{0}'", CardID);
            logger.Info("tempName='{0}'", TempFolder);
            logger.Info("EmployeeId='{0}'", EmployeeId);
            using (new Impersonator(ServerExtension.Domain, ServerExtension.User, ServerExtension.SecurePassword))
            {
                Guid CardId = new Guid(CardID);
                switch (Session.CardManager.GetCardState(CardId))
                {
                case ObjectState.Existing:
                    DirectoryInfo TempDirectory = new DirectoryInfo(Path.Combine(ArchiveTempPath, TempFolder));
                    FileInfo[]    TempFiles     = TempDirectory.GetFiles();
                    logger.Info("В папке файлов: " + TempFiles.Length);
                    if (TempFiles.Length > 0)
                    {
                        logger.Info("Файлы: " + TempFiles.Select(file => file.Name).Aggregate((a, b) => a + "; " + b));
                        CardData Card = Session.CardManager.GetCardData(CardId);
                        Card.UnlockCard();
                        if (Card.InUpdate)
                        {
                            Card.CancelUpdate();
                        }
                        Card.PlaceLock();
                        Card.BeginUpdate();
                        foreach (Protocol Protocol in TempFiles.Select(fi => new Protocol(fi)))
                        {
                            if (Protocol.IsParsed)
                            {
                                RowData MainInfoRow   = Card.Sections[CardOrd.MainInfo.ID].FirstRow;
                                Guid    FilesID       = MainInfoRow.GetGuid(CardOrd.MainInfo.FilesID) ?? Guid.Empty;
                                Boolean FileListExist = !(FilesID.IsEmpty() && Card.Session.CardManager.GetCardState(FilesID) == ObjectState.Existing);
                                logger.Info("FileListExist = " + FileListExist);
                                CardData FileListCard;
                                if (FileListExist)
                                {
                                    FileListCard = Card.Session.CardManager.GetCardData(FilesID);
                                }
                                else
                                {
                                    FileListCard = Card.Session.CardManager.CreateCardData(FileList.ID);
                                    MainInfoRow.SetGuid(CardOrd.MainInfo.FilesID, FileListCard.Id);
                                }

                                SectionData FileReferencesSection = FileListCard.Sections[FileList.FileReferences.ID];
                                /* Проверка существования файла протокола в карточке */
                                if (!FileReferencesSection.Rows.Any(file => Protocol.PhysicalFile.Name.Contains(file.GetString(CardFile.MainInfo.FileName))))
                                {
                                    FileListCard.UnlockCard();

                                    VersionedFileCard FileCard        = (VersionedFileCard)Card.Session.CardManager.CreateCard(DocsVision.Platform.Cards.Constants.VersionedFileCard.ID);
                                    FileVersion       FileCardVersion = FileCard.Initialize(Protocol.PhysicalFile.FullName, Guid.Empty, false, true);
                                    CardData          FileData        = Card.Session.CardManager.CreateCardData(CardFile.ID);

                                    FileData.BeginUpdate();
                                    FileData.Description = "Файл: " + FileCard.Name;

                                    RowData FileMainInfoRow = FileData.Sections[CardFile.MainInfo.ID].Rows.AddNew();
                                    FileMainInfoRow.SetGuid(CardFile.MainInfo.FileID, FileCard.Id);
                                    FileMainInfoRow.SetString(CardFile.MainInfo.FileName, FileCardVersion.Name);
                                    FileMainInfoRow.SetGuid(CardFile.MainInfo.Author, FileCardVersion.AuthorId);
                                    FileMainInfoRow.SetInt32(CardFile.MainInfo.FileSize, FileCardVersion.Size);
                                    FileMainInfoRow.SetInt32(CardFile.MainInfo.VersioningType, 0);

                                    RowData FilePropertiesRow = FileData.Sections[CardFile.Properties.ID].Rows.AddNew();
                                    FilePropertiesRow.SetString(CardFile.Properties.Name, "Дата начала испытаний");
                                    FilePropertiesRow.SetInt32(CardFile.Properties.ParamType, (Int32)PropertieParamType.Date);
                                    FilePropertiesRow.SetString(CardFile.Properties.Value, Protocol.StringDate);
                                    FilePropertiesRow.SetString(CardFile.Properties.DisplayValue, Protocol.StringDate);

                                    FileData.Sections[CardFile.Categories.ID].Rows.AddNew().SetGuid(CardFile.Categories.CategoryID, MyHelper.RefCategory_CalibrationProtocol);

                                    FileData.EndUpdate();

                                    Int32 FilesCount = FileReferencesSection.Rows.Count;
                                    FileReferencesSection.Rows.AddNew().SetGuid(FileList.FileReferences.CardFileID, FileData.Id);
                                    FileListCard.Sections[FileList.MainInfo.ID].FirstRow.SetInt32(FileList.MainInfo.Count, FilesCount + 1);

                                    SectionData PropertiesSection = Card.Sections[CardOrd.Properties.ID];
                                    RowData     PropertyRow       = PropertiesSection.GetProperty("Дата");
                                    if (!PropertyRow.IsNull())
                                    {
                                        RowDataCollection SelectedValuesRows = PropertyRow.ChildSections[CardOrd.SelectedValues.ID].Rows;
                                        RowData           SelectedValuesRow  = SelectedValuesRows.AddNew();
                                        SelectedValuesRow.SetInt32(CardOrd.SelectedValues.Order, SelectedValuesRows.Count);
                                        SelectedValuesRow.SetDateTime(CardOrd.SelectedValues.SelectedValue, DateTime.Now);
                                    }
                                    PropertyRow = PropertiesSection.GetProperty("Действие");
                                    if (!PropertyRow.IsNull())
                                    {
                                        RowDataCollection SelectedValuesRows = PropertyRow.ChildSections[CardOrd.SelectedValues.ID].Rows;
                                        RowData           SelectedValuesRow  = SelectedValuesRows.AddNew();
                                        SelectedValuesRow.SetInt32(CardOrd.SelectedValues.Order, SelectedValuesRows.Count);
                                        SelectedValuesRow.SetString(CardOrd.SelectedValues.SelectedValue, "Прикреплен протокол калибровки");
                                    }
                                    PropertyRow = PropertiesSection.GetProperty("Участник");
                                    if (!PropertyRow.IsNull())
                                    {
                                        RowDataCollection SelectedValuesRows = PropertyRow.ChildSections[CardOrd.SelectedValues.ID].Rows;
                                        RowData           SelectedValuesRow  = SelectedValuesRows.AddNew();
                                        SelectedValuesRow.SetInt32(CardOrd.SelectedValues.Order, SelectedValuesRows.Count);
                                        SelectedValuesRow.SetGuid(CardOrd.SelectedValues.SelectedValue, EmployeeId);
                                    }
                                    PropertyRow = PropertiesSection.GetProperty("Комментарий");
                                    if (!PropertyRow.IsNull())
                                    {
                                        RowDataCollection SelectedValuesRows = PropertyRow.ChildSections[CardOrd.SelectedValues.ID].Rows;
                                        RowData           SelectedValuesRow  = SelectedValuesRows.AddNew();
                                        SelectedValuesRow.SetInt32(CardOrd.SelectedValues.Order, SelectedValuesRows.Count);
                                        SelectedValuesRow.SetString(CardOrd.SelectedValues.SelectedValue, "Автоматическое прикрепление протокола калибровки " + Protocol.PhysicalFile.Name);
                                    }
                                    PropertyRow = PropertiesSection.GetProperty("Ссылки");
                                    if (!PropertyRow.IsNull())
                                    {
                                        RowDataCollection SelectedValuesRows = PropertyRow.ChildSections[CardOrd.SelectedValues.ID].Rows;
                                        RowData           SelectedValuesRow  = SelectedValuesRows.AddNew();
                                        SelectedValuesRow.SetInt32(CardOrd.SelectedValues.Order, SelectedValuesRows.Count);
                                        SelectedValuesRow.SetString(CardOrd.SelectedValues.SelectedValue, null);
                                    }

                                    if (!FileListExist)
                                    {
                                        Card.Sections[CardOrd.MainInfo.ID].FirstRow.SetGuid(CardOrd.MainInfo.FilesID, FileListCard.Id);
                                    }
                                }
                            }
                            else
                            {
                                logger.Warn("Нераспознаный файл: " + Protocol.PhysicalFile.Name);
                            }
                        }

                        Card.EndUpdate();
                        Card.RemoveLock();

                        TempDirectory.Delete(true);
                        logger.Info("RegisterProtocol - выполнено.");
                    }
                    else
                    {
                        logger.Info("RegisterProtocol - не выполнено.");
                    }
                    return(true);

                default:
                    logger.Info("RegisterProtocol - не выполнено. Паспорт прибора не существует.");
                    return(false);
                }
            }
        }
Beispiel #5
0
    //public string UpdateDepartment(string unitId, string unit, string unitFull, string ownerId, string chief, string curator)
    public object UpdateDepartment(string unitId, string unit, string unitFull, string ownerId, string chief, string curator)
    {
        if (string.IsNullOrEmpty(unit))
        {
            //logger.Info(string.Format(LogEmptyInfo, "Unit"));
            //return string.Format(LogEmptyInfo, "Unit");
            return(true);
        }

        CardData    refStaffData = Session.CardManager.GetDictionaryData(RefStaff.ID);
        SectionData unitsSection = refStaffData.Sections[RefStaff.Units.ID];

        //im RowData department = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, unitId);
        RowDataCollection departmentColl = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, unitId);
        RowData           department     = null;

        try{
            department = departmentColl[0];
        }
        catch {}

        if (department == null)
        {
            return(AddDepartment(unitId, unit, unitFull, ownerId, chief, curator));
        }

        refStaffData.BeginUpdate();

        //Родитель
        if (ownerId == unitId)
        {
            return(true);
        }
        var existedParentDepartmentCode = department.ParentRow[RefStaff.Units.Code];

        if (!(existedParentDepartmentCode == null && ownerId == null) && !ownerId.Equals(existedParentDepartmentCode))
        {
            SectionQuery sectionQueryParentDepartment = Session.CreateSectionQuery();
            sectionQueryParentDepartment.ConditionGroup.Conditions.AddNew(RefStaff.Units.Code, FieldType.Unistring,
                                                                          ConditionOperation.Equals, ownerId);

            RowDataCollection departmentParentCollection = unitsSection.FindRows(sectionQueryParentDepartment.GetXml());
            if (departmentParentCollection != null && departmentParentCollection.Count > 0)
            {
                department.Move(departmentParentCollection[0].Id, Guid.Empty);
            }
        }

        refStaffData.EndUpdate();

        refStaffData.BeginUpdate();
        try{
            var isFirstLoad = ConfigurationManager.AppSettings["FirstLoad"];
            if (isFirstLoad == "1")
            {
                department[RefStaff.Units.Name]     = unit;
                department[RefStaff.Units.FullName] = unitFull;
            }
            else
            {
                department[RefStaff.Units.Name]     = unit;
                department[RefStaff.Units.FullName] = unitFull;
            }
            department[RefStaff.Units.Code] = unitId;

            //Руководитель подразделения
            if (chief != string.Empty)
            {
                try{
                    UpdateDepartmentChief(department, refStaffData, chief);
                }
                catch {
                    refStaffData.EndUpdate();
                    return("Руководитель не найден.");
                }
            }

            //Куратор подразделения
            if (curator != string.Empty)
            {
                try{
                    UpdateDepartmentCurator(department, refStaffData, curator);
                }
                catch {
                    refStaffData.EndUpdate();
                    return("Куратор не найден.");
                }
            }

            refStaffData.EndUpdate();

            //return "Департамент обновлен";
            return(true);
        }
        catch {
            return("Ошибка при попытке обновить подразделение. Необходимо перезапустить сервис!");
        }
    }
Beispiel #6
0
    //Подразделения
    //im public string AddDepartment(string unitId, string unit, string unitFull, string ownerId, string chief, string curator)
    public object AddDepartment(string unitId, string unit, string unitFull, string ownerId, string chief, string curator)
    {
        try{
            if (string.IsNullOrEmpty(unit))
            {
                //logger.Info(string.Format(base.LogEmptyInfo, "Unit"));
                //return string.Format(LogEmptyInfo, "Unit");
                return(true);
            }

            CardData refStaffData = Session.CardManager.GetDictionaryData(RefStaff.ID);

            SectionData unitsSection = refStaffData.Sections[RefStaff.Units.ID];

            //im RowData department = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, unitId);
            RowDataCollection departmentColl = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, unitId);
            if (departmentColl == null || departmentColl.Count == 0)
            {
                RowData unitRow = null;

                //Поиск по родителю

                if (!String.IsNullOrEmpty(ownerId))
                {
                    //im unitRow = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, ownerId);
                    RowDataCollection unitRowColl = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, ownerId);
                    if (unitRowColl != null)
                    {
                        unitRow = unitRowColl[0];
                    }
                }

                if (unitRow == null)
                {
                    unitRow = unitsSection.GetRow(new Guid(ConfigurationManager.AppSettings["RootDepartmentGuid"]));                     //Нужно брать по известному ID подразделения
                }
                RowDataCollection departmentRows = unitRow.ChildRows;

                refStaffData.BeginUpdate();

                var newRowDepartment = departmentRows.AddNew();
                var isFirstLoad      = ConfigurationManager.AppSettings["FirstLoad"];
                if (isFirstLoad == "1")
                {
                    newRowDepartment[RefStaff.Units.Name]     = unit;
                    newRowDepartment[RefStaff.Units.FullName] = unitFull;
                }
                else
                {
                    newRowDepartment[RefStaff.Units.Name]     = unit;
                    newRowDepartment[RefStaff.Units.FullName] = unitFull;
                }
                newRowDepartment[RefStaff.Units.Code] = unitId;
                newRowDepartment[RefStaff.Units.Type] = StaffUnitType.Department;

                //Руководитель подразделения

                /*im
                 * UpdateDepartmentChief(newRowDepartment, refStaffData, chief);
                 */
                if (!String.IsNullOrEmpty(chief))
                {
                    //im unitRow = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, ownerId);
                    RowDataCollection unitRowColl = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, chief);
                    if (unitRowColl != null)
                    {
                        unitRow = unitRowColl[0];
                    }
                }
                //Куратор подразделения

                /*
                 * UpdateDepartmentCurator(newRowDepartment, refStaffData, curator);
                 */
                if (!String.IsNullOrEmpty(curator))
                {
                    //im unitRow = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, ownerId);
                    RowDataCollection unitRowColl = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, curator);
                    if (unitRowColl != null)
                    {
                        unitRow = unitRowColl[0];
                    }
                }

                refStaffData.EndUpdate();
                //return "Департамент добавлен";
                return(true);
            }
            else
            {
                //return "Подразделение уже добавлено";
                return(true);
            }
        }
        catch {
            CardData refStaffData = Session.CardManager.GetDictionaryData(RefStaff.ID);
            refStaffData.BeginUpdate();
            refStaffData.EndUpdate();
            return("Ошибка при попытке добавить новое подразделение. Необходимо перезапустить сервис!");
            //return false;
        }
    }
Beispiel #7
0
    //Сотрудники

    //im public string AddEmployee(string code, string familyName, string firstName, string middleName, bool? actual, string titleId,
    public object AddEmployee(string code, string familyName, string firstName, string middleName, bool?actual, string titleId,
                              string title, int routingType, string departmentCode, string email, string employeeChief)
    {
        try
        {
            string requestEmptyField = GetRequestEmployee(code, familyName, departmentCode, actual);
            if (!string.IsNullOrEmpty(requestEmptyField))
            {
                //logger.Info(requestEmptyField);
                //im return requestEmptyField;
                return(true);
            }

            if (!actual.HasValue || !actual.Value)
            {
                //im return "Сотрудник неактуален, добавление не произведено.";
                return(true);
            }

            //Поиск сотрудника ***
            //im RowData employeeDocsvision = GetExistObject(RefStaff.Employees.ID, RefStaff.Employees.IDCode, code);
            RowDataCollection employeeDocsvision = GetExistObject(RefStaff.Employees.ID, RefStaff.Employees.IDCode, code);
            //im if (employeeDocsvision == null)
            if (employeeDocsvision == null || employeeDocsvision.Count == 0)
            {
                //Поиск подразделения
                //im RowData department = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, departmentCode);
                RowDataCollection departmentColl = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, departmentCode);
                //im if (department == null)
                if (departmentColl == null || departmentColl.Count == 0 || departmentColl.Count > 1)
                {
                    return("Не найдено подразделение.");
                    //return false;
                }
                RowData department = departmentColl[0];

                CardData refStaffData = Session.CardManager.GetDictionaryData(RefStaff.ID);

                refStaffData.BeginUpdate();

                // Создание нового пользователя
                RowData newEmployeeDocsvision = CreateEmployee(department);


                // Обновление следующих полей: 1. Фамилия  2. Имя  3. Отчество 6. E-mail, 8. Маршрутизация, так же IDCode, displayName
                UpdateEmployeeSimple(newEmployeeDocsvision, refStaffData, code, familyName, firstName, middleName, email, routingType);

                // 7. Пользователь
                if (!string.IsNullOrEmpty(email))
                {
                    SetAccountName(newEmployeeDocsvision, familyName, firstName, middleName, email);
                }

                //4. Должность
                UpdateEmployeePosition(newEmployeeDocsvision, refStaffData, titleId, title);

                //5. Руководитель
                UpdateEmployeeManager(newEmployeeDocsvision, refStaffData, employeeChief);

                refStaffData.EndUpdate();

                // 9. Папки
                DocsVisionFilesHelper filesHelper = new DocsVisionFilesHelper(Session, ObjectContext /*, logger*/);
                filesHelper.UpdateEmployeeFolder(newEmployeeDocsvision);

                //logger.Info("Создание сотрудника завершено.");

                //Проверка наличия созданного сотрудника

                /*logger.Info(base.SearchEmployeeTest(refStaffData, employee1C) == true
                 *                              ? "Наличие созданного сотрудника подтверждено!"
                 *                              : "Созданный сотрудник не подтвержден!");*/
                /*im
                 * return (SearchEmployeeTest(refStaffData, code)
                 *                              ? "Наличие созданного сотрудника подтверждено!"
                 *                              : "Созданный сотрудник не подтвержден!");*/

                return(SearchEmployeeTest(refStaffData, code)
                                                                ? true
                                                                : true); // создал, но не подтвердил
            }
            else
            {
                //im return "Сотрудник уже есть в справочнике";
                return(true);
            }
        }
        catch (Exception ex)
        {
            //im return string.Format("Ошибка создания сотрудника {0}", ex.Message);
            return("Не удалось добавить сотрудника в справочник.");
        }
    }
Beispiel #8
0
    //im public string UpdateEmployee(string code, string familyName, string firstName, string middleName, bool? actual, string titleId,
    public object UpdateEmployee(string code, string familyName, string firstName, string middleName, bool?actual, string titleId,
                                 string title, int routingType, string departmentCode, string email, string employeeChief)
    {
        string requestEmptyField = GetRequestEmployee(code, familyName, departmentCode, actual);

        if (!string.IsNullOrEmpty(requestEmptyField))
        {
            //logger.Info(requestEmptyField);
            //im return requestEmptyField;
            return(true);
        }

        CardData refStaffData = Session.CardManager.GetDictionaryData(RefStaff.ID);

        // Поиск пользователя
        //var rowColl = new RowDataCollection<RowData>(); //im

        //im RowData employeeDocsvision = GetExistObject(RefStaff.Employees.ID, RefStaff.Employees.IDCode, code);
        RowDataCollection employeeDocsvisionColl = null;

        try{
            employeeDocsvisionColl = GetExistObject(RefStaff.Employees.ID, RefStaff.Employees.IDCode, code);
        }
        catch {}

        //im if (employeeDocsvision == null)

        /*
         * if (employeeDocsvisionColl == null || employeeDocsvisionColl.Count == 0 || employeeDocsvisionColl.Count > 1)
         * {
         *  //im var accountNameFromAd = GetAccountFromAD(familyName, firstName, middleName, email);
         *  //im employeeDocsvision = GetExistObject(RefStaff.Employees.ID, RefStaff.Employees.AccountName, accountNameFromAd);
         * return true;
         * }
         */
        RowData employeeDocsvision = null;

        try{
            employeeDocsvision = employeeDocsvisionColl[0];
        }
        catch {}

        //im if (employeeDocsvision == null)
        if (employeeDocsvision == null)
        {
            //logger.Info("Сотрудник не найден, началось создание нового сотрудника.");
            return(AddEmployee(code, familyName, firstName, middleName, actual, titleId, title, routingType,
                               departmentCode, email, employeeChief));
        }

        //Поиск подразделения
        //im RowData department = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, departmentCode);
        RowDataCollection departmentColl = null;

        try{
            departmentColl = GetExistObject(RefStaff.Units.ID, RefStaff.Units.Code, departmentCode);
        }
        catch {}
        //im if (department == null)
        if (departmentColl == null || departmentColl.Count == 0 || departmentColl.Count > 1)
        {
            //logger.Info("Не найдено подразделение сотрудника.");
            //im return "Не найдено подразделение сотрудника.";
            return("Не найдено подразделение для сотрудника.");
        }
        RowData department = departmentColl[0];

        refStaffData.BeginUpdate();

        // Перемещение сотрудника в требуемое подразделение, если необходимо
        MoveExistEmployee(employeeDocsvision, department);


        // Обновление следующих полей: 1. Фамилия  2. Имя  3. Отчество 6. E-mail, 8. Маршрутизация, так же IDCode, displayName
        UpdateEmployeeSimple(employeeDocsvision, refStaffData, code, familyName, firstName, middleName, email, routingType);

        // Обновление статуса сотрудника
        SetEmployeeStatus(actual, employeeDocsvision);

        //logger.Info("Обновление базовых полей сотрудника завершено.");

        //4. Должность
        UpdateEmployeePosition(employeeDocsvision, refStaffData, titleId, title);

        //5. Руководитель
        UpdateEmployeeManager(employeeDocsvision, refStaffData, employeeChief);

        /*
         * // 7. Пользователь
         * if (email != null || email != string.Empty)
         *      SetAccountName(employeeDocsvision, familyName, firstName, middleName, email);
         */

        refStaffData.EndUpdate();
        return(true);

        // 9. Папки
        //im DocsVisionFilesHelper filesHelper = new DocsVisionFilesHelper(Session, ObjectContext/*, logger*/);
        //im filesHelper.UpdateEmployeeFolder(employeeDocsvision);


        //im refStaffData.EndUpdate();
        //logger.Info("Обновление сотрудника завершено.");
        //im return "Обновление сотрудника завершено.";
        //im return true;
    }
Beispiel #9
0
        private void CreateAccountCard_ItemClick(Object sender, ItemClickEventArgs e)
        {
            try
            {
                IReferenceListService ReferenceListService = Context.GetService <IReferenceListService>();
                ReferenceList         RefList = Context.GetObject <ReferenceList>(Control_Links.ReferenceListID);
                if (RefList.References.Any(r => r.CardType.Equals(RefAccountCard.ID)))
                {
                    CardScript.CardFrame.CardHost.ShowCardModal(RefList.References.First(r => r.CardType.Equals(RefAccountCard.ID)).Card, ActivateMode.Edit);
                }

                if (Table_Service.RowCount > 0)
                {
                    throw new MyException(1);
                }

                if (!CardScript.SaveCard())
                {
                    throw new MyException(0);
                }

                /* Формирование задания на отгрузку */
                CardData AccountData = Context.CreateCard(RefAccountCard.ID);
                AccountData.BeginUpdate();

                RowData     MainInfoRow = AccountData.Sections[RefAccountCard.MainInfo.ID].FirstRow;
                SectionData Service     = AccountData.Sections[RefAccountCard.Service.ID];

                MainInfoRow.SetGuid(RefAccountCard.MainInfo.RegisterId, Context.GetCurrentUser());
                MainInfoRow.SetGuid(RefAccountCard.MainInfo.ContractSubjectId, AccountCard.Item_Subject_Service.ToGuid());
                MainInfoRow.SetGuid(RefAccountCard.MainInfo.ClientId, GetControlValue(RefApplicationCard.MainInfo.Client).ToGuid());


                Guid?RefListId = MainInfoRow.GetGuid(RefAccountCard.MainInfo.LinkListId);
                RefList = RefListId.HasValue ? Context.GetObject <ReferenceList>(RefListId.Value) : ReferenceListService.CreateReferenceList();

                if (!RefList.References.Any(RefRef => RefRef.Card.Equals(CardScript.CardData.Id)))
                {
                    ReferenceListService.CreateReference(RefList, null, CardScript.CardData.Id, RefApplicationCard.ID, false);
                    MainInfoRow.SetGuid(RefAccountCard.MainInfo.LinkListId, Context.GetObjectRef <ReferenceList>(RefList).Id);
                }

                RefList.References.First(RefRef => RefRef.Card.Equals(CardScript.CardData.Id)).LinkDescription = DateTime.Now.ToString("Создано dd.MM.yyyy HH:mm");
                Context.SaveObject(RefList);

                for (Int32 i = 0; i < Table_Service.RowCount; i++)
                {
                    BaseCardProperty Row        = Table_Service[i];
                    RowData          ServiceRow = Service.Rows.AddNew();
                    ServiceRow.SetGuid(RefAccountCard.Service.Id, Row[RefApplicationCard.Service.Id].ToGuid());
                    ServiceRow.SetGuid(RefAccountCard.Service.DeviceId, Row[RefApplicationCard.Service.DeviceID].ToGuid());
                    ServiceRow.SetBoolean(RefAccountCard.Service.AC, (Boolean)Row[RefApplicationCard.Service.Verify]);
                    ServiceRow.SetBoolean(RefAccountCard.Service.Verify, (Boolean)Row[RefApplicationCard.Service.Verify]);
                    ServiceRow.SetBoolean(RefAccountCard.Service.Repair, (Boolean)Row[RefApplicationCard.Service.Repair]);
                    ServiceRow.SetBoolean(RefAccountCard.Service.Calibrate, (Boolean)Row[RefApplicationCard.Service.Calibrate]);
                    ServiceRow.SetBoolean(RefAccountCard.Service.Delivery, false);
                    ServiceRow.SetInt32(RefAccountCard.Service.Count, 1);
                    ServiceRow.SetInt32(RefAccountCard.Service.Shipped, 0);
                    ServiceRow.SetInt32(RefAccountCard.Service.ToShip, 1);
                    ServiceRow.SetString(RefAccountCard.Service.ACList, Row[RefApplicationCard.Service.ACList]);
                    ServiceRow.SetString(RefAccountCard.Service.PackedListData, Row[RefApplicationCard.Service.PackedListData]);
                    ServiceRow.SetGuid(RefAccountCard.Service.PackedListId, Row[RefApplicationCard.Service.PackedListID].ToGuid());
                    ServiceRow.SetBoolean(RefAccountCard.Service.Warranty, (Boolean)Row[RefApplicationCard.Service.WarrantyServices]);
                }

                AccountData.EndUpdate();

                if (CardScript.CardFrame.CardHost.ShowCardModal(AccountData.Id, ActivateMode.Edit, ActivateFlags.New))
                {
                    Control_Links.AddRef(AccountData.Id, DateTime.Now.ToString("Создано dd.MM.yyyy HH:mm"), true, false);
                    MyHelper.SaveCard(CardScript);
                }
                else
                {
                    AccountData.ForceUnlock();
                    CardScript.Session.CardManager.DeleteCard(AccountData.Id, true);
                }
            }
            catch (MyException Ex)
            {
                switch (Ex.ErrorCode)
                {
                case 1: MyMessageBox.Show("Таблица «Сервисное обслуживание» не заполнена!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning); break;
                }
            }
            catch (Exception Ex) { CallError(Ex); }
        }