예제 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
            this.IsMouseVisible           = true;
            this.Window.AllowUserResizing = true;



            //------ MY CODE ------
            mainHandler = new UnityEngineMainHandler();

            var exporter = new ExportImport();

            var vv = exporter.JsonDeserialize(UIJsonData.data);

            var g = exporter.Deserialize(vv, mainHandler.main.transform);

            UnityEngine.GameObject eventSystem = new UnityEngine.GameObject("EventSystem");
            eventSystem.transform.parent = mainHandler.main.transform;
            var v         = eventSystem.AddComponent <UnityEngine.EventSystems.EventSystem>();
            var baseInput = eventSystem.AddComponent <UnityEngine.EventSystems.StandaloneInputModule>();

            inputModule = eventSystem.AddComponent <XnaInput>();
            inputModule.Init(this);
            baseInput.inputOverride = inputModule;
            // SUPER IMPORTANT
            UnityEngine.Cursor.visible   = true;
            UnityEngine.Cursor.lockState = UnityEngine.CursorLockMode.None;

            // Starts and Awakes all scripts
            mainHandler.Start();
        }
            public void CheckUpdate()
            {
                if (CheckAndSaveSql())
                {
                    AtMessageBox.Show("Найдены скрипты обновления программы, необходимо перезапустить программу, чтобы изменения вступили в силу", "Доступны обновления");
                    Application.Exit();
                    return;
                }

                string sha = CheckSetting();

                if (!this.settingSha.txtvalue.Equals(sha))
                {
                    SaveSettingFile();
                    Form mainForm = GetMainForm();
                    if (mainForm.ShowDialog() == DialogResult.OK)
                    {
                        //						MessageBox.Show(GetLastSaveFilePath());

                        string path = GetLastSaveFilePath();
                        if (String.IsNullOrEmpty(path) || !File.Exists(path))
                        {
                            throw new Exception("Файл настроек не найден!");
                        }

                        if (ExportImport.Import2(GetLastSaveFilePath(), false))
                        {
                            db.Exec(string.Format("update setting set txtvalue = '{0}' where name = '{1}' and deleted is null", sha, SETTING_SHA_NAME), false);
                        }
                    }
                }
            }
예제 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            ExportImport exportImport = db.ExportImports.Find(id);

            db.ExportImports.Remove(exportImport);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #4
0
 public ActionResult Edit([Bind(Include = "ExportImportId,EmployeeId,DateExportImport,ExportImportTypeId,Description")] ExportImport exportImport)
 {
     if (ModelState.IsValid)
     {
         db.Entry(exportImport).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeId         = new SelectList(db.Employees, "EmployeeId", "EmployeeName", exportImport.EmployeeId);
     ViewBag.ExportImportTypeId = new SelectList(db.ExportImportTypes, "ExportImportTypeId", "TypeName", exportImport.ExportImportTypeId);
     return(View(exportImport));
 }
예제 #5
0
        Task reallyImportAsync()
        {
            try
            {
                progressBar = true;

                if (SelectedItemI.Id < 0)
                {
                    p.Description = NamePath;
                    s.Comment     = Comment;
                    DataBaseManager.instance.InsertPath(p);
                    s.IdPath = p.Id;
                }
                else
                {
                    s.IdPath = SelectedItemI.Id;
                }

                DataBaseManager.instance.InsertSession(s);

                return(Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        if (await ExportImport.ImportKmlAsync(t.Files[0], false, p, s, this) != null)
                        {
                            //NavigationService.GoBack();
                        }
                        progressBar = false;
                    }
                    catch (Exception ex)
                    {
                        progressBar = false;
                        ExtraInfo = ex.Message;
                        nowhereman.LittleWatson.instance.Error("really import from Kml", ex);

                        //t0.Text = string.Format("Error {0}", ex.Message);
                    }
                }));
            }
            catch (Exception ex)
            {
                progressBar = false;
                ExtraInfo   = ex.Message;
                nowhereman.LittleWatson.instance.Error("really import from Kml", ex);

                //t0.Text = string.Format("Error {0}", ex.Message);
            }

            return(Task.CompletedTask);
        }
예제 #6
0
        // GET: Admin/ExportImports/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExportImport exportImport = db.ExportImports.Find(id);

            if (exportImport == null)
            {
                return(HttpNotFound());
            }
            return(View(exportImport));
        }
예제 #7
0
        // GET: Admin/ExportImports/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExportImport exportImport = db.ExportImports.Find(id);

            if (exportImport == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeId         = new SelectList(db.Employees, "EmployeeId", "EmployeeName", exportImport.EmployeeId);
            ViewBag.ExportImportTypeId = new SelectList(db.ExportImportTypes, "ExportImportTypeId", "TypeName", exportImport.ExportImportTypeId);
            return(View(exportImport));
        }
예제 #8
0
 /// <summary>
 ///     保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     MongoHelper.ActionDone += (x, y) => MyMessageBox.ShowMessage("ExportImport", y.Message);
     ExportImport.ExportToFile(_viewinfo, ctlExportFilePicker.SelectedPathOrFileName, _exportType,
                               RuntimeMongoDbContext.GetCurrentCollection());
 }
예제 #9
0
 public bool UpdateExportImport(ExportImport exportImport)
 {
     throw new NotImplementedException();
 }
예제 #10
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode modeNav, IDictionary <string, object> state)
        {
            Comment  = "IMPORTED";
            NamePath = "IMPORTED " + string.Format(resourceLoader.GetString("PathName"), DateTime.Now.ToString());

            t = SessionState["importFile"] as FileActivatedEventArgs;

            if (t != null)
            {
                var listI = new ObservableCollection <Paths>();

                p             = new Paths();
                p.Id          = -1;
                p.Type        = "I";
                p.Description = string.Format(resourceLoader.GetString("NewPath"), resourceLoader.GetString("I"));
                listI.Add(p);

                foreach (var t in DataBaseManager.instance.getPaths("I"))
                {
                    listI.Add(t);
                }

                ListI = listI;

                SelectedItemI = p;

                s              = new Sessions();
                s.IdPath       = p.Id;
                s.DayOfSession = Utils.NOW();
                s.Comment      = Comment;

                try
                {
                    progressBar = true;

                    Task.Factory.StartNew(async() =>
                    {
                        string description = null;
                        try
                        {
                            description = await ExportImport.ImportKmlAsync(t.Files[0], true, p, s, this);

                            Duration = (s.Duration.HasValue) ? s.Duration.Value : long.MinValue;
                            Distance = (s.Distance.HasValue) ? s.Distance.Value : double.NaN;
                        }
                        catch (Exception ex)
                        {
                            description = ex.Message;
                        }

                        //await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        //{
                        progressBar = false;

                        ExtraInfo = "<html><body>" + description + "</body></html>";
                        //});
                    });
                }
                catch (Exception ex)
                {
                    nowhereman.LittleWatson.instance.Error("import from Kml", ex);

                    progressBar = false;
                    //t0.Text = string.Format("Error {0}", ex.Message);
                }

                SessionState.Remove("importFile");
            }

            return(Task.CompletedTask);
        }
예제 #11
0
        public ActionResult Import(HttpPostedFileBase fileBase)
        {
            var file = Request.Files["files"];

            if (file == null || file.ContentLength <= 0)
            {
                ViewBag.Error = "文件不能为空";
                return(View());
            }

            int subjectId = int.Parse(Request.Form["SubjectId"]);
            int deptId    = int.Parse(Request.Form["DeptId"]);

            var          filename    = Path.GetFileName(file.FileName);
            var          fileEx      = Path.GetExtension(filename);                //获取上传文件的扩展名
            var          noFileName  = Path.GetFileNameWithoutExtension(filename); //获取无扩展名的文件名
            const string fileType    = ".xls,.xlsx";                               //定义上传文件的类型字符串
            var          newFileName = noFileName + DateTime.Now.ToString("yyyyMMddhhmmss") + fileEx;

            if (fileEx != null && !fileType.Contains(fileEx))
            {
                ViewBag.Error = "文件类型不对,只能导入xls和xlsx格式的文件";
                return(View());
            }
            string path = AppDomain.CurrentDomain.BaseDirectory + "uploads/excel/";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string savePath = Path.Combine(path, newFileName);

            file.SaveAs(savePath);

            var expImp = new ExportImport();
            var dt     = expImp.GetFillData(savePath, false);

            if (dt == null)
            {
                ViewBag.Error = "导入的数据文件格式不正确";
                return(View());
            }
            var importCount = dt.Rows.Count;

            if (importCount == 0)
            {
                ViewBag.Error = "导入的数据文件为空";
                return(View());
            }

            string message;

            if (!CheckExcel(ref dt, out message))
            {
                ViewBag.Error = "!!!导入失败!!!<br/>" + message;
                return(View());
            }

            if (dt.Rows.Count == 0)
            {
                ViewBag.Error = "无正确的数据可导入";
                return(View());
            }

            var examDb = new List <exam_database>();


            foreach (DataRow dr in dt.Rows)
            {
                var exam = new exam_database()
                {
                    Type      = dr[0].ToString(),
                    Question  = dr[1].ToString(),
                    Text1     = dr[2].ToString(),
                    Text2     = dr[3].ToString(),
                    Text3     = dr[4].ToString(),
                    Text4     = dr[5].ToString(),
                    Text5     = dr[6].ToString(),
                    Text6     = dr[7].ToString(),
                    Answer    = dr[8].ToString().ToUpper(),
                    SubjectId = subjectId,
                    DeptId    = deptId
                };
                examDb.Add(exam);
            }

            //写库
            bool ret = _examRep.Add(examDb) > 0;

            ViewBag.Error = ret ? "导入成功" : "导入失败";

            return(View());
        }
예제 #12
0
        public ActionResult Import(HttpPostedFileBase fileBase)
        {
            var file = Request.Files["files"];

            //int deptId = int.Parse(Request.Form["DeptId"]);

            if (file == null || file.ContentLength <= 0)
            {
                ViewBag.error = "文件不能为空";
                return(View());
            }

            var          filename    = Path.GetFileName(file.FileName);
            var          fileEx      = Path.GetExtension(filename);                //获取上传文件的扩展名
            var          noFileName  = Path.GetFileNameWithoutExtension(filename); //获取无扩展名的文件名
            const string fileType    = ".xls,.xlsx";                               //定义上传文件的类型字符串
            var          newFileName = noFileName + DateTime.Now.ToString("yyyyMMddhhmmss") + fileEx;

            if (fileEx != null && !fileType.Contains(fileEx))
            {
                ViewBag.error = "文件类型不对,只能导入xls和xlsx格式的文件";
                return(View());
            }
            string path = AppDomain.CurrentDomain.BaseDirectory + "uploads/excel/";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string savePath = Path.Combine(path, newFileName);

            file.SaveAs(savePath);

            var expImp = new ExportImport();
            var dt     = expImp.GetFillData(savePath, false);

            if (dt == null)
            {
                ViewBag.Error = "导入的数据文件格式不正确";
                return(View());
            }
            var importCount = dt.Rows.Count;

            if (importCount == 0)
            {
                ViewBag.Error = "导入的数据文件为空";
                return(View());
            }

            string message;

            if (!CheckExcel(ref dt, out message))
            {
                ViewBag.Error = "导入失败";
                return(View());
            }
            if (dt.Rows.Count == 0)
            {
                ViewBag.Error = "无正确的数据可导入";
                return(View());
            }

            var empList = new List <cadre_info>();

            foreach (DataRow dr in dt.Rows)
            {
                cadre_info emp = new cadre_info
                {
                    UserID   = dr[0].ToString(),
                    UserName = dr[1].ToString(),
                    Pwd      = dr[2].ToString(),
                    DeptId   = AdminLoginHelper.LoginInfo.DeptId
                };

                empList.Add(emp);
            }

            //写库
            bool ret = _cadreInfoRep.Add(empList) > 0;

            ViewBag.Error = ret ? "导入成功" : "导入失败";

            return(View());
        }