/// <summary> /// Добавление выписок в БД /// </summary> /// <param name="cashBankAllUlFace">Выписки</param> /// <param name="innUl">ИНН ЮЛ</param> public void AddCashBankAllUlFace(ArrayBodyDoc cashBankAllUlFace, string innUl) { //ИНН Есть ли лицо int idUl; using (var context = new Base.Automation()) { context.Database.CommandTimeout = 120000; idUl = (from users in context.UlFaces where users.Inn == innUl select users.IdUl).SingleOrDefault(); cashBankAllUlFace.CashBankAllUlFace.ToList().ForEach(cashBank => cashBank.IdUl = idUl); } if (cashBankAllUlFace.CashBankAllUlFace[0].IdUl != 0) { //Удаляем старые записи по выписке заполняем новыми using (var contextDelete = new Base.Automation()) { contextDelete.Database.CommandTimeout = 120000; contextDelete.CashBankAllUlFaces.RemoveRange(contextDelete.CashBankAllUlFaces.Where(x => x.IdUl == idUl)); contextDelete.SaveChanges(); } XmlReadOrWrite xml = new XmlReadOrWrite(); var xsdFile = $"{ConfigurationManager.AppSettings["PathXsdScheme"]}XsdAllBodyData.xsd"; var xmlFile = $"{ConfigurationManager.AppSettings["PathDownloadTempXml"]}CashDataBank.xml"; xml.CreateXmlFile(xmlFile, cashBankAllUlFace, typeof(ArrayBodyDoc)); BulkInsertIntoDb(xsdFile, xmlFile); } //Отсутствует лицо сохранение не возможно }
/// <summary> /// Загрузка деклараций всех в БД /// </summary> /// <param name="declarationAll">Декларации</param> /// <param name="declarationData">Массив строк декларации</param> public void AddDeclarationAllModel(DeclarationAll declarationAll, ArrayBodyDoc declarationData) { if (!(from declarationAlls in Automation.DeclarationAlls where declarationAlls.RegNumDecl == declarationAll.RegNumDecl select new { DeclarationAlls = declarationAlls }).Any()) { XmlReadOrWrite xml = new XmlReadOrWrite(); var xsdFile = $"{ConfigurationManager.AppSettings["PathXsdScheme"]}XsdAllBodyData.xsd"; var xmlFile = $"{ConfigurationManager.AppSettings["PathDownloadTempXml"]}DeclarationDataAll.xml"; xml.CreateXmlFile(xmlFile, declarationData, typeof(XsdShemeSqlLoad.XsdAllBodyData.ArrayBodyDoc)); Automation.DeclarationAlls.Add(declarationAll); try { Automation.SaveChanges(); BulkInsertIntoDb(xsdFile, xmlFile); } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors) { Trace.WriteLine(validationError.Entry.Entity.ToString()); Trace.WriteLine(""); foreach (DbValidationError err in validationError.ValidationErrors) { Trace.WriteLine(err.ErrorMessage); } } } } //Обновление данных и внутренних полей не требуется }
/// <summary> /// Загрузка сведений по фактическому действию патента /// </summary> /// <param name="docPatent">Модель для загрузки сведений по фактическому действию патента</param> public void AddSvedFactPatent(ArrayBodyDoc docPatent) { var index = docPatent.SvedFactPatent[0].IdPatent; if (index != 0) { Automation.SvedFactPatents.RemoveRange(Automation.SvedFactPatents.Where(x => x.IdPatent == index)); Automation.SaveChanges(); XmlReadOrWrite xml = new XmlReadOrWrite(); var xsdFile = $"{ConfigurationManager.AppSettings["PathXsdScheme"]}XsdAllBodyData.xsd"; var xmlFile = $"{ConfigurationManager.AppSettings["PathDownloadTempXml"]}SvedFactPatent.xml"; xml.CreateXmlFile(xmlFile, docPatent, typeof(ArrayBodyDoc)); BulkInsertIntoDb(xsdFile, xmlFile); } }
/// <summary> /// Добавление в БД Книги Продаж /// </summary> /// <param name="books">Книга</param> /// <param name="bookPurchase">Книга продаж</param> public void AddBookPurchase(ref Book books, ArrayBodyDoc bookPurchase) { var book = books; bookPurchase.BookPurchase.ToList().ForEach(sales => sales.IdBook = book.IdBook); using (var contextDelete = new Base.Automation()) { contextDelete.Database.CommandTimeout = 120000; contextDelete.BookPurchases.RemoveRange(contextDelete.BookPurchases.Where(x => x.IdBook == book.IdBook)); contextDelete.SaveChanges(); } XmlReadOrWrite xml = new XmlReadOrWrite(); var xsdFile = $"{ConfigurationManager.AppSettings["PathXsdScheme"]}XsdAllBodyData.xsd"; var xmlFile = $"{ConfigurationManager.AppSettings["PathDownloadTempXml"]}bookPurchase.xml"; xml.CreateXmlFile(xmlFile, bookPurchase, typeof(ArrayBodyDoc)); BulkInsertIntoDb(xsdFile, xmlFile); UpdeteBookPurchase(ref books); }
/// <summary> /// Добавление деклараций на все /// </summary> /// <param name="declarationUl">Основа декларации</param> /// <param name="declarationData">Массив строк декларации</param> /// <param name="innUl">ИНН</param> public void AddDeclarationModel(DeclarationUl declarationUl, ArrayBodyDoc declarationData, string innUl) { using (var context = new Base.Automation()) { context.Database.CommandTimeout = 120000; var idUl = (from users in context.UlFaces where users.Inn == innUl select users.IdUl).SingleOrDefault(); declarationUl.IdUl = idUl; } if (declarationUl.IdUl != 0) { if (!(from declarationUls in Automation.DeclarationUls where declarationUls.RegNumDecl == declarationUl.RegNumDecl select new { DeclarationUls = declarationUls }).Any()) { XmlReadOrWrite xml = new XmlReadOrWrite(); var xsdFile = $"{ConfigurationManager.AppSettings["PathXsdScheme"]}XsdAllBodyData.xsd"; var xmlFile = $"{ConfigurationManager.AppSettings["PathDownloadTempXml"]}DeclarationData.xml"; xml.CreateXmlFile(xmlFile, declarationData, typeof(XsdShemeSqlLoad.XsdAllBodyData.ArrayBodyDoc)); Automation.DeclarationUls.Add(declarationUl); try { Automation.SaveChanges(); BulkInsertIntoDb(xsdFile, xmlFile); } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors) { Trace.WriteLine(validationError.Entry.Entity.ToString()); Trace.WriteLine(""); foreach (DbValidationError err in validationError.ValidationErrors) { Trace.WriteLine(err.ErrorMessage); } } } } //Обновление данных и внутренних полей не требуется } //Отсутствует лицо сохранение не возможно }
/// <summary> /// Добавление данных в выписку Внутрянка /// </summary> /// <param name="statementFull">Body Statement</param> /// <param name="innUl">ИНН</param> public void AddStatementFull(XsdShemeSqlLoad.XsdAllBodyData.ArrayBodyDoc statementFull, string innUl) { //ИНН Есть ли лицо int idUl; using (var context = new Base.Automation()) { context.Database.CommandTimeout = 120000; idUl = (from users in context.UlFaces where users.Inn == innUl select users.IdUl).SingleOrDefault(); statementFull.StatementData.ToList().ForEach(state => state.IdUl = idUl); } if (statementFull.StatementData[0].IdUl != 0) { ////Удаляем старые записи по выписке заполняем новыми using (var contextDelete = new Base.Automation()) { contextDelete.Database.CommandTimeout = 120000; contextDelete.StatementFulls.RemoveRange(contextDelete.StatementFulls.Where(x => x.IdUl == idUl)); contextDelete.SaveChanges(); } XmlReadOrWrite xml = new XmlReadOrWrite(); var xsdFile = $"{ConfigurationManager.AppSettings["PathXsdScheme"]}XsdAllBodyData.xsd"; var xmlFile = $"{ConfigurationManager.AppSettings["PathDownloadTempXml"]}DeclarationData.xml"; xml.CreateXmlFile(xmlFile, statementFull, typeof(ArrayBodyDoc)); BulkInsertIntoDb(xsdFile, xmlFile); } //Процедура вытягивания учредителей и Руководителей Цель Выписки и Карточки организации var logicModel = Automation.LogicsSelectAutomations.FirstOrDefault(logic => logic.Id == 9); if (logicModel != null) { using (var context = new Base.Automation()) { context.Database.CommandTimeout = 120000; var resultDb = context.Database.SqlQuery <string>(logicModel.SelectUser, new SqlParameter(logicModel.SelectedParametr.Split(',')[0], innUl)).FirstOrDefault(); } } }
public void AllIpTelephoneAndMacAdress() { var ipModel = "10.77.67.{0}"; var i = 2; var listIp = new List <IpAndMac>(); var xmlWrite = new XmlReadOrWrite(); while (i < 255) { var mac = new IpAndMac(); var ipAdress = string.Format(ipModel, i); try { IPAddress[] address = Dns.GetHostAddresses(ipAdress); byte[] ab = new byte[6]; int len = ab.Length; SendARP(BitConverter.ToInt32(address[0].GetAddressBytes(), 0), 0, ab, ref len); string[] macAddressString = new string[(int)len]; for (int j = 0; j < len; j++) { macAddressString[i] = ab[i].ToString("x2"); } mac.Ip = ipAdress; mac.Mac = string.Join(":", macAddressString); } catch (Exception exception) { mac.Ip = ipAdress; mac.Mac = "Mac не определен"; } i++; listIp.Add(mac); } xmlWrite.CreateXmlFile("D:\\Telephone.xml", listIp, typeof(List <IpAndMac>)); }