/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(DataVersions dataversions, System.Data.DataSet data) { // Do nothing if we have nothing if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0) { return; } // Create a local variable for the new instance. DataVersion newobj = null; // Create a local variable for the data row instance. System.Data.DataRow dr = null; // Iterate through the table rows for (int i = 0; i < data.Tables[0].Rows.Count; i++) { // Get a reference to the data row dr = data.Tables[0].Rows[i]; // Create a new object instance newobj = System.Activator.CreateInstance(dataversions.ContainsType[0]) as DataVersion; // Let the instance set its own members newobj.SetMembers(ref dr); // Add the new object to the collection instance dataversions.Add(newobj); } }
/// <summary> /// Fill method for populating an entire collection of DataVersions /// </summary> public virtual void Fill(DataVersions dataVersions) { // create the connection to use SqlConnection cnn = new SqlConnection(DataVersion.GetConnectionString()); try { using (cnn) { // open the connection cnn.Open(); // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectDataVersions"); // Send the collection and data to the object factory CreateObjectsFromData(dataVersions, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
/// <summary> /// Gets the objects for the DATA_VERSION relationship. /// </summary> public DataVersions GetDataVersions() { DataVersions dataversions = new DataVersions(); DataVersionBase.ServiceObject.FillByDataInformation(dataversions, _loanapplicationid); return(dataversions); }
public async Task <bool> Update(JsonVersions jsonVersions, DataVersions dataVersions) { if (!(jsonVersions.Contents > dataVersions.Contents)) { return(false); } await UpdateContents(jsonVersions, dataVersions); return(true); }
/// <summary> /// Gets all the available objects. /// </summary> public virtual DataVersions GetAll() { // create a new instance of the return object DataVersions objects = new DataVersions(); // fill the objects this.Fill(objects); // return the filled object from the service return(objects); }
public async Task Update() { DataBaseHelper.CreateDataBase(); var dataVersionsEntiry = DataBaseHelper.Select <DataVersionsEntity>(q => q.Take(1)).First(); var jsonVersionsJson = await App.DIContainer.Resolve <ISourceDataProvider>().JsonDataVersions(); var dataVersions = new DataVersions(dataVersionsEntiry); var jsonVersions = new JsonVersions(jsonVersionsJson); // コンテンツ await App.DIContainer.Resolve <IContentsUpdater>().Update(jsonVersions, dataVersions); foreach (var plugin in App.Plugins) { await plugin.DataUpdate(); } }
/// <summary> /// Fill method for populating a collection by DATA_INFORMATION /// </summary> public void FillByDataInformation(DataVersions dataVersions, System.Int64 loanApplicationId) { // create the connection to use SqlConnection cnn = new SqlConnection(DataVersion.GetConnectionString()); try { // discover the sql parameters SqlParameterHash sqlparams = SqlHelperParameterCache.GetSpParameterSet(DataVersion.GetConnectionString(), "gsp_SelectDataVersionsByDataInformation"); using (cnn) { // open the connection cnn.Open(); // set the parameters sqlparams["@loanApplicationId"].Value = loanApplicationId; // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectDataVersionsByDataInformation", sqlparams); // Send the collection and data to the object factory. CreateObjectsFromData(dataVersions, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
private async Task UpdateContents(JsonVersions jsonVersions, DataVersions dataVersions) { var jsonContents = await _sourceDataProvider.JsonContentSummariesAndDetails(); _localDataProvider.UnzipImages(await _sourceDataProvider.Images()); foreach (var(summary, detail) in jsonContents) { _localDataProvider.UnzipImages(await _sourceDataProvider.Images(summary?.ContentId)); } using (var db = DataBaseHelper.CreateConnection()) { var dbSummaries = _localDataProvider.ContentSummaries(db).ToList(); var dbDetails = _localDataProvider.ContentDetails(db).ToList(); foreach (var(summary, detail) in jsonContents) { var dbSummary = dbSummaries.Where(d => d.ContentId == summary.ContentId).FirstOrDefault() ?? new ContentSummaryEntity(); var dbDetail = dbDetails.Where(d => d.ContentId == detail.ContentId).FirstOrDefault() ?? new ContentDetailEntity(); dbSummaries.Remove(dbSummary); dbDetails.Remove(dbDetail); _localDataProvider.InsertOrReplace(db, PropertyCopier.CopyTo(summary, dbSummary)); _localDataProvider.InsertOrReplace(db, PropertyCopier.CopyTo(detail, dbDetail)); } foreach (var dbSummary in dbSummaries) { db.Delete(dbSummary); } foreach (var dbDetail in dbDetails) { db.Delete(dbDetail); } // バージョン dataVersions.Entity.Contents = jsonVersions.Json.Contents; _localDataProvider.InsertOrReplace(db, dataVersions.Entity); } }
public ActionResult GetByVersion(int VersionId) { dataviews = new List <DataViewModel>(); DataVersions version = _dataRequests.getVersions().Result.Find(o => o.id == VersionId); var constructionObjcts = _dataRequests.getConstructions().Result; foreach (var obj in constructionObjcts) //получаем все объекты и соответсвенно все значения, которые соответствуют данной версии { dataviews.Add ( new DataViewModel { ObjectName = obj.Name, ObjectCode = obj.ObjectCode, VersionName = version.Name, DataIntersection = _values.getValue.ToList().Find(di => di.Objectindex == obj.id && di.Versionindex == version.id).Intersection } ); } return(this.Ok(dataviews)); }
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(DataVersions dataversions, System.Data.SqlClient.SqlDataReader data) { // Do nothing if we have nothing if (data == null) { return; } // Create a local variable for the new instance. DataVersion newobj = null; // Iterate through the data reader while (data.Read()) { // Create a new object instance newobj = System.Activator.CreateInstance(dataversions.ContainsType[0]) as DataVersion; // Let the instance set its own members newobj.SetMembers(ref data); // Add the new object to the collection instance dataversions.Add(newobj); } }