示例#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();
                }
            }
        }
示例#2
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);
        }