public IActionResult Save()
        {
            var formData = this.Request.Form;

            try
            {
                OnlineCosmeticShop onlineCosmeticShop = ObjectConstuctor.constructXMLObject(formData);

                XmlSerializer xmlSerializer = new XmlSerializer(typeof(OnlineCosmeticShop));

                FileStream fileStream = new FileStream(
                    $"C:\\Users\\ksimeonova\\Documents\\ASP\\CozmeticZone\\CozmeticZone\\XML\\G_Products.xml",
                    FileMode.CreateNew);

                using (StreamWriter streamWriter = new StreamWriter(fileStream))
                {
                    xmlSerializer.Serialize(streamWriter, onlineCosmeticShop);
                }

                string name       = "G_Products.xml";
                bool   isValidXML = XMLValidator.isValidXML(name);

                if (isValidXML)
                {
                    DBManipulator.fillDatabase(onlineCosmeticShop);
                }

                ViewBag.ValidXML = isValidXML;
            }
            catch (IOException e)
            {
                Console.WriteLine(e);
                ViewBag.FileExists = true;
            }
            catch (FormatException e)
            {
                Console.WriteLine(e);
                ViewBag.IncorrectFormat = true;
            }

            return(View("Save"));
        }
示例#2
0
        public IActionResult Save()
        {
            var formData = this.Request.Form;

            try
            {
                SmartphoneCatalog onlineCosmeticShop = ObjectConstuctor.constructXMLObject(formData);

                XmlSerializer xmlSerializer = new XmlSerializer(typeof(SmartphoneCatalog));
                FileStream    fileStream    = new FileStream(
                    $"C:\\Users\\Dan4inatora\\Desktop\\Kris_proj\\SmartPhone_Catalog\\SmartPhone_Catalog\\XML\\G_Books.xml",
                    FileMode.CreateNew);

                using (StreamWriter streamWriter = new StreamWriter(fileStream))
                {
                    xmlSerializer.Serialize(streamWriter, onlineCosmeticShop);
                }

                string name       = "G_Books.xml";
                bool   isValidXML = XMLValidator.isValidXML(name);

                if (isValidXML)
                {
                    DBManipulator.fillDatabase(onlineCosmeticShop);
                }

                ViewBag.ValidXML = isValidXML;
            }
            catch (IOException e)
            {
                Console.WriteLine(e);
                ViewBag.FileExists = true;
            }
            catch (FormatException e)
            {
                Console.WriteLine(e);
                ViewBag.IncorrectFormat = true;
            }

            return(View("Save"));
        }
        public IActionResult Serialize()
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(OnlineCosmeticShop));

            var filesInfo = new Dictionary <string, bool>();

            for (int index = 1; index <= 20; index++)
            {
                try
                {
                    string fileName = $"Products_{index}.xml";
                    bool   validXML = XMLValidator.isValidXML(fileName);

                    bool isValid = XMLValidator.isValidXML();

                    FileStream fileStream = new FileStream(
                        $"C:\\Users\\ksimeonova\\Documents\\ASP\\CozmeticZone\\CozmeticZone\\XML\\Products_{index}.xml",
                        FileMode.Open);

                    if (validXML)
                    {
                        OnlineCosmeticShop onlineCosmeticShop =
                            (OnlineCosmeticShop)xmlSerializer.Deserialize(fileStream);
                        var success = DBManipulator.fillDatabase(onlineCosmeticShop);
                        ViewBag.Sucess = success;
                    }

                    fileStream.Close();
                    filesInfo.Add(fileName, validXML);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    ViewBag.IncorrectFormat = true;
                }
            }

            ViewBag.FilesInfo = filesInfo;

            return(View());
        }
示例#4
0
        public IActionResult Serialize()
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(SmartphoneCatalog));

            var filesInfo = new Dictionary <string, bool>();

            for (int index = 1; index <= 20; index++)
            {
                try
                {
                    string fileName = $"Book_{index}.xml";
                    bool   validXML = XMLValidator.isValidXML(fileName);
                    string path     = Environment.CurrentDirectory;

                    FileStream fileStream = new FileStream(
                        $"C:\\Users\\Dan4inatora\\Desktop\\Kris_proj\\SmartPhone_Catalog\\SmartPhone_Catalog\\XML\\Book_{index}.xml",
                        FileMode.Open);

                    if (validXML)
                    {
                        SmartphoneCatalog smartphoneCatalog =
                            (SmartphoneCatalog)xmlSerializer.Deserialize(fileStream);
                        var success = DBManipulator.fillDatabase(smartphoneCatalog);
                        ViewBag.Sucess = success;
                    }

                    fileStream.Close();
                    filesInfo.Add(fileName, validXML);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    ViewBag.IncorrectFormat = true;
                }
            }

            ViewBag.FilesInfo = filesInfo;

            return(View());
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DBManipulator dhelper = DBConfigurator.OpenDBManipulator();


            //List<CModel> models1 = dhelper.GetModels();


            //ModelFilter filter = new ModelFilter(typeof(C_ACCOUNT));
            //filter.AndParam("ROW_ID", 40);

            //CModel jsonmode = dhelper.GetModel(filter);


            //C_ACCOUNT s = JsonConverter.CModelToModel<C_ACCOUNT>(jsonmode);

            //string getdata = jsonmode.GetValue("USER_NAME");


            //C_ACCOUNT c = dhelper.GetModel<C_ACCOUNT>(filter);   //实体获取日期时间出错了,导致转换json数据的日期格式错误

            //c.CREATE_DATE = DateTime.Now;
            //c.DELETE_DATE = DateTime.Now;
            //c.UPDATE_DATE = DateTime.Now;



            //List<C_ACCOUNT> models2 = dhelper.GetModels<C_ACCOUNT>(filter);

            //CModel jsonmodel = dhelper.GetModel(filter);

            //string json1 = JsonConverter.CModelToJson(jsonmodel);

            //string json2 = JsonConverter.JsonSerializer(c);

            //CModel md = new CModel();

            //md = JsonConverter.JsonToCModel(json2);

            ////dhelper.DeleteModel(filter);

            ////dhelper.DeleteModels(models2);

            ////filter.AndParam("USER_ID", "C22");

            //ModelFilter filter1 = new ModelFilter(typeof(C_ACCOUNT));

            ////filter1.AndParam("ROW_ID", 1);

            //C_ACCOUNT model = dhelper.GetModel<C_ACCOUNT>(filter1);


            //dhelper.InsertModel(model);



            //List<C_ACCOUNT> c_accounts = dhelper.GetModels<C_ACCOUNT>();


            //dhelper.InsertModels(c_accounts);


            //ModelFilter filter2 = new ModelFilter("C_ACCOUNT");


            //CModel cm = dhelper.GetModel(filter1);



            ////model.SEX = "女";

            //cm["SEX"] = "女";

            //dhelper.UpdateModel(cm);

            CModel modela = new CModel(typeof(C_ACCOUNT));

            modela["USER_ID"]     = "C21";
            modela["USER_NAME"]   = "詹姆斯";
            modela["USER_PWD"]    = "15768091384";
            modela["SEX"]         = "男";
            modela["AGE"]         = 34;
            modela["PHONE"]       = "13232138056";
            modela["CREATE_DATE"] = DateTime.Now;
            modela["UPDATE_DATE"] = DateTime.Now;
            modela["DELETE_DATE"] = DateTime.Now;

            dhelper.InsertModel(modela);



            List <CModel> modess = new List <CModel>();

            modela                = new CModel(typeof(C_ACCOUNT));
            modela["USER_ID"]     = "C22";
            modela["USER_NAME"]   = "詹姆斯";
            modela["USER_PWD"]    = "15768091384";
            modela["SEX"]         = "男";
            modela["AGE"]         = 34;
            modela["PHONE"]       = "13232138056";
            modela["CREATE_DATE"] = DateTime.Now;
            modela["UPDATE_DATE"] = DateTime.Now;
            modela["DELETE_DATE"] = DateTime.Now;

            modess.Add(modela);


            modela                = new CModel(typeof(C_ACCOUNT));
            modela["USER_ID"]     = "C23";
            modela["USER_NAME"]   = "詹姆斯";
            modela["USER_PWD"]    = "15768091384";
            modela["SEX"]         = "男";
            modela["AGE"]         = 34;
            modela["PHONE"]       = "13232138056";
            modela["CREATE_DATE"] = DateTime.Now;
            modela["UPDATE_DATE"] = DateTime.Now;
            modela["DELETE_DATE"] = DateTime.Now;

            modess.Add(modela);



            modela                = new CModel(typeof(C_ACCOUNT));
            modela["USER_ID"]     = "C24";
            modela["USER_NAME"]   = "詹姆斯";
            modela["USER_PWD"]    = "15768091384";
            modela["SEX"]         = "男";
            modela["AGE"]         = 34;
            modela["PHONE"]       = "13232138056";
            modela["CREATE_DATE"] = DateTime.Now;
            modela["UPDATE_DATE"] = DateTime.Now;
            modela["DELETE_DATE"] = DateTime.Now;

            modess.Add(modela);


            modela                = new CModel(typeof(C_ACCOUNT));
            modela["USER_ID"]     = "C25";
            modela["USER_NAME"]   = "詹姆斯";
            modela["USER_PWD"]    = "15768091384";
            modela["SEX"]         = "男";
            modela["AGE"]         = 34;
            modela["PHONE"]       = "13232138056";
            modela["CREATE_DATE"] = DateTime.Now;
            modela["UPDATE_DATE"] = DateTime.Now;
            modela["DELETE_DATE"] = DateTime.Now;

            modess.Add(modela);


            modela                = new CModel("C_ACCOUNT");
            modela["USER_ID"]     = "C26";
            modela["USER_NAME"]   = "詹姆斯";
            modela["USER_PWD"]    = "15768091384";
            modela["SEX"]         = "男";
            modela["AGE"]         = 34;
            modela["PHONE"]       = "13232138056";
            modela["CREATE_DATE"] = DateTime.Now;
            modela["UPDATE_DATE"] = DateTime.Now;
            modela["DELETE_DATE"] = DateTime.Now;

            modess.Add(modela);

            dhelper.InsertModels(modess);
        }
示例#6
0
        /// <summary>
        /// 登录
        /// </summary>
        public HttpResult Login()
        {
            string name = HttpRequestData.FormString("user_name");
            string pwd  = HttpRequestData.Form <string>("user_pwd");

            DBManipulator manipulator = DBConfigurator.OpenDBManipulator();

            ModelFilter filter = new ModelFilter(typeof(C_ACCOUNT));

            filter.PageQuery = new PagingQuery(5, 0);


            //int count = manipulator.SelectCount(typeof(C_ACCOUNT));


            //filter.AndParam("USER_NAME", name);
            //filter.AndParam("USER_PWD", pwd);
            //filter.PageQuery = new PagingQuery() { PageCount = 5, PageIndex = 0 };

            //CModel cm = new CModel(typeof(C_ACCOUNT));


            //C_ACCOUNT xincm = manipulator.GetModelByKey<C_ACCOUNT>(43);


            //DateTime st = xincm.CREATE_DATE;

            List <CModel> cs = manipulator.GetModels(filter);

            //C_ACCOUNT model = manipulator.GetModel<C_ACCOUNT>(filter);


            //string c_json1 = JsonConverter.JsonSerializer<C_ACCOUNT>(model);

            //C_ACCOUNT c_json2 = JsonConverter.JsonDeserialize<C_ACCOUNT>(c_json1);


            //CModel cmodel = manipulator.GetModel(filter);

            //string c_json3 = JsonConverter.CModelToJson(cmodel);

            //CModel c_json4 = JsonConverter.JsonToCModel(c_json3);


            //C_ACCOUNT dsa = JsonConverter.CModelToModel<C_ACCOUNT>(c_json4);

            //CModel cmode = manipulator.GetModelByKey("C_ACCOUNT", 43);


            //CModel cmodel = manipulator.GetModel(filter);

            //CModel col = new CModel();
            //col["user"] = "******";
            //col["pwd"] = "123";

            //List<CModel> firends = new List<CModel>();
            //firends.Add(cmodel);
            //firends.Add(cmodel);
            //col["firends"] = firends;

            //List<string> familys = new List<string>();
            //familys.Add("aa");
            //familys.Add("bb");
            //familys.Add("dd");
            //col["familys"] = familys;

            //CModel col1 = new CModel();
            //col1["user"] = "******";
            //col1["pwd"] = "123";
            //col1["firends"] = firends;
            //col1["familys"] = familys;
            //col1["col"] = col;
            //col1["col1"] = col;

            //CModelList<C_ACCOUNT> models = new CModelList<C_ACCOUNT>();

            //foreach (var item in models)
            //{

            //}


            return(WebResponse.Result(""));
        }