Beispiel #1
0
        static void Main()
        {
            log4net.Config.XmlConfigurator.Configure();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            s          = new Sunisoft.IrisSkin.SkinEngine();
            s.SkinFile = System.AppDomain.CurrentDomain.BaseDirectory + "\\Skins\\RealOne.ssk";
            //读取配置文件是否自动登录
            EncryptedNameValueSectionHandler hand = new EncryptedNameValueSectionHandler();
            string autoLogin = hand.ReadConfig("autoLogin");

            if (autoLogin == "T")
            {
                string       passWord = hand.ReadConfig("userPwd");
                string       userName = hand.ReadConfig("userName");
                LoginService login    = new LoginService();
                string       result   = login.login(userName, passWord);
                if (result.Equals("1"))
                {
                    Application.Run(new Main());
                }
                else
                {
                    MessageBox.Show(result);
                    //首先载入登录窗体实例
                    Login frmLogin = new Login();
                    frmLogin.StartPosition = FormStartPosition.CenterScreen;
                    DialogResult loginResult = frmLogin.ShowDialog();
                    //若登录成功则加载主窗体
                    if (loginResult == DialogResult.OK)
                    {
                        Application.Run(new Main());
                    }
                    else
                    {
                        //登录失败则关闭当前程序进程
                        Application.Exit();
                    }
                }
            }
            else
            {
                //首先载入登录窗体实例
                Login frmLogin = new Login();
                frmLogin.StartPosition = FormStartPosition.CenterScreen;
                DialogResult loginResult = frmLogin.ShowDialog();
                //若登录成功则加载主窗体
                if (loginResult == DialogResult.OK)
                {
                    Application.Run(new Main());
                }
                else
                {
                    //登录失败则关闭当前程序进程
                    Application.Exit();
                }
            }
        }
Beispiel #2
0
        //加载首页配置
        private void ShowUI()
        {
            string autoLogin = hand.ReadConfig("autoLogin");
            string saveId    = hand.ReadConfig("saveId");
            string userName  = hand.ReadConfig("userName");

            this.autoLogin.Checked = autoLogin == "T";
            this.saveId.Checked    = saveId == "T";

            if (saveId == "T")
            {
                this.username.Text = userName;
            }
        }
Beispiel #3
0
        //加载配置
        private void ShowUI()
        {
            try
            {
                mTwain.Language       = TwLanguage.CHINESE_SINGAPORE;
                mTwain.IsTwain2Enable = false;
                mTwain.OpenDSM();
                List <string> srclst = new List <string>();

                for (int i = 0; i < mTwain.SourcesCount; i++)
                {
                    srclst.Add(mTwain.GetSourceProductName(i));
                }
                scanCmb.DataSource = srclst;
                mTwain.CloseDSM();
                //读取扫描仪配置
                if (!string.IsNullOrEmpty(hand.ReadConfig("twIndex")))
                {
                    this.scanCmb.SelectedIndex = Convert.ToInt32(hand.ReadConfig("twIndex"));
                }



                this.urlTxt.Text       = hand.ReadConfig("url");
                this.IsAutoCbx.Checked = hand.ReadConfig("autoLogin") == "T" ? true : false;

                this.saveDayTxt.Text = hand.ReadConfig("saveDay");
                //this.saveUrlTxt.Text = hand.ReadConfig("saveUrl");
                //if (hand.ReadConfig("isShowConfig") == "T")
                //    this.Yradio.Checked = true;
                //else
                //    this.Nradio.Checked = true;

                //this.skinList.DataSource = new DirectoryInfo("Skins").GetFiles();
                //this.skinList.DisplayMember = "Name";
            }
            catch (Exception)
            {
                Logger.Error("未找到支持TWAIN扫描协议的设备,启动失败!");
                MessageBox.Show("未找到支持TWAIN扫描协议的设备,启动失败!");
                Application.Exit();
            }
        }
Beispiel #4
0
        public bool uploadImg(string zipImgPath, UploadObj imgInfo)
        {
            EncryptedNameValueSectionHandler hand = new EncryptedNameValueSectionHandler();
            bool   result   = false;
            string infoJson = JsonConvert.SerializeObject(imgInfo);
            List <FormItemModel> formDatas = new List <Common.FormItemModel>();
            //添加JSON参数
            FormItemModel jsModel = new Common.FormItemModel();

            jsModel.Key   = "data";
            jsModel.Value = infoJson;
            formDatas.Add(jsModel);
            //添加zip文件流
            FormItemModel fileModel = new Common.FormItemModel();

            fileModel.Key      = "file";
            fileModel.Value    = "";
            fileModel.FileName = zipImgPath;
            //fileModel.FileContent = File.OpenRead(zipImgPath);
            formDatas.Add(fileModel);
            //调用方法
            string url = hand.ReadConfig("url");

            url = url + "/client/upload";
            Logger.Info("传参文件名==" + zipImgPath + "传参JSON==" + infoJson);

            string resultJson = HttpUtils.PostForm2(url, formDatas);

            Logger.Info("返回结果==" + resultJson);
            if (string.IsNullOrEmpty(resultJson))
            {
                result = false;
            }
            else
            {
                JObject obj = (JObject)JsonConvert.DeserializeObject(resultJson);
                if (obj["code"].ToString().Equals("0"))
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }

            return(result);
        }
Beispiel #5
0
        public string login(string userName, string userPwd)
        {
            //cashTest();
            //return "1";

            string postData = string.Empty;

            postData = "username="******"&password="******"url");

            url = url + "/client/login";
            try
            {
                string  result = HttpUtils.HttpPost(url, postData);
                JObject obj    = (JObject)JsonConvert.DeserializeObject(result);
                if (obj["code"].ToString().Equals("0"))
                {
                    string token         = obj["token"].ToString();
                    string billNoRegular = obj["data"].Value <string>("codebar_regular");
                    //将相关信息放入缓存中
                    //用户信息放入缓存
                    UserInfo user = new UserInfo();
                    user.userName = userName;
                    user.userPwd  = userPwd;
                    user.token    = token;
                    AffectCacheObject.Instance[Constants.USERKEY] = user;
                    //token信息放入缓存
                    AffectCacheObject.Instance[Constants.TOKEN] = token;
                    //单号识别正则表达式放入缓存
                    AffectCacheObject.Instance[Constants.BILL_REGULAR] = billNoRegular;
                    return("1");
                }
                else
                {
                    return("用户名或密码错误!");
                }
            }
            catch (Exception ex)
            {
                return("登陆异常!" + ex.Message);
            }
        }