private void AddOrganisationName(Organisation organisation, string name, SourceOfData sourceOfData) { organisation.OrganisationName = name; string source; switch (sourceOfData) { case SourceOfData.CompaniesHouse: source = "CoHo"; break; case SourceOfData.Manual: source = "User"; break; default: throw new ArgumentOutOfRangeException(nameof(sourceOfData), sourceOfData, null); } var organisationName = new OrganisationName { Organisation = organisation, Name = name, Source = source }; organisation.OrganisationNames.Add(organisationName); dataRepository.Insert(organisationName); }
public static DataTable GetDataForExport(SourceOfData objType, string ObjectName) { string Query = ""; switch (objType) { case SourceOfData.Table: case SourceOfData.View: Query = string.Format("SELECT * FROM [{0}];", ObjectName); break; case SourceOfData.Query: Query = ObjectName; break; } DataTable dtResult = Business.CommonController.ExecDynamicQuery(Query); return(dtResult); }
private void SetInitialStatus(Organisation organisation, User user, SourceOfData sourceOfData) { OrganisationStatuses status; string organisationStatusDetails; switch (sourceOfData) { case SourceOfData.CompaniesHouse: status = OrganisationStatuses.Active; organisationStatusDetails = "Imported from CoHo"; break; case SourceOfData.Manual: status = OrganisationStatuses.Pending; organisationStatusDetails = "Manually registered"; break; default: throw new ArgumentOutOfRangeException(nameof(sourceOfData), sourceOfData, null); } organisation.Status = status; organisation.StatusDate = VirtualDateTime.Now; organisation.StatusDetails = organisationStatusDetails; var organisationStatus = new OrganisationStatus { Organisation = organisation, Status = status, StatusDate = VirtualDateTime.Now, StatusDetails = organisationStatusDetails, ByUser = user }; organisation.OrganisationStatuses.Add(organisationStatus); dataRepository.Insert(organisationStatus); }
public static void ExportData(SourceOfData objSourceType, string ObjectName, ExportType objExportType) { DataTable dtResult = GetDataForExport(objSourceType, ObjectName); string ResultName = string.Format("{0}_{1}", ObjectName, DateTime.Now.Ticks); if (objSourceType == SourceOfData.Query) { ResultName = string.Format("CustomQuery_{0}", DateTime.Now.Ticks); } switch (objExportType) { case ExportType.Excel: ExportToExcel(dtResult, ResultName); break; case ExportType.XML: ExportToXML(dtResult, ResultName); break; case ExportType.CSV: ExportToCSV(dtResult, ResultName); break; } }
public static void SetKey(string projectId, string keyId, string fileNameOrValueOrGeometry) { CheckForInitAndLoginSDK(); Project project = GetProjectById(projectId); CellInfo key = project.DataTable.Cells.FirstOrDefault(c => c.CellId == keyId); if (key == null) { throw new Exception(string.Format("Key by id: '{0}' not found.", keyId)); } string valueForSet; SourceOfData sourceOfData = SourceOfData.Primitive; string name = string.Empty; //checking parameter as filename string fileName = string.Empty; if (fileNameOrValueOrGeometry.StartsWith("<") && fileNameOrValueOrGeometry.Length > 1) { //delete first char fileName = fileNameOrValueOrGeometry.Substring(1); if (!FileHelper.IsFileExists(ref fileName)) { Console.WriteLine("File name '{0}' is not exists", fileName); } valueForSet = File.ReadAllText(fileName); sourceOfData = SourceOfData.File; } else { name = fileNameOrValueOrGeometry.ToUpper(); //check parameter, if name is inside Geometric Primitives if (!GeometricPrimitives.TryGetValue(name, out valueForSet)) { //check parameter, if number is inside Geometric Primitives int numberPrimitive; if (int.TryParse(name, out numberPrimitive) && numberPrimitive <= GeometricPrimitives.Count) { valueForSet = GeometricPrimitives.Values.ElementAt(numberPrimitive - 1); name = GeometricPrimitives.Keys.ElementAt(numberPrimitive - 1); } else { valueForSet = fileNameOrValueOrGeometry; sourceOfData = SourceOfData.Value; } } } var serializedValueStr = DataSerializer.Serialize(valueForSet); Stream stream = StreamUtils.GenerateStreamFromString(serializedValueStr); CellInfo updatingKey = project.DataTable.SetCell(key.CellId, stream, key.ClientMetadata); switch (sourceOfData) { case SourceOfData.File: Console.WriteLine("Key '{0}' was updated from file: '{1}'", updatingKey.ClientMetadata.Label, fileName); break; case SourceOfData.Primitive: Console.WriteLine("Key '{0}' was updated by predefined geometric primitive '{1}': ", updatingKey.ClientMetadata.Label, name); Console.WriteLine(@"Please vivsit https://flux.io, project - '{0}', key - '{1}' to review this changes.", project.Name, key.ClientMetadata.Label); break; case SourceOfData.Value: Console.WriteLine("Key '{0}' was updated with value: '{1}'", updatingKey.ClientMetadata.Label, valueForSet); break; } }
private void AddOrganisationSicCode(Organisation organisation, int sicCodeInt, SourceOfData sourceOfData) { SicCode sicCode = dataRepository.Get <SicCode>(sicCodeInt); if (sicCode == null) { CustomLogger.Warning( "Bad SIC code", new { OrganisationName = organisation.OrganisationName, CompanyNumber = organisation.CompanyNumber, SicCode = sicCodeInt, Source = sourceOfData.ToString(), Error = $"SIC code ({sicCodeInt}) not found in our database" }); return; } string source; switch (sourceOfData) { case SourceOfData.CompaniesHouse: source = "CoHo"; break; case SourceOfData.Manual: source = "Manual"; break; default: throw new ArgumentOutOfRangeException(nameof(sourceOfData), sourceOfData, null); } var organisationSicCode = new OrganisationSicCode { Organisation = organisation, SicCode = sicCode, Source = source }; organisation.OrganisationSicCodes.Add(organisationSicCode); dataRepository.Insert(organisationSicCode); }
private void AddOrganisationSicCode(Organisation organisation, string sicCodeString, SourceOfData sourceOfData) { if (!int.TryParse(sicCodeString, out int sicCodeInt)) { CustomLogger.Warning( "Bad SIC code", new { OrganisationName = organisation.OrganisationName, CompanyNumber = organisation.CompanyNumber, SicCode = sicCodeString, Source = sourceOfData.ToString(), Error = $"Could not parse ({sicCodeString}) as an integer" }); return; } AddOrganisationSicCode(organisation, sicCodeInt, sourceOfData); }
private void AddOrganisationSicCodes(Organisation organisation, List <int> sicCodes, SourceOfData sourceOfData) { if (sicCodes != null) { foreach (int sicCode in sicCodes) { AddOrganisationSicCode(organisation, sicCode, sourceOfData); } } }
private void AddOrganisationSicCodes(Organisation organisation, List <string> sicCodes, SourceOfData sourceOfData) { if (sicCodes != null) { foreach (string sicCodeString in sicCodes) { AddOrganisationSicCode(organisation, sicCodeString, sourceOfData); } } }