Exemplo n.º 1
0
        public void InjectStrings(ContextWrapper context)
        {
            OnInjecting(context);

            injectByType(context, typeof(InjectStringAttribute),
                (attribute, type) => context.Resources.GetString(((InjectStringAttribute)attribute).ResourceId));

            OnInjected();
        }
        //Initialiser
        public RtStationSearchDialog(Context Context, ContextWrapper ContextWrapper, Window Window)
        {
            //Set variables
            this.Context        = Context;
            this.ContextWrapper = ContextWrapper;
            this.Window         = Window;

            //Set variables from settings
            Option_SearchLocation  = RtSettings.ReadSetting("SSBD") == "1";
            Option_SearchNavigable = RtSettings.ReadSetting("SSO") == "1";

            //Initialise Graphics Layouts
            RtGraphicsLayouts = new RtGraphicsLayouts(this.Context);

            //Create the view
            GenerateView();
        }
Exemplo n.º 3
0
        public void GetInbox(Context context)
        {
            var contentResolver = new ContextWrapper(context).ContentResolver;
            var cursor          = contentResolver.Query(Android.Net.Uri.Parse("content://sms/inbox"), null, null, null, null);

            if (cursor.MoveToFirst())
            {
                do
                {
                    var msgData = "";

                    for (int idx = 0; idx < cursor.ColumnCount; idx++)
                    {
                        msgData += " " + cursor.GetColumnName(idx) + ":" + cursor.GetString(idx);
                    }
                }while (cursor.MoveToNext());
            }
        }
Exemplo n.º 4
0
 public static async Task RemoveFile(string filename)
 {
     try
     {
         using (var cw = new ContextWrapper(Application.Context))
         {
             // path to /data/data/yourapp/app_data/imageDir
             var    directory = cw.GetDir("imageDir", FileCreationMode.Private);
             string fullPath  = Path.Combine(directory.Path, filename);
             File.Delete(fullPath);
         }
     }
     catch (Exception)
     {
         //no file
     }
     await Task.Delay(1000);
 }
Exemplo n.º 5
0
        public static Color GetThemeColor(ContextWrapper ctx, int attrId)
        {
            try
            {
                TypedValue val = new TypedValue();
                ctx.Theme.ResolveAttribute(attrId, val, true);

                if (val.Type >= DataType.FirstColorInt && val.Type <= DataType.LastColorInt)
                {
                    //simple colors
                    return(new Color((int)val.Data));
                }
                else
                {
                    var clrRes = val.ResourceId != 0 ? val.ResourceId : val.Data;


                    if (clrRes != 0)
                    {
                        //val colorRes = resolvedAttr.run { if (resourceId != 0) resourceId else data }
                        var clr = ContextCompat.GetColor(ctx, clrRes);
                        return(new Color(clr));
                    }

                    //android colorSet
                    TypedArray themeArray = ctx.Theme.ObtainStyledAttributes(new int[] { (int)val.Data });
                    try
                    {
                        int index = 0;
                        int defaultColourValue = 0;
                        int aColour            = themeArray.GetColor(index, defaultColourValue);
                        return(new Color((int)aColour));
                    }
                    finally
                    {
                        // Calling recycle() is important. Especially if you use alot of TypedArrays
                        // http://stackoverflow.com/a/13805641/8524
                        themeArray.Recycle();
                    }
                }
            }
            catch { }
            return(Color.Pink);
        }
Exemplo n.º 6
0
 public static void CheckClientIp(ref ContextWrapper wrapper)
 {
     string action = DataManager.Instance.GetAclAction(wrapper.context.Request.UserHostAddress, wrapper.context.Request.Path);
     switch (action)
     {
         case "Permit":
             break;
         case "Deny":
             lock (SyncLocks.ContextSync)
             {
                 wrapper.context.Response.Clear();
                 wrapper.context.Response.End();
                 wrapper.IsCompleted = true;
             }
             break;
         default: //Log
             break;
     }
 }
Exemplo n.º 7
0
        public async Task <bool> DeleteContextAsync(ContextWrapper context)
        {
            try
            {
                _chatBotContext.Contexts.Remove(context);
                await _chatBotContext.SaveChangesAsync();

                var contextToRemove = _projectsContexts[context.ProjectId]
                                      .Where(ctx => ctx.Id == context.Id).First();
                _projectsContexts[context.ProjectId].Remove(contextToRemove);
                _logger.LogInformation("Pattern deleted ({context.Id})", context.Id);
                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "can't remove context");
                return(false);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// This helper method will obain a reference to the Android activity
        /// that is host a given control.
        /// </summary>
        /// <returns>A reference to the activity hosting the view.</returns>
        /// <param name="view">View.</param>
        public static Activity HostActivity(this View view)
        {
            if (view == null)
            {
                throw new NullReferenceException("Need a valid View reference in order to find the hosting activity.");
            }

            ContextWrapper context = view.Context as ContextWrapper;

            while (context != null)
            {
                if (context is Activity)
                {
                    return((Activity)context);
                }
                context = context.BaseContext as ContextWrapper;
            }

            return(null);
        }
Exemplo n.º 9
0
        public static async Task SaveFile(string filename, byte[] fileBytes)
        {
            try
            {
                using (var cw = new ContextWrapper(Application.Context))
                {
                    // path to /data/data/yourapp/app_data/imageDir
                    var directory = cw.GetDir("imageDir", FileCreationMode.Private);
                    // Create imageDir
                    //                var mypath = new File(directory, $"{filename}.jpg");
                    string fullPath = Path.Combine(directory.Path, filename);
                    await File.WriteAllBytesAsync(fullPath, fileBytes);
                }
            }
            catch (Exception)
            {
                //Could save the file
            }

            await Task.Delay(1000);
        }
        public static ServiceToken BindToService(Context context, IServiceConnection connection)
        {
            var activity = ((Activity)context).Parent;

            if (activity is null)
            {
                activity = (Activity)context;
            }

            var wrapper = new ContextWrapper(activity);

            wrapper.StartService(new Intent(wrapper, typeof(MusicService)));
            var conn = new ServiceConnection(connection);

            if (wrapper.BindService(new Intent(wrapper, typeof(MusicService)), conn, 0))
            {
                _connectionMap.Add(wrapper, conn);
                return(new ServiceToken(wrapper));
            }
            return(null);
        }
Exemplo n.º 11
0
        private string SaveToInternalStorage(Bitmap bitmap)
        {
            ContextWrapper cw        = new ContextWrapper(ApplicationContext);
            File           directory = cw.GetDir("pictures", FileCreationMode.Private);
            File           myPath    = new File(directory, "picture.png");

            try
            {
                using (var os = new System.IO.FileStream(myPath.AbsolutePath, System.IO.FileMode.Create))
                {
                    bitmap.Compress(Bitmap.CompressFormat.Png, 100, os);
                    os.Close();
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Write("Deze lijn: " + e.Message);
            }

            return(directory.AbsolutePath);
        }
Exemplo n.º 12
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

			// Get our button from the layout resource,
			// and attach an event to it
			Button button = FindViewById<Button> (Resource.Id.myButton);
			
			button.Click += delegate {
				
				//Get image bitmap from url
				Bitmap imageBitmap = GetImageBitmapFromUrl("http://xamarin.com/content/images/pages/platform/sketches-screenshot.png");

				ImageView image = FindViewById<ImageView>(Resource.Id.imageView1);


				//Save Image to internal storage
				ContextWrapper cw = new ContextWrapper(this.ApplicationContext);
				File directory = cw.GetDir("imgDir", FileCreationMode.Private);
				File myPath = new File(directory, "test.png");
				try 
				{
					using (var os = new System.IO.FileStream(myPath.AbsolutePath, System.IO.FileMode.Create))
					{
						imageBitmap.Compress(Bitmap.CompressFormat.Png, 100, os);
					}
				}
				catch (Exception ex) 
				{
					System.Console.Write(ex.Message);
				}

				//Load Image from internal storage
				Bitmap loadedImage = BitmapFactory.DecodeFile(myPath.AbsoluteFile.AbsolutePath);
				image.SetImageBitmap(loadedImage);
			};
		}
Exemplo n.º 13
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            object instance;
            FlexDesignerHostServices services;

            if (!Util.EditableModelHelper.GetInstanceAndServices(context, out instance, out services))
            {
                return(base.EditValue(context, provider, value));
            }

            var set = instance as Chart3DDataSetGrid;

            if (set == null)
            {
                return(base.EditValue(context, provider, value));
            }

            var c1Set      = CreateSet(set);
            var c1Property = TypeDescriptor.GetProperties(c1Set)["GridData"];
            var c1Editor   = c1Property.GetEditor(typeof(UITypeEditor)) as UITypeEditor;

            if (c1Editor == null)
            {
                return(base.EditValue(context, provider, value));
            }

            var c1Context = new ContextWrapper(context, c1Set, c1Property);
            var c1Values  = c1Editor.EditValue(c1Context, provider, c1Set.GridData);

            object newValue = value;

            if (c1Context.ComponentChanged)
            {
                newValue = c1Values;
                context.OnComponentChanged();
            }

            return(newValue);
        }
Exemplo n.º 14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button> (Resource.Id.myButton);

            button.Click += delegate {
                //Get image bitmap from url
                Bitmap imageBitmap = GetImageBitmapFromUrl("http://xamarin.com/content/images/pages/platform/sketches-screenshot.png");

                ImageView image = FindViewById <ImageView>(Resource.Id.imageView1);


                //Save Image to internal storage
                ContextWrapper cw        = new ContextWrapper(this.ApplicationContext);
                File           directory = cw.GetDir("imgDir", FileCreationMode.Private);
                File           myPath    = new File(directory, "test.png");
                try
                {
                    using (var os = new System.IO.FileStream(myPath.AbsolutePath, System.IO.FileMode.Create))
                    {
                        imageBitmap.Compress(Bitmap.CompressFormat.Png, 100, os);
                    }
                }
                catch (Exception ex)
                {
                    System.Console.Write(ex.Message);
                }

                //Load Image from internal storage
                Bitmap loadedImage = BitmapFactory.DecodeFile(myPath.AbsoluteFile.AbsolutePath);
                image.SetImageBitmap(loadedImage);
            };
        }
Exemplo n.º 15
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            // Make it available in the gallery
            Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
            Android.Net.Uri contentUri = Android.Net.Uri.FromFile(App._file);
            mediaScanIntent.SetData(contentUri);
            SendBroadcast(mediaScanIntent);

            // Display in ImageView. We will resize the bitmap to fit the display.
            // Loading the full sized image will consume to much memory
            // and cause the application to crash.

            int height = Resources.DisplayMetrics.HeightPixels;
            int width = _imageView.Height;
            App.bitmap = App._file.Path.LoadAndResizeBitmap(width, height);

            // Save the bitmap to a file
            ContextWrapper cw = new ContextWrapper(this.ApplicationContext);
            Java.IO.File directory = cw.GetDir("imgDir", FileCreationMode.Private);
            Java.IO.File myPath = new Java.IO.File(directory, this.imgFileName);
            try
            {
                using (var os = new System.IO.FileStream(myPath.AbsolutePath, System.IO.FileMode.Create))
                {
                    Matrix matrix = new Matrix();
                    matrix.SetRotate(90);
                    Bitmap scaledBitmap = Bitmap.CreateScaledBitmap(App.bitmap, App.bitmap.Height, App.bitmap.Width/2, true);
                    Bitmap rotatedBitmap = Bitmap.CreateBitmap(scaledBitmap, 0, 0, scaledBitmap.Width, scaledBitmap.Height, matrix, true);
                    App.bitmap = rotatedBitmap;
                    App.bitmap.Compress(Bitmap.CompressFormat.Png, 100, os);
                    os.Close();
                }
            }
            catch (Exception ex) {
                System.Console.Write(ex.Message);
            }

            // Dispose of the Java side bitmap.
            GC.Collect();
            try
            {
                System.IO.FileStream imgFile = new FileStream(myPath.AbsolutePath, FileMode.Open);
                int b = imgFile.ReadByte();
                imgFile.Close();
            }
            catch (Java.IO.IOException e)
            {
            }
            if (App.bitmap != null)
            {
                _imageView.SetImageBitmap(App.bitmap);
                App.bitmap = null;
            }
        }
Exemplo n.º 16
0
 public Repository(ContextWrapper <T> context)
 {
     Context = context;
 }
Exemplo n.º 17
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Config);

            LinearLayout cancel = FindViewById<LinearLayout>(Resource.Id.Config_cancel);
            TextView version = FindViewById<TextView>(Resource.Id.Config_version);
            TextView printername = FindViewById<TextView>(Resource.Id.Config_PrinterName);
            TextView usernanme = FindViewById<TextView>(Resource.Id.Config_username);
            RelativeLayout update = FindViewById<RelativeLayout>(Resource.Id.Config_btn_update);
            RelativeLayout zhuxiao = FindViewById<RelativeLayout>(Resource.Id.Config_btn_zhuxiao);
            RelativeLayout Refresh = FindViewById<RelativeLayout>(Resource.Id.Config_btn_Refresh);
            RelativeLayout RefreshAdd = FindViewById<RelativeLayout>(Resource.Id.Config_btn_RefreshAdd);
            RelativeLayout QRCode = FindViewById<RelativeLayout>(Resource.Id.Config_btn_QRCode);
            RelativeLayout exit = FindViewById<RelativeLayout>(Resource.Id.Config_btn_exit);
            RelativeLayout TestPrinter = FindViewById<RelativeLayout>(Resource.Id.Config_btn_TestPrinter);
            TextView netType = FindViewById<TextView>(Resource.Id.Config_netType);
            usernanme.Text = Core.SysVisitor.UserName;
            string ls_printerName= baseclass.MyConfig.of_GetMySysSet("printer", "name");
            if(!string.IsNullOrEmpty(ls_printerName))
            {
                printername.Text = ls_printerName;
            }
            version.Text = "版本:" + Core.SysVisitor.getVersionName(this) + "  日期:" + Core.SysVisitor.getVersionCode(this);
            cancel.Click += delegate
            {
                OnBackPressed();
                //StartActivity(typeof(Index));
            };
            update.Click += delegate
            {
                update.Enabled = false;
                string str = Core.Update.of_update(true);
                update.Enabled = true;
                if (str.Substring(0, 2) != "ER")
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("提示:");
                    builder.SetMessage("当前版本为" + Core._publicfuns.of_GetMySysSet("app", "vercode") + "服务器上最新版本为 " + str + " ,确定下载更新吗?");
                    builder.SetPositiveButton("确定", delegate
                    {
                        Intent intent = new Intent();
                        Bundle bu = new Bundle();
                        bu.PutString("name", "download");
                        intent.PutExtras(bu);
                        intent.SetClass(this, typeof(Loading));
                        StartActivity(intent);
                    });
                    builder.SetNegativeButton("取消", delegate { return; });
                    builder.Show();
                }
                else
                {
                    str = str.Substring(4);
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("提示:");
                    builder.SetMessage(str);
                    builder.SetPositiveButton("确定", delegate
                    {
                        return;
                    });
                    builder.Show();
                }
            };
            zhuxiao.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                //Core._publicfuns.of_SetMySysSet("Login", "username", "");
                //Core._publicfuns.of_SetMySysSet("Login", "password", "");
                //Core._publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.AddDays(-30).ToString());
                _publicfuns.of_SetMySysSet("Login", "Login", "N");//标记为不自动登录
                StartActivity(typeof(MainActivity));
            };
            Refresh.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.SetTitle("提示:");
                builder.SetMessage("确认刷新本地所有数据吗?\n此操作将会删除所有本地数据,并重新从服务器上下载\n建议在WiFi环境下执行此操作");
                builder.SetPositiveButton("确定", delegate
                {
                    SysVisitor.CreateServerDB();
                    Intent intent = new Intent();
                    Bundle bu = new Bundle();
                    bu.PutString("name", "data");
                    bu.PutString("update", "update");
                    intent.PutExtras(bu);
                    intent.SetClass(this, typeof(Loading));
                    StartActivity(intent);
                });
                builder.SetNegativeButton("取消", delegate { });
                builder.Show();
            };
            RefreshAdd.Click += delegate
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.SetTitle("提示:");
                builder.SetMessage("每次启动程序是会同步客户数据,历史销价数据与产品数据\n确定手动同步数据吗?");
                builder.SetPositiveButton("确定", delegate
                {
                    StarThread st = new StarThread();
                    int row = st.UpdateTableRow;
                    if (row == 0)
                        Toast.MakeText(this, "服务器没有更新数据或在启动时客户端已经完成同步", ToastLength.Short).Show();
                    else
                        Toast.MakeText(this, "成功从服务器同步" + row + "条数据", ToastLength.Short).Show();
                });
                builder.SetNegativeButton("取消", delegate { return; });
                builder.Show();

            };
            QRCode.Click += delegate
            {
                StartActivity(typeof(QRCode));
            };
            exit.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                System.Threading.Thread.Sleep(500);
                ContextWrapper cw = new ContextWrapper(this);
                Intent exitIntent = new Intent(Intent.ActionMain);
                exitIntent.AddCategory(Intent.CategoryHome);
                exitIntent.SetFlags(ActivityFlags.NewTask);
                cw.StartActivity(exitIntent);
                Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
            };
            netType.Click += delegate
            {
                if (as_date == null)
                    ai_clickNum++;
                else
                {
                    if (SysVisitor.DateDiff(as_date, SysVisitor.timeSpan.Milliseconds) < 300)
                    {
                        if (ai_clickNum == 3)
                        {
                            SysVisitor.GetVibrator(this);
                            StartActivity(typeof(TelePhoneManager));
                            Finish();
                        }
                        ai_clickNum++;
                    }
                    else
                    {
                        ai_clickNum = 0;
                    }
                }
                as_date = DateTime.Now;
            };
            TestPrinter.Click += delegate
            {
                string ls_BluetoothName = new BluetoothPrinter(this).as_BluetoothName;
                if (!string.IsNullOrEmpty(ls_BluetoothName))
                    baseclass.MyConfig.of_SetMySysSet("printer", "name", ls_BluetoothName);
            };
            System.Threading.Thread thr = new System.Threading.Thread(new System.Threading.ThreadStart(of_netType));
            thr.Start();
        }
Exemplo n.º 18
0
 public OrderRepository(ContextWrapper <Order> context, IMapper mapper) : base(context)
 {
     this.Mapper = mapper;
 }
Exemplo n.º 19
0
        /// <summary>
        /// A workflow item, implementing a simple instrumentation of the client IP address, port, and URL.
        /// </summary>
        public static WorkflowState LogIPAddress(WorkflowContinuation <ContextWrapper> workflowContinuation, ContextWrapper wrapper)
        {
            Console.WriteLine(wrapper.Context.Request.RemoteEndPoint.ToString() + " : " + wrapper.Context.Request.RawUrl);

            return(WorkflowState.Continue);
        }
Exemplo n.º 20
0
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                if (convertView != null)
                    return convertView;
                LayoutInflater mInflater = LayoutInflater.From(context);
                View view = null;
                view = mInflater.Inflate(Resource.Layout.Index_Item, null);
                ImageView image = view.FindViewById<ImageView>(Resource.Id.Index_ItemImage);
                TextView name = view.FindViewById<TextView>(Resource.Id.Index_ItemText);
                TextView no = view.FindViewById<TextView>(Resource.Id.Index_ItemText_no);
                switch (list[position])
                {
                    #region 录入补货
                    case "录入补货":
                        image.SetImageResource(Resource.Drawable.AccBook);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            //Intent intent = new Intent();
                            //intent.SetClass(context, typeof(Customer));
                            //context.StartActivity(intent);
                            context.StartActivity(typeof(Customer));
                        };
                        break;
                    #endregion
                    #region 购 物 车
                    case "购 物 车":
                        image.SetImageResource(Resource.Drawable.shoppingcart);
                        name.Text = list[position];
                        //if (Shopping.GetShoppingToStr() != "")
                        //    no.Visibility = ViewStates.Visible;
                        view.Click += delegate
                        {
                            context.StartActivity(typeof(OrderSave));
                        };
                        break;
                    #endregion
                    #region 本地订单
                    case "本地订单":
                        image.SetImageResource(Resource.Drawable.GetMain);
                        name.Text = list[position];
                        //int row = SqliteHelper.ExecuteNum("select count(*) from getmain where isupdate ='N'");
                        //if (row > 0)
                        //    no.Visibility = ViewStates.Visible;
                        view.Click += delegate
                        {
                            context.StartActivity(typeof(GetMian));
                        };
                        break;
                    #endregion
                    #region 订单查询
                    case "订单查询":
                        image.SetImageResource(Resource.Drawable.Replenishment);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "App/Dw_GetMain");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Web));
                            context.StartActivity(intent);
                        };
                        break;
                    #endregion
                    #region 出货单查询
                    case "出货单查询":
                        image.SetImageResource(Resource.Drawable.OutOne);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "App/Dw_OutOne");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Web));
                            context.StartActivity(intent);
                        };
                        break;
                    #endregion
                    #region 库存查询
                    case "库存查询":
                        image.SetImageResource(Resource.Drawable.btn_Stock);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "App/Dw_Stock");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Web));
                            context.StartActivity(intent);
                        };
                        break;
                    #endregion
                    #region 刷新数据
                    case "刷新数据":
                        image.SetImageResource(Resource.Drawable.Refresh);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(context);
                            builder.SetTitle("提示:");
                            builder.SetMessage("确认刷新所有数据吗?建议在WiFi环境下执行此操作");
                            builder.SetPositiveButton("确定", delegate
                            {
                                SysVisitor.CreateServerDB();
                                Intent intent = new Intent();
                                Bundle bu = new Bundle();
                                bu.PutString("name", "data");
                                bu.PutString("update", "update");
                                intent.PutExtras(bu);
                                intent.SetClass(context, typeof(Loading));
                                context.StartActivity(intent);
                            });
                            builder.SetNegativeButton("取消", delegate { });
                            builder.Show();
                        };
                        break;
                    #endregion
                    #region 注销登陆
                    case "注销登陆":
                        image.SetImageResource(Resource.Drawable.zhuxiao);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            _publicfuns.of_SetMySysSet("Login", "username", "");
                            _publicfuns.of_SetMySysSet("Login", "password", "");
                            _publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.AddDays(-30).ToString());
                            Intent it = new Intent();
                            it.SetClass(context.ApplicationContext, typeof(MainActivity));
                            context.StartActivity(it);
                        };
                        break;
                    #endregion
                    #region 退出系统
                    case "退出系统":
                        image.SetImageResource(Resource.Drawable.btn_Exit);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            System.Threading.Thread.Sleep(500);
                            ContextWrapper cw = new ContextWrapper(context);
                            Intent exitIntent = new Intent(Intent.ActionMain);
                            exitIntent.AddCategory(Intent.CategoryHome);
                            exitIntent.SetFlags(ActivityFlags.NewTask);
                            cw.StartActivity(exitIntent);
                            Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                        };
                        break;
                    #endregion
                    #region 检查更新
                    case "检查更新":
                        image.SetImageResource(Resource.Drawable.btn_update);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            view.Enabled = false;
                            string str = Core.Update.of_update(true);
                            view.Enabled = true;
                            if (str.Substring(0, 2) != "ER")
                            {
                                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                                builder.SetTitle("提示:");
                                builder.SetMessage("当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode") + "服务器上最新版本为 " + str + " ,确定下载更新吗?");
                                builder.SetPositiveButton("确定", delegate
                                {
                                    Intent intent = new Intent();
                                    Bundle bu = new Bundle();
                                    bu.PutString("name", "download");
                                    intent.PutExtras(bu);
                                    intent.SetClass(context, typeof(Loading));
                                    context.StartActivity(intent);
                                });
                                builder.SetNegativeButton("取消", delegate { return; });
                                builder.Show();
                            }
                            else
                            {
                                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                                builder.SetTitle("提示:");
                                builder.SetMessage(str + " 当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode"));
                                builder.SetPositiveButton("确定", delegate
                                {
                                    return;
                                });
                                builder.Show();
                            }

                        };
                        break;
                    #endregion
                    #region 录入回款
                    case "录入回款":
                        image.SetImageResource(Resource.Drawable.backmoneyrecord);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            //Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture);
                            //string file = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(),
                            //    Android.OS.Environment.DirectoryDcim.ToString(), "test.jpg");
                            //outputFileUri = Android.Net.Uri.Parse(file);
                            //intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, outputFileUri);
                            //activity.StartActivityForResult(intent, TAKE_PICTRUE);

                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "backmoneyrecord");
                            bu.PutString("ischeck", "false");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Customer));
                            context.StartActivity(intent);
                        };
                        break;
                    #endregion
                    #region 本地回款
                    case "本地回款":
                        image.SetImageResource(Resource.Drawable.GetBackmoney);
                        name.Text = list[position];
                        //int row = SqliteHelper.ExecuteNum("select count(*) from Backmoneyrecord  where isupdate ='N'");
                        //if (row > 0)
                        //    no.Visibility = ViewStates.Visible;
                        view.Click += delegate
                        {
                            context.StartActivity(typeof(GetBackmoney));
                        };
                        break;
                    #endregion
                    #region 消息通知
                    case "消息通知":
                        image.SetImageResource(Resource.Drawable.message);
                        int li_msg_count = 0;
                        try
                        {
                            //以后在后台刷新 防止网络不好时卡在启动页面
                            //li_msg_count = int.Parse(SysVisitor.Of_GetStr(SysVisitor.Get_ServerUrl()+ "/App/MsgList.aspx?select=num"));
                        }
                        catch { }
                        if (li_msg_count > 0)
                        {
                            no.Visibility = ViewStates.Visible;

                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "App/GetAppMsg.ashx");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Web));
                            nMgr = (NotificationManager)context.GetSystemService(Context.NotificationService);

                            Notification notify = new Notification(Resource.Drawable.Icon, "有新的通知消息");
                            //初始化点击通知后打开的活动
                            PendingIntent pintent = PendingIntent.GetActivity(context, 0, intent, PendingIntentFlags.UpdateCurrent);
                            //设置通知的主体
                            notify.SetLatestEventInfo(context, "有新的通知消息", "点击查看详细内容", pintent);
                            nMgr.Notify(0, notify);
                        }
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "App/GetAppMsg.ashx");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Web));
                            context.StartActivity(intent);
                        };
                        break;
                    #endregion
                    #region 即时通讯
                    case "即时通讯":
                        image.SetImageResource(Resource.Drawable.im3);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            context.StartActivity(typeof(Buddylist));
                        };
                        break;
                    #endregion
                    #region 系统设置
                    case "系统设置":
                        image.SetImageResource(Resource.Drawable.config);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            context.StartActivity(typeof(Config));
                        };
                        break;
                    #endregion
                    #region 拍照上传
                    case "拍照上传":
                        image.SetImageResource(Resource.Drawable.picture);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            context.StartActivity(typeof(PhotoBrowse));
                        };
                        break;
                    #endregion
                    #region 新品订货
                    case "新品订货":
                        image.SetImageResource(Resource.Drawable.AccBook_new);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            //Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture);
                            //string file = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(),
                            //    Android.OS.Environment.DirectoryDcim.ToString(), "test.jpg");
                            //outputFileUri = Android.Net.Uri.Parse(file);
                            //intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, outputFileUri);
                            //activity.StartActivityForResult(intent, TAKE_PICTRUE);

                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "OrderCar");
                            bu.PutString("ischeck", "false");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Customer));
                            context.StartActivity(intent);
                        };
                        break;
                    #endregion
                    #region 客户对账
                    case "客户对账":
                        image.SetImageResource(Resource.Drawable.BackMoney);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "WebDw_AccBook");
                            bu.PutString("ischeck", "false");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Customer));
                            context.StartActivity(intent);
                        };
                        break;
                    #endregion
                    #region 回款查询
                    case "回款查询":
                        image.SetImageResource(Resource.Drawable.ShowBackMoneyreCord);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "App/Dw_BackMoneyreCord.aspx");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Web));
                            context.StartActivity(intent);
                        };
                        break;
                    #endregion
                    #region 查看销价
                    case "查看销价":
                        image.SetImageResource(Resource.Drawable.SalePrice);
                        name.Text = list[position];
                        view.Click += delegate
                        {
                            context.StartActivity(typeof(SalePrice));
                        };
                        break;
                        #endregion
                }
                view.SetPadding(2, 4, 2, 8);
                return view;
            }
Exemplo n.º 21
0
 protected abstract void Execute(ContextWrapper context);
Exemplo n.º 22
0
        static void AbortHandler(ContextWrapper wrapper)
        {
            HttpListenerResponse response = wrapper.Context.Response;

            response.OutputStream.Close();
        }
Exemplo n.º 23
0
        public static WorkflowState CsrfInjector(WorkflowContinuation <ContextWrapper> workflowContinuation, ContextWrapper wrapper)
        {
            PendingPageResponse pageResponse = wrapper.PendingResponse as PendingPageResponse;

            if (pageResponse != null)
            {
                // For form postbacks.
                pageResponse.Html = pageResponse.Html.Replace("%AntiForgeryToken%", "<input name=" + "csrf".SingleQuote() +
                                                              " type='hidden' value=" + wrapper.Session["_CSRF_"].ToString().SingleQuote() +
                                                              " id='__csrf__'/>");

                // For AJAX calls where the CSRF is in the RequestVerificationToken header:
                pageResponse.Html = pageResponse.Html.Replace("%CsrfValue%", wrapper.Session["_CSRF_"].ToString().SingleQuote());
            }

            return(WorkflowState.Continue);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Apply the Razor view engine to a page response.
        /// </summary>
        public static WorkflowState ViewEngine(WorkflowContinuation <ContextWrapper> workflowContinuation, ContextWrapper wrapper)
        {
            PendingPageResponse pageResponse = wrapper.PendingResponse as PendingPageResponse;

            // Only send page responses to the templating engine.
            if (pageResponse != null)
            {
                string html        = pageResponse.Html;
                string templateKey = html.GetHashCode().ToString();
                // pageResponse.Html = Engine.Razor.RunCompile(html, templateKey, null, new { /* your dynamic model */ });
                try
                {
                    pageResponse.Html = Engine.Razor.RunCompile(html, templateKey, null, new { People = codeProject2015Mvp });
                }
                catch (Exception ex)
                {
                    // Helps with debugging runtime compilation errors!
                    Console.WriteLine(ex.Message);
                }
            }

            return(WorkflowState.Continue);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Final step is to actually issue the response.
        /// </summary>
        public static WorkflowState Responder(WorkflowContinuation <ContextWrapper> workflowContinuation, ContextWrapper wrapper)
        {
            wrapper.Stopwatch.Stop();
            Server.CumulativeTime += wrapper.Stopwatch.ElapsedTicks;
            ++Server.Samples;

            wrapper.Context.Response.ContentEncoding = wrapper.PendingResponse.Encoding;
            wrapper.Context.Response.ContentType     = wrapper.PendingResponse.MimeType;
            wrapper.Context.Response.ContentLength64 = wrapper.PendingResponse.Data.Length;
            wrapper.Context.Response.OutputStream.Write(wrapper.PendingResponse.Data, 0, wrapper.PendingResponse.Data.Length);
            wrapper.Context.Response.StatusCode = 200;                                  // OK
            wrapper.Context.Response.Close();

            return(WorkflowState.Continue);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Only intranet IP addresses are allowed.
        /// </summary>
        public static WorkflowState WhiteList(WorkflowContinuation <ContextWrapper> workflowContinuation, ContextWrapper wrapper)
        {
            string        url   = wrapper.Context.Request.RemoteEndPoint.ToString();
            bool          valid = url.StartsWith("192.168") || url.StartsWith("127.0.0.1") || url.StartsWith("[::1]");
            WorkflowState ret   = valid ? WorkflowState.Continue : WorkflowState.Abort;

            return(ret);
        }
Exemplo n.º 27
0
        public static WorkflowState LogHit(WorkflowContinuation <ContextWrapper> workflowContinuation, ContextWrapper wrapper)
        {
            Console.Write(".");

            return(WorkflowState.Continue);
        }
Exemplo n.º 28
0
 /// <summary>
 /// 关闭程序并释放所有程序占用的资源
 /// </summary>
 /// <param name="active"></param>
 public static void EXIT(Context context)
 {
     ContextWrapper cw = new ContextWrapper(context);
     Intent exitIntent = new Intent(Intent.ActionMain);
     exitIntent.AddCategory(Intent.CategoryHome);
     exitIntent.SetFlags(ActivityFlags.NewTask);
     cw.StartActivity(exitIntent);
     Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
 }
Exemplo n.º 29
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            SetContentView(Resource.Layout.Config);

            ImageButton cancel = FindViewById<ImageButton>(Resource.Id.Config_cancel);
            TextView version = FindViewById<TextView>(Resource.Id.Config_version);
            TextView usernanme = FindViewById<TextView>(Resource.Id.Config_username);
            RelativeLayout update = FindViewById<RelativeLayout>(Resource.Id.Config_btn_update);
            RelativeLayout zhuxiao = FindViewById<RelativeLayout>(Resource.Id.Config_btn_zhuxiao);
            RelativeLayout Refresh = FindViewById<RelativeLayout>(Resource.Id.Config_btn_Refresh);
            RelativeLayout exit = FindViewById<RelativeLayout>(Resource.Id.Config_btn_exit);

            usernanme.Text = Core.SysVisitor.UserName;
            version.Text = "版本:" + Core.SysVisitor.getVersionName(this) + "  日期:" + Core.SysVisitor.getVersionCode(this);
            cancel.Click += delegate { StartActivity(typeof(Index)); };
            update.Click += delegate
            {
                update.Enabled = false;
                string str = Core.Update.of_update(true);
                update.Enabled = true;
                if (str.Substring(0, 2) != "ER")
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("提示:");
                    builder.SetMessage("当前版本为" + Core._publicfuns.of_GetMySysSet("app", "vercode") + "服务器上最新版本为 " + str + " ,确定下载更新吗?");
                    builder.SetPositiveButton("确定", delegate
                    {
                        Intent intent = new Intent();
                        Bundle bu = new Bundle();
                        bu.PutString("name", "download");
                        intent.PutExtras(bu);
                        intent.SetClass(this, typeof(Loading));
                        StartActivity(intent);
                    });
                    builder.SetNegativeButton("取消", delegate { return; });
                    builder.Show();
                }
                else
                {
                    str = str.Substring(4);
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("提示:");
                    builder.SetMessage(str);
                    builder.SetPositiveButton("确定", delegate
                    {
                        return;
                    });
                    builder.Show();
                }
            };
            zhuxiao.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                //Core._publicfuns.of_SetMySysSet("Login", "username", "");
                //Core._publicfuns.of_SetMySysSet("Login", "password", "");
                //Core._publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.AddDays(-30).ToString());
                _publicfuns.of_SetMySysSet("Login", "Login", "N");//标记为不自动登录
                StartActivity(typeof(MainActivity));
            };
            Refresh.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.SetTitle("提示:");
                builder.SetMessage("确认刷新所有数据吗?建议在WiFi环境下执行此操作");
                builder.SetPositiveButton("确定", delegate
                {
                    SysVisitor.CreateServerDB();
                    Intent intent = new Intent();
                    Bundle bu = new Bundle();
                    bu.PutString("name", "data");
                    bu.PutString("update", "update");
                    intent.PutExtras(bu);
                    intent.SetClass(this, typeof(Loading));
                    StartActivity(intent);
                });
                builder.SetNegativeButton("取消", delegate { });
                builder.Show();
            };
            exit.Click += delegate
            {
                SysVisitor.GetVibrator(this);
                System.Threading.Thread.Sleep(500);
                ContextWrapper cw = new ContextWrapper(this);
                Intent exitIntent = new Intent(Intent.ActionMain);
                exitIntent.AddCategory(Intent.CategoryHome);
                exitIntent.SetFlags(ActivityFlags.NewTask);
                cw.StartActivity(exitIntent);
                Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
            };

            System.Threading.Thread thr = new System.Threading.Thread(new System.Threading.ThreadStart(of_netType));
            thr.Start();

            System.Threading.Thread thr1 = new System.Threading.Thread(() => { int a = 0;a++; });
            thr1.Start();
        }
        public static Thread CreateServer(
            ContextWrapper InternalContext,
            IPAddress ipa, int port,
            Action <string> Console_WriteLine,
            InternalFileInfo[] Files)
        {
            var random = new System.Random();

            // Error 312 (net::ERR_UNSAFE_PORT): Unknown error.
            if (port < 1024)
            {
                port = random.Next(1024, 32000);
            }


            var cid = 0;

            NetworkStreamAction AtConnection =
                InternalStream =>
            {
                var id = cid++;

                Console_WriteLine("#" + cid);

                //log("AtConnection");

                var r = new SmartStreamReader(InternalStream);

                #region __Global
                var __Request  = new __HttpRequest();
                var __Response = new __HttpResponse {
                    InternalStream = InternalStream, InternalContext = InternalContext
                };
                var __Global = new __Global();
                __Global.Files      = Files;
                __Global.WebMethods =
                    new InternalWebMethodInfo[]
                {
                    new InternalWebMethodInfo
                    {
                        Name          = "WebMethod2",
                        TypeFullName  = "TestGAE.ApplicationWebService",
                        MetadataToken = "06000001",

                        Parameters = new InternalWebMethodParameterInfo[]
                        {
                            new InternalWebMethodParameterInfo
                            {
                                Name       = "e",
                                Value      = "",
                                IsDelegate = false
                            },

                            new InternalWebMethodParameterInfo
                            {
                                Name       = "y",
                                Value      = "",
                                IsDelegate = true
                            }
                        }
                    }
                };

                __Global.ScriptApplications =
                    new[]
                {
                    new WebServiceScriptApplication
                    {
                        TypeName     = "Application",
                        TypeFullName = "TestGAE.Application",

                        PageSource = "<body>\r\n  <noscript>Error: This Application requires JavaScript.</noscript>\r\n  <link rel=\"stylesheet\" href=\"assets/TestGAE/Default.css\" />\r\n  <div id=\"PageContainer\">\r\n    <h1 id=\"Header\">JSC - The .NET crosscompiler for web platforms.</h1>\r\n    <p id=\"Content\" style=\"padding: 2em;     color: blue;\">Hello world</p>\r\n  </div>\r\n</body>",

                        References = new []
                        {
                            new WebServiceScriptApplication.Reference
                            {
                                AssemblyFile = "ScriptCoreLib.dll"
                            },
                            new WebServiceScriptApplication.Reference
                            {
                                AssemblyFile = "TestGAE.Application.exe"
                            }
                        }
                    }
                };

                ((__HttpApplication)(object)__Global).Request  = (HttpRequest)(object)__Request;
                ((__HttpApplication)(object)__Global).Response = (HttpResponse)(object)__Response;
                var Context = __Global.Context;
                #endregion



                #region __Request { HttpMethod, QueryString, Headers }
                var HTTP_METHOD_PATH_QUERY = r.ReadLine();
                var HTTP_METHOD            = HTTP_METHOD_PATH_QUERY.TakeUntilOrEmpty(" ");
                __Request.HttpMethod = HTTP_METHOD;

                Console.WriteLine("#" + cid + " " + HTTP_METHOD_PATH_QUERY);

                #region check METHOD
                if (HTTP_METHOD != "POST")
                {
                    if (HTTP_METHOD != "GET")
                    {
                        var m = new MemoryStream();

                        Action <string> WriteLineASCII = (string e) =>
                        {
                            var x = Encoding.ASCII.GetBytes(e + "\r\n");

                            m.Write(x, 0, x.Length);
                        };

                        Console_WriteLine("#" + cid + " 500");

                        WriteLineASCII("HTTP/1.1 500 OK");
                        WriteLineASCII("Connection: close");

                        var oa = m.ToArray();

                        InternalStream.Write(oa, 0, oa.Length);

                        InternalStream.Flush();
                        InternalStream.Close();
                        return;
                    }
                }
                #endregion


                var HTTP_PATH_QUERY = HTTP_METHOD_PATH_QUERY.SkipUntilOrEmpty(" ").TakeUntilLastOrEmpty(" ");
                var HTTP_PATH       = HTTP_PATH_QUERY.TakeUntilIfAny("?");
                __Request.Path = HTTP_PATH;

                #region QueryString
                var HTTP_QUERY = HTTP_PATH_QUERY.SkipUntilOrEmpty("?");

                var __QueryStringItems = HTTP_QUERY.Split('&');

                foreach (var item in __QueryStringItems)
                {
                    var Key = item.TakeUntilOrEmpty("=");
                    if (!string.IsNullOrEmpty(Key))
                    {
                        var Value = item.SkipUntilIfAny("=");

                        __Request.QueryString[Key] = Value;
                    }
                }
                #endregion

                __Request.Headers["Content-Type"] = "";

                #region Headers
                var NextHeader = r.ReadLine();
                while (!string.IsNullOrEmpty(NextHeader))
                {
                    // http://www.nextthing.org/archives/2005/08/07/fun-with-http-headers

                    var HeaderKey   = NextHeader.TakeUntilOrEmpty(":");
                    var HeaderValue = NextHeader.SkipUntilIfAny(":").Trim();

                    __Request.Headers[HeaderKey] = HeaderValue;

                    NextHeader = r.ReadLine();
                }
                #endregion

                #endregion

                var data = r.ReadToMemoryStream();

                var boundary = __Request.Headers["Content-Type"].SkipUntilOrEmpty("multipart/form-data; boundary=");

                #region Form
                if (__Request.Headers["Content-Type"] == "application/x-www-form-urlencoded")
                {
                    var p = Encoding.UTF8.GetString(data.ToBytes());
                    var q = p.Split('&');

                    foreach (var item in q)
                    {
                        var Key   = item.TakeUntilOrEmpty("=");
                        var Value = item.SkipUntilIfAny("=");

                        __Request.Form[Key] = Value;
                    }
                }
                #endregion

                #region selected_item
                var selected_item = default(InternalFileInfo);

                foreach (var item in Files)
                {
                    // LINQ please!
                    if (HTTP_PATH == "/" + item.Name)
                    {
                        selected_item = item;
                    }
                }
                #endregion



                {
                    if (__Request.Path == "/jsc")
                    {
                        __InternalGlobalExtensions.InternalApplication_BeginRequest(__Global);
                    }
                    else
                    {
                        InternalGlobalExtensions.InternalApplication_BeginRequest(__Global);
                    }


                    Console.WriteLine("#" + cid + " " + HTTP_METHOD_PATH_QUERY + " done");

                    return;

                    //}

                    #region selected_item
                    if (selected_item != null)
                    {
                        var path = selected_item.Name;

                        __Response.StatusCode           = 200;
                        __Response.Headers["X-Handler"] = "http://jsc-solutions.net";

                        if (path.EndsWith(".gif"))
                        {
                            __Response.ContentType = ("image/gif");
                        }
                        else if (path.EndsWith(".png"))
                        {
                            __Response.ContentType = ("image/png");
                        }
                        else if (path.EndsWith(".htm"))
                        {
                            __Response.ContentType = ("text/html; charset=utf-8");
                        }
                        else
                        {
                            __Response.ContentType = ("application/octet-stream");
                        }


                        __Response.WriteFile(path);

                        InternalStream.Close();
                        __Global.CompleteRequest();
                        return;
                    }
                    #endregion


                    __Response.StatusCode           = 200;
                    __Response.ContentType          = ("text/html; charset=utf-8");
                    __Response.Headers["X-Handler"] = "http://jsc-solutions.net";


                    #region index

                    #region WriteLineASCII
                    Action <string> WriteLine = (string e) =>
                    {
                        __Response.Write(e + "\r\n");
                    };
                    #endregion



                    #region html index

                    WriteLine("<html>");
                    WriteLine("<body>");

                    foreach (var HeaderKey in Context.Request.Headers.AllKeys)
                    {
                        var HeaderValue = Context.Request.Headers[HeaderKey];

                        WriteLine("<code style='color: gray;'>" + HeaderKey + "</code>:");
                        WriteLine("<code style='color: green;'>" + HeaderValue + "</code><br />");
                    }

                    WriteLine("<h3>data: 0x" + data.Length.ToString("x8") + "</h3>");


                    WriteLine("<pre>" + boundary + "</pre>");
                    WriteLine("<hr />");

                    WriteLine("<pre>" + HTTP_METHOD_PATH_QUERY + "</pre>");

                    if (string.IsNullOrEmpty(boundary))
                    {
                        WriteLine("<pre>" + WriteHexDump(data.ToBytes()) + "</pre>");
                    }



                    #region by boundary
                    if (!string.IsNullOrEmpty(boundary))
                    {
                        boundary = "--" + boundary;

                        var bytes         = data.ToBytes();
                        var boundarybytes = Encoding.ASCII.GetBytes(boundary);

                        var boundaries = new List <Int32Box>();

                        for (int i = 0; i < bytes.Length - boundarybytes.Length; i++)
                        {
                            var AtBoundary = false;

                            // is i at boundary?
                            for (int j = 0; j < boundarybytes.Length; j++)
                            {
                                if (bytes[i + j] != boundarybytes[j])
                                {
                                    AtBoundary = false;
                                    break;
                                }
                                AtBoundary = true;
                            }

                            if (AtBoundary)
                            {
                                boundaries.Add(new Int32Box {
                                    value = i
                                });
                            }
                        }

                        var boundaries_a = boundaries.ToArray();

                        for (int i = 0; i < boundaries_a.Length - 1; i++)
                        {
                            var start = boundaries_a[i].value + boundarybytes.Length + 2;
                            var end   = boundaries_a[i + 1].value;

                            var chunk = new byte[end - start];

                            Array.Copy(bytes, start, chunk, 0, chunk.Length);
                            WriteLine("<hr />");
                            WriteLine("<pre>" + WriteHexDump(chunk) + "</pre>");
                        }
                    }
                    #endregion

                    WriteLine("<hr />");

                    WriteLine("<form target='_blank' action='/jsc?WebMethod=06000048' method='POST'><br /> <img src='http://i.msdn.microsoft.com/deshae98.pubmethod(en-us,VS.90).gif' /> method: <code><a href='?WebMethod=06000048'>Hello</a></code><input type='submit' value='Invoke'  /><br />");
                    WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://i.msdn.microsoft.com/yxcx7skw.pubclass(en-us,VS.90).gif' /> parameter: <code>data</code> = <input type='text'  name='_06000048_data' value='' /><br />");
                    WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://i.msdn.microsoft.com/yxcx7skw.pubclass(en-us,VS.90).gif' /> parameter: <code>foo</code> = <input type='text'  name='_06000048_foo' value='' /><br />");
                    WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://i.msdn.microsoft.com/yxcx7skw.pubdelegate(en-us,VS.90).gif' /> parameter: <code>result</code></form>");

                    WriteLine("<hr />");
                    WriteLine("<form target='_blank' action='/jsc?WebMethod=06000048' method='POST' enctype='multipart/form-data'>");
                    WriteLine("  <br /> <img src='http://i.msdn.microsoft.com/deshae98.pubmethod(en-us,VS.90).gif' /> method: <code><a href='?WebMethod=06000048'>Hello</a></code><input type='submit' value='Invoke'  /><br />");
                    WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://i.msdn.microsoft.com/yxcx7skw.pubclass(en-us,VS.90).gif' /> parameter: <code>data</code> = <input type='text'  name='_06000048_data' value='' /><br />");
                    WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://i.msdn.microsoft.com/yxcx7skw.pubclass(en-us,VS.90).gif' /> parameter: <code>foo</code> = <input type='text'  name='_06000048_foo' value='' /><br />");
                    WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://i.msdn.microsoft.com/yxcx7skw.pubdelegate(en-us,VS.90).gif' /> parameter: <code>result</code></form>");


                    WriteLine("<hr />");
                    WriteLine("<form target='_blank' action='?WebMethod=06000048' method='POST' enctype='multipart/form-data'>");
                    WriteLine("  <input type='file' name='pic' size='40' accept='image/*' />");
                    WriteLine("  <input type='file' name='foo' />");
                    WriteLine("  <br /> <img src='http://i.msdn.microsoft.com/deshae98.pubmethod(en-us,VS.90).gif' /> method: <code><a href='?WebMethod=06000048'>Hello</a></code><input type='submit' value='Invoke'  /><br />");
                    WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://i.msdn.microsoft.com/yxcx7skw.pubclass(en-us,VS.90).gif' /> parameter: <code>data</code> = <input type='text'  name='_06000048_data' value='' /><br />");
                    WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://i.msdn.microsoft.com/yxcx7skw.pubclass(en-us,VS.90).gif' /> parameter: <code>foo</code> = <input type='text'  name='_06000048_foo' value='' /><br />");
                    WriteLine("&nbsp;&nbsp;&nbsp;&nbsp;<img src='http://i.msdn.microsoft.com/yxcx7skw.pubdelegate(en-us,VS.90).gif' /> parameter: <code>result</code></form>");

                    WriteLine("</body>");

                    WriteLine("</html>");
                    #endregion

                    InternalStream.Flush();
                    InternalStream.Close();
                    #endregion
                }
            };


            var t = new Thread(
                delegate()
            {
                Console_WriteLine(ipa + ":" + port);

                var r = new TcpListener(ipa, port);

                //try
                //{
                r.Start();

                while (true)
                {
                    //log("AcceptTcpClient");
                    var c = r.AcceptTcpClient();
                    //log("AcceptTcpClient done, GetStream");

                    var s = c.GetStream();
                    //log("AcceptTcpClient done, GetStream done");


                    //AtConnection(s);

                    new Thread(
                        delegate()
                    {
                        //log("before AtConnection");
                        AtConnection(s);
                    }
                        )
                    {
                        IsBackground = true,
                    }.Start();
                }

                //}
                //catch
                //{
                //    log("AcceptTcpClient error!");

                //    throw;
                //}
            }
                )
            {
                IsBackground = true,
            };

            return(t);
        }
		private async Task<Bitmap> GetImageFromUrl(string url)
		{
			// let's check if the file exists...
			ContextWrapper cw = new ContextWrapper (this.ApplicationContext);
			File directory = cw.GetDir("imgDir", FileCreationMode.Private);
			string[] elements = url.Split (new char[] { '/' });

			bool fileExists = false;
			string fileName = directory + "/" + elements [elements.Length - 1];
			if (System.IO.File.Exists (fileName)) {
				fileExists = true;
				var imageFile = new Java.IO.File(fileName);
				Bitmap bitmap = BitmapFactory.DecodeFile(imageFile.AbsolutePath);
				return bitmap;
			}



			if (!fileExists) {
				using (var client = new HttpClient ()) {
					var msg = await client.GetAsync (url);
					if (msg.IsSuccessStatusCode) {
						using (var stream = await msg.Content.ReadAsStreamAsync ()) {						
							var bitmap = await BitmapFactory.DecodeStreamAsync (stream);
							File myPath = new File (directory, elements [elements.Length - 1]);
							try {
								using (var os = new System.IO.FileStream (myPath.AbsolutePath, System.IO.FileMode.Create)) {
									bitmap.Compress (Bitmap.CompressFormat.Png, 100, os);
								}
							} catch (Exception ex) {
								System.Console.Write (ex.Message);
							}				
							return bitmap;
						}
					}
				}
			}
			return null;
		}
Exemplo n.º 32
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            // TODO Auto-generated method stub  
            LayoutInflater mInflater = LayoutInflater.From(context);
            //产生一个View  
            View view = null;
            //根据type不同的数据类型构造不同的View,也可以根据1,2,3天数构造不同的样式  
            //view = mInflater.inflate(R.layout.city_item, null);  
            view = mInflater.Inflate(Resource.Layout.Index_Item, null);
            ImageView image = view.FindViewById<ImageView>(Resource.Id.Index_ItemImage);
            TextView name = view.FindViewById<TextView>(Resource.Id.Index_ItemText);
            switch (list[position])
            {
                case "在线补货":
                    image.SetImageResource(Resource.Drawable.customer);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        //Intent intent = new Intent();
                        //intent.SetClass(context, typeof(Customer));
                        //context.StartActivity(intent);
                        context.StartActivity(typeof(Customer));
                    };
                    break;
                case "购物车":
                    image.SetImageResource(Resource.Drawable.shoppingcart);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        Intent intent = new Intent();
                        intent.SetClass(context, typeof(OrderSave));
                        context.StartActivity(intent);
                    };
                    break;
                case "查看订单":
                    image.SetImageResource(Resource.Drawable.GetMain);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        Intent intent = new Intent();
                        intent.SetClass(context, typeof(GetMian));
                        context.StartActivity(intent);
                    };
                    break;
                case "网上查单":
                    image.SetImageResource(Resource.Drawable.Replenishment);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        Intent intent = new Intent();
                        intent.SetClass(context, typeof(Web));
                        context.StartActivity(intent);
                    };
                    break;
                case "库存查询":
                    image.SetImageResource(Resource.Drawable.btn_Stock);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        Intent intent = new Intent();
                        Bundle bu = new Bundle();
                        bu.PutString("name", "Dw_Stock");
                        intent.PutExtras(bu);
                        intent.SetClass(context, typeof(Web));
                        context.StartActivity(intent);
                    };
                    break;
                case "刷新数据":
                    image.SetImageResource(Resource.Drawable.Refresh);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        AlertDialog.Builder builder = new AlertDialog.Builder(context);
                        builder.SetTitle("提示:");
                        builder.SetMessage("确认刷新所有数据吗?建议在WiFi环境下执行此操作");
                        builder.SetPositiveButton("确定", delegate
                        {
                            SysVisitor.CreateServerDB();
                            Intent intent = new Intent();
                            Bundle bu = new Bundle();
                            bu.PutString("name", "data");
                            bu.PutString("update", "update");
                            intent.PutExtras(bu);
                            intent.SetClass(context, typeof(Loading));
                            context.StartActivity(intent);
                        });
                        builder.SetNegativeButton("取消", delegate { });
                        builder.Show();
                    };
                    break;
                case "注销登陆":
                    image.SetImageResource(Resource.Drawable.zhuxiao);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        _publicfuns.of_SetMySysSet("Login", "username", "");
                        _publicfuns.of_SetMySysSet("Login", "password", "");
                        _publicfuns.of_SetMySysSet("Login", "logindate", DateTime.Now.AddDays(-30).ToString());
                        Intent it = new Intent();
                        it.SetClass(context.ApplicationContext, typeof(MainActivity));
                        context.StartActivity(it);
                    };
                    break;
                case "退出系统":
                    image.SetImageResource(Resource.Drawable.btn_Exit);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        ContextWrapper cw = new ContextWrapper(context);
                        Intent exitIntent = new Intent(Intent.ActionMain);
                        exitIntent.AddCategory(Intent.CategoryHome);
                        exitIntent.SetFlags(ActivityFlags.NewTask);
                        cw.StartActivity(exitIntent);
                        Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                    };
                    break;
                case "检查更新":
                    image.SetImageResource(Resource.Drawable.btn_update);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        view.Enabled = false;
                        string str = Core.Update.of_update(true);
                        view.Enabled = true;
                        if (str.Substring(0, 2) != "ER")
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(context);
                            builder.SetTitle("提示:");
                            builder.SetMessage("当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode") + "服务器上最新版本为 " + str + " ,确定下载更新吗?");
                            builder.SetPositiveButton("确定", delegate
                            {
                                Intent intent = new Intent();
                                Bundle bu = new Bundle();
                                bu.PutString("name", "download");
                                intent.PutExtras(bu);
                                intent.SetClass(context, typeof(Loading));
                                context.StartActivity(intent);
                            });
                            builder.SetNegativeButton("取消", delegate { return; });
                            builder.Show();
                        }
                        else
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(context);
                            builder.SetTitle("提示:");
                            builder.SetMessage(str + " 当前版本为" + _publicfuns.of_GetMySysSet("app", "vercode"));
                            builder.SetPositiveButton("确定", delegate
                            {
                                return;
                            });
                            builder.Show();
                        }

                    };
                    break;
                case "选择相片":
                    image.SetImageResource(Resource.Drawable.Icon);
                    name.Text = list[position];
                    view.Click += delegate
                    {
                        //Intent intent = new Intent(Android.Provider.MediaStore.ActionImageCapture);
                        //string file = System.IO.Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(),
                        //    Android.OS.Environment.DirectoryDcim.ToString(), "test.jpg");
                        //outputFileUri = Android.Net.Uri.Parse(file);
                        //intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, outputFileUri);
                        //activity.StartActivityForResult(intent, TAKE_PICTRUE);
                        context.StartActivity(typeof(ChatMian));
                    };
                    break;
            }
            view.SetPadding(8, 8, 8, 28);
            return view;
        }
Exemplo n.º 33
0
 public virtual bool HandleException(ContextWrapper Wrapper)
 {
     return(false);
 }
Exemplo n.º 34
0
 private void UploadImg(object sender, EventArgs eventArgs)
 {
     ContextWrapper cw = new ContextWrapper(this.ApplicationContext);
     Java.IO.File directory = cw.GetDir("imgDir", FileCreationMode.WorldReadable);
     Java.IO.File myPath = new Java.IO.File(directory, this.imgFileName);
     System.IO.FileStream imgFile = new FileStream(myPath.AbsolutePath, FileMode.Open);
     /*
     BinaryReader br = new BinaryReader(imgFile);
     long numBytes = new FileInfo(this.imgFileName).Length;
     byte[] buff = null;
     buff = br.ReadBytes((int) numBytes);
     */
     DialogService.ShowLoading("Uploading");
     try
     {
         RESTService.UploadFilesToRemoteUrl("http://joi-testp.chinacloudapp.cn:8090/image/upload/jinmin", imgFile);
     }
     catch (WebException e)
     {
     }
     DialogService.HideLoading();
 }
Exemplo n.º 35
0
 /// <summary>
 /// 在ContextWrapper OnCreate時呼叫
 /// 指定ContextWrapper建立Broadcast
 /// </summary>
 /// <param name="context">指定ContextWrapper</param>
 public void OnCreate(ContextWrapper context, OnReceiveFunc _onReceiveFunc)
 {
     scanservice.OnCreate(context, _onReceiveFunc);
 }
Exemplo n.º 36
0
 public CategoryRepository(ContextWrapper <Category> context) : base(context)
 {
 }
Exemplo n.º 37
0
    public async Task onPictureTakeAsync(byte[] data, Camera camera)
    {
            /*ContextWrapper cw = new ContextWrapper(ApplicationContext);
            imageFileFolder = cw.GetExternalFilesDir(Android.OS.Environment.DirectoryPictures);

            Calendar c = Calendar.Instance;
            imageFileName = new Java.IO.File(imageFileFolder, c.Time.Seconds + ".bmp");
            imageFileName.CreateNewFile();

            using (var os = new FileStream(imageFileName.AbsolutePath, FileMode.Create))
            {
                os.Write(data, 0, data.Length);
            }
            */
            TesseractApi tesseractApi = new TesseractApi(ApplicationContext, AssetsDeployment.OncePerInitialization);
            if (!tesseractApi.Initialized)
                await tesseractApi.Init("eng");
            var tessResult = await tesseractApi.SetImage(data);
            if (tessResult)
            {
                var a = tesseractApi.Text;
                var b = a;
            }

            Bitmap cameraBitmap = BitmapFactory.DecodeByteArray(data, 0, data.Length);
            int wid = cameraBitmap.Width;
            int hgt = cameraBitmap.Height;

            Bitmap resultImage = Bitmap.CreateBitmap(wid, hgt, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(resultImage);
            canvas.DrawBitmap(cameraBitmap, 0f, 0f, null);

            image.DrawingCacheEnabled = true;
            image.Measure(MeasureSpec.MakeMeasureSpec(300, MeasureSpecMode.Exactly),
                          MeasureSpec.MakeMeasureSpec(300, MeasureSpecMode.Exactly));
            image.Layout(0, 0, image.MeasuredWidth, image.MeasuredHeight);
            image.BuildDrawingCache(true);
            Bitmap layoutBitmap = Bitmap.CreateBitmap(image.DrawingCache);
            image.DrawingCacheEnabled = false;
            canvas.DrawBitmap(layoutBitmap, 80f, 0f, null);

            ContextWrapper cw = new ContextWrapper(ApplicationContext);
            imageFileFolder = cw.GetExternalFilesDir(Android.OS.Environment.DirectoryPictures);

            imageFileName = new Java.IO.File(imageFileFolder, DateTime.Now.Ticks.ToString() + ".jpg");
            imageFileName.CreateNewFile();

            try
            {
                using (var os = new FileStream(imageFileName.AbsolutePath, FileMode.Create))
                {
                    resultImage.Compress(Bitmap.CompressFormat.Jpeg, 95, os);
                }
            }
            catch (Exception e)
            {
                Log.Debug("In Saving File", e + "");
            }

            dialog.Dismiss();

            var activity = new Intent(this, typeof(ImageActivity));

            activity.PutExtra("AbsolutePath", imageFileName.AbsolutePath);
            StartActivity(activity);
            Finish();
            //StartActivity(typeof(ImageActivity));
        }
Exemplo n.º 38
0
				public ExpandableExtensionConverter(IORMPropertyExtension extension, PropertyDescriptor descriptor)
				{
					this.myExtensionElement = extension;
					this.myExtensionElementType = extension.GetType();
					this.myOriginalDescriptor = descriptor;
					this.myContextWrapper = new ContextWrapper(descriptor, myExtensionElement);
				}
Exemplo n.º 39
0
 public BaseController(ReleaseContext dbContext)
 {
     DbContext     = new ContextWrapper <ReleaseContext>(dbContext);
     IndexViewName = "List";
     EditViewName  = "Edit";
 }
Exemplo n.º 40
0
 public string upload(byte[] image)
 {
     if (AppGlobalData.context == null) return null;
     ContextWrapper cw = new ContextWrapper(AppGlobalData.context);
     Java.IO.File directory = cw.GetDir("imgDir", FileCreationMode.WorldReadable);
     Java.IO.File myPath = new Java.IO.File(directory, "tmpimgfile");
     FileStream fs = new FileStream(myPath.AbsolutePath, FileMode.OpenOrCreate);
     //fs.Write(image, 0, image.Length);
     string ret = UploadFilesToRemoteUrl("http://joi-testp.chinacloudapp.cn:8090/image/upload/jinmin", fs);
     fs.Close();
     return ret;
 }
Exemplo n.º 41
0
 protected override Registry CreateRegistry(Type taskType, ContextWrapper contextWrapper)
 {
     return(new TestRegistry());
 }
		public void ActivityResult (int requestCode, Result resultCode, Intent data)
		{			
			if (resultCode == Result.Ok) {				
				var packageName = Application.Context.PackageName.ToString ();
				int position = VacationInfoCreateTabsFragment._viewPager.CurrentItem;
				int viewId = _container.Context.Resources.GetIdentifier ("view_" + position, "id", packageName);
				View currentView = _container.FindViewById (viewId);
				ImageView image = currentView.FindViewById<ImageView> (Resource.Id.ItemImageView);

				if (requestCode == CAMERA_CAPTURE_IMAGE_REQUEST_CODE) {
					Intent mediaScanIntent = new Intent (Intent.ActionMediaScannerScanFile);
					mediaScanIntent.SetData (_imageUriFromFile);
					ContextWrapper wrapper = new ContextWrapper (_container.Context);
					wrapper.SendBroadcast (mediaScanIntent);

					var file = new Java.IO.File (mediaScanIntent.Data.EncodedPath);
					Bitmap bitmap = BitmapFactory.DecodeFile (file.Path);

					image.SetImageBitmap (bitmap);
					_imageUri = _imageUriFromFile;
					return;
				} else {
					_imageUri = data.Data;
					image.SetImageURI (data.Data);
				}
			}
		}
Exemplo n.º 43
0
 public static void StartActivity <T>(this ContextWrapper activity, Context context = null)
 {
     activity.StartActivity(new Intent(context ?? Application.Context, typeof(T)));
 }
 public static void Init(ContextWrapper ctx)
 {
     context = ctx;
 }