コード例 #1
0
        public Envelope GetZoneExtent(string zone)
        {
            Envelope        extent    = new Envelope();
            CommonDataFrame dataFrame = AppContext.GetDataFrame(this);

            foreach (Configuration.MapTabLayerRow mapTabLayer in GetMapTabLayerRows())
            {
                Configuration.LayerRow layer = mapTabLayer.LayerRow;

                if (!layer.IsZoneFieldNull())
                {
                    CommonLayer commonLayer = dataFrame.Layers.First(o => o.Name == layer.LayerName);
                    CommonField field       = commonLayer.FindField(layer.ZoneField);

                    string zoneValue = field.IsNumeric ? zone : String.Format("'{0}'", zone);
                    extent = commonLayer.GetFeatureExtent(String.Format("{0} = {1}", field.Name, zoneValue));

                    if (!extent.IsNull)
                    {
                        break;
                    }
                }
            }

            return(extent);
        }
コード例 #2
0
ファイル: SelectionManager.cs プロジェクト: jsmeyers/GPV
    public DataTable GetFeatures(FeatureType featureType, IGeometry spatialConstraint)
    {
        DataTable table = null;

        string layerId = featureType == FeatureType.Selection ? _appState.SelectionLayer : _appState.TargetLayer;

        if (layerId.Length > 0)
        {
            Configuration          config   = AppContext.GetConfiguration();
            Configuration.LayerRow layerRow = config.Layer.FindByLayerID(layerId);

            CommonDataFrame dataFrame = AppContext.GetDataFrame(_appState.MapTab);
            CommonLayer     layer     = dataFrame.Layers.FirstOrDefault(lyr => String.Compare(lyr.Name, layerRow.LayerName, true) == 0);

            string query = GetQuery(featureType, layerRow, layer);

            if (query != null)
            {
                CommonField keyField = layer.FindField(layerRow.KeyField);

                if (spatialConstraint == null)
                {
                    table = layer.GetFeatureTable(String.Format("{0},{1}", layer.GeometryField.Name, keyField.Name), query);
                }
                else
                {
                    table = layer.GetFeatureTable(String.Format("{0},{1}", layer.GeometryField.Name, keyField.Name), query, spatialConstraint);
                }
            }
        }

        return(table);
    }
コード例 #3
0
ファイル: Tag.cs プロジェクト: retahc/old-code
        protected void AddCommonFieldMapping(CommonField field_id, string internal_name)
        {
            if (internal_name == null)
            {
                return;
            }

            common_field_lookup[internal_name.ToLower()] = field_id;
        }
コード例 #4
0
        public string GetLevelQuery(CommonLayer layer, string level)
        {
            string query = null;

            if (!IsLevelFieldNull() && !String.IsNullOrEmpty(level))
            {
                CommonField field = layer.FindField(LevelField);
                query = String.Format("{0} = {1}", field.Name, field.IsNumeric ? level : String.Format("'{0}'", level));
            }

            return(query);
        }
コード例 #5
0
  private string GetQuery(FeatureType featureType, Configuration.LayerRow layerRow, CommonLayer layer, bool inSet)
  {
    StringCollection ids = GetIds(featureType);

    if (ids.Count == 0)
    {
      return null;
    }

    CommonField keyField = layer.FindField(layerRow.KeyField);
    string joinedIds = keyField.IsNumeric ? ids.Join(",") : String.Format("'{0}'", ids.Join("','"));
    return String.Format("{0} {1} ({2})", keyField.Name, inSet ? "in" : "not in", joinedIds);
  }
コード例 #6
0
ファイル: Tag.cs プロジェクト: retahc/old-code
        public IList Get(CommonField id)
        {
            IList list = Get(id.ToString());

            if (list.Count == 0)
            {
                try {
                    return(Get(((CommonField)common_field_aliases[id]).ToString()));
                } catch (Exception) {
                    return(list);
                }
            }

            return(list);
        }
コード例 #7
0
        public IEnumerable <CommonField> GetCommonField(CommonField commonField)
        {
            using (DemsifyEntities dataContext = new DemsifyEntities())
            {
                var commonFields = dataContext.CommonFieldGet(commonField.FieldTypeName, commonField.SearchText).ToList();

                var commonFieldList = new List <CommonField>();
                foreach (var commonFieldDetail in commonFields)
                {
                    commonFieldList.Add(new CommonField()
                    {
                        FieldId   = Convert.ToInt32(commonFieldDetail.FieldId),
                        FieldName = commonFieldDetail.FieldName,
                        Alias     = commonFieldDetail.Alias
                    });
                }
                return(commonFieldList);
            }
        }
コード例 #8
0
        public static string SendSMS(string to, string[] datas, string appId, string templateId)
        {
            if (string.IsNullOrEmpty(appId))
            {
                appId = CommonField.RL_ApplicationID;
            }
            var Template = new
            {
                to,         //发送的手机号码
                appId,      //应用ID
                templateId, //【云通讯】您使用的是云通讯短信模板,您的验证码是{1},请于{2}分钟内正确输入
                datas,      //外层变量
                //subAppend = "", //扩展码
                //reqId = "" // 第三方自定义消息id,最大支持32位,同账号下同一自然天内不允许重复。
            };
            string jsonData = JsonConvert.SerializeObject(Template);

            return(HttpHelper.PostJson(CommonField.RL_MsgPostUrl(), jsonData, CommonField.RL_Authorization()));
        }
コード例 #9
0
        public void PaymentRequestAppInfoExternalTest()
        {
            var externalPlatform    = new Model.ApplicationInformation.ExternalPlatform();
            var merchantApplication = new CommonField();

            externalPlatform.Integrator = "TestExternalPlatformIntegration";
            externalPlatform.Name       = "TestExternalPlatformName";
            externalPlatform.Version    = "TestExternalPlatformVersion";
            merchantApplication.Name    = "MerchantApplicationName";
            merchantApplication.Version = "MerchantApplicationVersion";
            var paymentRequest = CreatePaymentRequestCheckout();

            paymentRequest.ApplicationInfo.ExternalPlatform    = externalPlatform;
            paymentRequest.ApplicationInfo.MerchantApplication = merchantApplication;
            Assert.AreEqual(paymentRequest.ApplicationInfo.ExternalPlatform.Integrator, "TestExternalPlatformIntegration");
            Assert.AreEqual(paymentRequest.ApplicationInfo.ExternalPlatform.Name, "TestExternalPlatformName");
            Assert.AreEqual(paymentRequest.ApplicationInfo.ExternalPlatform.Version, "TestExternalPlatformVersion");
            Assert.AreEqual(paymentRequest.ApplicationInfo.MerchantApplication.Name, "MerchantApplicationName");
            Assert.AreEqual(paymentRequest.ApplicationInfo.MerchantApplication.Version, "MerchantApplicationVersion");
        }
コード例 #10
0
        public IHttpActionResult GetCommonField([FromUri] GetCommonFieldRequest getCommonFieldRequest)
        {
            var responses = new Responses();

            try
            {
                //if (Utility.UserId < 0)
                //    return BadRequest(Utility.INVALID_USER);

                var commonField = new CommonField()
                {
                    FieldTypeName = getCommonFieldRequest.FieldTypeName,
                    SearchText    = getCommonFieldRequest.SearchText
                };
                var commonFields = iCommonField.GetCommonField(commonField);

                var commonFieldList = new List <GetCommonFieldResponse>();
                foreach (var commonFieldDetail in commonFields)
                {
                    commonFieldList.Add(new GetCommonFieldResponse()
                    {
                        FieldId   = commonFieldDetail.FieldId,
                        FieldName = commonFieldDetail.FieldName,
                        Alias     = commonFieldDetail.Alias
                    });
                }

                responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                responses.Description = "CommonField retrieved successfully";
                responses.Response    = commonFieldList;
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while retrieving CommonField.";

                Utility.WriteLog("GetCommonField", null, "Error while retrieving CommonField. (UtilityController)", ex.ToString());
            }
            return(Ok(responses));
        }
コード例 #11
0
ファイル: Tag.cs プロジェクト: emtees/old-code
 public IList Get(CommonField id)
 {
     IList list = Get(id.ToString());
     if(list.Count == 0) {
         try {
             return Get(((CommonField)common_field_aliases[id]).ToString());
         } catch(Exception) {
             return list;
         }
     }
     
     return list;
 }
コード例 #12
0
ファイル: Tag.cs プロジェクト: emtees/old-code
 protected void AddCommonFieldMapping(CommonField field_id, string internal_name)
 {
     if(internal_name == null) {
         return;
     }
     
     common_field_lookup[internal_name.ToLower()] = field_id;
 }
コード例 #13
0
ファイル: Tag.cs プロジェクト: emtees/old-code
 protected void AddCommonFieldAlias(CommonField field_id, CommonField map_field_id)
 {
     common_field_aliases[field_id] = map_field_id;
 }
コード例 #14
0
ファイル: Tag.cs プロジェクト: retahc/old-code
 protected void AddCommonFieldAlias(CommonField field_id, CommonField map_field_id)
 {
     common_field_aliases[field_id] = map_field_id;
 }
コード例 #15
0
        private void BtnClickSaveCouponData_Click(object sender, EventArgs e)
        {
            //Serial number
            EditText edtSerialNumberCoupon = FindViewById <EditText>(Resource.Id.serinumberCoupon);
            string   serialNumber          = edtSerialNumberCoupon.Text.Trim().ToString();

            if (TextUtils.IsEmpty(serialNumber))
            {
                Toast.MakeText(this, "Serialnumber can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Organization id
            EditText edtOrganizationIdCoupon = FindViewById <EditText>(Resource.Id.cardNumberCoupon);
            string   organizationId          = edtOrganizationIdCoupon.Text.Trim().ToString();

            if (TextUtils.IsEmpty(organizationId))
            {
                Toast.MakeText(this, "Cardnumber can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Style id
            EditText edtPassStyleIdentifierCoupon = FindViewById <EditText>(Resource.Id.passStyleIdentifierCoupon);
            string   styleId = edtPassStyleIdentifierCoupon.Text.Trim().ToString();

            if (TextUtils.IsEmpty(styleId))
            {
                Toast.MakeText(this, "Template ID can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Pass type id
            EditText edtPassType = FindViewById <EditText>(Resource.Id.typeIdentifierCoupon);
            string   typeId      = edtPassType.Text.Trim().ToString();

            if (TextUtils.IsEmpty(typeId))
            {
                Toast.MakeText(this, "Pass type can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Issuer id.
            EditText edtIssuerId = FindViewById <EditText>(Resource.Id.issuerIdCoupon);
            string   issuerId    = edtIssuerId.Text.Trim().ToString();

            if (TextUtils.IsEmpty(issuerId))
            {
                Toast.MakeText(this, "Issuer id can't be empty.", ToastLength.Long).Show();
                return;
            }

            EditText edtBackgroundColor = FindViewById <EditText>(Resource.Id.backgroundColorCoupon);
            EditText edtLogoCoupon      = FindViewById <EditText>(Resource.Id.logoCoupon);

            //Merchant name
            EditText edtMerchantNameCoupon = FindViewById <EditText>(Resource.Id.merchantNameCoupon);
            string   merchantName          = edtMerchantNameCoupon.Text.Trim().ToString();

            if (TextUtils.IsEmpty(merchantName))
            {
                Toast.MakeText(this, "Merchant name can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Coupon title
            EditText edtNameCoupon = FindViewById <EditText>(Resource.Id.nameCoupon);
            string   name          = edtNameCoupon.Text.Trim().ToString();

            if (TextUtils.IsEmpty(name))
            {
                Toast.MakeText(this, "Coupon title can't be empty.", ToastLength.Long).Show();
                return;
            }

            //State
            string state = WalletPassConstant.PassStateActive;

            switch (dataList[index])
            {
            case "ACTIVE":
                state = WalletPassConstant.PassStateActive;
                break;

            case "COMPLETED":
                state = WalletPassConstant.PassStateCompleted;
                break;

            case "EXPIRED":
                state = WalletPassConstant.PassStateExpired;
                break;

            case "INACTIVE":
                state = WalletPassConstant.PassStateInactive;
                break;

            default:
                break;
            }

            //Time check
            long start = 0;
            long end   = 0;
            Date date  = new Date();

            if (TextUtils.IsEmpty(startTime))
            {
                Toast.MakeText(this, "Please select StartTime.", ToastLength.Long).Show();
                return;
            }
            else
            {
                start = BasisTimesUtils.GetLongtimeOfYMD(startTime);
            }

            if (TextUtils.IsEmpty(endTime))
            {
                Toast.MakeText(this, "Please select EndTime", ToastLength.Long).Show();
                return;
            }
            else
            {
                end = BasisTimesUtils.GetLongtimeOfYMD(endTime);
            }

            if (end <= start || end <= date.Time)
            {
                Toast.MakeText(this, "Please check (EndTime > StartTime) && (EndTime > CurrentTime)", ToastLength.Long).Show();
                return;
            }

            //Provider name
            EditText edtMerchantProviderCoupon = FindViewById <EditText>(Resource.Id.merchantProvidesCoupon);
            string   providesCoupon            = edtMerchantProviderCoupon.Text.ToString();

            if (TextUtils.IsEmpty(providesCoupon))
            {
                Toast.MakeText(this, "ProvidesName can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Bar code
            EditText edtPassBarcode      = FindViewById <EditText>(Resource.Id.barcodeTextCoupon);
            EditText edtPassBarcodeValue = FindViewById <EditText>(Resource.Id.barcodeValueCoupon);

            //Details
            EditText edtDetailsCoupon = FindViewById <EditText>(Resource.Id.DetailsCoupon);

            //ImageUris
            EditText edtImageModuleDataMainImageUrisCoupon        = FindViewById <EditText>(Resource.Id.imageModuleDataMainImageUrisCoupon);
            EditText edtImageModuleDataMainImageUrisDescCoupon    = FindViewById <EditText>(Resource.Id.imageModuleDataMainImageUrisDesCoupon);
            EditText edtImageModuleDataMainImageUrisCouponOne     = FindViewById <EditText>(Resource.Id.imageModuleDataMainImageUrisCoupon1);
            EditText edtImageModuleDataMainImageUrisDescCouponOne = FindViewById <EditText>(Resource.Id.imageModuleDataMainImageUrisDesCoupon1);

            string imageUris    = edtImageModuleDataMainImageUrisCoupon.Text.Trim().ToString();
            string imageDesc    = edtImageModuleDataMainImageUrisDescCoupon.Text.Trim().ToString();
            string imageUrisOne = edtImageModuleDataMainImageUrisCouponOne.Text.Trim().ToString();
            string imageDescOne = edtImageModuleDataMainImageUrisDescCouponOne.Text.Trim().ToString();

            //DisclaimerCoupon
            EditText edtDisclaimerCoupon = FindViewById <EditText>(Resource.Id.disclaimerCoupon);

            //Message
            EditText edtMessageHeaderCoupon    = FindViewById <EditText>(Resource.Id.messageHeaderCoupon);
            EditText edtMessageBodyCoupon      = FindViewById <EditText>(Resource.Id.messageBodyCoupon);
            EditText edtMessageHeaderCouponOne = FindViewById <EditText>(Resource.Id.messageHeaderCoupon1);
            EditText edtMessageBodyCouponOne   = FindViewById <EditText>(Resource.Id.messageBodyCoupon1);

            string messageHeader    = edtMessageHeaderCoupon.Text.Trim().ToString();
            string messageBody      = edtMessageBodyCoupon.Text.Trim().ToString();
            string messageHeaderOne = edtMessageHeaderCouponOne.Text.Trim().ToString();
            string messageBodyOne   = edtMessageBodyCouponOne.Text.Trim().ToString();

            PassObject.Builder passBuilder = PassObject.GetBuilder();
            //Common fields
            List <CommonField> commonFields = new List <CommonField>();
            //Append fields
            List <AppendField> appendFields = new List <AppendField>();

            //1 Background color of the outer frame.
            CommonField backgroundColorCommonField = CommonField.GetBuilder()
                                                     .SetKey(WalletPassConstant.PassAppendFieldKeyBackgroundColor)
                                                     .SetLabel("Background color label")
                                                     .SetValue(edtBackgroundColor.Text.Trim().ToString())
                                                     .Build();

            commonFields.Add(backgroundColorCommonField);

            //3 Logo on the coupon.
            CommonField logoCommonField = CommonField.GetBuilder()
                                          .SetKey(WalletPassConstant.PassCommonFieldKeyLogo)
                                          .SetLabel("This is logo label")
                                          .SetValue(edtLogoCoupon.Text.Trim().ToString())
                                          .Build();

            commonFields.Add(logoCommonField);

            //4 Merchant name
            CommonField merchantNameCommonField = CommonField.GetBuilder()
                                                  .SetKey(WalletPassConstant.PassCommonFieldKeyMerchantName)
                                                  .SetLabel("This is merchant name label")
                                                  .SetValue(merchantName)
                                                  .Build();

            commonFields.Add(merchantNameCommonField);

            //5 Coupon title
            CommonField couponTitleCommonField = CommonField.GetBuilder()
                                                 .SetKey(WalletPassConstant.PassCommonFieldKeyName)
                                                 .SetLabel("This is Coupon title label")
                                                 .SetValue(name)
                                                 .Build();

            commonFields.Add(couponTitleCommonField);

            //6 Expiration time
            //Simple date format.
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

            passBuilder.SetStatus(PassStatus.GetBuilder().SetState(state).SetEffectTime(format.Format(new Date(start))).SetExpireTime(format.Format(new Date(end))).Build());

            //7 Merchant that provides the coupon
            AppendField merchantProvidesAppendField = AppendField.GetBuilder()
                                                      .SetKey(WalletPassConstant.PassCommonFieldKeyProviderName)
                                                      .SetLabel("This is merchant provider label")
                                                      .SetValue(providesCoupon)
                                                      .Build();

            appendFields.Add(merchantProvidesAppendField);

            //8 Barcode or QR code
            //9 Remarks
            BarCode barCode = BarCode.GetBuilder()
                              .SetType(BarCode.BarcodeTypeQrCode)
                              .SetValue(edtPassBarcodeValue.Text.Trim().ToString())
                              .SetText(edtPassBarcode.Text.Trim().ToString())
                              .Build();

            passBuilder.SetBarCode(barCode);

            //10 Details
            AppendField detailsAppendField = AppendField.GetBuilder()
                                             .SetKey(WalletPassConstant.PassAppendFieldKeyDetails)
                                             .SetLabel("This is details label")
                                             .SetValue(edtDetailsCoupon.Text.Trim().ToString())
                                             .Build();

            appendFields.Add(detailsAppendField);

            //11 Scrolling images
            List <AppendField> imageList = new List <AppendField>();

            imageList.Add(AppendField.GetBuilder()
                          .SetKey("1")
                          .SetLabel(imageDesc)
                          .SetValue(imageUris)
                          .Build());
            imageList.Add(AppendField.GetBuilder()
                          .SetKey("2")
                          .SetLabel(imageDescOne)
                          .SetValue(imageUrisOne)
                          .Build());
            passBuilder.AddImageList(imageList);

            //Urllist
            EditText edtCouponUrlLabel    = FindViewById <EditText>(Resource.Id.couponUrlLable);
            EditText edtCouponUrlValue    = FindViewById <EditText>(Resource.Id.couponUrlValue);
            EditText edtCouponUrlLabelOne = FindViewById <EditText>(Resource.Id.couponUrlLable1);
            EditText edtCouponUrlValueOne = FindViewById <EditText>(Resource.Id.couponUrlValue1);

            List <AppendField> urlList = new List <AppendField>();

            urlList.Add(AppendField.GetBuilder()
                        .SetKey("1")
                        .SetLabel(edtCouponUrlLabel.Text.Trim().ToString())
                        .SetValue(edtCouponUrlValue.Text.Trim().ToString())
                        .Build());
            urlList.Add(AppendField.GetBuilder()
                        .SetKey("2")
                        .SetLabel(edtCouponUrlLabelOne.Text.Trim().ToString())
                        .SetValue(edtCouponUrlValueOne.Text.Trim().ToString())
                        .Build());
            passBuilder.AddUrlList(urlList);

            //12 Disclaimer
            AppendField disclaimerAppendField = AppendField.GetBuilder()
                                                .SetKey(WalletPassConstant.PassAppendFieldKeyDisclaimer)
                                                .SetLabel("This is Disclaimer label")
                                                .SetValue(edtDisclaimerCoupon.Text.Trim().ToString())
                                                .Build();

            appendFields.Add(disclaimerAppendField);

            //13 Message
            List <AppendField> messageList = new List <AppendField>();

            messageList.Add(AppendField.GetBuilder()
                            .SetKey("1")
                            .SetLabel(messageHeader)
                            .SetValue(messageBody)
                            .Build());
            messageList.Add(AppendField.GetBuilder()
                            .SetKey("2")
                            .SetLabel(messageHeaderOne)
                            .SetValue(messageBodyOne)
                            .Build());
            passBuilder.AddMessageList(messageList);

            passBuilder.SetOrganizationPassId(organizationId);
            passBuilder.SetPassStyleIdentifier(styleId);
            passBuilder.SetPassTypeIdentifier(typeId);
            passBuilder.SetSerialNumber(serialNumber);
            passBuilder.AddAppendFields(appendFields);
            passBuilder.AddCommonFields(commonFields);

            PassObject passObject = passBuilder.Build();
            Intent     intent     = new Intent(this, typeof(PassTestActivity));

            intent.PutExtra("passObject", passObject.ToJson());
            intent.PutExtra("passId", organizationId);
            intent.PutExtra("issuerId", issuerId);
            intent.PutExtra("typeId", typeId);
            StartActivity(intent);
        }
コード例 #16
0
ファイル: MapTipHandler.cs プロジェクト: jsmeyers/GPV
    private void DefaultMethod()
    {
        string v = Request.Form["visiblelayers"];

        string[] visibleLayers = v == null ? new string[0] : v.Split('\u0001');

        string level    = Request.Form["level"];
        double x        = Convert.ToDouble(Request.Form["x"]);
        double y        = Convert.ToDouble(Request.Form["y"]);
        double distance = Convert.ToDouble(Request.Form["distance"]);
        double scale    = Convert.ToDouble(Request.Form["scale"]);

        Configuration config = AppContext.GetConfiguration();

        Configuration.MapTabRow mapTab    = config.MapTab.First(o => o.MapTabID == Request.Form["maptab"]);
        CommonDataFrame         dataFrame = AppContext.GetDataFrame(mapTab);

        Dictionary <String, Configuration.LayerRow>         layers         = new Dictionary <String, Configuration.LayerRow>();
        Dictionary <String, Configuration.LayerFunctionRow> layerFunctions = new Dictionary <String, Configuration.LayerFunctionRow>();

        foreach (Configuration.MapTabLayerRow mapTabLayer in mapTab.GetMapTabLayerRows())
        {
            bool isCandidateLayer = mapTab.IsInteractiveLegendNull() || mapTab.InteractiveLegend == 0;

            if (!isCandidateLayer)
            {
                bool shownInLegend   = !mapTabLayer.IsShowInLegendNull() && mapTabLayer.ShowInLegend == 1;
                bool checkedInLegend = mapTabLayer.IsCheckInLegendNull() || mapTabLayer.CheckInLegend < 0 || visibleLayers.Any(o => o == mapTabLayer.LayerID);
                isCandidateLayer = !shownInLegend || checkedInLegend;
            }

            if (isCandidateLayer)
            {
                Configuration.LayerRow         layer         = mapTabLayer.LayerRow;
                Configuration.LayerFunctionRow layerFunction = layer.GetLayerFunctionRows().FirstOrDefault(o => o.FunctionName.ToLower() == "maptip");

                if (layerFunction != null)
                {
                    layers.Add(layer.LayerName, layer);
                    layerFunctions.Add(layer.LayerName, layerFunction);
                }
            }
        }

        string tipText = null;

        for (int i = 0; i < dataFrame.Layers.Count - 1 && tipText == null; ++i)
        {
            CommonLayer commonLayer = dataFrame.Layers[i];
            string      id          = null;

            if (layers.ContainsKey(commonLayer.Name) && commonLayer.IsWithinScaleThresholds(scale))
            {
                if (commonLayer.Type == CommonLayerType.Feature)
                {
                    Configuration.LayerRow layer = layers[commonLayer.Name];
                    string levelQuery            = layer.GetLevelQuery(commonLayer, level);

                    CommonField keyField = commonLayer.FindField(layer.KeyField);
                    DataTable   table    = commonLayer.GetFeatureTable(keyField.Name, levelQuery, x, y, commonLayer.FeatureType == OgcGeometryType.MultiPolygon ? 0 : distance * scale);

                    if (table != null && table.Rows.Count > 0)
                    {
                        id = table.Rows[table.Rows.Count - 1][0].ToString();
                    }
                }

                if (commonLayer.Type == CommonLayerType.Image)
                {
                    id = ((AgsLayer)commonLayer).GetRasterValue(x, y);
                }
            }

            if (!String.IsNullOrEmpty(id))
            {
                Configuration.LayerFunctionRow layerFunction = layerFunctions[commonLayer.Name];

                using (OleDbCommand command = layerFunction.GetDatabaseCommand())
                {
                    command.Parameters[0].Value = id;

                    if (command.Parameters.Count > 1)
                    {
                        command.Parameters[1].Value = AppUser.GetRole();
                    }

                    using (OleDbDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            StringCollection text = new StringCollection();

                            for (int j = 0; j < reader.FieldCount; ++j)
                            {
                                if (!reader.IsDBNull(j))
                                {
                                    text.Add(reader.GetValue(j).ToString());
                                }
                            }

                            if (text.Count > 0)
                            {
                                tipText = text.Join("\n");
                            }
                        }
                    }

                    command.Connection.Close();
                }
            }
        }

        if (tipText == null)
        {
            ReturnJson(null);
        }
        else
        {
            Dictionary <String, Object> result = new Dictionary <String, Object>();
            result.Add("tipText", tipText);
            ReturnJson(result);
        }
    }
コード例 #17
0
ファイル: Tag.cs プロジェクト: retahc/old-code
 public void Set(CommonField id, string content)
 {
     Set(id.ToString(), content);
 }
コード例 #18
0
        /// <summary>
        /// 获取更新字段集合
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static List <CommonField> GetCommonFields(HttpContext context)
        {
            string entityName      = GetEntityName(context);
            string enityNameFromUI = context.Request["ENTITY_NAME"];

            if (enityNameFromUI.IndexOf("_") != -1)
            {
                enityNameFromUI = enityNameFromUI.Substring(0, enityNameFromUI.IndexOf("_"));
            }
            if (enityNameFromUI.Contains(entityName))
            {
                entityName = enityNameFromUI;
            }
            string             moduleName      = GetModuleName(context);
            object             obj             = DataCommon.GetClassObject("DM." + moduleName, entityName + "Info");
            List <CommonField> commonfieldlist = new List <CommonField>();

            ///此处因为Keys中最后一项是method、key参数,所以需要向前移两位
            for (int i = 0; i < context.Request.Form.AllKeys.Length; i++)
            {
                string propName = context.Request.Form.AllKeys[i];
                if (propName.ToLower() == "method")
                {
                    break;
                }
                string       propValue = context.Request[propName];
                PropertyInfo p         = obj.GetType().GetProperty(propName);
                if (p == null)
                {
                    continue;
                }
                #region FIELD_NAME
                string fieldName = propName.Substring(0, 1).ToUpper();
                for (int j = 1; j < propName.Length; j++)
                {
                    if (propName[j] >= 'a' && propName[j] <= 'z')
                    {
                        fieldName += propName[j].ToString().ToUpper();
                    }
                    else if (propName[j] >= 'A' && propName[j] <= 'Z')
                    {
                        fieldName += "_" + propName[j].ToString().ToUpper();
                    }
                    else
                    {
                        fieldName += propName[j].ToString();
                    }
                }
                #endregion
                CommonField commonfield = new CommonField();
                commonfield.FieldName  = fieldName;
                commonfield.PropName   = propName;
                commonfield.FieldValue = propValue;
                commonfield.DataType   = p.PropertyType.Name;
                if (commonfield.DataType.ToLower() == "nullable`1")
                {
                    if (p.PropertyType.FullName.ToLower().Contains("system.int32"))
                    {
                        commonfield.DataType = "int32?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.int64"))
                    {
                        commonfield.DataType = "int64?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.boolean"))
                    {
                        commonfield.DataType = "boolean?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.decimal"))
                    {
                        commonfield.DataType = "decimal?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.guid"))
                    {
                        commonfield.DataType = "guid?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.datetime"))
                    {
                        commonfield.DataType = "datetime?";
                    }
                }
                commonfieldlist.Add(commonfield);
            }
            return(commonfieldlist);
        }
コード例 #19
0
ファイル: Tag.cs プロジェクト: retahc/old-code
 public void Add(CommonField id, string content)
 {
     Add(id.ToString(), content, false);
 }
コード例 #20
0
ファイル: MapMaker.cs プロジェクト: ClaireBrill/GPV
    private void DrawFeatures(Graphics graphics, string layerId, StringCollection ids, Color color, double opacity, string polygonMode, int penWidth, int dotSize)
    {
        if (ids.Count == 0)
        {
            return;
        }

        bool drawPolygonOutlines = polygonMode == "outline";

        // get the layer

        Configuration config = AppContext.GetConfiguration();

        Configuration.LayerRow layerRow = config.Layer.FindByLayerID(layerId);

        CommonDataFrame dataFrame = AppContext.GetDataFrame(_appState.MapTab);
        CommonLayer     layer     = dataFrame.Layers.FirstOrDefault(lyr => String.Compare(lyr.Name, layerRow.LayerName, true) == 0);

        // build the query string and select the features

        CommonField field     = layer.FindField(layerRow.KeyField);
        string      joinedIds = field.IsNumeric ? ids.Join(",") : String.Format("'{0}'", ids.Join("','"));
        string      query     = String.Format("{0} in ({1})", field.Name, joinedIds);

        string levelQuery = layerRow.GetLevelQuery(layer, _appState.Level);

        if (!String.IsNullOrEmpty(levelQuery))
        {
            query += " and " + levelQuery;
        }

        CommonField keyField = layer.FindField(layerRow.KeyField);
        DataTable   table    = layer.GetFeatureTable(String.Format("{0},{1}", layer.GeometryField.Name, keyField.Name), query);

        if (table == null || table.Rows.Count == 0)
        {
            return;
        }

        OgcGeometryType geometryType = ((IGeometry)table.Rows[0][layer.GeometryField.Name]).OgcGeometryType;

        // prepare the temporary image for drawing transparent highlight graphics

        int width  = Convert.ToInt32(graphics.VisibleClipBounds.Width);
        int height = Convert.ToInt32(graphics.VisibleClipBounds.Height);

        Bitmap   bitMap        = new Bitmap(width, height);
        Graphics imageGraphics = Graphics.FromImage(bitMap);

        imageGraphics.Clear(Color.Transparent);

        // prepare the drawing objects

        Brush brush = new SolidBrush(color);
        Pen   pen   = new Pen(color, Convert.ToSingle(penWidth * _resolution));

        pen.EndCap   = System.Drawing.Drawing2D.LineCap.Square;
        pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
        Pen bufferPen = new Pen(color, Convert.ToSingle(5 * _resolution));

        bufferPen.EndCap   = System.Drawing.Drawing2D.LineCap.Round;
        bufferPen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;

        float dot = Convert.ToSingle(dotSize * _resolution);

        // draw each shape in the table

        foreach (DataRow row in table.Rows)
        {
            switch (geometryType)
            {
            case OgcGeometryType.Point:
                IPoint point = (IPoint)row[layer.GeometryField.Name];
                DrawPoint(imageGraphics, point, brush, dot);
                break;

            case OgcGeometryType.MultiPoint:
                IMultiPoint multiPoint = (IMultiPoint)row[layer.GeometryField.Name];
                DrawPoint(imageGraphics, (IPoint)multiPoint[0], brush, dot);
                break;

            case OgcGeometryType.MultiLineString:
                DrawMultiLineString(imageGraphics, (IMultiLineString)row[layer.GeometryField.Name], pen);
                break;

            case OgcGeometryType.MultiPolygon:
                if (drawPolygonOutlines)
                {
                    DrawMultiPolygon(imageGraphics, (IMultiPolygon)row[layer.GeometryField.Name], null, null, pen);
                }
                else
                {
                    DrawMultiPolygon(imageGraphics, (IMultiPolygon)row[layer.GeometryField.Name], brush, bufferPen);
                }

                break;
            }
        }

        // draw the temporary image containing the highlight graphics on the output image at
        // the specified opacity

        float[][] matrixItems =
        {
            new float[] { 1, 0, 0,                         0, 0 },
            new float[] { 0, 1, 0,                         0, 0 },
            new float[] { 0, 0, 1,                         0, 0 },
            new float[] { 0, 0, 0, Convert.ToSingle(opacity), 0 },
            new float[] { 0, 0, 0,                         0, 1 }
        };

        ColorMatrix colorMatrix = new ColorMatrix(matrixItems);

        ImageAttributes imageAtts = new ImageAttributes();

        imageAtts.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

        Rectangle drawRect = new Rectangle(0, 0, width, height);

        graphics.DrawImage(bitMap, drawRect, 0, 0, width, height, GraphicsUnit.Pixel, imageAtts);
    }
コード例 #21
0
ファイル: Tag.cs プロジェクト: emtees/old-code
 public void Set(CommonField id, string content)
 {
     Set(id.ToString(), content);
 }
コード例 #22
0
ファイル: SelectionManager.cs プロジェクト: jsmeyers/GPV
    public bool SelectTargets()
    {
        if (String.IsNullOrEmpty(_appState.TargetLayer) || String.IsNullOrEmpty(_appState.SelectionLayer))
        {
            return(false);
        }

        _appState.TargetIds.Clear();

        if (_appState.SelectionIds.Count == 0)
        {
            return(false);
        }

        Configuration config = AppContext.GetConfiguration();

        Configuration.LayerRow targetLayerRow = config.Layer.FindByLayerID(_appState.TargetLayer);

        CommonDataFrame dataFrame   = AppContext.GetDataFrame(_appState.MapTab);
        CommonLayer     targetLayer = dataFrame.Layers.FirstOrDefault(lyr => String.Compare(lyr.Name, targetLayerRow.LayerName, true) == 0);
        CommonField     keyField    = targetLayer.FindField(targetLayerRow.KeyField);

        DataTable targetTable = null;
        string    filter      = "";
        string    sort        = "";
        bool      truncated   = false;

        IGeometry selectionShape;

        switch (_appState.Action)
        {
        case Action.FindAllWithin:
            Configuration.ProximityRow proximity = config.Proximity.FindByProximityID(_appState.Proximity);

            targetTable = GetFeatures(FeatureType.Selection);

            if (targetTable.Rows.Count > 0)
            {
                selectionShape = MergeShapes(targetTable);

                if (proximity.Distance > 0)
                {
                    selectionShape = selectionShape.Buffer(proximity.Distance);
                }

                targetTable = targetLayer.GetFeatureTable(String.Format("{0},{1}", targetLayer.GeometryField.Name, keyField.Name), selectionShape);
            }
            break;

        case Action.FindNearest1:
        case Action.FindNearest2:
        case Action.FindNearest3:
        case Action.FindNearest4:
        case Action.FindNearest5:
            Envelope extent = config.Application.FindByApplicationID(_appState.Application).GetFullExtentEnvelope();

            double minDist = targetLayerRow.IsMinNearestDistanceNull() ? 100 : targetLayerRow.MinNearestDistance;
            double maxDist = targetLayerRow.IsMaxNearestDistanceNull() ? Math.Max(extent.Width, extent.Height) : targetLayerRow.MaxNearestDistance;
            int    count   = Convert.ToInt32(Enum.GetName(typeof(Action), _appState.Action).Substring(11));

            targetTable = GetFeatures(FeatureType.Selection);

            if (targetTable.Rows.Count > 0)
            {
                selectionShape = MergeShapes(targetTable);

                double distance = minDist;

                do
                {
                    targetTable = targetLayer.GetFeatureTable(String.Format("{0},{1}", targetLayer.GeometryField.Name, keyField.Name), selectionShape.Buffer(distance));
                    distance   *= 1.414213562;
                }while ((targetTable == null || targetTable.Rows.Count < count) && distance < maxDist);

                if (targetTable != null)
                {
                    targetTable.Columns.Add("Distance", typeof(double));
                    targetTable.Columns.Add("Index", typeof(int));
                    filter = "Index <= " + count.ToString();
                    sort   = "Index";

                    DataColumn targetShapeColumn    = targetTable.Columns.Cast <DataColumn>().First(c => c.DataType.IsSubclassOf(typeof(Geometry)));
                    int        targetDistanceColumn = targetTable.Columns.IndexOf("Distance");

                    DataTable  selectionTable       = GetFeatures(FeatureType.Selection);
                    DataColumn selectionShapeColumn = selectionTable.Columns.Cast <DataColumn>().First(c => c.DataType.IsSubclassOf(typeof(Geometry)));

                    foreach (DataRow selectionRow in selectionTable.Rows)
                    {
                        selectionShape = (Geometry)selectionRow[selectionShapeColumn];

                        foreach (DataRow targetRow in targetTable.Rows)
                        {
                            double d = selectionShape.Distance((Geometry)targetRow[targetShapeColumn]);

                            if (targetRow.IsNull(targetDistanceColumn))
                            {
                                targetRow[targetDistanceColumn] = d;
                            }
                            else
                            {
                                targetRow[targetDistanceColumn] = Math.Min((double)targetRow[targetDistanceColumn], d);
                            }
                        }
                    }

                    DataRow[] targetRows = targetTable.Select("", "Distance");

                    for (int i = 0; i < targetRows.Length; ++i)
                    {
                        targetRows[i]["Index"] = i + 1;
                    }
                }
            }
            break;
        }

        if (targetTable != null)
        {
            int maxTargets = targetLayerRow.IsMaxNumberSelectedNull() ? Int32.MaxValue : targetLayerRow.MaxNumberSelected;
            int c          = targetTable.Columns.IndexOf(keyField.Name);

            foreach (DataRow row in targetTable.Select(filter, sort))
            {
                if (!row.IsNull(c))
                {
                    if (_appState.TargetIds.Count == maxTargets)
                    {
                        truncated = true;
                        break;
                    }

                    _appState.TargetIds.Add(row[c].ToString());
                }
            }
        }

        return(truncated);
    }
コード例 #23
0
ファイル: Tag.cs プロジェクト: emtees/old-code
 public void Add(CommonField id, string content)
 {
     Add(id.ToString(), content, false);
 }
コード例 #24
0
ファイル: SelectionHandler.cs プロジェクト: jsmeyers/GPV
    private void SelectFeatures()
    {
        AppState appState  = AppState.FromJson(Request.Form["state"]);
        bool     updated   = false;
        bool     truncated = false;

        if (Request.Form["geo"] == null)
        {
            appState.SelectionManager.SelectTargets();
            updated = true;
        }
        else
        {
            double[] geo = Request.Form["geo"].Split(',').Select(o => Convert.ToDouble(o)).ToArray();

            CommonDataFrame        dataFrame   = AppContext.GetDataFrame(appState.MapTab);
            Configuration.LayerRow layer       = Configuration.Layer.First(o => o.LayerID == (appState.Action == Action.Select ? appState.TargetLayer : appState.SelectionLayer));
            CommonLayer            commonLayer = dataFrame.Layers.FirstOrDefault(o => String.Compare(o.Name, layer.LayerName, true) == 0);
            CommonField            keyField    = commonLayer.FindField(layer.KeyField);

            string levelQuery = layer.GetLevelQuery(commonLayer, appState.Level);

            DataTable table = null;

            if (geo.Length == 4)
            {
                Envelope box = EnvelopeExtensions.FromArray(geo);

                if (!layer.IsMaxSelectionAreaNull() && layer.MaxSelectionArea > 0 && box.Width * box.Height > layer.MaxSelectionArea)
                {
                    throw new AppException("The selection shape was too large; try again with a smaller shape");
                }

                table = commonLayer.GetFeatureTable(keyField.Name, levelQuery, box.ToPolygon());
            }
            else
            {
                table = commonLayer.GetFeatureTable(keyField.Name, levelQuery, geo[0], geo[1], geo[2]);
            }

            UpdateMode mode = (UpdateMode)Enum.Parse(typeof(UpdateMode), Request.Form["mode"], true);

            if (table != null && table.Rows.Count > 0)
            {
                if (appState.Action == Action.Select)
                {
                    updated = UpdateIds(appState.TargetIds, table, mode);

                    if (!layer.IsMaxNumberSelectedNull())
                    {
                        truncated = appState.TargetIds.Truncate(layer.MaxNumberSelected);
                    }

                    if (mode != UpdateMode.Remove && table.Rows.Count == 1)
                    {
                        updated = UpdateActive(appState, table.Rows[0][0].ToString()) || updated;
                    }
                }
                else
                {
                    updated = UpdateIds(appState.SelectionIds, table, mode);

                    if (!layer.IsMaxNumberSelectedNull())
                    {
                        appState.SelectionIds.Truncate(layer.MaxNumberSelected);
                    }

                    if (updated)
                    {
                        truncated = appState.SelectionManager.SelectTargets();
                    }
                }
            }
            else if (mode == UpdateMode.New)
            {
                updated = appState.Action == Action.Select ? appState.TargetIds.Count > 0 : appState.SelectionIds.Count > 0;
                appState.TargetIds.Clear();
                appState.SelectionIds.Clear();
                appState.ActiveMapId  = "";
                appState.ActiveDataId = "";
            }
        }

        if (!updated)
        {
            ReturnJson(null);
        }

        if (!appState.TargetIds.Contains(appState.ActiveMapId))
        {
            appState.ActiveMapId  = "";
            appState.ActiveDataId = "";
        }

        Dictionary <String, Object> state = new Dictionary <String, Object>();

        state.Add("ActiveMapId", appState.ActiveMapId);
        state.Add("ActiveDataId", appState.ActiveDataId);
        state.Add("TargetIds", appState.TargetIds);
        state.Add("SelectionIds", appState.SelectionIds);

        Dictionary <String, Object> result = new Dictionary <String, Object>();

        result.Add("state", state);
        result.Add("truncated", truncated);
        ReturnJson(result);
    }
コード例 #25
0
        private void BtnClickSaveGiftData_Click(object sender, EventArgs e)
        {
            //Pass style identifier.
            EditText edtPassStyleIdentifierGift = FindViewById <EditText>(Resource.Id.passStyleIdentifierGift);
            string   styleId = edtPassStyleIdentifierGift.Text.Trim().ToString();

            if (TextUtils.IsEmpty(styleId))
            {
                Toast.MakeText(this, "Template Id cant be empty.", ToastLength.Long).Show();
                return;
            }

            //Construct gift card data.
            PassObject.Builder passBuilder = PassObject.GetBuilder();

            //Common fields.
            List <CommonField> commonFields = new List <CommonField>();
            //Append fields.
            List <AppendField> appendFields = new List <AppendField>();

            //Background and description
            EditText edtBackgroundColor     = FindViewById <EditText>(Resource.Id.giftBackGroundImage);
            EditText edtBackgroundColorDesc = FindViewById <EditText>(Resource.Id.giftBackGroundImageDesc);

            //1 Background image of the card.
            CommonField backgroundImageCommonField = CommonField.GetBuilder()
                                                     .SetKey(WalletPassConstant.PassCommonFieldKeyBackgroundImg)
                                                     .SetLabel(edtBackgroundColorDesc.Text.Trim().ToString())
                                                     .SetValue(edtBackgroundColor.Text.Trim().ToString())
                                                     .Build();

            commonFields.Add(backgroundImageCommonField);

            //2 Logo on the card
            //Logo
            EditText    edtGiftCardLogo = FindViewById <EditText>(Resource.Id.giftCardLogo);
            CommonField logoCommonField = CommonField.GetBuilder()
                                          .SetKey(WalletPassConstant.PassCommonFieldKeyLogo)
                                          .SetLabel("This is logo label")
                                          .SetValue(edtGiftCardLogo.Text.Trim().ToString())
                                          .Build();

            commonFields.Add(logoCommonField);

            //3 Merchant name
            EditText edtMerchantName = FindViewById <EditText>(Resource.Id.giftMerchantName);

            CommonField merchantNameCommonField = CommonField.GetBuilder()
                                                  .SetKey(WalletPassConstant.PassCommonFieldKeyMerchantName)
                                                  .SetLabel("This is Merchant Name label")
                                                  .SetValue(edtMerchantName.Text.Trim().ToString())
                                                  .Build();

            commonFields.Add(merchantNameCommonField);

            //4 Card name
            EditText    edtGiftCardname     = FindViewById <EditText>(Resource.Id.giftCardname);
            CommonField cardNameCommonField = CommonField.GetBuilder()
                                              .SetKey(WalletPassConstant.PassCommonFieldKeyName)
                                              .SetLabel("This is Card name label")
                                              .SetValue(edtGiftCardname.Text.Trim().ToString())
                                              .Build();

            commonFields.Add(cardNameCommonField);

            //5 Card number
            EditText edtGiftCardNumber = FindViewById <EditText>(Resource.Id.giftCardNumber);
            string   giftCardNumber    = edtGiftCardNumber.Text.Trim().ToString();

            if (TextUtils.IsEmpty(giftCardNumber))
            {
                Toast.MakeText(this, "Card number can't be empty.", ToastLength.Long).Show();
                return;
            }
            CommonField cardNumberCommonField = CommonField.GetBuilder()
                                                .SetKey(WalletPassConstant.PassCommonFieldKeyCardNumber)
                                                .SetLabel("This is CardNumber label")
                                                .SetValue(giftCardNumber)
                                                .Build();

            commonFields.Add(cardNumberCommonField);

            //6 Balance
            EditText    edtGiftBalance     = FindViewById <EditText>(Resource.Id.giftBalance);
            CommonField balanceCommonField = CommonField.GetBuilder()
                                             .SetKey(WalletPassConstant.PassCommonFieldKeyBalance)
                                             .SetLabel("This is balance label")
                                             .SetValue(edtGiftBalance.Text.Trim().ToString())
                                             .Build();

            commonFields.Add(balanceCommonField);

            //Gift currrency
            EditText edtGiftCurrency = FindViewById <EditText>(Resource.Id.giftCurrency);

            passBuilder.SetCurrencyCode(edtGiftCurrency.Text.Trim().ToString());

            //7 Barcode or Qrcode
            EditText edtPassBarcodeAlternate = FindViewById <EditText>(Resource.Id.passBarcodeAlternateText);
            string   barType             = BarCode.BarcodeTypeQrCode;
            EditText edtPassBarcodeValue = FindViewById <EditText>(Resource.Id.passBarcodeValue);

            switch (barcodeStyleList[barcodeStyleIndex])
            {
            case "Codabar":
                barType = BarCode.BarcodeTypeCodabar;
                break;

            case "QrCode":
                barType = BarCode.BarcodeTypeQrCode;
                break;

            default:
                break;
            }

            BarCode barCode = BarCode.GetBuilder()
                              .SetType(barType)
                              .SetValue(edtPassBarcodeValue.Text.Trim().ToString())
                              .SetText(edtPassBarcodeAlternate.Text.Trim().ToString())
                              .Build();

            passBuilder.SetBarCode(barCode);

            //9 Balance update time
            // balance update time
            long update = 0;

            if (TextUtils.IsEmpty(updateTime))
            {
                Toast.MakeText(this, "Please select balance updateTime", ToastLength.Long).Show();
                return;
            }
            else
            {
                update = BasisTimesUtils.GetLongtimeOfYMD(updateTime);
            }

            //Simple date format
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
            // Create SimpleDateFormat
            string      updateTimeValue = format.Format(new Java.Util.Date(update));
            CommonField balanceUpdateTimeAppendfield = CommonField.GetBuilder()
                                                       .SetKey(WalletPassConstant.PassCommonFieldKeyBalanceRefreshTime)
                                                       .SetLabel("Updated")
                                                       .SetValue(updateTimeValue)
                                                       .Build();

            commonFields.Add(balanceUpdateTimeAppendfield);

            //10 Pin
            EditText    edtGiftCardPin = FindViewById <EditText>(Resource.Id.giftCardPin);
            CommonField pinCommonField = CommonField.GetBuilder()
                                         .SetKey(WalletPassConstant.PassCommonFieldKeyBlancePin)
                                         .SetLabel("PIN Number")
                                         .SetValue(edtGiftCardPin.Text.ToString())
                                         .Build();

            commonFields.Add(pinCommonField);

            //11 Event number
            EditText    edtGiftEventNumber     = FindViewById <EditText>(Resource.Id.giftEventNumber);
            AppendField eventNumberAppendField = AppendField.GetBuilder()
                                                 .SetKey(WalletPassConstant.PassAppendFieldKeyEventNumber)
                                                 .SetLabel("Event Number")
                                                 .SetValue(edtGiftEventNumber.Text.Trim().ToString())
                                                 .Build();

            appendFields.Add(eventNumberAppendField);

            //12 Message
            //message
            EditText edtMessageHeaderGift    = FindViewById <EditText>(Resource.Id.messageHeaderGift);
            EditText edtMessageBodyGift      = FindViewById <EditText>(Resource.Id.messageBodyGift);
            EditText edtMessageHeaderGiftOne = FindViewById <EditText>(Resource.Id.messageHeaderGift1);
            EditText edtMessageBodyGiftOne   = FindViewById <EditText>(Resource.Id.messageBodyGift1);

            List <AppendField> messageList = new List <AppendField>();

            messageList.Add(AppendField.GetBuilder()
                            .SetKey("1")
                            .SetLabel(edtMessageHeaderGift.Text.Trim().ToString())
                            .SetValue(edtMessageBodyGift.Text.Trim().ToString())
                            .Build());
            messageList.Add(AppendField.GetBuilder()
                            .SetKey("2")
                            .SetLabel(edtMessageHeaderGiftOne.Text.Trim().ToString())
                            .SetValue(edtMessageBodyGiftOne.Text.Trim().ToString())
                            .Build());
            passBuilder.AddMessageList(messageList);

            //13 Scrolling images
            List <AppendField> imageList                 = new List <AppendField>();
            EditText           edtScrollingImagesOne     = FindViewById <EditText>(Resource.Id.giftScrollingImages1);
            EditText           edtScrollingImagesDescOne = FindViewById <EditText>(Resource.Id.giftScrollingDesc1);
            EditText           edtScrollingImagesTwo     = FindViewById <EditText>(Resource.Id.giftScrollingImages2);
            EditText           edtScrollingImagesDescTwo = FindViewById <EditText>(Resource.Id.giftScrollingDesc2);

            imageList.Add(AppendField.GetBuilder()
                          .SetKey("1")
                          .SetLabel(edtScrollingImagesDescOne.Text.Trim().ToString())
                          .SetValue(edtScrollingImagesDescTwo.Text.Trim().ToString())
                          .Build());
            imageList.Add(AppendField.GetBuilder()
                          .SetKey("2")
                          .SetLabel(edtScrollingImagesDescTwo.Text.Trim().ToString())
                          .SetValue(edtScrollingImagesTwo.Text.Trim().ToString())
                          .Build());
            passBuilder.AddImageList(imageList);

            //UrlList
            EditText edtGiftUrlLabel    = FindViewById <EditText>(Resource.Id.giftUrlLable);
            EditText edtGiftUrlValue    = FindViewById <EditText>(Resource.Id.giftUrlValue);
            EditText edtGiftUrlLabelOne = FindViewById <EditText>(Resource.Id.giftUrlLable1);
            EditText edtGiftUrlValueOne = FindViewById <EditText>(Resource.Id.giftUrlValue1);

            List <AppendField> urlList = new List <AppendField>();

            urlList.Add(AppendField.GetBuilder()
                        .SetKey("1")
                        .SetLabel(edtGiftUrlLabel.Text.Trim().ToString())
                        .SetValue(edtGiftUrlValue.Text.Trim().ToString())
                        .Build());
            urlList.Add(AppendField.GetBuilder()
                        .SetKey("2")
                        .SetLabel(edtGiftUrlLabelOne.Text.Trim().ToString())
                        .SetValue(edtGiftUrlValueOne.Text.Trim().ToString())
                        .Build());
            passBuilder.AddUrlList(urlList);

            //14 Nearby stores
            EditText    edtGiftNearbyStoresUrl  = FindViewById <EditText>(Resource.Id.giftNearbyStoresUrl);
            EditText    edtGiftNearbyStoresName = FindViewById <EditText>(Resource.Id.giftNearbyStoresName);
            AppendField nearbyAppendField       = AppendField.GetBuilder()
                                                  .SetKey(WalletPassConstant.PassAppendFieldKeyNearbyLocations)
                                                  .SetLabel(edtGiftNearbyStoresName.Text.Trim().ToString())
                                                  .SetValue(edtGiftNearbyStoresUrl.Text.Trim().ToString())
                                                  .Build();

            appendFields.Add(nearbyAppendField);

            //15 Main page
            EditText edtGiftMainPageUrl  = FindViewById <EditText>(Resource.Id.giftMainPageUrl);
            EditText edtGiftMainPageName = FindViewById <EditText>(Resource.Id.giftMainPageName);

            AppendField mainPageAppendField = AppendField.GetBuilder()
                                              .SetKey(WalletPassConstant.PassAppendFieldKeyMainpage)
                                              .SetLabel(edtGiftMainPageName.Text.Trim().ToString())
                                              .SetValue(edtGiftMainPageUrl.Text.Trim().ToString())
                                              .Build();

            appendFields.Add(mainPageAppendField);
            //16 Hotline
            EditText    edtGiftHotlinePone = FindViewById <EditText>(Resource.Id.giftHotlinePone);
            EditText    edtGiftHotlineName = FindViewById <EditText>(Resource.Id.giftHotlineName);
            AppendField hotlineAppendField = AppendField.GetBuilder()
                                             .SetKey(WalletPassConstant.PassAppendFieldKeyHotline)
                                             .SetLabel(edtGiftHotlineName.Text.Trim().ToString())
                                             .SetValue(edtGiftHotlinePone.Text.Trim().ToString())
                                             .Build();
            //Public constant
            //Time check
            long start = 0;
            long end   = 0;
            Date date  = new Date();

            if (TextUtils.IsEmpty(startTime))
            {
                Toast.MakeText(this, "Please select Starttime", ToastLength.Long).Show();
                return;
            }
            else
            {
                start = BasisTimesUtils.GetLongtimeOfYMD(startTime);
            }

            if (TextUtils.IsEmpty(endTime))
            {
                Toast.MakeText(this, "Please select EndTime", ToastLength.Long).Show();
                return;
            }
            else
            {
                end = BasisTimesUtils.GetLongtimeOfYMD(endTime);
            }

            if (end <= start || end <= date.Time)
            {
                Toast.MakeText(this, "Please check (EndTime > StartTime)&& (EndTime > Current Time)", ToastLength.Long).Show();
                return;
            }
            //serial Number
            EditText organizationPassIdGift = FindViewById <EditText>(Resource.Id.organizationPassIdGift);
            string   organizationPassId     = organizationPassIdGift.Text.Trim().ToString();

            if (TextUtils.IsEmpty(organizationPassId))
            {
                Toast.MakeText(this, "SerialNumber can't be empty.", ToastLength.Long).Show();
                return;
            }

            EditText passTypeId = FindViewById <EditText>(Resource.Id.passTypeIdentifier);
            string   typeId     = passTypeId.Text.Trim().ToString();

            if (TextUtils.IsEmpty(typeId))
            {
                Toast.MakeText(this, "Pass Type can't be empty", ToastLength.Long).Show();
                return;
            }

            EditText edtIssuerIdGift = FindViewById <EditText>(Resource.Id.issuerIdGift);
            string   issuerId        = edtIssuerIdGift.Text.Trim().ToString();

            if (TextUtils.IsEmpty(issuerId))
            {
                Toast.MakeText(this, "Issuer id can't be empty.", ToastLength.Long).Show();
                return;
            }

            //State
            string state = WalletPassConstant.PassStateActive;

            switch (dataList[index])
            {
            case "ACTIVE":
                state = WalletPassConstant.PassStateActive;
                break;

            case "COMPLETED":
                state = WalletPassConstant.PassStateCompleted;
                break;

            case "EXPIRED":
                state = WalletPassConstant.PassStateExpired;
                break;

            case "INACTIVE":
                state = WalletPassConstant.PassStateInactive;
                break;

            default:
                break;
            }

            appendFields.Add(hotlineAppendField);
            //PassStyleIdentifier
            EditText edtPassStyleIdentifier = FindViewById <EditText>(Resource.Id.passStyleIdentifierGift);

            passBuilder.SetOrganizationPassId(edtGiftCardNumber.Text.Trim().ToString());
            passBuilder.SetPassStyleIdentifier(edtPassStyleIdentifier.Text.Trim().ToString());
            passBuilder.SetPassTypeIdentifier(typeId);
            passBuilder.SetSerialNumber(organizationPassId);
            passBuilder.SetStatus(PassStatus.GetBuilder().SetState(state).SetEffectTime(format.Format(new Date(start))).SetExpireTime(format.Format(new Date(end))).Build());
            passBuilder.AddAppendFields(appendFields);
            passBuilder.AddCommonFields(commonFields);
            PassObject passObject = passBuilder.Build();

            Log.Info("GiftCardActivity", "passObject: " + passObject.ToJson());
            Intent intent = new Intent(this, typeof(PassTestActivity));

            intent.PutExtra("passObject", passObject.ToJson());
            intent.PutExtra("passId", organizationPassId);
            intent.PutExtra("issuerId", issuerId);
            intent.PutExtra("typeId", typeId);
            StartActivity(intent);
        }
コード例 #26
0
        private void BtnClickSaveData_Click(object sender, EventArgs e)
        {
            // Serial number
            EditText serialNumberLoyalty = FindViewById <EditText>(Resource.Id.serinumberLoyalty);
            string   serialNumber        = serialNumberLoyalty.Text.ToString().Trim();

            if (TextUtils.IsEmpty(serialNumber))
            {
                Toast.MakeText(this, "Serial number can't be empty.", ToastLength.Long).Show();
                return;
            }

            // Pass type.
            EditText passStyleIdentifier = FindViewById <EditText>(Resource.Id.passStyleIdentifier);
            TextView passTypeId          = FindViewById <TextView>(Resource.Id.passTypeId);
            string   typeId = passTypeId.Text.ToString().Trim();

            if (TextUtils.IsEmpty(typeId))
            {
                Toast.MakeText(this, "Pass type can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Issuer Id(App ID)
            TextView issuerIdView = FindViewById <TextView>(Resource.Id.issuerId);
            string   issuerId     = issuerIdView.Text.ToString().Trim();

            if (TextUtils.IsEmpty(issuerId))
            {
                Toast.MakeText(this, "IssuerId can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Card Number.
            EditText edtCardNumber = FindViewById <EditText>(Resource.Id.cardNumberLoyalty);
            string   cardNumber    = edtCardNumber.Text.ToString().Trim();

            if (TextUtils.IsEmpty(cardNumber))
            {
                Toast.MakeText(this, "Card Number can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Member Name.
            EditText edtMemberName = FindViewById <EditText>(Resource.Id.memberName);
            string   memberName    = edtMemberName.Text.ToString().Trim();

            if (TextUtils.IsEmpty(memberName))
            {
                Toast.MakeText(this, "Member Name can't be empty.", ToastLength.Long).Show();
                return;
            }

            //Locations
            EditText latitude   = FindViewById <EditText>(Resource.Id.latitude);
            EditText longitude  = FindViewById <EditText>(Resource.Id.longitude);
            EditText latitude1  = FindViewById <EditText>(Resource.Id.latitude1);
            EditText longitude1 = FindViewById <EditText>(Resource.Id.longitude1);

            //Add location.
            double latitudeValue  = 0.0;
            double longitudeValue = 0.0;
            string latitudeStr    = latitude.Text.ToString().Trim();
            string longitudeStr   = longitude.Text.ToString().Trim();
            string latitude1Str   = latitude1.Text.ToString().Trim();
            string longitude1Str  = longitude1.Text.ToString().Trim();

            if (TextUtils.IsEmpty(latitudeStr) || TextUtils.IsEmpty(longitudeStr))
            {
                Toast.MakeText(this, "Latitude & Longitude can't be empty.", ToastLength.Long).Show();
                return;
            }
            else
            {
                if (-90.0d <= Convert.ToDouble(latitudeStr) && Convert.ToDouble(latitudeStr) <= 90.0d &&
                    -180.0d <= Convert.ToDouble(longitudeStr) && Convert.ToDouble(longitudeStr) <= 180.0d)
                {
                    latitudeValue  = Convert.ToDouble(latitudeStr);
                    longitudeValue = Convert.ToDouble(longitudeStr);
                }
                else
                {
                    Toast.MakeText(this, "Latitude or Longitude value is illegal.", ToastLength.Long).Show();
                    return;
                }
            }

            //State
            string state = WalletPassConstant.PassStateActive;

            switch (dataList[index])
            {
            case "ACTIVE":
                state = WalletPassConstant.PassStateActive;
                break;

            case "COMPLETED":
                state = WalletPassConstant.PassStateCompleted;
                break;

            case "EXPIRED":
                state = WalletPassConstant.PassStateExpired;
                break;

            case "INACTIVE":
                state = WalletPassConstant.PassStateInactive;
                break;

            default:
                break;
            }

            //Create PassObject.Builder object.
            PassObject.Builder passBuilder = PassObject.GetBuilder();
            //Create common fields list.
            List <CommonField> commonField = new List <CommonField>();
            //Create append fields list.
            List <AppendField> appendFields = new List <AppendField>();

            //1	Background image of the card
            EditText    backgroundImage            = FindViewById <EditText>(Resource.Id.backgroundImage);
            CommonField backgroundImageCommonField = CommonField.GetBuilder()
                                                     .SetKey(WalletPassConstant.PassCommonFieldKeyBackgroundImg)
                                                     .SetLabel("backgroundImageLabel")
                                                     .SetValue(backgroundImage.Text.Trim().ToString())
                                                     .Build();

            commonField.Add(backgroundImageCommonField);

            //2	Logo on the card
            EditText    logoLoyalty     = FindViewById <EditText>(Resource.Id.logoLoyalty);
            CommonField logoCommonField = CommonField.GetBuilder()
                                          .SetKey(WalletPassConstant.PassCommonFieldKeyLogo)
                                          .SetLabel("This is logo label")
                                          .SetValue(logoLoyalty.Text.Trim().ToString())
                                          .Build();

            commonField.Add(logoCommonField);

            //3 Merchant name
            EditText    merchantNameLoyalty     = FindViewById <EditText>(Resource.Id.merchantNameLoyalty);
            CommonField merchantNameCommonField = CommonField.GetBuilder()
                                                  .SetKey(WalletPassConstant.PassCommonFieldKeyMerchantName)
                                                  .SetLabel("This is merchantName label.")
                                                  .SetValue(merchantNameLoyalty.Text.Trim().ToString())
                                                  .Build();

            commonField.Add(merchantNameCommonField);

            //4 Card name
            EditText    cardNameLoyalty     = FindViewById <EditText>(Resource.Id.nameLoyalty);
            CommonField cardNameCommonField = CommonField.GetBuilder()
                                              .SetKey(WalletPassConstant.PassCommonFieldKeyName)
                                              .SetLabel("This is cardName label")
                                              .SetValue(cardNameLoyalty.Text.Trim().ToString())
                                              .Build();

            commonField.Add(cardNameCommonField);

            //5 Card number
            CommonField cardNumberCommonField = CommonField.GetBuilder()
                                                .SetKey(WalletPassConstant.PassCommonFieldKeyCardNumber)
                                                .SetLabel("This is cardNumber label")
                                                .SetValue(cardNumber)
                                                .Build();

            //6 Balance
            EditText    balance            = FindViewById <EditText>(Resource.Id.balanceLoyalty);
            AppendField balanceCommonField = AppendField.GetBuilder()
                                             .SetKey(WalletPassConstant.PassCommonFieldKeyBalance)
                                             .SetLabel("Balance")
                                             .SetValue(balance.Text.Trim().ToString())
                                             .Build();

            appendFields.Add(balanceCommonField);

            //7 Number of associated coupons
            EditText relatedPassIdOne = FindViewById <EditText>(Resource.Id.relatedPassId1);
            EditText relatedPassTwo   = FindViewById <EditText>(Resource.Id.relatedPassId2);
            EditText relatedPassThree = FindViewById <EditText>(Resource.Id.relatedPassId3);
            EditText relatedPassFour  = FindViewById <EditText>(Resource.Id.relatedPassId4);
            List <RelatedPassInfo> relatedPassInfos = new List <RelatedPassInfo>();

            relatedPassInfos.Add(new RelatedPassInfo(relatedPassIdOne.Text.Trim().ToString(), relatedPassTwo.Text.Trim().ToString()));
            relatedPassInfos.Add(new RelatedPassInfo(relatedPassThree.Text.Trim().ToString(), relatedPassFour.Text.Trim().ToString()));
            passBuilder.AddRelatedPassIds(relatedPassInfos);

            //8 Number of loyalty points
            EditText    pointsLoyalty        = FindViewById <EditText>(Resource.Id.pointsLoyalty);
            AppendField pointsNubAppendField = AppendField.GetBuilder()
                                               .SetKey(WalletPassConstant.PassAppendFieldKeyPoints)
                                               .SetLabel("Points")
                                               .SetValue(pointsLoyalty.Text.Trim().ToString())
                                               .Build();

            appendFields.Add(pointsNubAppendField);

            //9 Barcode or QR Code
            //10 Remarks
            EditText barcodeText  = FindViewById <EditText>(Resource.Id.barcodeTextLoyalty);
            EditText barcodeValue = FindViewById <EditText>(Resource.Id.barcodeValueLoyalty);
            BarCode  barCode      = BarCode.GetBuilder()
                                    .SetType(BarCode.BarcodeTypeQrCode)
                                    .SetValue(barcodeValue.Text.Trim().ToString())
                                    .SetText(barcodeText.Text.Trim().ToString())
                                    .Build();

            passBuilder.SetBarCode(barCode);

            //11 Member name
            CommonField memberNameCommonField = CommonField.GetBuilder()
                                                .SetKey(WalletPassConstant.PassCommonFieldKeyMemberName)
                                                .SetLabel("Member Name")
                                                .SetValue(memberName)
                                                .Build();

            commonField.Add(memberNameCommonField);
            //12	Loyalty card number ->same to 5.Card number

            //13 Loyalty level
            EditText    edtLevelLoyalty  = FindViewById <EditText>(Resource.Id.levelLoyalty);
            AppendField levelAppendField = AppendField.GetBuilder()
                                           .SetKey(WalletPassConstant.PassAppendFieldKeyRewardsLevel)
                                           .SetLabel("Tier")
                                           .SetValue(edtLevelLoyalty.Text.Trim().ToString())
                                           .Build();

            appendFields.Add(levelAppendField);

            //14 Message
            EditText           messageHeader    = FindViewById <EditText>(Resource.Id.messageHeader);
            EditText           messageBody      = FindViewById <EditText>(Resource.Id.messageBody);
            EditText           messageHeaderOne = FindViewById <EditText>(Resource.Id.messageHeader1);
            EditText           messageBodyOne   = FindViewById <EditText>(Resource.Id.messageBody1);
            List <AppendField> messageList      = new List <AppendField>();

            messageList.Add(AppendField.GetBuilder()
                            .SetKey("1")
                            .SetLabel(messageHeader.Text.Trim().ToString())
                            .SetValue(messageBody.Text.Trim().ToString())
                            .Build());
            messageList.Add(AppendField.GetBuilder()
                            .SetKey("2")
                            .SetLabel(messageHeaderOne.Text.Trim().ToString())
                            .SetValue(messageBodyOne.Text.Trim().ToString())
                            .Build());
            passBuilder.AddMessageList(messageList);

            //15 Scrolling Images
            //ImageUris
            EditText           imageModuleDataMainUris       = FindViewById <EditText>(Resource.Id.imageModuleDataMainImageUris);
            EditText           imageModuleDataMainUrisDes    = FindViewById <EditText>(Resource.Id.imageModuleDataMainImageUrisDes);
            EditText           imageModuleDataMainUrisOne    = FindViewById <EditText>(Resource.Id.imageModuleDataMainImageUris1);
            EditText           imageModuleDataMainUrisDesOne = FindViewById <EditText>(Resource.Id.imageModuleDataMainImageUrisDes1);
            List <AppendField> imageList = new List <AppendField>();

            imageList.Add(AppendField.GetBuilder()
                          .SetKey("1")
                          .SetLabel(imageModuleDataMainUrisDes.Text.Trim().ToString())
                          .SetValue(imageModuleDataMainUris.Text.Trim().ToString())
                          .Build());
            imageList.Add(AppendField.GetBuilder()
                          .SetKey("2")
                          .SetLabel(imageModuleDataMainUrisDesOne.Text.Trim().ToString())
                          .SetValue(imageModuleDataMainUrisOne.Text.Trim().ToString())
                          .Build());
            passBuilder.AddImageList(imageList);

            //UrlList
            EditText           loyaltyUrlLabel    = FindViewById <EditText>(Resource.Id.loyaltyUrlLable);
            EditText           loyaltyUrlValue    = FindViewById <EditText>(Resource.Id.loyaltyUrlValue);
            EditText           loyaltyUrlLabelOne = FindViewById <EditText>(Resource.Id.loyaltyUrlLable1);
            EditText           loyaltyUrlValueOne = FindViewById <EditText>(Resource.Id.loyaltyUrlValue1);
            List <AppendField> urlList            = new List <AppendField>();

            urlList.Add(AppendField.GetBuilder()
                        .SetKey("1")
                        .SetLabel(loyaltyUrlLabel.Text.Trim().ToString())
                        .SetValue(loyaltyUrlValue.Text.Trim().ToString())
                        .Build());
            urlList.Add(AppendField.GetBuilder()
                        .SetKey("2")
                        .SetLabel(loyaltyUrlLabelOne.Text.Trim().ToString())
                        .SetValue(loyaltyUrlValueOne.Text.Trim().ToString())
                        .Build());
            passBuilder.AddUrlList(urlList);

            //16 Nearby stores
            EditText    nearbyLocationsLabel    = FindViewById <EditText>(Resource.Id.nearbyLocationsLable);
            EditText    nearbyLocationsValue    = FindViewById <EditText>(Resource.Id.nearbyLocationsValue);
            string      nearbyLocationsLabelStr = nearbyLocationsLabel.Text.Trim().ToString();
            string      nearbyLocationsValueStr = nearbyLocationsValue.Text.Trim().ToString();
            AppendField nearbyAppendField       = AppendField.GetBuilder()
                                                  .SetKey(WalletPassConstant.PassAppendFieldKeyNearbyLocations)
                                                  .SetLabel(nearbyLocationsLabelStr)
                                                  .SetValue(nearbyLocationsValueStr)
                                                  .Build();

            appendFields.Add(nearbyAppendField);

            //17 Main Page
            EditText    webSiteLabel        = FindViewById <EditText>(Resource.Id.websiteLable);
            EditText    webSiteValue        = FindViewById <EditText>(Resource.Id.websiteValue);
            string      webSiteLabelStr     = webSiteLabel.Text.Trim().ToString();
            string      webSiteValueStr     = webSiteValue.Text.Trim().ToString();
            AppendField mainPageAppendField = AppendField.GetBuilder()
                                              .SetKey(WalletPassConstant.PassAppendFieldKeyMainpage)
                                              .SetLabel(webSiteLabelStr)
                                              .SetValue(webSiteValueStr)
                                              .Build();

            appendFields.Add(mainPageAppendField);

            //18 Hotline
            EditText    hotLineLabel       = FindViewById <EditText>(Resource.Id.hotlineLable);
            EditText    hotLineValue       = FindViewById <EditText>(Resource.Id.hotlineValue);
            string      hotLineLabelStr    = hotLineLabel.Text.Trim().ToString();
            string      hotLineValueStr    = hotLineValue.Text.Trim().ToString();
            AppendField hotLineAppendField = AppendField.GetBuilder()
                                             .SetKey(WalletPassConstant.PassAppendFieldKeyHotline)
                                             .SetLabel(hotLineLabelStr)
                                             .SetValue(hotLineValueStr)
                                             .Build();

            appendFields.Add(hotLineAppendField);

            //Latlng
            List <Location> locationList = new List <Location>();

            locationList.Add(new Location(longitudeStr, latitudeStr));
            locationList.Add(new Location(longitude1Str, latitude1Str));
            passBuilder.AddLocationList(locationList);

            //Time
            long start = 0;
            long end   = 0;
            Date date  = new Date();

            if (TextUtils.IsEmpty(startTime))
            {
                Toast.MakeText(this, "Please select StartTime", ToastLength.Long).Show();
                return;
            }
            else
            {
                start = BasisTimesUtils.GetLongtimeOfYMD(startTime);
            }

            if (TextUtils.IsEmpty(endTime))
            {
                Toast.MakeText(this, "Please select EndTime", ToastLength.Long).Show();
                return;
            }
            else
            {
                end = BasisTimesUtils.GetLongtimeOfYMD(endTime);
            }

            if (end <= start || end <= date.Time)
            {
                Toast.MakeText(this, "Please check (EndTime > StartTime) && (EndTime > Current time)", ToastLength.Long).Show();
                return;
            }

            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.English);

            passBuilder.SetStatus(PassStatus.GetBuilder()
                                  .SetState(state)
                                  .SetEffectTime(format.Format(new Date(start)))
                                  .SetExpireTime(format.Format(new Date(end)))
                                  .Build())
            .SetOrganizationPassId(cardNumber)
            .SetPassStyleIdentifier(passStyleIdentifier.Text.Trim().ToString())
            .SetPassTypeIdentifier(typeId)
            .SetSerialNumber(serialNumber)
            .AddAppendFields(appendFields)
            .AddCommonFields(commonField);

            PassObject passObject = passBuilder.Build();
            Intent     intent     = new Intent(this, typeof(PassTestActivity));

            intent.PutExtra("passObject", passObject.ToJson());
            intent.PutExtra("passId", cardNumber);
            intent.PutExtra("issuerId", issuerId);
            intent.PutExtra("typeId", typeId);
            StartActivity(intent);
        }
コード例 #27
0
    public static DataListBuilder SearchMapTab(string mapTabID, string[] visibleLayers, string levelID, double x, double y,
                                               double distance, double scale, bool addSpace)
    {
        DataListBuilder dataListBuilder = new DataListBuilder();

        Configuration config = AppContext.GetConfiguration();

        Configuration.MapTabRow mapTab    = config.MapTab.First(o => o.MapTabID == mapTabID);
        CommonDataFrame         dataFrame = AppContext.GetDataFrame(mapTab);

        Dictionary <String, Configuration.LayerRow>         layers         = new Dictionary <String, Configuration.LayerRow>();
        Dictionary <String, Configuration.LayerFunctionRow> layerFunctions = new Dictionary <String, Configuration.LayerFunctionRow>();

        bool useDefaultVisible = visibleLayers.Length == 1 && visibleLayers[0] == "*";

        foreach (Configuration.MapTabLayerRow mapTabLayer in mapTab.GetMapTabLayerRows())
        {
            bool isCandidateLayer = mapTab.IsInteractiveLegendNull() || mapTab.InteractiveLegend == 0;

            if (!isCandidateLayer)
            {
                bool shownInLegend   = !mapTabLayer.IsShowInLegendNull() && mapTabLayer.ShowInLegend == 1;
                bool checkedInLegend = mapTabLayer.IsCheckInLegendNull() || mapTabLayer.CheckInLegend < 0 || visibleLayers.Any(o => o == mapTabLayer.LayerID);
                bool defaultVisible  = useDefaultVisible && !mapTabLayer.IsCheckInLegendNull() && mapTabLayer.CheckInLegend == 1;
                isCandidateLayer = !shownInLegend || checkedInLegend || defaultVisible;
            }

            if (isCandidateLayer)
            {
                Configuration.LayerRow         layer         = mapTabLayer.LayerRow;
                Configuration.LayerFunctionRow layerFunction = layer.GetLayerFunctionRows().FirstOrDefault(o => o.FunctionName.ToLower() == "identify");

                if (layerFunction != null)
                {
                    layers.Add(layer.LayerName, layer);
                    layerFunctions.Add(layer.LayerName, layerFunction);
                }
            }
        }

        foreach (CommonLayer commonLayer in dataFrame.Layers)
        {
            DataTable table = null;

            if (layers.ContainsKey(commonLayer.Name) && commonLayer.IsWithinScaleThresholds(scale))
            {
                Configuration.LayerRow layer = layers[commonLayer.Name];

                if (commonLayer.Type == CommonLayerType.Feature)
                {
                    CommonField keyField   = commonLayer.FindField(layer.KeyField);
                    string      levelQuery = layer.GetLevelQuery(commonLayer, levelID);
                    table = commonLayer.GetFeatureTable(keyField.Name, levelQuery, x, y, commonLayer.FeatureType == OgcGeometryType.MultiPolygon ? 0 : distance * scale);
                }

                if (commonLayer.Type == CommonLayerType.Image && commonLayer is AgsLayer)
                {
                    string id = ((AgsLayer)commonLayer).GetRasterValue(x, y);
                    table = new DataTable();
                    table.Columns.Add("ID");
                    table.Rows.Add(id);
                }
            }

            if (table != null && table.Rows.Count > 0)
            {
                Configuration.LayerFunctionRow layerFunction = layerFunctions[commonLayer.Name];

                foreach (DataRow row in table.Rows)
                {
                    string id = row[0].ToString();

                    using (OleDbCommand command = layerFunction.GetDatabaseCommand())
                    {
                        command.Parameters[0].Value = id;

                        if (command.Parameters.Count > 1)
                        {
                            command.Parameters[1].Value = AppUser.GetRole();
                        }

                        using (OleDbDataReader reader = command.ExecuteReader())
                        {
                            dataListBuilder.AddFromReader(reader, addSpace);
                        }

                        command.Connection.Dispose();
                    }
                }
            }
        }

        return(dataListBuilder);
    }
コード例 #28
0
ファイル: Mp4TagReader.cs プロジェクト: retahc/old-code
        private void ParseData(ref long pos, ref long len, int level, BinaryReader br, DataAtoms dataatom)
        {
            byte [] buffer = new byte[4];
            pos += br.Read(buffer, 0, 4);

            long size = BitConverter.ToInt32(new byte [] { buffer[3], buffer[2], buffer[1], buffer[0] }, 0);

            pos += br.Read(buffer, 0, 4);
            pos += br.Read(buffer, 0, 4);

            long type = BitConverter.ToInt32(new byte [] { buffer[3], buffer[2], buffer[1], buffer[0] }, 0);

            size -= 16;
            type &= 255;
            pos  += br.Read(buffer, 0, 4);

            byte [] data = new byte[size];
            pos += br.Read(data, 0, (int)size);

            switch (type)
            {
            case 0:
                int [] intvals = new int[size / 2];
                for (int i = 0; i < size / 2; i++)
                {
                    intvals[i] = BitConverter.ToInt16(new byte[] {
                        data[1 + (i * 2)],
                        data[0 + (i * 2)]
                    }, 0);
                }

                switch (dataatom)
                {
                case DataAtoms.GNRE:
                    tag.AddGenre(GENRE_MAP[intvals[0]]);
                    break;

                case DataAtoms.TRKN:
                    tag.AddTrack(Convert.ToString(intvals[1]));
                    break;

                default:
                    Console.WriteLine("DataAtom: {0}", dataatom);
                    break;
                }

                break;

            case 1:
                CommonField field = 0;
                switch (dataatom)
                {
                case DataAtoms.GEN:
                    field = CommonField.Genre;
                    break;

                case DataAtoms.NAM:
                    field = CommonField.Title;
                    break;

                case DataAtoms.ART:
                    field = CommonField.Artist;
                    break;

                case DataAtoms.ALB:
                    field = CommonField.Album;
                    break;

                case DataAtoms.DAY:
                    field = CommonField.Year;
                    break;

                case DataAtoms.CMT:
                    field = CommonField.Comment;
                    break;
                }

                tag.Add(field, Encoding.Default.GetString(data));
                break;

            case 2:
                // other byte data
                break;

            default:
                // non-standard data
                break;
            }
        }