Exemplo n.º 1
0
        private void btn_query_Click(object sender, EventArgs e)
        {
            var qName = this.tbx_Name.Text;
            var qDate = this.q_date.text;
            var qID   = this.tbx_id.Text;

            string dataName = System.IO.Path.Combine(OSHelper.DataDefaultDirectory, "data.xml");

            qns = QuestionHelper.DeSerializeObject <List <QuestionWorkflow> >(dataName);

            if (null == qns)
            {
                return;
            }

            List <QuestionWorkflow> result = qns.FindAll(o => {
                return(o.user.Name.Equals(string.IsNullOrEmpty(qName) ? o.user.Name : qName) &&
                       o.date.ToShortDateString().Equals((null == qDate || string.IsNullOrEmpty(qDate)) ? o.date.ToShortDateString() : qDate) &&
                       o.user.ID.Equals(string.IsNullOrEmpty(qID) ? o.user.ID : qID));
            });

            this.lv_result.Items.Clear();

            foreach (QuestionWorkflow qwf in result)
            {
                ListViewItem lvItem = new ListViewItem(new string[] { qwf.user.Name, qwf.user.Age.ToString(), qwf.user.Gender, qwf.user.ID, qwf.result, qwf.date.ToShortDateString(), "打印" });
                this.lv_result.Items.Add(lvItem);
            }
        }
Exemplo n.º 2
0
        public Tuple <bool, string> SaveWorkflow(string _result, string _result_code)
        {
            Tuple <bool, string> tupSaveResult = null;

            if (null == user)
            {
                tupSaveResult = new Tuple <bool, string>(false, string.Format("{0} (用户信息未填写,保存无效)", _result));

                return(tupSaveResult);
            }

            try
            {
                //set ace user
                var ds  = new DirectorySecurity();
                var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
                var ace = new FileSystemAccessRule(sid,
                                                   FileSystemRights.FullControl,
                                                   AccessControlType.Allow);
                ds.AddAccessRule(ace);

                var dataDir = System.IO.Path.Combine(OSHelper.DataDefaultDirectory, "");

                if (!Directory.Exists(dataDir))
                {
                    Directory.CreateDirectory(dataDir, ds);
                }


                result = _result;

                resultCode = _result_code;

                List <QuestionWorkflow> qns = QuestionHelper.DeSerializeObject <List <QuestionWorkflow> >(dataName);

                date = System.DateTime.Now;

                if (null != qns)
                {
                    qns.Add(this);
                }
                else
                {
                    qns = new List <QuestionWorkflow>();
                    qns.Add(this);
                }

                QuestionHelper.SerializeObject <List <QuestionWorkflow> >(qns, dataName);

                tupSaveResult = new Tuple <bool, string>(true, result);
            }
            catch (Exception ex)
            {
                tupSaveResult = new Tuple <bool, string>(false, string.Format("保存异常 {0}", ex.Message));
            }
            return(tupSaveResult);
        }
Exemplo n.º 3
0
        private QuestionWorkflow()
        {
            questionnaire = new Questionnaire();

            questionnaires = QuestionHelper.ReadQuestionnairesFromXML(questionnaireFile);

            assesses = QuestionHelper.ReadAssessFromXML(assessesFile);

            report = new Report();

            if (File.Exists(dataReportName))
            {
                report = QuestionHelper.DeSerializeObject <Report>(dataReportName);
            }
        }
Exemplo n.º 4
0
        private void btn_end_Click(object sender, EventArgs e)
        {
            //calculte

            questionWorkflow.result = QuestionHelper.GetCurrentResult();

            MessageBox.Show(questionWorkflow.result);

            //save to file

            if (null == questionWorkflow.user)
            {
                MessageBox.Show("请录入身份信息,方可保存数据");

                return;
            }

            string dataName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "data.xml");

            List <QuestionWorkflow> qns = QuestionHelper.DeSerializeObject <List <QuestionWorkflow> >(dataName);

            questionWorkflow.date = System.DateTime.Now;

            if (null != qns)
            {
                qns.Add(questionWorkflow);
            }
            else
            {
                qns = new List <QuestionWorkflow>();
                qns.Add(questionWorkflow);
            }

            QuestionHelper.SerializeObject <List <QuestionWorkflow> >(qns, dataName);

            this.Close();
        }