Esempio n. 1
0
        /// <summary>
        /// получает запись доп. изделия в универсальном справочнике.
        /// </summary>
        /// <param name="GotNumber">Заводской номер.</param>
        /// <param name="Device">Наименование изделия.</param>
        public RowData GetDeviceRow(String GotNumber, String Device)
        {
            String Number = null, Year = null;

            if (GotNumber.Contains("/"))
            {
                Year   = GotNumber.Split('/')[1];
                Number = GotNumber.Split('/')[0];
            }
            else
            {
                Number = GotNumber;
            }

            SectionData Items = ApplicationCard.UniversalCard.Sections[RefUniversal.Item.ID];

            SectionQuery Query = Card.CardScript.Session.CreateSectionQuery();

            Query.ConditionGroup.Operation = ConditionGroupOperation.And;
            Query.ConditionGroup.Conditions.AddNew("Name", FieldType.Unistring, ConditionOperation.Contains, String.Format("{0} № {1}/{2}", Device, Number, Year));

            RowDataCollection Found = Items.FindRows(Query.GetXml());

            return(Found.Count == 1 ? Found[0] : null);
        }
        private static string GetSectionSearchQuery(UserSession Session, string fieldName, string fieldValue,
                                                    FieldType fieldType = FieldType.Unistring,
                                                    ConditionOperation conditionOperation = ConditionOperation.Equals)
        {
            SectionQuery query = Session.CreateSectionQuery();

            query.ConditionGroup.Conditions.AddNew(fieldName, fieldType, conditionOperation, fieldValue);
            return(query.GetXml(null, true));
        }
Esempio n. 3
0
        public static RowData GetEmployeeRowDataByAccount(string account)
        {
            account = BuildAccountDomain(account);
            SectionQuery query = Session.CreateSectionQuery();

            query.ConditionGroup.Conditions.AddNew("AccountName", FieldType.Unistring, ConditionOperation.Equals, account);
            RowData rdEmployee = SessionManager.SecStaffEmployees.FindRows(query.GetXml())[0];

            return(rdEmployee);
        }
Esempio n. 4
0
    //im private RowData GetExistObject(Guid mode, string alias, string value)
    private RowDataCollection GetExistObject(Guid mode, string alias, string value)
    {
        if (string.IsNullOrEmpty(alias) || string.IsNullOrEmpty(value) || mode == null || mode == Guid.Empty)
        {
            return(null);
        }
        try
        {
            CardData    refStaffData = Session.CardManager.GetDictionaryData(RefStaff.ID);
            SectionData unitsSection = null;

            if (mode == RefStaff.Employees.ID)
            {
                unitsSection = refStaffData.Sections[RefStaff.Employees.ID];
            }
            else if (mode == RefStaff.Units.ID)
            {
                unitsSection = refStaffData.Sections[RefStaff.Units.ID];
            }
            else if (mode == RefStaff.Positions.ID)
            {
                unitsSection = refStaffData.Sections[RefStaff.Positions.ID];
            }

            if (unitsSection == null)
            {
                return(null);
            }

            SectionQuery sectionQuery = Session.CreateSectionQuery();
            sectionQuery.ConditionGroup.Conditions.AddNew(alias, FieldType.Unistring, ConditionOperation.Equals, value);

            RowDataCollection employeeCollection = unitsSection.FindRows(sectionQuery.GetXml());
            if (employeeCollection != null && employeeCollection.Count > 0)
            {
                //im return employeeCollection[0];
                return(employeeCollection);
            }
        }
        catch (Exception ex)
        {
            return(null);
        }

        return(null);
    }
Esempio n. 5
0
    private void UpdateEmployeePosition(RowData employeeDocsvision, CardData refStaffData, string titleId, string title)
    {
        SectionData  positionSection      = refStaffData.Sections[RefStaff.Positions.ID];
        SectionQuery sectionQueryPosition = Session.CreateSectionQuery();

        // Добавление условия поиска по дате создания документа
        sectionQueryPosition.ConditionGroup.Conditions.AddNew(RefStaff.Positions.Name, FieldType.Unistring,
                                                              ConditionOperation.Equals, title);

        RowDataCollection positionCollection = positionSection.FindRows(sectionQueryPosition.GetXml());

        if (positionCollection.Count > 0)
        {
            //logger.Info("Должность сотрудника обновлена");
            employeeDocsvision[RefStaff.Employees.Position] = positionCollection[0].Id;
        }
        else
        {
            //logger.Info("Создана новая должность. Должность сотрудника обновлена");
            employeeDocsvision[RefStaff.Employees.Position] = AddPositionManual(title, titleId);
        }
    }
Esempio n. 6
0
        public static Boolean CheckDuplication(UserSession Session, String CheckName)
        {
            logger.Info("checkName='{0}'", CheckName);

            String[] CheckNameParts = CheckName.Split('\t');
            if (CheckNameParts.Length == 2)
            {
                return(Directory.Exists(Path.Combine(ArchivePath, MyHelper.RemoveInvalidFileNameChars(CheckNameParts[0]), MyHelper.RemoveInvalidFileNameChars(CheckNameParts[1]))));
            }
            else if (CheckNameParts.Length == 3)
            {
                return(Directory.Exists(Path.Combine(ArchivePath, MyHelper.RemoveInvalidFileNameChars(CheckNameParts[0]), MyHelper.RemoveInvalidFileNameChars(CheckNameParts[1]), MyHelper.RemoveInvalidFileNameChars(CheckNameParts[2]))));
            }
            else if (CheckName.Contains("Админ"))
            {
                logger.Info("Big files permission");
                return(false);
            }
            else
            {
                CardData     UniversalCard = Session.CardManager.GetDictionaryData(RefUniversal.ID);
                SectionQuery Query_Section = UniversalCard.Session.CreateSectionQuery();
                Query_Section.ConditionGroup.Conditions.AddNew(RefUniversal.Item.Name, FieldType.Unistring, ConditionOperation.StartsWith, CheckName);
                RowDataCollection FoundItems = UniversalCard.Sections[RefUniversal.Item.ID].FindRows(Query_Section.GetXml(null, true));

                if (FoundItems.Count > 0)
                {
                    logger.Info("Запись найдена");
                    logger.Info("Идентификатор: " + FoundItems[0].Id);

                    return(true);
                }

                logger.Info("Запись не найдена");
                return(false);
            }
        }
Esempio n. 7
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("Ошибка при попытке обновить подразделение. Необходимо перезапустить сервис!");
        }
    }
Esempio n. 8
0
    private bool SearchEmployeeTest(CardData refStaffData, string code)
    {
        SectionQuery sectionQueryTest = Session.CreateSectionQuery();

        sectionQueryTest.ConditionGroup.Conditions.AddNew(RefStaff.Employees.IDCode, FieldType.Unistring,
                                                          ConditionOperation.Equals, code);

        RowDataCollection employeeCollection = refStaffData.Sections[RefStaff.Employees.ID].FindRows(sectionQueryTest.GetXml());

        return(employeeCollection.Count > 0);
    }
Esempio n. 9
0
    private void UpdateEmployeeManager(RowData employeeDocsvision, CardData refStaffData, string employeeChief)
    {
        if (employeeChief == null)
        {
            // logger.Info("Руководитель сотрудника не найден.");
            return;
        }

        SectionQuery sectionQueryEmployee = Session.CreateSectionQuery();

        sectionQueryEmployee.ConditionGroup.Conditions.AddNew(RefStaff.Employees.IDCode, FieldType.Unistring,
                                                              ConditionOperation.Equals, employeeChief);

        RowDataCollection employeeCollection = refStaffData.Sections[RefStaff.Employees.ID].FindRows(sectionQueryEmployee.GetXml());

        if (employeeCollection != null && employeeCollection.Count > 0)
        {
            employeeDocsvision[RefStaff.Units.Manager] = employeeCollection[0].Id;
            //logger.Info("Руководитель сотрудника обновлен.");
        }

        /*else
        *  {
        *   logger.Info("Руководитель сотрудника не найден.");
        *
        *  }   */
    }