Example #1
0
        public static bool IsHoliday(this DateTime originalDate)
        {
            SelectSql select    = new SelectSql();
            var       isHoliday = select.IsHolidays(originalDate);

            select.Dispose();
            return(isHoliday);
        }
Example #2
0
        /// <summary>
        /// Получение модели из БД
        /// </summary>
        /// <param name="report">Отчет</param>
        public void ReportInvoice(ref EfDatabaseInvoice.Report report)
        {
            SelectSql select = new SelectSql();

            AddObjectDb.AddObjectDb adddoc = new AddObjectDb.AddObjectDb();
            select.ReportInvoice(ref report);
            report.Main.Barcode    = new Barcode();
            report.Main.Barcode.Id = adddoc.AddDocument(report.ParamRequest.IdNameDocument, report.Main.Received.NameUser, report.ParamRequest.IdUsers);
        }
Example #3
0
        /// <summary>
        /// Выгрузка ролей пользователя
        /// </summary>
        /// <param name="idUser">УН пользователя</param>
        /// <returns></returns>
        public RuleUsers[] AllRuleUser(int idUser)
        {
            SelectSql   sql   = new SelectSql();
            ModelSelect model = new ModelSelect {
                LogicaSelect = sql.SqlSelectModel(34)
            };

            sql.Dispose();
            var ruleAndUser = Inventory.Database.SqlQuery <RuleUsers>(model.LogicaSelect.SelectUser,
                                                                      new SqlParameter(model.LogicaSelect.SelectedParametr.Split(',')[0], idUser)).ToArray();

            return(ruleAndUser);
        }
Example #4
0
        /// <summary>
        /// Получение данных для личного кабинета пользователя инвенторизации
        /// </summary>
        /// <param name="idUser">Ун пользователя</param>
        /// <returns></returns>
        public string AllTechicsLkInventory(int idUser)
        {
            SerializeJson json  = new SerializeJson();
            SelectSql     sql   = new SelectSql();
            ModelSelect   model = new ModelSelect {
                LogicaSelect = sql.SqlSelectModel(33)
            };
            var idDepartment = Inventory.Database.SqlQuery <int>(model.LogicaSelect.SelectUser,
                                                                 new SqlParameter(model.LogicaSelect.SelectedParametr.Split(',')[0], idUser)).FirstOrDefault();

            sql.Dispose();
            if (idDepartment != 0)
            {
                return(json.JsonLibaryIgnoreDate(Inventory.AllTechnics.Where(x => x.IdOtdel == idDepartment)));
            }
            return(json.JsonLibaryIgnoreDate(Inventory.AllTechnics.Where(x => x.IdUser == idUser)));
        }
Example #5
0
        /// <summary>
        /// Генерация параметров для запроса на СТО
        /// </summary>
        /// <param name="modelSupport">Модель запроса на сервис</param>
        public void GenerateTemplateUrlParameter(ref ModelParametrSupport modelSupport)
        {
            SelectSql select = new SelectSql();

            ModelSelect model = new ModelSelect {
                LogicaSelect = select.SqlSelectModel(28)
            };

            if (modelSupport.IdSysBlock == 0)
            {
                var idUser = modelSupport.IdUser;
                modelSupport.IdSysBlock = Inventory.SysBlocks.Where(x => x.IdUser == idUser).Select(sel => sel.IdSysBlock).FirstOrDefault();
            }
            modelSupport.TemplateSupport = Inventory.Database.SqlQuery <TemplateSupport1>(model.LogicaSelect.SelectUser,
                                                                                          new SqlParameter(model.LogicaSelect.SelectedParametr.Split(',')[0], modelSupport.IdTemplate)).ToArray();
            if (modelSupport?.TemplateSupport != null && modelSupport?.TemplateSupport.Length > 0)
            {
                var description = modelSupport.Discription;
                modelSupport.TemplateSupport.Where(discription => discription.NameGuidParametr == "UF_DESCRIPTION").ToList().ForEach(d => d.Parametr = description);
                var modelParameterInput = modelSupport.TemplateSupport.Where(temple => temple.NameStepSupport == "Step2" && temple.TemplateParametrType != null);

                foreach (var template in modelParameterInput)
                {
                    if (template.TemplateParametrType.Equals("User") && modelSupport.IdUser != 0)
                    {
                        template.Parametr = Inventory.Database.SqlQuery <string>(template.SelectParametr,
                                                                                 new SqlParameter("IdUser", modelSupport.IdUser)).FirstOrDefault();
                    }
                    if (template.TemplateParametrType.Equals("SysBlock") && modelSupport.IdSysBlock != 0)
                    {
                        template.Parametr = Inventory.Database.SqlQuery <string>(template.SelectParametr,
                                                                                 new SqlParameter("IdSysBlock", modelSupport.IdSysBlock)).FirstOrDefault();
                    }
                    if (template.TemplateParametrType.Equals("Monitors") && modelSupport.IdMonitor != 0)
                    {
                        template.Parametr = Inventory.Database.SqlQuery <string>(template.SelectParametr,
                                                                                 new SqlParameter("IdMonitor", modelSupport.IdMonitor)).FirstOrDefault();
                    }
                    if (template.TemplateParametrType.Equals("Printer") && modelSupport.IdPrinter != 0)
                    {
                        template.Parametr = Inventory.Database.SqlQuery <string>(template.SelectParametr,
                                                                                 new SqlParameter("IdPrinter", modelSupport.IdPrinter)).FirstOrDefault();
                    }
                    if (template.TemplateParametrType.Equals("Mfu") && modelSupport.IdMfu != 0)
                    {
                        template.Parametr = Inventory.Database.SqlQuery <string>(template.SelectParametr,
                                                                                 new SqlParameter("IdMfu", modelSupport.IdMfu)).FirstOrDefault();
                    }
                    if (template.TemplateParametrType.Equals("Scanner") && modelSupport.IdScanner != 0)
                    {
                        template.Parametr = Inventory.Database.SqlQuery <string>(template.SelectParametr,
                                                                                 new SqlParameter("IdScaner", modelSupport.IdScanner)).FirstOrDefault();
                    }
                    if (template.TemplateParametrType.Equals("Telephon") && modelSupport.IdTelephon != 0)
                    {
                        template.Parametr = Inventory.Database.SqlQuery <string>(template.SelectParametr,
                                                                                 new SqlParameter("IdTelephon", modelSupport.IdTelephon)).FirstOrDefault();
                    }
                    if (template.TemplateParametrType.Equals("DomainUser") && modelSupport.IdUser != 0)
                    {
                        var personnelNumberAndGroupOtdel = Inventory.Database.SqlQuery <string>(template.SelectParametr,
                                                                                                new SqlParameter("IdUser", modelSupport.IdUser)).FirstOrDefault();
                        if (template.NameParametrType.Equals("Group"))
                        {
                            template.Parametr = FindGroupAccess(personnelNumberAndGroupOtdel).Aggregate((element, next) => element + (string.IsNullOrWhiteSpace(element) ? string.Empty : ",") + next);
                        }
                        if (template.NameParametrType.Equals("GroupOtdel"))
                        {
                            template.Parametr = FindIdentytyGroup(personnelNumberAndGroupOtdel.Replace("№", "№ "));
                        }

                        if (template.NameParametrType.Contains("GroupOtdelBoss"))
                        {
                            template.Parametr = FindFullPathActiveDirectory(personnelNumberAndGroupOtdel);
                        }
                    }
                    if (template.TemplateParametrType.Equals("DomainSysBlock") && modelSupport.IdSysBlock != 0)
                    {
                        var nameComputer = Inventory.Database.SqlQuery <string>(template.SelectParametr, new SqlParameter("IdSysBlock", modelSupport.IdSysBlock)).FirstOrDefault();
                        var parameters   = template.Parametr.Split('/');
                        template.Parametr = IsCheckComputer(nameComputer) ? parameters[0] : parameters[1];
                    }
                }
            }
            else
            {
                throw new InvalidOperationException($"Фатальная ошибка отсутствует шаблон запроса на CTO по id {modelSupport.IdTemplate}!");
            }
            select.Dispose();
        }