Пример #1
0
 public void SaveDataChanges()
 {
     State = WorkerState.Saving;
     CurrentDbContext.SubmitChanges();
     //CurrentDbContext.GetChangeSet();
     State = WorkerState.Working;
 }
Пример #2
0
        private void CreateImageSku(Guid guidFileName, string originalFileUri)
        {
            _db.SubmitChanges();

            var newSku = new Sku(_db)
            {
                ID        = guidFileName,
                ItemID    = guidFileName.ToString(),
                ProjectID = _projectId,
                SkuType   = Sku.ItemType.EnrichmentImage.ToString()
            };

            _db.Skus.InsertOnSubmit(newSku);
            _db.SubmitChanges();

            ImageSku        = newSku;
            RemoteImageGuid = newSku.ID.ToString();
            var originalFilename = originalFileUri;
            Uri resultUri;

            if (Uri.TryCreate(originalFileUri, UriKind.Absolute, out resultUri))
            {
                // if (resultUri.IsFile)
                originalFilename = Path.GetFileName(resultUri.AbsolutePath);
            }

            AddAttributeValue(Properties.Resources.ImageSkuGuidFileNameNoExtensionAttributeName, guidFileName.ToString());
            AddAttributeValue(Properties.Resources.ImageSkuImageFileExtensionAttributeName, Path.GetExtension(originalFileUri));
            AddAttributeValue(Properties.Resources.ImageSkuImageOriginalFileUriAttributeName, originalFileUri);
            AddAttributeValue(Properties.Resources.ImageSkuImageOriginalFileNameAttributeName, originalFilename);

            _db.SubmitChanges();
        }
        /// <summary>
        /// Process each SKU Set separately (using a new Data Context)
        /// </summary>
        /// <param name="skuSet"></param>
        private void ProcessSkuSet(List <Guid> skuSet)
        {
            using (var dc = new AryaDbDataContext(Arguments.ProjectId, Arguments.UserId))
            {
                //Get all Derived attributes
                var derivedAttributes =
                    dc.Attributes.Where(att => att.AttributeType == AttributeTypeEnum.Derived.ToString()).ToList();

                var skus = dc.Skus.Where(sku => skuSet.Contains(sku.ID));

                var iCtr = 0;

                if (Summary.Warnings == null)
                {
                    Summary.Warnings = new List <WorkerWarning>();
                }
                //var dbCommand = dc.GetCommand(skus);
                //Summary.Warnings.Add(new WorkerWarning { ErrorDetails = dbCommand.CommandText });
                //foreach (DbParameter parameter in dbCommand.Parameters)
                //{
                //    Summary.Warnings.Add(new WorkerWarning
                //                         {
                //                             ErrorMessage = parameter.ParameterName,
                //                             ErrorDetails = parameter.Value.ToString()
                //                         });
                //}
                foreach (var sku in skus)
                {
                    ProcessSku(sku, derivedAttributes, dc);

                    if (++iCtr % 100 != 0)
                    {
                        continue;
                    }

                    dc.SubmitChanges();
                    StatusMessage = string.Format("{0} SKUs processed, {1} Values inserted/updated.", _iSkuCount, _iValueCount);
                }

                dc.SubmitChanges();
                StatusMessage = string.Format("{0} SKUs processed, {1} Values inserted/updated.", _iSkuCount, _iValueCount);
            }
        }