Ejemplo n.º 1
0
    public void Initialize()
    {
        if (frontGround == null)
        {
            frontGround = GameObject.Find("FrontGround").GetComponent <Image>();
        }
        if (IntroUI == null)
        {
            IntroUI = GameObject.FindObjectOfType <UIIntro>();
        }
        if (LoadingUI == null)
        {
            LoadingUI = GameObject.FindObjectOfType <UILoading>();
        }
        if (TimerUI == null)
        {
            TimerUI = GameObject.FindObjectOfType <UITimer>();
        }
        if (ScoreUI == null)
        {
            ScoreUI = GameObject.FindObjectOfType <UIScore>();
        }
        if (ResultUI == null)
        {
            ResultUI = GameObject.FindObjectOfType <UIResult>();
        }

        IntroUI.Initialize(this);
        LoadingUI.Initialize(this);
        TimerUI.Initialize(this);
        ScoreUI.Initialize(this);
        ResultUI.Initialize(this);
    }
Ejemplo n.º 2
0
        public async Task <IActionResult> OnPostDeleteRelative([FromBody] DeletePersonRelativesCommand deleteCommand)
        {
            UIResult result = new UIResult();

            try
            {
                string dbResult;
                dbResult = await Mediator.Send(deleteCommand);

                return(new JsonResult(new UIResult()
                {
                    Data = new { list = dbResult },
                    Status = UIStatus.Success,
                    Text = "شهرت اقارب کارمند موفقانه حذف شد",
                    Description = string.Empty
                }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new UIResult()
                {
                    Data = null,
                    Status = UIStatus.Failure,
                    Text = CustomMessages.InternalSystemException,
                    // Can be changed from app settings
                    Description = ex.Message
                }));
            }
        }
Ejemplo n.º 3
0
    IEnumerator Repeat()
    {
        yield return(new WaitForSeconds(0.3f));

        UIGame.SetActive(true);
        UIResult.SetActive(false);
    }
Ejemplo n.º 4
0
        public void View(UIResult result)
        {
            ResultDetailsView details = new ResultDetailsView(result);

            details.Owner = System.Windows.Application.Current.MainWindow;
            details.ShowDialog();
        }
Ejemplo n.º 5
0
        public void upload(UIResult result)
        {
            var adjustRecord = base.LocalID.DeSerializeAdjustRecord <ResultAdjustmentModel>(result.TaskID);

            if (adjustRecord == null)
            {
                this.ShowDialog("提示信息", "没有调整记录,无法上传!", DialogSettingType.OnlyOkButton, DialogType.Warning);
                return;
            }

            var confirm = this.ShowDialog("提示信息", "确认上传方案?", DialogSettingType.OkAndCancel, DialogType.Warning);

            if (confirm == DialogResultType.OK)
            {
                var operation = WebAPI.Instance.WriteBackResult(result.TaskID, adjustRecord);
                if (operation.Item1)
                {
                    result.IsUploaded = true;
                    var local   = CommonDataManager.GetLocalCase(base.LocalID);
                    var results = ResultDataManager.GetResults(base.LocalID);
                    local.Serizlize(results);
                    this.ShowDialog("提示信息", "上传成功!", DialogSettingType.NoButton, DialogType.None);
                }
                else
                {
                    this.ShowDialog("提示信息", operation.Item3, DialogSettingType.OnlyOkButton, DialogType.Warning);
                }
            }
        }
Ejemplo n.º 6
0
    protected override void SpecificInit()
    {
        if (option != null)//有設置
        {
            messageText.text = option.message;

            //按鍵設置
            if (option.btnSettings != null)
            {
                //清空按鍵
                foreach (Transform b in buttonZone)
                {
                    Destroy(b.gameObject);
                }

                int btnAmount = option.btnSettings.Count;
                if (btnAmount < minAmount && btnAmount > maxAmount)
                {
                    Debug.LogErrorFormat("按鍵數量錯誤,需於{0}~{1}之間", minAmount, maxAmount);
                }
                else
                {
                    //依序設置按鍵
                    for (int i = 0; i < btnAmount; i++)
                    {
                        GameObject btn = Instantiate(buttonPrefab);
                        btn.name = (i + 1).ToString();
                        btn.transform.SetParent(buttonZone.transform, false);
                        //顏色
                        btn.GetComponent <Image>().color = option.btnSettings[i].color;
                        //內容
                        btn.GetComponentInChildren <Text>().text = option.btnSettings[i].text;
                        //動作
                        if (option.btnSettings[i].onClick != null)
                        {
                            UIOption.UICallback callback = option.btnSettings[i].onClick;
                            btn.GetComponent <Button>().onClick.AddListener(() => {
                                callback.Invoke(UIResult.Memo(btn.name));
                                Cancel();
                            });
                        }
                        else
                        {
                            btn.GetComponent <Button>().onClick.AddListener(Cancel);
                        }
                    }
                }
            }
            else //無按鍵設置
            {
                DefaultBtnSettings();
            }
        }
        else
        {
            Debug.LogErrorFormat("需進行視窗設置。");//需要DialogOption
        }
    }
Ejemplo n.º 7
0
        public void analysis(UIResult result)
        {
            ResultDataManager.CurrentResult = result;

            var local = CommonDataManager.GetLocalCase(base.LocalID);

            Analysis.Result.Administrative.HostWindow host = new Analysis.Result.Administrative.HostWindow(result.Name);
            host.ShowDialog();
        }
Ejemplo n.º 8
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (filterContext.HttpContext.Request.IsAjaxRequest())
            {
                UIResult res;
                //异常处理
                if (filterContext.Exception != null)
                {
                    filterContext.ExceptionHandled = true;
                    if (filterContext.Exception.GetInnerException() is zExceptionBase)
                    {
                        zExceptionBase ex = filterContext.Exception.GetInnerException() as zExceptionBase;
                        res = new UIResult()
                        {
                            Flag = ex.Flag,
                            Msg  = ex.Message
                        };
                    }
                    else
                    {
                        res = new UIResult()
                        {
                            Flag = -1,
                            Msg  = filterContext.Exception.InnerMessage()
                        };
                    }
                    filterContext.Result = res;
                }


                if (filterContext.Result is EmptyResult)
                {
                    filterContext.Result = new UIResult();
                }
                if (filterContext.Result is UIResult)
                {
                    filterContext.Result = new UIResult()
                    {
                        Data = (filterContext.Result as UIResult).GetData()
                    };
                }
            }
            else
            {
                filterContext.Controller.ViewBag.ControllerUrl =
                    IOExtension.MakeUri(
                        HttpExtension.GetWebBasePath(),
                        filterContext.RouteData.Values["area"].ToString(),
                        filterContext.RouteData.Values["controller"].ToString()) + "/";
                filterContext.Controller.ViewBag.CommonControllerUrl =
                    IOExtension.MakeUri(
                        HttpExtension.GetWebBasePath(),
                        "Base",
                        "Common") + "/";
            }
        }
Ejemplo n.º 9
0
        public void Adjust(UIResult result)
        {
            AdjustResult window = new AdjustResult(result);

            window.Closed += (s, arg) =>
            {
                if (window.DialogResult.Value)
                {
                }
            };
            window.ShowDialog();
        }
Ejemplo n.º 10
0
        public void AddResult(string key, UIResult result)
        {
            var has = this.Results.ContainsKey(key);

            if (has)
            {
                this.Results[key].Add(result);
            }
            else
            {
                this.Results.Add(key, new List <UIResult> {
                    result
                });
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 树形业态
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public Tuple <dynamic> GetTreeCategory()
        {
            List <CATEGORYEntity> p = DbHelper.SelectList(new CATEGORYEntity()).OrderBy(a => a.CATEGORYCODE).ToList();
            var treeOrg             = new UIResult(TreeModel.Create(p,
                                                                    a => a.CATEGORYCODE,
                                                                    a => new TreeModel()
            {
                code   = a.CATEGORYCODE,
                title  = a.CATEGORYNAME,
                value  = a.CATEGORYID,
                label  = a.CATEGORYNAME,
                expand = true
            })?.ToArray());

            return(new Tuple <dynamic>(treeOrg));
        }
Ejemplo n.º 12
0
        public Tuple <dynamic> GetKindInit()
        {
            List <GOODS_KINDEntity> p = DbHelper.SelectList(new GOODS_KINDEntity()).OrderBy(a => a.CODE).ToList();
            var treeOrg = new UIResult(TreeModel.Create(p,
                                                        a => a.CODE,
                                                        a => new TreeModel()
            {
                code   = a.CODE,
                title  = a.NAME,
                value  = a.ID,
                label  = a.NAME,
                expand = true
            })?.ToArray());

            return(new Tuple <dynamic>(treeOrg));
        }
Ejemplo n.º 13
0
        public void Delete(UIResult result)
        {
            var confirm = this.ShowDialog("提示信息", $"是否确认删除?\r\n {result.Name}", DialogSettingType.OkAndCancel, DialogType.Warning);

            if (confirm == DialogResultType.OK)
            {
                Results.Remove(result);
                var results = ResultDataManager.GetResults(base.LocalID);
                results.RemoveAll(r => r.TaskID == result.TaskID);

                var caseModel = CommonDataManager.GetLocalCase(base.LocalID);
                if (caseModel != null)
                {
                    caseModel.Serizlize(results);
                }
            }
        }
Ejemplo n.º 14
0
    private void ResultProcess(bool IsSuccess)
    {
        GameObject ResultUI = Instantiate(Resources.Load("Prefabs/UI/Result", typeof(GameObject))) as GameObject;

        UIResult Result = ResultUI.GetComponent <UIResult>();

        if (SkipBool)
        {
            Result.PointText.text = CalPlayerPoint().ToString();

            Result.GaugeSlider.maxValue = StageList[SelectedStageNumber].Point;
            Result.GaugeSlider.value    = CalPlayerPoint();
        }
        else
        {
            Result.PointText.text = NowPoint.ToString();

            Result.GaugeSlider.maxValue = StageList[SelectedStageNumber].Point;
            Result.GaugeSlider.value    = NowPoint;
        }

        if (IsSuccess)
        {
            Result.SuccessWhether.text = "Success!";

            Result.GetJewelText.text = "+ " + StageList[SelectedStageNumber].Jewel.ToString();
            Result.GetExpText.text   = "+ " + StageList[SelectedStageNumber].Exp.ToString();
        }
        else
        {
            Result.SuccessWhether.text = "Fail!";

            Result.GetJewelText.text = "+ 0";
            Result.GetExpText.text   = "+ 0";
        }

        Result.LevelCircle.fillAmount = ((float)ResourceManager.Instance.GetNowExp() / (float)ResourceManager.Instance.GetMaxExp());

        Result.LevelText.text = "LV. " + ResourceManager.Instance.GetLevel().ToString();
        Result.ExpText.text   = "\n\n" + ResourceManager.Instance.GetNowExp().ToString() + " / " + ResourceManager.Instance.GetMaxExp().ToString();

        NowPoint = 0;
    }
Ejemplo n.º 15
0
        /// <summary>
        /// 从列表页编辑跳转到编辑页数据的展示查询
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public Tuple <dynamic, DataTable, dynamic> GetMerchantElement(MERCHANTEntity Data)
        {
            if (Data.MERCHANTID.IsEmpty())
            {
                throw new LogicException("请确认商户编号!");
            }
            string sql = $@"SELECT * FROM MERCHANT WHERE 1=1 ";

            if (!Data.MERCHANTID.IsEmpty())
            {
                sql += (" AND MERCHANTID= " + Data.MERCHANTID);
            }
            DataTable merchant = DbHelper.ExecuteTable(sql);

            merchant.NewEnumColumns <普通单据状态>("STATUS", "STATUSMC");

            string sqlitem = $@"SELECT M.BRANDID,C.NAME,D.CATEGORYCODE,D.CATEGORYNAME " +
                             " FROM MERCHANT_BRAND M,MERCHANT E,BRAND C,CATEGORY D " +
                             " where M.MERCHANTID = E.MERCHANTID AND M.BRANDID=C.ID AND  C.CATEGORYID = D.CATEGORYID ";

            if (!Data.MERCHANTID.IsEmpty())
            {
                sqlitem += (" and E.MERCHANTID= " + Data.MERCHANTID);
            }
            DataTable merchantBrand = DbHelper.ExecuteTable(sqlitem);


            List <ORGEntity> p = DbHelper.SelectList(new ORGEntity()).OrderBy(a => a.ORGCODE).ToList();
            var treeOrg        = new UIResult(TreeModel.Create(p,
                                                               a => a.ORGCODE,
                                                               a => new TreeModel()
            {
                code   = a.ORGCODE,
                title  = a.ORGNAME,
                value  = a.ORGID,
                label  = a.ORGNAME,
                expand = true
            })?.ToArray());

            return(new Tuple <dynamic, DataTable, dynamic>(merchant.ToOneLine(), merchantBrand, treeOrg));
        }
Ejemplo n.º 16
0
    IEnumerator IE_GameEnd()
    {
        float delay = 2f;

//        Time.timeScale = 0.1f;
        yield return(new WaitForSeconds(delay * Time.timeScale));

        Enemy[] arrEnemy = FindObjectsOfType <Enemy>();
        foreach (Enemy en in arrEnemy)
        {
            Destroy(en.gameObject);
        }

//        Time.timeScale = 1f;

        bool isFail = false;

        if (_PlayerManager._PlayerController._UnitInfo._HP <= 0)
        {
            isFail = true;
        }

        Destroy(_PlayerManager._PlayerController.gameObject);

        GameObject obj = (GameObject)Instantiate(_pfResult);

        obj.transform.parent     = _UI_Center;
        obj.transform.localScale = new Vector3(1f, 1f, 1f);
        UIResult game_result = obj.GetComponent <UIResult>();

        if (isFail == true)
        {
            game_result._MessageTitle.text = "Mission Fail !";
            game_result._btnNext.gameObject.SetActive(false);
        }

        SaveUserExp();
        SaveUnitData();
    }
Ejemplo n.º 17
0
    IEnumerator CheckSelectedSpin()
    {
        bool tResult = false;

        if (((EUtil.Symbol)randNUmList[currentIndex]).ToString() == popupList.value)
        {
            tResult = true;            //			Debug.Log("SUCCESS");
            CFunc.successCount++;
        }
        else
        {
            tResult = false;             //Debug.Log("FAILED");
            CFunc.failedCount++;
        }


        CFunc.SaveScore();
        yield return(new WaitForSeconds(0.7f));

        UIResult.SetActive(true, tResult);
        UIGame.SetActive(false);
    }
Ejemplo n.º 18
0
    public static void SetActive(bool bActive, bool _result = false)
    {
        UIResult ui = null;

        if (bActive)
        {
            ui           = Inst;
            ui.isSuccess = _result;
        }
        else
        {
            ui = s_inst;
            if (ui)
            {
                if (ui.gameObject.activeSelf)
                {
                    ui.gameObject.SetActive(false);
                }
                Destroy(ui.gameObject);
            }
        }
    }
        public void GetData(UIResult result, MetroWindow window)
        {
            _window       = window;
            _window.Title = $"{result.Name} 结果";

            var value = WebAPI.Instance.GetMixedResult(result.TaskID);

            if (!value.Item1)
            {
                if (value.Item3.IndexOf("签名非法") != -1)
                {
                    if (SignLogic.SignCheck())
                    {
                        value = WebAPI.Instance.GetMixedResult(result.TaskID);
                    }
                }
            }

            if (value.Item1)
            {
                // 获取模型
                var model = value.Item2;

                // 结果班级
                _resultClasses = model.ResultClasses?.ToList();

                // 走班模型
                var cl = CommonDataManager.GetCLCase(base.LocalID);

                // 课时详细
                var details = (from c in model.ResultClasses
                               from rc in c.ResultDetails
                               select new
                {
                    c.ClassID,
                    rc.ClassHourId,
                    rc.DayPeriod
                });

                List <UITeacher> teachers = new List <UITeacher>();

                foreach (var rc in model.ResultClasses)
                {
                    var classModel = cl.GetClassByID(rc.ClassID);

                    if (rc.ResultDetails != null)
                    {
                        foreach (var rd in rc.ResultDetails)
                        {
                            Button rb = new Button();
                            rb.Style      = (Style)window.FindResource("ItemStyle");
                            rb.Background = this.GetRandomColor(classModel.CourseID);
                            rb.Click     += Rb_Click;
                            rb.Content    = classModel.Display;
                            rb.Opacity    = 0.9;
                            rb.FontSize   = 13;
                            rb.Margin     = new System.Windows.Thickness(2);

                            var position = this.Results.FirstOrDefault(r => r.Period.Period == rd.DayPeriod.Period);
                            if (position != null)
                            {
                                if (rd.DayPeriod.Day == DayOfWeek.Friday)
                                {
                                    position.Fridays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Thursday)
                                {
                                    position.Thursdays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Wednesday)
                                {
                                    position.Wednesdays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Tuesday)
                                {
                                    position.Tuesdays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Monday)
                                {
                                    position.Mondays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Saturday)
                                {
                                    position.Saturdays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Sunday)
                                {
                                    position.Sundays.Add(rb);
                                }
                            }

                            _buttons.Add(rb);
                        }
                    }

                    #region 获取教师信息

                    var classHourIDs = from c in details select c.ClassHourId;
                    var classHours   = cl.GetClassHours(classHourIDs?.ToArray());
                    classHours?.ForEach(ch =>
                    {
                        ch.Teachers.ForEach(t =>
                        {
                            var teacher = teachers.FirstOrDefault(tt => tt.ID.Equals(t.ID));
                            if (teacher == null)
                            {
                                teachers.Add(new UITeacher()
                                {
                                    ID           = t.ID,
                                    Name         = t.Name,
                                    ClassHourIDs = new List <int> {
                                        ch.ID
                                    }
                                });
                            }
                            else
                            {
                                var has = teacher.ClassHourIDs.Contains(ch.ID);
                                if (!has)
                                {
                                    teacher.ClassHourIDs.Add(ch.ID);
                                }
                            }
                        });
                    });

                    #endregion
                }

                this.Teachers      = teachers;
                this.SelectTeacher = teachers.FirstOrDefault();
            }
        }
Ejemplo n.º 20
0
 public ResultDetailsView(UIResult result) : this()
 {
     // 设置数据源
     (this.DataContext as ResultDetailsViewModel).GetData(result, this);
 }
Ejemplo n.º 21
0
 public AdjustResult(UIResult result) : this()
 {
     this.Title = $"{result.Name} 结果";
     VM?.GetData(result, this);
 }
Ejemplo n.º 22
0
    //----------------------------------------------------------------------//

    void OnDisable()
    {
        s_inst = null;
        Resources.UnloadUnusedAssets();
    }
Ejemplo n.º 23
0
    //----------------------------------------------------------------------//

    void OnEnable()
    {
        s_inst = this;
    }
Ejemplo n.º 24
0
    /// <summary>
    /// 根據類型視窗進行初始化。
    /// </summary>
    protected override void SpecificInit()
    {
        //文字內容設置
        messageText.text = option.message;
        Debug.Log(option.type);
        //按鍵配置
        if (option.type == DialogOption.Type.ALERT_DIALOG)
        {
            confirmBtn.SetActive(true);
            cancelBtn.SetActive(false);
        }
        else if (option.type == DialogOption.Type.OK_OR_CANCEL_DIALOG)
        {
            confirmBtn.SetActive(true);
            cancelBtn.SetActive(true);
        }
        else//按鍵配置Custom
        {
            //有按鍵配置
            if (option.btnSettings != null)
            {
                //清除按鍵
                foreach (Transform b in buttonZone)
                {
                    Destroy(b.gameObject);
                }

                int btnAmount = option.btnSettings.Count;
                if (btnAmount > 2 || btnAmount == 0)
                {
                    Debug.LogError("按鍵數量錯誤: " + btnAmount);
                }
                else
                {
                    //依序設置按鍵
                    for (int i = 0; i < btnAmount; i++)
                    {
                        GameObject btn = Instantiate(buttonPrefab);
                        btn.transform.SetParent(buttonZone.transform, false);
                        //顏色
                        btn.GetComponent <Image>().color = option.btnSettings[i].color;
                        //內容
                        btn.GetComponentInChildren <Text>().text = option.btnSettings[i].text;
                        //動作
                        if (option.btnSettings[i].onClick != null)
                        {
                            UIOption.UICallback callback = option.btnSettings[i].onClick;
                            btn.GetComponent <Button>().onClick.AddListener(() => { callback.Invoke(UIResult.Memo("")); Cancel(); });
                            Cancel();
                        }
                        else
                        {
                            btn.GetComponent <Button>().onClick.AddListener(Cancel);
                        }
                    }
                }
            }
            else
            {
                DefaultBtnSettings();
            }
        }
    }
Ejemplo n.º 25
0
        public void View(UIResult result)
        {
            ResultDetailsView details = new ResultDetailsView(result);

            details.ShowDialog();
        }
Ejemplo n.º 26
0
 /// <summary>
 /// 關閉視窗。
 /// </summary>
 public override void Cancel()
 {
     option.onCancel?.Invoke(UIResult.Failed());
     Destroy(gameObject);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// 確認。
 /// </summary>
 public void Confirm()
 {
     option.onOk?.Invoke(UIResult.Ok());
     Destroy(gameObject);
 }
        public void GetData(UIResult result, MetroWindow window)
        {
            _resultDetailsWindow       = window;
            _resultDetailsWindow.Title = $"{result.Name} 结果";

            var cp = CommonDataManager.GetCPCase(base.LocalID);

            _courses = cp.Courses;

            var value = WebAPI.Instance.GetAdminResult(result.TaskID);

            if (!value.Item1)
            {
                if (value.Item3.IndexOf("签名非法") != -1)
                {
                    if (SignLogic.SignCheck())
                    {
                        value = WebAPI.Instance.GetAdminResult(result.TaskID);
                    }
                }
            }

            if (value.Item1)
            {
                _resultClasses = value.Item2.ResultClasses?.ToList();

                List <UIClass>   classes  = new List <UIClass>();
                List <UITeacher> teachers = new List <UITeacher>();

                if (_resultClasses != null)
                {
                    // 1.根据结果获取班级
                    foreach (var rc in _resultClasses)
                    {
                        var classInfo = cp.Classes.FirstOrDefault(c => c.ID.Equals(rc.ClassID));
                        if (classInfo != null)
                        {
                            UIClass uiClass = new UIClass()
                            {
                                ID   = classInfo.ID,
                                Name = classInfo.Name
                            };
                            classes.Add(uiClass);
                        }
                    }

                    // 2.根据班级获取教师
                    var classHourIDs = from c in _resultClasses from rd in c.ResultDetails select rd.ClassHourId;
                    var classHours   = cp.GetClassHours(classHourIDs?.ToArray());
                    classHours?.ForEach(ch =>
                    {
                        ch.Teachers.ForEach(t =>
                        {
                            var teacher = teachers.FirstOrDefault(tt => tt.ID.Equals(t.ID));
                            if (teacher == null)
                            {
                                teachers.Add(new UITeacher()
                                {
                                    ID           = t.ID,
                                    Name         = t.Name,
                                    ClassHourIDs = new List <int> {
                                        ch.ID
                                    }
                                });
                            }
                            else
                            {
                                teacher.ClassHourIDs.Add(ch.ID);
                            }
                        });
                    });
                }

                this.Classes     = classes;
                this.SelectClass = this.Classes.FirstOrDefault();

                this.Teachers      = teachers;
                this.SelectTeacher = teachers?.FirstOrDefault();
            }
        }
Ejemplo n.º 29
0
        public void exportTable(UIResult result)
        {
            var adjustRecord = base.LocalID.DeSerializeAdjustRecord <ResultAdjustmentModel>(result.TaskID);

            if (adjustRecord != null)
            {
                if (!result.IsUploaded)
                {
                    this.ShowDialog("提示信息", "本地结果发生改变请先上传结果!", DialogSettingType.OnlyOkButton, DialogType.Warning);
                    return;
                }
            }

            // (1:班级 2:教师 4 年级)
            int exportType          = 1;
            ExportTypeWindow window = new ExportTypeWindow(false);

            window.Closed += (s, arg) =>
            {
                if (window.DialogResult.Value)
                {
                    exportType = window.Type;

                    #region 导出

                    var cp    = CommonDataManager.GetCPCase(base.LocalID);
                    var local = CommonDataManager.GetLocalCase(base.LocalID);

                    ResultModel resultModel = base.LocalID.DeSerializeLocalResult <ResultModel>(result.TaskID);
                    if (resultModel == null)
                    {
                        var value = WebAPI.Instance.GetAdminResult(result.TaskID);
                        if (value.Item1)
                        {
                            resultModel = value.Item2;
                        }
                        else
                        {
                            this.ShowDialog("提示信息", "获取行政班结果失败", CustomControl.Enums.DialogSettingType.OnlyOkButton, CustomControl.Enums.DialogType.Warning);
                            return;
                        }
                    }

                    string typeName = string.Empty;
                    if (exportType == 1)
                    {
                        typeName = "班级课表";
                    }
                    else if (exportType == 2)
                    {
                        typeName = "教师课表";
                    }
                    else if (exportType == 4)
                    {
                        typeName = "年级课表";
                    }

                    System.Windows.Forms.SaveFileDialog saveDialog = new System.Windows.Forms.SaveFileDialog();
                    saveDialog.Filter   = "Microsoft Excel files(*.xls)|*.xls;*.xlsx";
                    saveDialog.FileName = $"{local.Name}-{result.TaskID}-({typeName})";
                    var confirm = saveDialog.ShowDialog();
                    if (confirm == System.Windows.Forms.DialogResult.OK)
                    {
                        if (exportType == 1)
                        {
                            Dictionary <string, DataTable> values = new Dictionary <string, DataTable>();
                            foreach (var rc in resultModel.ResultClasses)
                            {
                                // 创建基础结构
                                var dt = this.CreateTableFrame();
                                // 创建sheet
                                var firstClass = cp.Classes.FirstOrDefault(c => rc.ClassID.Equals(c.ID));
                                values.Add(firstClass.Name, dt);
                                // 常规
                                var normals = rc.ResultDetails.Where(rd => rd.ResultType == XYKernel.OS.Common.Enums.ClassHourResultType.Normal)?.ToList();
                                normals?.ForEach(n =>
                                {
                                    var classHourInfo = cp.GetClassHours(new int[] { n.ClassHourId })?.FirstOrDefault();
                                    SetCellData(dt, classHourInfo.Course + "\n" + classHourInfo.TeacherString, n.DayPeriod);
                                });
                                // 单双周
                                var mulitplys = rc.ResultDetails.Where(rd => rd.ResultType != XYKernel.OS.Common.Enums.ClassHourResultType.Normal)?.ToList();
                                var groups    = mulitplys?.GroupBy(m => $"{m.DayPeriod.Day}{m.DayPeriod.Period}");
                                if (groups != null)
                                {
                                    foreach (var g in groups)
                                    {
                                        var first      = g.FirstOrDefault();
                                        var courseName = g.Select(gi =>
                                        {
                                            return(cp.Courses.FirstOrDefault(c => c.ID.Equals(gi.CourseID))?.Name);
                                        })?.Parse("|");
                                        var teacherName = g.Select(gi =>
                                        {
                                            return(cp.GetTeachersByIds(gi.Teachers.ToList()).Select(a => a.Name).ToArray().Parse(","));
                                        })?.Parse("|");
                                        SetCellData(dt, courseName + "\n" + teacherName, first.DayPeriod);
                                    }
                                }
                            }

                            #region 导出

                            List <int> enableIndex = new List <int>();

                            var abIndex = cp.Positions.FirstOrDefault(p => p.Position == XYKernel.OS.Common.Enums.Position.AB);
                            if (abIndex != null)
                            {
                                enableIndex.Add(abIndex.DayPeriod.Period);
                            }

                            var noonIndex = cp.Positions.FirstOrDefault(p => p.Position == XYKernel.OS.Common.Enums.Position.Noon);
                            if (noonIndex != null)
                            {
                                enableIndex.Add(noonIndex.DayPeriod.Period);
                            }

                            var pbIndex = cp.Positions.FirstOrDefault(p => p.Position == XYKernel.OS.Common.Enums.Position.PB);
                            if (pbIndex != null)
                            {
                                enableIndex.Add(pbIndex.DayPeriod.Period);
                            }

                            var table = NPOIClass.DataTableToExcel(values, saveDialog.FileName, enableIndex);
                            if (table.Item1)
                            {
                                this.ShowDialog("提示信息", "导出成功!", CustomControl.Enums.DialogSettingType.NoButton, CustomControl.Enums.DialogType.None);
                                FileHelper.OpenFilePath(saveDialog.FileName);
                            }
                            else
                            {
                                this.ShowDialog("提示信息", table.Item2, CustomControl.Enums.DialogSettingType.OnlyOkButton, CustomControl.Enums.DialogType.Warning);
                            }

                            #endregion
                        }
                        else if (exportType == 4)
                        {
                            GradeExcelModel excelModel = new GradeExcelModel();

                            // 检查是否有周六周日
                            List <string> weeks = new List <string>()
                            {
                                "星期一",
                                "星期二",
                                "星期三",
                                "星期四",
                                "星期五",
                            };

                            // 是否有周末
                            var hasWeekend = resultModel.ResultClasses.Any(rc => rc.ResultDetails.Any(rd => (rd.DayPeriod.Day == DayOfWeek.Saturday || rd.DayPeriod.Day == DayOfWeek.Sunday)));

                            if (hasWeekend)
                            {
                                weeks.Add("星期六");
                                weeks.Add("星期日");
                            }

                            // 节次
                            List <string> periods = new List <string>();
                            cp.Positions.GroupBy(p => p.DayPeriod.PeriodName)?.ToList()?.ForEach(p =>
                            {
                                periods.Add(p.Key);
                            });

                            // 设置节次
                            excelModel.SetPeriods(periods);

                            // 设置星期
                            excelModel.SetWeeks(weeks);

                            foreach (var rc in resultModel.ResultClasses)
                            {
                                var classInfo = resultModel.Classes.FirstOrDefault(c => rc.ClassID.Equals(c.ID));

                                // 添加结果
                                List <string> values = new List <string>();
                                excelModel.AddClassesDictionary(classInfo.Name, values);

                                var mondays    = rc.ResultDetails.Where(rd => rd.DayPeriod.Day == DayOfWeek.Monday)?.ToList();
                                var tuesdays   = rc.ResultDetails.Where(rd => rd.DayPeriod.Day == DayOfWeek.Tuesday)?.ToList();
                                var wednesdays = rc.ResultDetails.Where(rd => rd.DayPeriod.Day == DayOfWeek.Wednesday)?.ToList();
                                var thursdays  = rc.ResultDetails.Where(rd => rd.DayPeriod.Day == DayOfWeek.Thursday)?.ToList();
                                var fridays    = rc.ResultDetails.Where(rd => rd.DayPeriod.Day == DayOfWeek.Friday)?.ToList();
                                var saturdays  = rc.ResultDetails.Where(rd => rd.DayPeriod.Day == DayOfWeek.Saturday)?.ToList();
                                var sundays    = rc.ResultDetails.Where(rd => rd.DayPeriod.Day == DayOfWeek.Sunday)?.ToList();

                                values.AddRange(FillGradeExportValues(mondays, periods));
                                values.AddRange(FillGradeExportValues(tuesdays, periods));
                                values.AddRange(FillGradeExportValues(wednesdays, periods));
                                values.AddRange(FillGradeExportValues(thursdays, periods));
                                values.AddRange(FillGradeExportValues(fridays, periods));

                                if (saturdays?.Count > 0)
                                {
                                    values.AddRange(FillGradeExportValues(saturdays, periods));
                                }

                                if (sundays?.Count > 0)
                                {
                                    values.AddRange(FillGradeExportValues(sundays, periods));
                                }
                            }

                            var table = GradeExcel.Export(excelModel, saveDialog.FileName);
                            if (table.Item1)
                            {
                                this.ShowDialog("提示信息", "导出成功!", CustomControl.Enums.DialogSettingType.NoButton, CustomControl.Enums.DialogType.None);
                                FileHelper.OpenFilePath(saveDialog.FileName);
                            }
                            else
                            {
                                this.ShowDialog("提示信息", table.Item2, CustomControl.Enums.DialogSettingType.OnlyOkButton, CustomControl.Enums.DialogType.Warning);
                            }
                        }
                        else if (exportType == 2)
                        {
                            Dictionary <string, DataTable> values = new Dictionary <string, DataTable>();

                            // 获取所有教师
                            var classHourIDs          = from c in resultModel.ResultClasses from rd in c.ResultDetails select rd.ClassHourId;
                            var classHours            = cp.GetClassHours(classHourIDs?.ToArray());
                            List <UITeacher> teachers = new List <UITeacher>();
                            classHours?.ForEach(ch =>
                            {
                                ch.Teachers.ForEach(t =>
                                {
                                    var teacher = teachers.FirstOrDefault(tt => tt.ID.Equals(t.ID));
                                    if (teacher == null)
                                    {
                                        teachers.Add(new UITeacher()
                                        {
                                            ID           = t.ID,
                                            Name         = t.Name,
                                            ClassHourIDs = new List <int> {
                                                ch.ID
                                            }
                                        });
                                    }
                                    else
                                    {
                                        teacher.ClassHourIDs.Add(ch.ID);
                                    }
                                });
                            });

                            if (teachers.Count == 0)
                            {
                                this.ShowDialog("提示信息", "没有教师信息无法导出教师课表!", DialogSettingType.OnlyOkButton, DialogType.Warning);
                                return;
                            }

                            teachers.ForEach(t =>
                            {
                                // 创建基础结构
                                var dt = this.CreateTableFrame();
                                values.Add(t.Name, dt);

                                var resultDetails = (from rc in resultModel.ResultClasses
                                                     from rd in rc.ResultDetails
                                                     select new
                                {
                                    rc.ClassID,
                                    rd.ClassHourId,
                                    rd.CourseID,
                                    rd.DayPeriod,
                                    rd.ResultType
                                });

                                var filters = (from ch in t.ClassHourIDs from rc in resultDetails where ch == rc.ClassHourId select rc)?.ToList();

                                var groups = filters?.GroupBy(g => $"{g.DayPeriod.Day}{g.DayPeriod.Period}");
                                if (groups != null)
                                {
                                    foreach (var g in groups)
                                    {
                                        var dayPeriod = g.FirstOrDefault().DayPeriod;

                                        var ids = g.Select(gs =>
                                        {
                                            return(gs.ClassHourId);
                                        })?.ToArray();

                                        var setValue = cp.GetClassHours(ids)?.Select(ss => $"{ss.Course}-{ss.Class}")?.Parse("|");

                                        SetCellData(dt, setValue, dayPeriod);
                                    }
                                }
                            });

                            #region 导出

                            List <int> enableIndex = new List <int>();

                            var abIndex = cp.Positions.FirstOrDefault(p => p.Position == XYKernel.OS.Common.Enums.Position.AB);
                            if (abIndex != null)
                            {
                                enableIndex.Add(abIndex.DayPeriod.Period);
                            }

                            var noonIndex = cp.Positions.FirstOrDefault(p => p.Position == XYKernel.OS.Common.Enums.Position.Noon);
                            if (noonIndex != null)
                            {
                                enableIndex.Add(noonIndex.DayPeriod.Period);
                            }

                            var pbIndex = cp.Positions.FirstOrDefault(p => p.Position == XYKernel.OS.Common.Enums.Position.PB);
                            if (pbIndex != null)
                            {
                                enableIndex.Add(pbIndex.DayPeriod.Period);
                            }

                            var table = NPOIClass.DataTableToExcel(values, saveDialog.FileName, enableIndex);
                            if (table.Item1)
                            {
                                this.ShowDialog("提示信息", "导出成功!", CustomControl.Enums.DialogSettingType.NoButton, CustomControl.Enums.DialogType.None);
                                FileHelper.OpenFilePath(saveDialog.FileName);
                            }
                            else
                            {
                                this.ShowDialog("提示信息", table.Item2, CustomControl.Enums.DialogSettingType.OnlyOkButton, CustomControl.Enums.DialogType.Warning);
                            }

                            #endregion
                        }
                    }

                    #endregion
                }
            };
            window.ShowDialog();
        }
Ejemplo n.º 30
0
        public void precharge(UIResult result)
        {
            var sample = WebAPI.Instance.SampleTask(result.TaskID);

            if (sample.Item1)
            {
                // 预览
                PrechargeResultWindow precharge = new PrechargeResultWindow(result.Name, sample.Item2);
                precharge.Closed += (s, arg) =>
                {
                    // 如果预览结果为True.
                    if (precharge.DialogResult == true)
                    {
                        var results = ResultDataManager.GetResults(base.LocalID);
                        var local   = CommonDataManager.GetLocalCase(base.LocalID);

                        if (precharge.IsUseResult)
                        {
                            var value = WebAPI.Instance.ConfirmTask(result.TaskID);
                            if (value.Item1)
                            {
                                result.IsUsed = true;
                                local.Serizlize(results);

                                // 更新界面
                                var uiTask = this.Results.FirstOrDefault(r => r.TaskID.Equals(result.TaskID));
                                if (uiTask != null)
                                {
                                    uiTask.IsUsed = true;
                                    uiTask.RaiseChanged();
                                }

                                this.ShowDialog("提示信息", "操作成功!", DialogSettingType.NoButton, DialogType.None);
                            }
                            else
                            {
                                this.ShowDialog("提示信息", "操作失败!", DialogSettingType.OnlyOkButton, DialogType.Warning);
                            }
                        }
                        else
                        {
                            var value = WebAPI.Instance.AbandonTask(result.TaskID);
                            if (value.Item1)
                            {
                                this.Results.Remove(result);
                                results.RemoveAll(r => r.TaskID == result.TaskID);
                                local.Serizlize(results);

                                this.ShowDialog("提示信息", "操作成功!", DialogSettingType.NoButton, DialogType.None);
                            }
                            else
                            {
                                this.ShowDialog("提示信息", "操作失败!", DialogSettingType.OnlyOkButton, DialogType.Warning);
                            }
                        }
                    }
                };
                precharge.ShowDialog();
            }
            else
            {
                this.ShowDialog("提示信息", sample.Item3, DialogSettingType.OnlyOkButton, DialogType.Warning);
            }
        }