public Transaction() { order = new Order(); payer = new Payer(); creditCard = new CreditCard(); extraParameters = new ExtraParameters(); }
protected bool Equals(PaginatedRequestParams other) { return(Start.Equals(other.Start) && End.Equals(other.End) && Limit == other.Limit && Direction == other.Direction && ExtraParameters.SequenceEqual(other.ExtraParameters)); }
public override int GetHashCode() { unchecked { var hashCode = Start.GetHashCode(); hashCode = (hashCode * 397) ^ End.GetHashCode(); hashCode = (hashCode * 397) ^ Limit.GetHashCode(); hashCode = (hashCode * 397) ^ (int)Direction; hashCode = (hashCode * 397) ^ (ExtraParameters != null ? ExtraParameters.GetHashCode() : 0); return(hashCode); } }
public void AddExtra(ExtraParameters parameters) { if (null != m_telemetryObject) { m_telemetry.mask |= FSMI_TEL_BIT.EXTRA_YAW_PITCH_ROLL_SWAY_HEAVE_SURGE; m_telemetry.extraYaw = parameters.yaw; m_telemetry.extraPitch = parameters.pitch; m_telemetry.extraRoll = parameters.roll; m_telemetry.extraSway = parameters.sway; m_telemetry.extraHeave = parameters.heave; m_telemetry.extraSurge = parameters.surge; } }
public QueryResponse DoSearch(MovieQuery query) { //Create an object to hold results FiltersFacets filtersFacets = new FiltersFacets(); Highlights highlights = new Highlights(); ExtraParameters extraParameters = new ExtraParameters(); SolrQueryResults <Movie> solrResults; QueryResponse queryResponse = new QueryResponse { //Echo back the original query OriginalQuery = query }; //Get a connection ISolrOperations <Movie> solr = connection.GetSolrInstance(); QueryOptions queryOptions = new QueryOptions { Rows = query.Rows, StartOrCursor = new StartOrCursor.Start(query.Start), FilterQueries = filtersFacets.BuildFilterQueries(query), Facet = filtersFacets.BuildFacets(), Highlight = highlights.BuildHighlightParameters(), ExtraParams = extraParameters.BuildExtraParameters() }; //Execute the query ISolrQuery solrQuery = new SolrQuery(query.Query); solrResults = solr.Query(solrQuery, queryOptions); //Set response ResponseExtraction extractResponse = new ResponseExtraction(); extractResponse.SetHeader(queryResponse, solrResults); extractResponse.SetBody(queryResponse, solrResults); extractResponse.SetSpellcheck(queryResponse, solrResults); extractResponse.SetFacets(queryResponse, solrResults); //Return response; return(queryResponse); }
public static ExtraParameters DeSerializeExtraParameters(byte[] buffer, ref int offset, int length) { ExtraParameters parameters = new ExtraParameters(); byte nParameters = buffer[offset++]; for (int i = 0; i < nParameters; i++) { ExtraParameterType type = (ExtraParameterType)BinarySerializer.DeSerializeUInt16_Le(buffer, ref offset, length); int len = (int)BinarySerializer.DeSerializeUInt32_Le(buffer, ref offset, length); int paramLimit = offset + len; switch (type) { case ExtraParameterType.Light: parameters.LightParameter = DeSerializeLightParameter(buffer, ref offset, paramLimit); break; case ExtraParameterType.Flexible: parameters.FlexibleObjectData = DeSerializeFlexibleObjectData(buffer, ref offset, paramLimit); break; case ExtraParameterType.Mesh: // A Mesh is a Sculpt with SculptType = Mesh case ExtraParameterType.Sculpt: parameters.SculptParams = DeSerializeSculptParams(buffer, ref offset, paramLimit); break; case ExtraParameterType.LightImage: parameters.LightImageParams = DeSerializeLightImageParams(buffer, ref offset, paramLimit); break; case ExtraParameterType.ExtendedMesh: parameters.ExtendedMeshParams = DeSerializeExtendedMeshParams(buffer, ref offset, paramLimit); break; default: Logger.LogWarning("ObjectUpdateCompressedMessage.DeSerialise", $"Unknown ExtraParameterType: {type}"); offset += len; break; } } return(parameters); }
public IDbCommand GetCmd <T>(string sqlTxt, T obj, CommandType cmdType = CommandType.Text) { if (_parameters == null) { _parameters = Object2Parameter(obj); } var sqlCmd = new SqlCommand(); foreach (var p in _parameters) { sqlCmd.Parameters.Add(p); } if (ExtraParameters != null) { sqlCmd.Parameters.AddRange(ExtraParameters.ToArray()); } sqlCmd.CommandText = sqlTxt; sqlCmd.CommandType = cmdType; sqlCmd.CommandTimeout = _cmdTimeOut; return(sqlCmd); }
public override string ToString() { var builder = new StringBuilder($"Error ( Id = {Identifier}, Messages = "); if (!ExtraParameters.Any()) builder.Append("'none' )"); else { foreach (var message in ExtraParameters) { string errorMessage; var type = message.Value.GetType(); if (type != typeof(string) && type.GetTypeInfo().GetInterface("IEnumerable") != null) { errorMessage = string.Join(", ", (IEnumerable<object>) message.Value); } else errorMessage = message.Value.ToString(); builder.Append($"ErrorMessage ( Key = {message.Key}, Message = {errorMessage} ), "); } builder.Remove(builder.Length - 2, 2); } return builder.ToString(); }
/// <summary> /// Сохранение сущности в RX. /// </summary> /// <param name="shift">Сдвиг по горизонтали в XLSX документе. Необходим для обработки документов, составленных из элементов разных сущностей.</param> /// <param name="logger">Логировщик.</param> /// <returns>Число запрашиваемых параметров.</returns> public override IEnumerable <Structures.ExceptionsStruct> SaveToRX(NLog.Logger logger, int shift = 0) { var exceptionList = new List <Structures.ExceptionsStruct>(); using (var session = new Session()) { var regNumber = this.Parameters[shift + 0]; var regDate = DateTime.MinValue; var style = NumberStyles.Number | NumberStyles.AllowCurrencySymbol; var culture = CultureInfo.CreateSpecificCulture("en-GB"); var regDateDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 1]) && !double.TryParse(this.Parameters[shift + 1].Trim(), style, culture, out regDateDouble)) { var message = string.Format("Не удалось обработать дату регистрации \"{0}\".", this.Parameters[shift + 1]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 1].ToString())) { regDate = DateTime.FromOADate(regDateDouble); } } var counterparty = BusinessLogic.GetConterparty(session, this.Parameters[shift + 2], exceptionList, logger); if (counterparty == null) { var message = string.Format("Не найден контрагент \"{0}\".", this.Parameters[shift + 2]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var documentKind = BusinessLogic.GetDocumentKind(session, this.Parameters[shift + 3], exceptionList, logger); if (documentKind == null) { var message = string.Format("Не найден вид документа \"{0}\".", this.Parameters[shift + 3]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var subject = this.Parameters[shift + 4]; var department = BusinessLogic.GetDepartment(session, this.Parameters[shift + 5], exceptionList, logger); if (department == null) { var message = string.Format("Не найдено подразделение \"{0}\".", this.Parameters[shift + 5]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var filePath = this.Parameters[shift + 6]; var dated = DateTime.MinValue; var datedDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 7]) && !double.TryParse(this.Parameters[shift + 7].Trim(), style, culture, out datedDouble)) { var message = string.Format("Не удалось обработать значение в поле \"Письмо от\" \"{0}\".", this.Parameters[shift + 7]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 7].ToString())) { dated = DateTime.FromOADate(datedDouble); } } var inNumber = this.Parameters[shift + 8]; var addressee = BusinessLogic.GetEmployee(session, this.Parameters[shift + 9], exceptionList, logger); var note = this.Parameters[shift + 10]; try { var incomingLetters = Enumerable.ToList(session.GetAll <Sungero.RecordManagement.IIncomingLetter>().Where(x => x.RegistrationNumber == regNumber && regDate != DateTime.MinValue && x.RegistrationDate == regDate)); var incomingLetter = (Enumerable.FirstOrDefault <Sungero.RecordManagement.IIncomingLetter>(incomingLetters)); if (incomingLetter != null) { var message = string.Format("Входящее письмо не может быть импортировано. Найден дубль с такими же реквизитами \"Дата документа\" {0} и \"Рег. №\" {1}.", regDate.ToString("d"), regNumber); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } incomingLetter = session.Create <Sungero.RecordManagement.IIncomingLetter>(); if (regDate != DateTime.MinValue) { incomingLetter.RegistrationDate = regDate; } incomingLetter.RegistrationNumber = regNumber; incomingLetter.Correspondent = counterparty; incomingLetter.DocumentKind = documentKind; incomingLetter.Subject = subject; incomingLetter.Department = department; if (department != null) { incomingLetter.BusinessUnit = department.BusinessUnit; } if (dated != DateTime.MinValue) { incomingLetter.Dated = dated; } incomingLetter.InNumber = inNumber; incomingLetter.Addressee = addressee; incomingLetter.Note = note; incomingLetter.Save(); if (!string.IsNullOrWhiteSpace(filePath)) { exceptionList.Add(BusinessLogic.ImportBody(session, incomingLetter, filePath, logger)); } var documentRegisterId = 0; if (ExtraParameters.ContainsKey("doc_register_id")) { if (int.TryParse(ExtraParameters["doc_register_id"], out documentRegisterId)) { exceptionList.AddRange(BusinessLogic.RegisterDocument(session, incomingLetter, documentRegisterId, regNumber, regDate, Constants.RolesGuides.RoleIncomingDocumentsResponsible, logger)); } else { var message = string.Format("Не удалось обработать параметр \"doc_register_id\". Полученное значение: {0}.", ExtraParameters["doc_register_id"]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } } } catch (Exception ex) { exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = ex.Message }); return(exceptionList); } session.SubmitChanges(); } return(exceptionList); }
public XDocument ToXDocument() => new XDocument(new XElement("root", ExtraParameters.Select(ToAttribute).Concat(Children.Select(ToElement).ToArray())));
/// <summary> /// Сохранение сущности в RX. /// </summary> /// <param name="shift">Сдвиг по горизонтали в XLSX документе. Необходим для обработки документов, составленных из элементов разных сущностей.</param> /// <param name="logger">Логировщик.</param> /// <returns>Число запрашиваемых параметров.</returns> public override IEnumerable <Structures.ExceptionsStruct> SaveToRX(NLog.Logger logger, int shift = 0) { var exceptionList = new List <Structures.ExceptionsStruct>(); using (var session = new Session()) { var regNumber = this.Parameters[shift + 0]; var regDate = DateTime.MinValue; var style = NumberStyles.Number | NumberStyles.AllowCurrencySymbol; var culture = CultureInfo.CreateSpecificCulture("en-GB"); var regDateDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 1]) && !double.TryParse(this.Parameters[shift + 1].Trim(), style, culture, out regDateDouble)) { var message = string.Format("Не удалось обработать дату регистрации \"{0}\".", this.Parameters[shift + 1]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 1].ToString())) { regDate = DateTime.FromOADate(regDateDouble); } } var regNumberLeadingDocument = this.Parameters[shift + 2]; var regDateLeadingDocument = DateTime.MinValue; var regDateLeadingDocumentDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 3]) && !double.TryParse(this.Parameters[shift + 3].Trim(), style, culture, out regDateLeadingDocumentDouble)) { var message = string.Format("Не удалось обработать дату регистрации ведущего документа \"{0}\".", this.Parameters[shift + 3]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 3].ToString())) { regDateLeadingDocument = DateTime.FromOADate(regDateLeadingDocumentDouble); } } var counterparty = BusinessLogic.GetConterparty(session, this.Parameters[shift + 4], exceptionList, logger); if (counterparty == null) { var message = string.Format("Не найден контрагент \"{0}\".", this.Parameters[shift + 4]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var documentKind = BusinessLogic.GetDocumentKind(session, this.Parameters[shift + 5], exceptionList, logger); if (documentKind == null) { var message = string.Format("Не найден вид документа \"{0}\".", this.Parameters[shift + 5]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var subject = this.Parameters[shift + 6]; var department = BusinessLogic.GetDepartment(session, this.Parameters[shift + 7], exceptionList, logger); if (department == null) { var message = string.Format("Не найдено подразделение \"{0}\".", this.Parameters[shift + 7]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var filePath = this.Parameters[shift + 8]; DateTime?validFrom = new DateTime(); var validFromDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 9]) && !double.TryParse(this.Parameters[shift + 9].Trim(), style, culture, out validFromDouble)) { var message = string.Format("Не удалось обработать значение в поле \"Действует с\" \"{0}\".", this.Parameters[shift + 9]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 9].ToString())) { validFrom = DateTime.FromOADate(validFromDouble); } else { validFrom = null; } } DateTime?validTill = new DateTime(); var validTillDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 10]) && !double.TryParse(this.Parameters[shift + 10].Trim(), style, culture, out validTillDouble)) { var message = string.Format("Не удалось обработать значение в поле \"Действует по\" \"{0}\".", this.Parameters[shift + 10]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 10].ToString())) { validTill = DateTime.FromOADate(validTillDouble); } else { validTill = null; } } var totalAmount = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 11]) && !double.TryParse(this.Parameters[shift + 11].Trim(), style, culture, out totalAmount)) { var message = string.Format("Не удалось обработать значение в поле \"Сумма\" \"{0}\".", this.Parameters[shift + 11]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var currency = BusinessLogic.GetCurrency(session, this.Parameters[shift + 12], exceptionList, logger); if (currency == null) { var message = string.Format("Не найдено соответствующее наименование валюты \"{0}\".", this.Parameters[shift + 12]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var lifeCycleState = BusinessLogic.GetPropertyLifeCycleState(session, this.Parameters[shift + 13]); if (lifeCycleState == null) { var message = string.Format("Не найдено соответствующее значение состояния \"{0}\".", this.Parameters[shift + 13]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var responsibleEmployee = BusinessLogic.GetEmployee(session, this.Parameters[shift + 14], exceptionList, logger); var ourSignatory = BusinessLogic.GetEmployee(session, this.Parameters[shift + 15], exceptionList, logger); var note = this.Parameters[shift + 16]; try { var supAgreements = Enumerable.ToList(session.GetAll <Sungero.Contracts.ISupAgreement>().Where(x => x.RegistrationNumber == regNumber)); var supAgreement = (Enumerable.FirstOrDefault <Sungero.Contracts.ISupAgreement>(supAgreements)); if (supAgreement != null) { var message = string.Format("Доп.соглашение не может быть импортировано. Найден дубль с такими же реквизитами \"Дата документа\" {0} и \"Рег. №\" {1}.", regDate.ToString("d"), regNumber); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var contracts = Enumerable.ToList(session.GetAll <Sungero.Contracts.IContract>().Where(x => x.RegistrationDate == regDateLeadingDocument && x.RegistrationNumber == regNumberLeadingDocument)); var leadingDocument = (Enumerable.FirstOrDefault <Sungero.Contracts.IContract>(contracts)); if (leadingDocument == null) { var message = string.Format("Доп.соглашение не может быть импортировано. Не найден ведущий документ с реквизитами \"Дата документа\" {0} и \"Рег. №\" {1}.", regDateLeadingDocument.ToString("d"), regNumberLeadingDocument); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } // HACK: Создаем 2 сессии. В первой загружаем данные, во второй создаем объект системы. supAgreement = session.Create <Sungero.Contracts.ISupAgreement>(); session.Clear(); session.Dispose(); supAgreement.LeadingDocument = leadingDocument; using (var session1 = new Session()) { supAgreement.Counterparty = counterparty; if (regDate != DateTime.MinValue) { supAgreement.RegistrationDate = regDate; } supAgreement.RegistrationNumber = regNumber; supAgreement.DocumentKind = documentKind; supAgreement.Subject = subject; supAgreement.Department = department; supAgreement.ValidFrom = validFrom; supAgreement.ValidTill = validTill; supAgreement.TotalAmount = totalAmount; supAgreement.Currency = currency; supAgreement.LifeCycleState = lifeCycleState; supAgreement.ResponsibleEmployee = responsibleEmployee; supAgreement.OurSignatory = ourSignatory; supAgreement.Note = note; supAgreement.Save(); session1.SubmitChanges(); } if (!string.IsNullOrWhiteSpace(filePath)) { exceptionList.Add(BusinessLogic.ImportBody(session, supAgreement, filePath, logger)); } var documentRegisterId = 0; if (ExtraParameters.ContainsKey("doc_register_id")) { if (int.TryParse(ExtraParameters["doc_register_id"], out documentRegisterId)) { exceptionList.AddRange(BusinessLogic.RegisterDocument(session, supAgreement, documentRegisterId, regNumber, regDate, Constants.RolesGuides.RoleContractResponsible, logger)); } else { var message = string.Format("Не удалось обработать параметр \"doc_register_id\". Полученное значение: {0}.", ExtraParameters["doc_register_id"]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } } } catch (Exception ex) { exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = ex.Message }); return(exceptionList); } } return(exceptionList); }
/// <summary> /// Сохранение сущности в RX. /// </summary> /// <param name="shift">Сдвиг по горизонтали в XLSX документе. Необходим для обработки документов, составленных из элементов разных сущностей.</param> /// <param name="logger">Логировщик.</param> /// <returns>Число запрашиваемых параметров.</returns> public override IEnumerable <Structures.ExceptionsStruct> SaveToRX(NLog.Logger logger, bool supplementEntity, int shift = 0) { var exceptionList = new List <Structures.ExceptionsStruct>(); using (var session = new Session()) { var regNumber = this.Parameters[shift + 0]; DateTime?regDate = DateTime.MinValue; var style = NumberStyles.Number | NumberStyles.AllowCurrencySymbol; var culture = CultureInfo.CreateSpecificCulture("en-GB"); var regDateDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 1]) && !double.TryParse(this.Parameters[shift + 1].Trim(), style, culture, out regDateDouble)) { var message = string.Format("Не удалось обработать дату регистрации \"{0}\".", this.Parameters[shift + 1]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 1].ToString())) { regDate = DateTime.FromOADate(regDateDouble); } } var counterparty = BusinessLogic.GetConterparty(session, this.Parameters[shift + 2], exceptionList, logger); if (counterparty == null) { var message = string.Format("Не найден контрагент \"{0}\".", this.Parameters[shift + 2]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var documentKind = BusinessLogic.GetDocumentKind(session, this.Parameters[shift + 3], exceptionList, logger); if (documentKind == null) { var message = string.Format("Не найден вид документа \"{0}\".", this.Parameters[shift + 3]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var contractCategory = BusinessLogic.GetContractCategory(session, this.Parameters[shift + 4], exceptionList, logger); if (!string.IsNullOrEmpty(this.Parameters[shift + 4].ToString())) { if (contractCategory == null) { var message = string.Format("Не найдена категория договора \"{0}\".", this.Parameters[shift + 4]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } } var subject = this.Parameters[shift + 5]; var businessUnit = BusinessLogic.GetBusinessUnit(session, this.Parameters[shift + 6], exceptionList, logger); if (businessUnit == null) { var message = string.Format("Не найдено подразделение \"{0}\".", this.Parameters[shift + 6]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var department = BusinessLogic.GetDepartment(session, this.Parameters[shift + 7], exceptionList, logger); if (department == null) { var message = string.Format("Не найдено подразделение \"{0}\".", this.Parameters[shift + 7]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var filePath = this.Parameters[shift + 8]; DateTime?validFrom = DateTime.MinValue; var validFromDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 9]) && !double.TryParse(this.Parameters[shift + 9].Trim(), style, culture, out validFromDouble)) { var message = string.Format("Не удалось обработать значение в поле \"Действует с\" \"{0}\".", this.Parameters[shift + 9]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 9].ToString())) { validFrom = DateTime.FromOADate(validFromDouble); } } DateTime?validTill = DateTime.MinValue; var validTillDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 10]) && !double.TryParse(this.Parameters[shift + 10].Trim(), style, culture, out validTillDouble)) { var message = string.Format("Не удалось обработать значение в поле \"Действует по\" \"{0}\".", this.Parameters[shift + 10]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 10].ToString())) { validTill = DateTime.FromOADate(validTillDouble); } } var totalAmount = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 11]) && !double.TryParse(this.Parameters[shift + 11].Trim(), style, culture, out totalAmount)) { var message = string.Format("Не удалось обработать значение в поле \"Сумма\" \"{0}\".", this.Parameters[shift + 11]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var currency = BusinessLogic.GetCurrency(session, this.Parameters[shift + 12], exceptionList, logger); if (!string.IsNullOrEmpty(this.Parameters[shift + 12].Trim()) && currency == null) { var message = string.Format("Не найдено соответствующее наименование валюты \"{0}\".", this.Parameters[shift + 12]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var lifeCycleState = BusinessLogic.GetPropertyLifeCycleState(session, this.Parameters[shift + 13]); if (!string.IsNullOrEmpty(this.Parameters[shift + 13].Trim()) && lifeCycleState == null) { var message = string.Format("Не найдено соответствующее значение состояния \"{0}\".", this.Parameters[shift + 13]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var responsibleEmployee = BusinessLogic.GetEmployee(session, this.Parameters[shift + 14].Trim(), exceptionList, logger); if (!string.IsNullOrEmpty(this.Parameters[shift + 14].Trim()) && responsibleEmployee == null) { var message = string.Format("Не найден Ответственный \"{3}\". Договор: \"{0} {1} {2}\". ", regNumber, regDate.ToString(), counterparty, this.Parameters[shift + 14].Trim()); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Warn, Message = message }); logger.Warn(message); } var ourSignatory = BusinessLogic.GetEmployee(session, this.Parameters[shift + 15].Trim(), exceptionList, logger); if (!string.IsNullOrEmpty(this.Parameters[shift + 15].Trim()) && ourSignatory == null) { var message = string.Format("Не найден Подписывающий \"{3}\". Договор: \"{0} {1} {2}\". ", regNumber, regDate.ToString(), counterparty, this.Parameters[shift + 15].Trim()); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Warn, Message = message }); logger.Warn(message); } var note = this.Parameters[shift + 16]; try { var contracts = Enumerable.ToList(session.GetAll <Sungero.Contracts.IContract>().Where(x => Equals(x.RegistrationNumber, regNumber) && Equals(x.RegistrationDate, regDate) && Equals(x.Counterparty, counterparty))); var contract = (Enumerable.FirstOrDefault <Sungero.Contracts.IContract>(contracts)); if (contract != null) { var message = string.Format("Договор не может быть импортирован. Найден дубль с такими же реквизитами \"Рег. №\" {0}, \"Дата документа\" {1}, \"Контрагент\" {2}.", regNumber, regDate.ToString(), counterparty.ToString()); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } contract = session.Create <Sungero.Contracts.IContract>(); contract.Counterparty = counterparty; contract.DocumentKind = documentKind; contract.DocumentGroup = contractCategory; contract.Subject = subject; contract.BusinessUnit = businessUnit; contract.Department = department; if (validFrom != DateTime.MinValue) { contract.ValidFrom = validFrom; } if (validTill != DateTime.MinValue) { contract.ValidTill = validTill; } contract.TotalAmount = totalAmount; contract.Currency = currency; contract.LifeCycleState = lifeCycleState; contract.ResponsibleEmployee = responsibleEmployee; contract.OurSignatory = ourSignatory; contract.Note = note; if (regDate != DateTime.MinValue) { contract.RegistrationDate = regDate; } contract.RegistrationNumber = regNumber; contract.Save(); if (!string.IsNullOrWhiteSpace(filePath)) { exceptionList.Add(BusinessLogic.ImportBody(session, contract, filePath, logger)); } var documentRegisterId = 0; if (ExtraParameters.ContainsKey("doc_register_id")) { if (int.TryParse(ExtraParameters["doc_register_id"], out documentRegisterId)) { exceptionList.AddRange(BusinessLogic.RegisterDocument(session, contract, documentRegisterId, regNumber, regDate, Constants.RolesGuides.RoleContractResponsible, logger)); } else { var message = string.Format("Не удалось обработать параметр \"doc_register_id\". Полученное значение: {0}.", ExtraParameters["doc_register_id"]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } } } catch (Exception ex) { exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = ex.Message }); return(exceptionList); } session.SubmitChanges(); } return(exceptionList); }
/// <summary> /// Сохранение сущности в RX. /// </summary> /// <param name="shift">Сдвиг по горизонтали в XLSX документе. Необходим для обработки документов, составленных из элементов разных сущностей.</param> /// <param name="logger">Логировщик.</param> /// <returns>Число запрашиваемых параметров.</returns> public override IEnumerable <Structures.ExceptionsStruct> SaveToRX(NLog.Logger logger, bool supplementEntity, int shift = 0) { var exceptionList = new List <Structures.ExceptionsStruct>(); using (var session = new Session()) { var regNumber = this.Parameters[shift + 0]; DateTime?regDate = null; var style = NumberStyles.Number | NumberStyles.AllowCurrencySymbol; var culture = CultureInfo.CreateSpecificCulture("en-GB"); var regDateDouble = 0.0; if (!string.IsNullOrWhiteSpace(this.Parameters[shift + 1]) && !double.TryParse(this.Parameters[shift + 1].Trim(), style, culture, out regDateDouble)) { var message = string.Format("Не удалось обработать дату регистрации \"{0}\".", this.Parameters[shift + 1]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } else { if (!string.IsNullOrEmpty(this.Parameters[shift + 1].ToString())) { regDate = DateTime.FromOADate(regDateDouble); } } var documentKind = BusinessLogic.GetDocumentKind(session, this.Parameters[shift + 2], exceptionList, logger); if (documentKind == null) { var message = string.Format("Не найден вид документа \"{0}\".", this.Parameters[shift + 2]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var subject = this.Parameters[shift + 3]; var businessUnit = BusinessLogic.GetBusinessUnit(session, this.Parameters[shift + 4], exceptionList, logger); if (businessUnit == null) { var message = string.Format("Не найдена НОР \"{0}\".", this.Parameters[shift + 4]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var department = BusinessLogic.GetDepartment(session, this.Parameters[shift + 5], exceptionList, logger); if (department == null) { var message = string.Format("Не найдено подразделение \"{0}\".", this.Parameters[shift + 5]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var filePath = this.Parameters[shift + 6]; var assignee = BusinessLogic.GetEmployee(session, this.Parameters[shift + 7].Trim(), exceptionList, logger); if (!string.IsNullOrEmpty(this.Parameters[shift + 7].Trim()) && assignee == null) { var message = string.Format("Не найден Исполнитель \"{2}\". Приказ: \"{0} {1}\". ", regNumber, regDate.ToString(), this.Parameters[shift + 7].Trim()); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Warn, Message = message }); logger.Warn(message); } var preparedBy = BusinessLogic.GetEmployee(session, this.Parameters[shift + 8].Trim(), exceptionList, logger); if (!string.IsNullOrEmpty(this.Parameters[shift + 8].Trim()) && preparedBy == null) { var message = string.Format("Не найден Подготавливающий \"{2}\". Приказ: \"{0} {1}\". ", regNumber, regDate.ToString(), this.Parameters[shift + 8].Trim()); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var ourSignatory = BusinessLogic.GetEmployee(session, this.Parameters[shift + 9].Trim(), exceptionList, logger); if (!string.IsNullOrEmpty(this.Parameters[shift + 9].Trim()) && ourSignatory == null) { var message = string.Format("Не найден Подписывающий \"{2}\". Приказ: \"{0} {1}\". ", regNumber, regDate.ToString(), this.Parameters[shift + 9].Trim()); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Warn, Message = message }); logger.Warn(message); } var lifeCycleState = BusinessLogic.GetPropertyLifeCycleState(session, this.Parameters[shift + 10]); if (!string.IsNullOrEmpty(this.Parameters[shift + 10].Trim()) && lifeCycleState == null) { var message = string.Format("Не найдено соответствующее значение состояния \"{0}\".", this.Parameters[shift + 10]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } var note = this.Parameters[shift + 11]; try { var orders = Enumerable.ToList(session.GetAll <Sungero.RecordManagement.IOrder>().Where(x => x.RegistrationNumber == regNumber && regDate != DateTime.MinValue && x.RegistrationDate == regDate)); var order = (Enumerable.FirstOrDefault <Sungero.RecordManagement.IOrder>(orders)); if (order != null) { var message = string.Format("Приказ/распоряжение не может быть импортировано. Найден дубль с такими же реквизитами \"Дата документа\" {0} и \"Рег. №\" {1}.", regDate.ToString(), regNumber); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } order = session.Create <Sungero.RecordManagement.IOrder>(); if (regDate != null) { order.RegistrationDate = regDate; } order.RegistrationNumber = regNumber; order.DocumentKind = documentKind; order.Subject = subject; order.BusinessUnit = businessUnit; order.Department = department; order.Assignee = assignee; order.PreparedBy = preparedBy; order.OurSignatory = ourSignatory; order.LifeCycleState = lifeCycleState; order.Note = note; order.Save(); if (!string.IsNullOrWhiteSpace(filePath)) { exceptionList.Add(BusinessLogic.ImportBody(session, order, filePath, logger)); } var documentRegisterId = 0; if (ExtraParameters.ContainsKey("doc_register_id")) { if (int.TryParse(ExtraParameters["doc_register_id"], out documentRegisterId)) { exceptionList.AddRange(BusinessLogic.RegisterDocument(session, order, documentRegisterId, regNumber, regDate, Constants.RolesGuides.RoleIncomingDocumentsResponsible, logger)); } else { var message = string.Format("Не удалось обработать параметр \"doc_register_id\". Полученное значение: {0}.", ExtraParameters["doc_register_id"]); exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = message }); logger.Error(message); return(exceptionList); } } } catch (Exception ex) { exceptionList.Add(new Structures.ExceptionsStruct { ErrorType = Constants.ErrorTypes.Error, Message = ex.Message }); return(exceptionList); } session.SubmitChanges(); } return(exceptionList); }