Esempio n. 1
0
        public void TestConvolutionTranspose2()
        {
            var inputData = DataSourceFactory.Create(new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }, new int[] { 2, 2, 3 });
            // var inputData = DataSourceFactory.Create(new float[] { 1, 2, 3, 4 }, new int[] { 2, 2, 1 });

            var input = CNTKLib.InputVariable(new int[] { 2, 2, 3 }, DataType.Float);

            var convolutionMap = new Parameter(new int[] { 2, 2, 6, 3 }, DataType.Float, CNTKLib.ConstantInitializer(1));

            var f = CNTKLib.ConvolutionTranspose(convolutionMap, input, new int[] { 2, 2, 3 }, new BoolVector(new bool[] { true }), new BoolVector(new bool[] { true }), new int[] { 0 }, new int[] { 1 }, 1, 0, "");

            var inputs = new Dictionary <Variable, Value>()
            {
                { input, inputData.ToValue() }
            };
            var outputs = new Dictionary <Variable, Value>()
            {
                { f.Output, null }
            };

            f.Evaluate(inputs, outputs, DeviceDescriptor.UseDefaultDevice());
            var result = DataSourceFactory.FromValue(outputs[f.Output]);

            CollectionAssert.AreEqual(new int[] { 3, 3, 6, 1, 1 }, result.Shape.Dimensions);
            Assert.AreEqual(15, result.Data[0]);
            Assert.AreEqual(15, result.Data[1]);
            Assert.AreEqual(18, result.Data[2]);
            Assert.AreEqual(15, result.Data[3]);
        }
        public async Task <int> InsertOrder(Order order)
        {
            int result = 0;

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    result = await ds.ExecuteNonQuery("usp_InsertOrder",
                                                      ds.CreateParameter("UserID", order.UserID),
                                                      ds.CreateParameter("PaymentStatusID", order.PaymentStatusID),
                                                      ds.CreateParameter("TransactionID", order.TransactionID),
                                                      ds.CreateParameter("TrackingNumber", order.TrackingNumber),
                                                      ds.CreateParameter("SubTotal", order.SubTotal),
                                                      ds.CreateParameter("OrderTotal", order.OrderTotal),
                                                      ds.CreateParameter("Tax", order.Tax),
                                                      ds.CreateParameter("ShippingCharges", order.ShippingCharges),
                                                      ds.CreateParameter("OrderDate", order.OrderDate),
                                                      ds.CreateParameter("DeliveryDate", order.DeliveryDate),
                                                      ds.CreateParameter("SpecialInstruction", order.SpecialInstruction));
                }
            }
            catch (Exception)
            {
                return(0);
            }

            return(result);
        }
Esempio n. 3
0
        public void Create_CreatingExistingProvider_ReturnsDataSource()
        {
            var providerFactory = A.Fake <DbProviderFactory>();
            var dataSource      = DataSourceFactory.Create(providerFactory, string.Empty);

            Assert.IsNotNull(dataSource);
        }
Esempio n. 4
0
        public void DefaultDataSourceFactory()
        {
            ScarfConfiguration.DataSourceFactory = null;
            DataSourceFactory factory = ScarfConfiguration.DataSourceFactory;

            Assert.AreEqual("Scarf.DataSource.DefaultDataSourceFactory", factory.GetType().FullName);
        }
Esempio n. 5
0
        public void TestConvTrans()
        {
            var inputData = DataSourceFactory.Create(new float[] { 1, 2, 3, 4 }, new int[] { 2, 2, 1 });

            var input = CNTKLib.InputVariable(new int[] { 2, 2, 1 }, DataType.Float);

            var f = Composite.ConvolutionTranspose(input, new int[] { 2, 2 }, 1, null, CNTKLib.ConstantInitializer(1), new bool[] { true }, new int[] { 2, 2, 1 }, false, null, new int[] { 0 }, new int[] { 1 }, 1, 0, "");

            var inputs = new Dictionary <Variable, Value>()
            {
                { input, inputData.ToValue() }
            };
            var outputs = new Dictionary <Variable, Value>()
            {
                { f.Output, null }
            };

            f.Evaluate(inputs, outputs, DeviceDescriptor.UseDefaultDevice());
            var result = DataSourceFactory.FromValue(outputs[f.Output]);

            CollectionAssert.AreEqual(new int[] { 3, 3, 1, 1, 1 }, result.Shape.Dimensions);
            Assert.AreEqual(1, result.Data[0]);
            Assert.AreEqual(1, result.Data[1]);
            Assert.AreEqual(2, result.Data[2]);
            Assert.AreEqual(1, result.Data[3]);
        }
        public void HelloWorldWrite(String message)
        {
            DataSourceFactory dsf           = new DataSourceFactory();
            ISource           currentSource = dsf.CreateDataSource();

            currentSource.WriteMessage(message);
        }
Esempio n. 7
0
        public void TestDataSourceCTFBuilider()
        {
            var writer = new StringWriter();

            var ds1 = DataSourceFactory.Create(new float[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }, new int[] { 2, 3, 3 });
            var ds2 = DataSourceFactory.Create(new float[] { 0, 1, 2, 3, 4, 5 }, new int[] { 2, 1, 3 });

            var dss = new DataSourceSet();

            dss.Features.Add("data", ds1);
            dss.Features.Add("label", ds2);

            DataSourceSetCTFBuilder.Write(writer, dss, true);
            var s = writer.ToString();

            var expected =
                "0\t|data 0 1\t|label 0 1\r\n" +
                "0\t|data 2 3\r\n" +
                "0\t|data 4 5\r\n" +
                "1\t|data 6 7\t|label 2 3\r\n" +
                "1\t|data 8 9\r\n" +
                "1\t|data 10 11\r\n" +
                "2\t|data 12 13\t|label 4 5\r\n" +
                "2\t|data 14 15\r\n" +
                "2\t|data 16 17";

            Assert.AreEqual(expected, s);
        }
Esempio n. 8
0
        public async Task <int> InsertDeliveryAddress(DeliveryAddress deliveryAddress)
        {
            int result = 0;

            try
            {
                using (var ds = DataSourceFactory.CreateDataSource())
                {
                    result = await ds.ExecuteNonQuery("usp_InsertDeliveryAddress",
                                                      ds.CreateParameter("UserID", deliveryAddress.UserID),
                                                      ds.CreateParameter("OrderID", deliveryAddress.OrderID),
                                                      ds.CreateParameter("Name", deliveryAddress.Name),
                                                      ds.CreateParameter("Pincode", deliveryAddress.Pincode),
                                                      ds.CreateParameter("Address", deliveryAddress.Address),
                                                      ds.CreateParameter("Landmark", deliveryAddress.Landmark),
                                                      ds.CreateParameter("country", deliveryAddress.country),
                                                      ds.CreateParameter("state", deliveryAddress.state),
                                                      ds.CreateParameter("city", deliveryAddress.city),
                                                      ds.CreateParameter("phone", deliveryAddress.phone));
                }

                return(result);
            }
            catch (Exception)
            {
                return(0);
            }
        }
Esempio n. 9
0
        public void TestMsgPackSamplerMultipleFiles()
        {
            var files = new string[2];

            for (var i = 0; i < 2; ++i)
            {
                files[i] = Path.GetTempFileName();
                var a   = DataSourceFactory.Create(new float[] { i, i + 1, i + 2 }, new int[] { 3, 1 });
                var dss = new DataSourceSet();
                dss.Add("a", a);
                using (var stream = new FileStream(files[i], FileMode.Create, FileAccess.Write))
                {
                    MsgPackSerializer.Serialize(dss, stream);
                }
            }

            using (var sampler = new MsgPackSampler(files, 3, false, -1, 10, false, 10))
            {
                Assert.AreEqual(2, sampler.SampleCountPerEpoch);

                var batch = sampler.GetNextMinibatch();
                CollectionAssert.AreEqual(new int[] { 3, 3 }, batch.Features["a"].Shape.Dimensions.ToArray());
                var values = DataSourceFactory.FromValue(batch.Features["a"]);
                CollectionAssert.AreEqual(new float[] { 0, 1, 2, 1, 2, 3, 0, 1, 2 }, values.TypedData);
            }
        }
Esempio n. 10
0
        private DF3DPipeCreateApp()
        {
            try
            {
                IConnectionInfo connInfo1 = new ConnectionInfo();
                connInfo1.FromConnectionString(Config.GetConfigValue("3DTemplateDataConnStr"));
                IDataSourceFactory dsf1 = new DataSourceFactory();
                if (dsf1.HasDataSource(connInfo1))
                {
                    this._TemplateLib = dsf1.OpenDataSource(connInfo1);
                }

                IConnectionInfo connInfo2 = new ConnectionInfo();
                connInfo2.FromConnectionString(Config.GetConfigValue("3DPipeDataConnStr"));
                IDataSourceFactory dsf2 = new DataSourceFactory();
                if (dsf2.HasDataSource(connInfo2))
                {
                    this._PipeLib = dsf2.OpenDataSource(connInfo2);
                }

                IConnectionInfo connInfo3 = new ConnectionInfo();
                connInfo3.FromConnectionString(Config.GetConfigValue("3DTempDataConnStr"));
                IDataSourceFactory dsf3 = new DataSourceFactory();
                if (dsf3.HasDataSource(connInfo3))
                {
                    this._TempLib = dsf3.OpenDataSource(connInfo3);
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 11
0
        public async Task UpdateDataFormAsync(string tenant, string id, UpdateDataformRequest dataform)
        {
            using (var session = _documentStore.OpenAsyncSession(tenant))
            {
                var doc = await session.LoadAsync <DataForm>(id);

                if (doc == null)
                {
                    return;
                }

                doc.Description               = dataform.Description;
                doc.Title                     = dataform.Title;
                doc.Fields                    = new List <FieldConfiguration>(dataform.Fields.Project().To <FieldConfiguration>());
                doc.Plugins                   = dataform.Plugins;
                doc.Components                = dataform.Components;
                doc.AuthorizedClaims          = dataform.AuthorizedClaims?.ToArray() ?? new string[0];
                doc.DataSourceId              = dataform.DataSourceId;
                doc.RestrictDataAccessByOwner = dataform.RestrictDataAccessByOwner;

                if (!string.IsNullOrWhiteSpace(dataform.NewDataSourceName))
                {
                    var factory = new DataSourceFactory(session);
                    doc.DataSourceId = (await factory.CreateDataSourceAsync(dataform.NewDataSourceName)).Id;
                }

                await session.SaveChangesAsync();
            }
        }
Esempio n. 12
0
 public ActionResult CreateReminder()
 {
     using (IHoneyMustardDataSource ds = DataSourceFactory.GetDataSource())
     {
         return(View());
     }
 }
Esempio n. 13
0
        public void TestWithParameter()
        {
            var input = Variable.InputVariable(new int[] { 1 }, DataType.Float, "input", new Axis[] { Axis.DefaultBatchAxis() });
            var exp   = input + Constant.Scalar(DataType.Float, 1);

            var sampler = new ExpressionSampler("value", exp, input, 3);

            var batch = sampler.GetNextMinibatch();
            var data  = batch["value"];

            CollectionAssert.AreEqual(data.Shape.Dimensions.ToArray(), new int[] { 1, 3 });
            var ds = DataSourceFactory.FromValue(data);

            CollectionAssert.AreEqual(ds.TypedData, new float[] { 1, 1, 1 });

            batch = sampler.GetNextMinibatch();
            data  = batch["value"];
            CollectionAssert.AreEqual(data.Shape.Dimensions.ToArray(), new int[] { 1, 3 });
            ds = DataSourceFactory.FromValue(data);
            CollectionAssert.AreEqual(ds.TypedData, new float[] { 2, 2, 2 });

            batch = sampler.GetNextMinibatch();
            data  = batch["value"];
            CollectionAssert.AreEqual(data.Shape.Dimensions.ToArray(), new int[] { 1, 3 });
            ds = DataSourceFactory.FromValue(data);
            CollectionAssert.AreEqual(ds.TypedData, new float[] { 3, 3, 3 });
        }
Esempio n. 14
0
        /// <summary>
        /// 通过modelPoint查找model,修改model顶点,塞回数据源
        /// </summary>
        /// <param name="fdbPath"></param>
        void editModleNodeCoord(string fdbPath)
        {
            IConnectionInfo ci = new ConnectionInfo();

            ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
            ci.Database       = fdbPath;

            //获取数据源
            IDataSource ds = new DataSourceFactory().OpenDataSource(ci);

            string[]         dataSetNames = ds.GetFeatureDatasetNames();
            IFeatureDataSet  fds          = ds.OpenFeatureDataset("fdsName");
            IResourceManager resourceM    = (IResourceManager)fds;

            //获取所有featureClass
            string[] fcNames = fds.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
            for (int fci = 0; fci < fcNames.Length; fci++)
            {
                IFeatureClass        fc         = fds.OpenFeatureClass(fcNames[fci]);
                IFieldInfoCollection fieldInfos = fc.GetFields();
                for (int fieldi = 0; fieldi < fieldInfos.Count; fieldi++)
                {
                    IFieldInfo finfo = fieldInfos.Get(fieldi);
                    if (finfo.FieldType == gviFieldType.gviFieldGeometry)
                    {
                        //获取fc的几何属性及其索引,索引用于更新模型
                        aaa(fc, fieldi, resourceM);
                        break;
                    }
                }
            }
        }
Esempio n. 15
0
 public override void Run(object sender, System.EventArgs e)
 {
     if (CommonUtils.Instance().CurEditLayer != null)
     {
         bool               inProjectTree = false;
         bool               isCheckOut    = false;
         IFeatureLayer      fl            = CommonUtils.Instance().CurEditLayer.GetFeatureLayer();
         IDataSourceFactory dsf           = new DataSourceFactory();
         if (dsf.HasDataSourceByString(fl.FeatureClassInfo.DataSourceConnectionString))
         {
             IDataSource     ds  = dsf.OpenDataSourceByString(fl.FeatureClassInfo.DataSourceConnectionString);
             IFeatureDataSet fds = ds.OpenFeatureDataset(fl.FeatureClassInfo.DataSetName);
             if (fds != null)
             {
                 using (FCPropertyFrm fCPropertyForm = new FCPropertyFrm(ds, fl.FeatureClassInfo.DataSetName, CommonUtils.Instance().CurEditLayer.GetFeatureClass(), inProjectTree, isCheckOut))
                 {
                     fCPropertyForm.ShowDialog();
                 }
             }
         }
     }
     else
     {
         XtraMessageBox.Show("请设置当前编辑要素类!");
     }
 }
Esempio n. 16
0
        public static List <Record> LoadCfgRecords(TBean recordType, string originFile, string sheetName, byte[] content, bool multiRecord)
        {
            // (md5,sheet,multiRecord,exportTestData) -> (valuetype, List<(datas)>)
            var dataSource = DataSourceFactory.Create(originFile, sheetName, new MemoryStream(content));

            try
            {
                if (multiRecord)
                {
                    return(dataSource.ReadMulti(recordType));
                }
                else
                {
                    Record record = dataSource.ReadOne(recordType);
                    return(record != null ? new List <Record> {
                        record
                    } : new List <Record>());
                }
            }
            catch (DataCreateException dce)
            {
                if (string.IsNullOrWhiteSpace(dce.OriginDataLocation))
                {
                    dce.OriginDataLocation = originFile;
                }
                throw;
            }
            catch (Exception e)
            {
                throw new Exception($"配置文件:{originFile} 生成失败.", e);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Get count of container by query
        /// </summary>
        /// <typeparam name="T">The type of the resulting containers</typeparam>
        /// <param name="types">The allowed types of contained content items returned</param>
        /// <param name="queryBody">An operator on an IQueryable of the container type to filter the ones to count</param>
        /// <returns>The count of containers</returns>
        public virtual int GetCount <T>(IEnumerable <Type> types, Func <IQueryable <T>, IQueryable <T> > queryBody) where T : class
        {
            if (types == null || !types.Any())
            {
                return(0);
            }

            if (types.Count() == 1)
            {
                using (var dataSource = DataSourceFactory.Create(true))
                {
                    var qed = new QueryEventData <IQueryable>
                    {
                        Source    = dataSource.GetSource(typeof(T).UnextendedType()),
                        QueryBody = iq => queryBody(iq.AsFacade <T>())
                    };
                    qed = System.Events.ProcessEvent("Repository.Get.Count", this, qed).Data as QueryEventData <IQueryable>;

                    int ct = qed.QueryBody(qed.Source).AsFacade <T>().Count();
                    return(ct);
                }
            }
            else
            {
                int count = 0;
                foreach (Type t in types)
                {
                    count += this.GetCount <T>(new Type[] { t }, queryBody);
                }
                return(count);
            }
        }
Esempio n. 18
0
        public ActionResult ReminderDetails(int id)
        {
            using (IHoneyMustardDataSource ds = DataSourceFactory.GetDataSource())
            {
                var reminder = ds.Reminder.SingleOrDefault(x => x.ReminderID == id);

                ReminderCenter model = new ReminderCenter
                {
                    ReminderID = reminder.ReminderID,

                    Subject          = reminder.Subject,
                    Details          = reminder.Details,
                    ReminderDateTime = reminder.AlertDateTime,

                    From = ds.Contacts.Where(x => x.ContactID == reminder.From)
                           .Select(x => new FromReminderListTableRow
                    {
                        ContactID    = x.ContactID,
                        FirstMidName = x.FirstMidName,
                        LastName     = x.LastName
                    }).ToList(),

                    To = ds.Contacts.Where(x => x.ContactID == reminder.To)
                         .Select(x => new ToReminderListTableRow
                    {
                        ContactID    = x.ContactID,
                        FirstMidName = x.FirstMidName,
                        LastName     = x.LastName
                    }).ToList()
                };


                return(View(model));
            }
        }
Esempio n. 19
0
        public async Task OnGet()
        {
            var datasource = DataSourceFactory.Create(Program.DataSource);
            var databases  = await datasource.GetDatabases("*");

            Databases = databases.Select(x => new SelectListItem(x, x)).ToList();
        }
Esempio n. 20
0
        // GET: contact/Details/5
        public ActionResult Details(int id)
        {
            using (IHoneyMustardDataSource ds = DataSourceFactory.GetDataSource())
            {
                var contact = ds.Contacts.SingleOrDefault(x => x.ContactID == id);
                ContactCenterModel model = new ContactCenterModel
                {
                    ContactID           = contact.ContactID,
                    FirstMidName        = contact.FirstMidName,
                    LastName            = contact.LastName,
                    EmailAddress        = contact.EmailAddress,
                    Address             = contact.Address,
                    CountryID           = contact.CountryID,
                    CellPhone           = contact.CellPhone,
                    Phone               = contact.Phone,
                    TeudatZehutPassport = contact.TeudatZehutPassport,



                    contactType = ds.ContactType.Where(x => x.ContactTypeID == contact.ContactType)
                                  .Select(x => new ContactTypeModel
                    {
                        ContactTypeID   = x.ContactTypeID,
                        TypeDescription = x.TypeDescription
                    }).ToList()
                };

                return(View(model));
            }
        }
Esempio n. 21
0
        // GET: Contact
        public ActionResult Index()
        {
            using (IHoneyMustardDataSource ds = DataSourceFactory.GetDataSource())
            {
                ContactModel model = new ContactModel
                {
                    Contacts = ds.Contacts
                               //.Include(c => c.ContactType)
                               .Select(x => new ContactCenterModel
                    {
                        ContactID           = x.ContactID,
                        FirstMidName        = x.FirstMidName,
                        LastName            = x.LastName,
                        EmailAddress        = x.EmailAddress,
                        Address             = x.Address,
                        TeudatZehutPassport = x.TeudatZehutPassport,
                        CountryID           = x.CountryID,
                        Phone     = x.Phone,
                        CellPhone = x.CellPhone,
                    }).ToList()
                };

                return(View(model));
            }
        }
Esempio n. 22
0
        public ActionResult ContactEdit(int id, ContactCenterModel model)
        {
            using (IHoneyMustardDataSource ds = DataSourceFactory.GetDataSource())
            {
                if (ModelState.IsValid)
                {
                    foreach (ContactTypeModel contactType in model.contactType)
                    {
                        ds.ContactType.Single(x => x.ContactTypeID == contactType.ContactTypeID);
                        // .TypeDescription = contactType.TypeDescription;

                        ds.SaveChanges();
                    }

                    return(RedirectToAction("DisplayContactList"));
                }


                else
                {
                    var errors = ModelState.SelectMany(x => x.Value.Errors.Select(z => z.Exception));


                    return
                        (RedirectToAction("Options/" + id));
                }
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
        }
Esempio n. 23
0
        public async Task TestGetDatabases_Filter_NoMatch()
        {
            IDataSource ds        = DataSourceFactory.Create(dsi);
            var         databases = await ds.GetDatabases("²»¿ÉÄÜÆ¥Åä");

            Assert.AreEqual(0, databases.Count);
        }
 public ActionResult Practising()
 {
     using (IHoneyMustardDataSource ds = DataSourceFactory.GetDataSource())
     {
         return(View());
     }
 }
 public ControlUI(object app)
 {
     InitializeComponent();
     try
     {
         corelApp         = app as corel.Application;
         stylesController = new Styles.StylesController(this.Resources, corelApp);
         DataSourceFactory dataSourceFactory = new DataSourceFactory();
         dataSourceFactory.AddDataSource("FacaDS", typeof(FacaDataSource));
         dataSourceFactory.Register();
     }
     catch
     {
         global::System.Windows.MessageBox.Show("VGCore Erro");
     }
     btn_Command.Click += (s, e) => {
         try
         {
             DataSourceProxy dsp2 = corelApp.FrameWork.Application.DataContext.GetDataSource("FacaDS");
             dsp2.InvokeMethod("OnDraw");
         }
         catch (Exception err)
         {
             Debug.WriteLine(err.Message);
         }
     };
 }
        public ActionResult Index()
        {
            using (IHoneyMustardDataSource ds = DataSourceFactory.GetDataSource())
            {
                CourseModels model = new CourseModels
                {
                    Coursess = ds.Courses.Include(c => c.Contact)
                               .Select(x => new CourseModelsTableRow

                    {
                        CourseID           = x.CoursesID,
                        CourseName         = x.CourseName,
                        Module             = x.Module,
                        StartDate          = x.StartDate,
                        EndDate            = x.EndDate,
                        Credit             = x.Credit,
                        Price              = x.Price,
                        activated_date     = x.activated_date,
                        ParticapantsGender = (CourseModelsTableRow.Gender)x.Gender,
                        Format             = (CourseModelsTableRow.Location)x.Location,
                        DayOfWeek          = (CourseModelsTableRow.DaysOfWeek)x.DayOfWeek,
                        Comment            = x.Comment,
                        TimeClassBegins    = x.TimeClassBegins,
                        TimeClassEnds      = x.TimeClassEnds
                    }).ToList()
                };

                return(View(model));
            }
        }
Esempio n. 27
0
        private ArcUploadState taskUploadState;                        // the state of uploading archives according to the task


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public Exporter(ExportTargetConfig exporterConfig, EntityMap entityMap,
                        IServerData serverData, AppDirs appDirs, string arcDir)
        {
            this.exporterConfig = exporterConfig ?? throw new ArgumentNullException(nameof(exporterConfig));
            this.entityMap      = entityMap ?? throw new ArgumentNullException(nameof(entityMap));
            this.serverData     = serverData ?? throw new ArgumentNullException(nameof(serverData));
            this.arcDir         = arcDir ?? throw new ArgumentNullException(nameof(arcDir));

            GeneralOptions generalOptions = exporterConfig.GeneralOptions;

            dataLifetime = TimeSpan.FromSeconds(generalOptions.DataLifetime);
            string prefix = FilePrefix + "_" + generalOptions.ID.ToString("D3");

            log = new Log(Log.Formats.Simple)
            {
                FileName = Path.Combine(appDirs.LogDir, prefix + ".log")
            };
            infoFileName  = Path.Combine(appDirs.LogDir, prefix + ".txt");
            stateFileName = Path.Combine(appDirs.StorageDir, prefix + "_State.xml");
            exporterTitle = string.Format("[{0}] {1}", generalOptions.ID, generalOptions.Name);
            dataSource    = DataSourceFactory.GetDataSource(exporterConfig.ConnectionOptions);
            triggers      = new ClassifiedTriggers(exporterConfig.Triggers, dataSource);

            thread     = null;
            terminated = false;
            connStatus = ConnStatus.Undefined;

            CreateQueues();
            InitArcUploading();
        }
Esempio n. 28
0
        public void TestMultipleObjects()
        {
            var a   = DataSourceFactory.Create(new float[] { 1, 2, 3 }, new int[] { 3, 1, 1 });
            var dss = new DataSourceSet();

            dss.Add("a", a);

            var dss2 = new DataSourceSet();
            var b    = DataSourceFactory.Create(new float[] { 4, 5, 6, 7 }, new int[] { 2, 2, 1 });

            dss2.Add("b", b);

            var stream = new MemoryStream();

            MsgPackSerializer.Serialize(dss, stream);
            MsgPackSerializer.Serialize(dss2, stream);

            stream.Position = 0;
            var result  = MsgPackSerializer.Deserialize(stream);
            var result2 = MsgPackSerializer.Deserialize(stream);

            Assert.AreEqual(1, result.Features.Count);

            var x = result["a"];

            CollectionAssert.AreEqual(new int[] { 3, 1, 1 }, x.Shape.Dimensions);
            CollectionAssert.AreEqual(new float[] { 1, 2, 3 }, x.Data.ToArray());

            Assert.AreEqual(1, result2.Features.Count);

            var y = result2["b"];

            CollectionAssert.AreEqual(new int[] { 2, 2, 1 }, y.Shape.Dimensions);
            CollectionAssert.AreEqual(new float[] { 4, 5, 6, 7 }, y.Data.ToArray());
        }
Esempio n. 29
0
        private void Open3DMAndCreateFeatureLayer()
        {
            try
            {
                var dsFactory = new DataSourceFactory();
                var ds        = dsFactory.OpenDataSource(_ci);

                string[] setnames = (string[])ds.GetFeatureDatasetNames();
                if (setnames == null || setnames.Length == 0)
                {
                    return;
                }

                foreach (string name in setnames)
                {
                    var dataSet = ds.OpenFeatureDataset(name);
                    var fcnames = (string[])dataSet.GetNamesByType(i3dDataSetType.i3dDataSetFeatureClassTable);
                    if (fcnames == null || fcnames.Length == 0)
                    {
                        continue;
                    }

                    foreach (string fcname in fcnames)
                    {
                        ReadFieldAndDrawMap(dataSet, fcname);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                //LoggerHelper.Logger.Error(ex, $"执行{nameof(Open3DMAndCreateFeatureLayer)}错误");
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Set (create or update) a list of containers to the data source
        /// </summary>
        /// <param name="items">The list of containers</param>
        /// <param name="setOptions">Options for setting</param>
        /// <returns>List of flags for whether the corresponding by position item was created (rather than updated)</returns>
        public virtual List <bool> Set(List <object> items, Dictionary <string, object> setOptions)
        {
            if (!(items.All(i => i is ContentItem)))
            {
                throw new ArgumentException("Content repository can only set ContentItem type");
            }

            var  createds     = new List <bool>();
            bool?create       = setOptions.Get <bool?>("create");
            bool bypassChecks = setOptions.Get <bool>("bypassChecks", false);

            using (var dataSource = DataSourceFactory.Create(false))
            {
                var ciSaved = new List <Tuple <ContentItem, bool> >();

                bool anyUnhandled = false;
                foreach (ContentItem ci in items)
                {
                    if (ChangeProblems.Any(cp => cp.TypeName == ci.DataType) && !BypassChangeProblems)
                    {
                        throw new ProhibitedActionException("Changes in the structure of the data may cause data loss, please advise an administrator");
                    }
                    bool isAdd       = (create == null ? ci.Id == Guid.Empty : create.Value);
                    var  eventData   = new RepositoryEventData(ci, setOptions);
                    var  eventResult = System.Events.ProcessEvent("Repository.Set." + (isAdd ? "Add" : "Update"), this, eventData);
                    var  ciSave      = (ContentItem)((RepositoryEventData)eventResult.Data).Container;
                    bool wasHandled  = ((RepositoryEventData)eventResult.Data).WasHandled;
                    if (!wasHandled)
                    {
                        anyUnhandled = true;
                    }
                    isAdd = eventResult.EventName.EndsWith("Add");
                    createds.Add(isAdd);
                    if (isAdd)
                    {
                        DoAdd(dataSource, ciSave, wasHandled);
                    }
                    else if (!wasHandled)
                    {
                        dataSource.Update(ciSave);
                    }

                    ciSaved.Add(Tuple.Create(ciSave, isAdd));
                }

                if (ciSaved.Count > 0 && anyUnhandled)
                {
                    dataSource.SaveChanges();
                }

                foreach (var sv in ciSaved)
                {
                    var savedEventData = new RepositoryEventData(sv.Item1, setOptions);
                    System.Events.ProcessEvent("Repository.Saved." + (sv.Item2 ? "Add" : "Update"), this, savedEventData);
                }
            }

            return(createds);
        }