Exemplo n.º 1
0
        private bool DeleteExistQuestionnaireInDatabase(FormSetting formSetting)
        {
            var entities = _unitOfWork.QuestionnaireRepository.FindQuestionnaireListForDelete(formSetting.FormId);

            try
            {
                if (entities.Count() > 0)
                {
                    _unitOfWork.QuestionnaireRepository.DeleteQuestionnaireList(entities);
                    _unitOfWork.Commit();
                }
                var resultFormSetting   = _unitOfWork.FormSettingRepository.FindDescriptions(formSetting.Id);
                var logQuestionnaireDto = _logQuestionnaireFactory.CreateLogQuestionnaireDto(resultFormSetting, "Delete");
                var logQuestionnaire    = _logQuestionnaireFactory.CreateLogQuestionnaire(logQuestionnaireDto);
                if (entities.Count() > 0 && logQuestionnaire != null)
                {
                    _logQuestionnaireService.InsertLogQuestionnaire(logQuestionnaire);
                }
                return(true);
            }
            catch (Exception e)
            {
                ErrorSignal.FromCurrentContext().Raise(new Exception("Exception Message: " + e.Message + " ,ErrorType: Entity null references"));
                return(false);
            }
        }
Exemplo n.º 2
0
        public Response MeasureStart(DeviceInfo device, int measureResult)
        {
            Response res = new Response();

            res.MeasureId      = -1;
            res.PathFolderData = "";

            //Insert measure information
            var _measureId = _DBUltity.InsertMeasure(device.DeviceId,
                                                     (int)device.MeasureType,
                                                     device.AlarmValue,
                                                     device.Period,
                                                     device.FailLevel,
                                                     device.Samples,
                                                     DateTime.Now);

            if (_measureId < 1)
            {
                FormSetting.ShowMsg(MessageBoxIcon.Error, MSG_ERR_CONNECT_DB);
                return(res);
            }

            res.MeasureId = _measureId;

            return(res);
        }
Exemplo n.º 3
0
Arquivo: Form.cs Projeto: xhute/Kooboo
        public Guid UpdateKoobooForm(ApiCall call)
        {
            var model  = call.Context.Request.Model as KoobooFormEditModel;
            var sitedb = call.Context.WebSite.SiteDb();

            Guid formid = model.Id;

            // update form body....
            if (formid != default(Guid))
            {
                var form = sitedb.Forms.Get(call.ObjectId);
                if (form != null)
                {
                    form.Body   = model.Body;
                    form.Fields = model.Fields;
                    form.Style  = model.Style;
                    sitedb.Forms.AddOrUpdate(form, true, true, call.Context.User.Id);
                    formid = form.Id;
                }
                else
                {
                    throw new Exception(Data.Language.Hardcoded.GetValue("Form not found", call.Context));
                }
            }
            else
            {
                string name = call.GetValue("Name");
                Form   form = new Form()
                {
                    Name = model.Name, Body = model.Body, Fields = model.Fields, IsEmbedded = model.IsEmbedded
                };

                if (!string.IsNullOrEmpty(model.Fields))
                {
                    form.FormType   = FormType.KoobooForm;
                    form.IsEmbedded = false;
                }

                sitedb.Forms.AddOrUpdate(form);
                formid = form.Id;
            }

            FormSetting formsetting = new FormSetting();

            formsetting.FormId          = formid;
            formsetting.AllowAjax       = model.AllowAjax;
            formsetting.FailedCallBack  = model.FailedCallBack;
            formsetting.SuccessCallBack = model.SuccessCallBack;

            formsetting.RedirectUrl = model.RedirectUrl;
            formsetting.Method      = model.Method;
            formsetting.Setting     = model.Setting;
            formsetting.Enable      = true;

            formsetting.FormSubmitter = model.FormSubmitter;

            sitedb.FormSetting.AddOrUpdate(formsetting);

            return(formid);
        }
Exemplo n.º 4
0
        public void MeasureEnd(DeviceInfo device, List <MaxValue> lstMaxValue, int measureResult, DateTime?measureEndTime)
        {
            var _hasErrDB = false;

            if (device.MeasureType == emMeasureType.WalkingTest && lstMaxValue != null)
            {
                foreach (var data in lstMaxValue)
                {
                    var dtSample = data.dtSample;
                    dtSample.result = (int)emMeasureResult.Fail;
                    InsertMeasureLimit(dtSample, _DBUltity, device.MeasureId);
                }
            }

            if (!_DBUltity.UpdateEndTimeMeasure(device.MeasureId, measureEndTime.Value, measureResult))
            {
                _hasErrDB = true;
                WriteFileErrors(clsConfig.MEASURE_NAME_FILE, _DBUltity.GetUpdateEndTimeMeasure(device.MeasureId, measureEndTime.Value, measureResult), device.MeasureId);
            }

            if (_hasErrDB)
            {
                FormSetting.ShowMsg(MessageBoxIcon.Error, MSG_ERR_HAS_DB);
            }
        }
Exemplo n.º 5
0
        private void btnPosSetting_Click(object sender, EventArgs e)
        {
            var frm = new FormSetting {
                MdiParent = this
            };

            frm.Show();
        }
Exemplo n.º 6
0
        private void toolStripMenuItemSetting_Click(object sender, EventArgs e)
        {
            FormSetting form = new FormSetting();

            if (form.ShowDialog() == DialogResult.OK)
            {
                SetSetting();
            }
        }
Exemplo n.º 7
0
 public void ShowManagement(object sender, EventArgs e)
 {
     using (var frmManagement = new Management())
     {
         frmManagement.ShowDialog();
         if (frmManagement.ChangeSetting)
         {
             FormSetting?.LoadInfoDevice();
         }
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 相关设置方法
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void settingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (FormSetting set = new FormSetting())
     {
         if (set.ShowDialog() == DialogResult.OK)
         {
             this.timerNext.Interval = set.IntervalTime * 1000;//将秒转为毫秒
         }
     }
     //add for test
     //MessageBox.Show(this.timerNext.Interval.ToString());
 }
Exemplo n.º 9
0
        private bool LoadSetting()
        {
            var path = Application.StartupPath;

            CLIENT_ID      = "707972898274541629";
            SleepImageKey  = "cat_zzz";
            LastFmAPIKey   = Properties.Settings.Default.LastFmAPIKey;
            LastFmUserName = Properties.Settings.Default.LastFmUserName;

            switch (Properties.Settings.Default.CatImageIndex)
            {
            case (int)CATIMAGE.headphone:
                PlayingImageKey = "cat_music";
                break;

            case (int)CATIMAGE.dance:
                PlayingImageKey = "cat_dance";
                break;

            default:
                PlayingImageKey = "cat_dev";
                break;
            }

            if (LastFmAPIKey == "" || LastFmUserName == "")
            {
                var result = MessageBox.Show("Last.fm APIキー,ユーザーネームの設定をしてください。",
                                             "エラー",
                                             MessageBoxButtons.OK,
                                             MessageBoxIcon.Error);

                if (result == DialogResult.OK)
                {
                    if (FormSetting == null || FormSetting.IsDisposed)
                    {
                        FormSetting = new Form2();
                        FormSetting.Show();
                    }
                    else
                    {
                        FormSetting.Activate();
                    }
                    return(false);
                }
                else
                {
                    IsExit = true;
                    Environment.Exit(0);
                }
            }
            return(true);
        }
Exemplo n.º 10
0
 public void GetControlRes(Cnt_res res)
 {
     Console.WriteLine("Recieve feedback\n");
     if (res == Cnt_res.e_Setting) // open setting window
     {
         FormSetting fmSetting = new FormSetting(this);
         fmSetting.Show();
     }
     else if (res == Cnt_res.e_Exit) // exit window
     {
         this.Close();
     }
 }
Exemplo n.º 11
0
        internal static void SetWinFormLanguage(string ciName)
        {
            CultureInfo newCI = new CultureInfo(ciName);
            System.Threading.Thread.CurrentThread.CurrentCulture = newCI;
            System.Threading.Thread.CurrentThread.CurrentUICulture = newCI;

            if (FormSetting.GetInstance() != null)
            {
                ApplyResourceToControl(FormSetting.GetInstance(), new ComponentResourceManager(typeof(FormSetting)), newCI);
            }
            if (FormMain.GetInstance() != null)
            {
                ApplyResourceToControl(FormMain.GetInstance(), new ComponentResourceManager(typeof(FormMain)), newCI);
            }
        }
Exemplo n.º 12
0
 public void QuestionnaireTimer(Timer timer, FormSetting formSetting, int index)
 {
     if (formSetting.PeriodTime > 0)
     {
         timer.Interval = (convertToMin * formSetting.PeriodTime) + (intevalExternalTime * index);
     }
     else
     {
         timer.Interval = (convertToMin * 240);
         ErrorSignal.FromCurrentContext().Raise(new Exception("Exception Message: " + "ArgumentOutOfRangeException" + " ,ErrorType:  periodTime<0"));
     }
     timer.Elapsed  += (sender, e) => MyElapsedMethod(sender, e, formSetting, index);
     timer.AutoReset = true;
     timer.Enabled   = true;
 }
Exemplo n.º 13
0
        public LogQuestionnaireDto CreateLogQuestionnaireDto(FormSetting formSetting, string operations)
        {
            var operationsTypes = operations == "Delete" ? (int)OperationsType.Delete : (int)OperationsType.Add;

            var logQuestionnaireDto = new LogQuestionnaireDto
            {
                FormId         = formSetting.FormId,
                Operations     = operations,
                OperationsType = operationsTypes,
                CreateDate     = DateTime.Now,
                Descriptions   = formSetting.Descriptions
            };

            return(logQuestionnaireDto);
        }
Exemplo n.º 14
0
        public FormMain()
        {
            InitializeComponent();

            data = new ClassData();
            data.LoadData();
            notifyIconMain.Visible = true;
            tsAutoRun.Checked      = CheckAutoRun();
            if (ConfigurationManager.AppSettings.Get("CountStart") == "0")
            {
                FormSetting form = new FormSetting(true);
                form.ShowDialog();
            }

            SetSetting();
        }
Exemplo n.º 15
0
        public void MeasureStart()
        {
            //Insert measure information
            _measureId = _DBUltity.InsertMeasure(DeviceCurrent.deviceId,
                                                 (int)MeasureType,
                                                 DeviceCurrent.AlarmValue,
                                                 DeviceCurrent.period,
                                                 DeviceCurrent.failLevel,
                                                 DeviceCurrent.samples,
                                                 DateTime.Now);

            if (_measureId < 1)
            {
                FormSetting.ShowMsg(MessageBoxIcon.Error, MSG_ERR_CONNECT_DB);
                return;
            }
        }
Exemplo n.º 16
0
        private void btnConfig_Click(object sender, EventArgs e)
        {
            FormSetting setting = new FormSetting();

            if (cbConfig.Text.Length < 4)
            {
                FormCFGName  cfgName = new FormCFGName();
                DialogResult ret     = cfgName.ShowDialog();
                if (ret != DialogResult.OK)
                {
                    return;
                }
                cbConfig.Items.Add(cfgName.CFGName);
                cbConfig.Text = cfgName.CFGName;
            }
            if (0 == setting.LoadData(cbConfig.Text))
            {
                setting.ShowDialog();
            }
        }
Exemplo n.º 17
0
        public ActionResult UpdateFormSetting()
        {
            var formId  = Convert.ToInt32(Request.Params["data[0][FormId]"]);
            var roleId  = Convert.ToInt32(Request.Params["data[0][RoleId]"]);
            var setting = Request.Params["data[0][FormSetting]"];
            var value   = Convert.ToBoolean(Request.Params["data[0][Value]"]);

            var formSetting = FarmManagementEntities.FormSettings.SingleOrDefault(x => x.RoleId == roleId && x.FormId == formId);

            if (formSetting == null)
            {
                formSetting = new FormSetting();
            }

            switch (setting)
            {
            case "IsAdd":
                formSetting.IsAdd = value;
                break;

            case "IsUpdate":
                formSetting.IsUpdate = value;
                break;
            }

            if (formSetting.Id == 0)
            {
                formSetting.RoleId     = roleId;
                formSetting.FormId     = formId;
                formSetting.InsertDate = DateTime.Now;
                FarmManagementEntities.FormSettings.Add(formSetting);
            }

            FarmManagementEntities.SaveChanges();

            GetFormSetting();

            var message = string.Format(Constant.SuccessMessage, formSetting.Id > 0 ? "updated" : "added");

            return(ShowSuccessMessage(message));
        }
Exemplo n.º 18
0
        public void UpdateListDevice(List <DeviceInfo> lstDevice)
        {
            using (var objDb = new clsDBUltity())
            {
                try
                {
                    foreach (var device in lstDevice)
                    {
                        if (!string.IsNullOrEmpty(device.MacAddress))
                        {
                            objDb.SaveDevice(device);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            FormSetting?.LoadInfoDevice();
        }
Exemplo n.º 19
0
        public static string GetSubmitUrl(Kooboo.Sites.Models.Form form, FormSetting setting, RenderContext context)
        {
            var submitter = GetSubmitter(setting.FormSubmitter);

            if (submitter != null)
            {
                var url = submitter.CustomActionUrl(context, setting.Setting);
                if (!string.IsNullOrEmpty(url))
                {
                    return(url);
                }
            }

            string shortformid = Lib.Security.ShortGuid.Encode(form.Id);

            string submiturl = "/_api/submit/form/" + shortformid;

            //string baseulr = context.WebSite.BaseUrl();
            //submiturl = Kooboo.Lib.Helper.UrlHelper.Combine(baseulr, submiturl);

            return(submiturl);
        }
Exemplo n.º 20
0
        public void MeasureEnd()
        {
            if (MeasureType == emMeasureType.WalkingTest && FormSetting.ListMaxValue != null)
            {
                foreach (var data in FormSetting.ListMaxValue)
                {
                    var dtSample = data.dtSample;
                    dtSample.result = (int)emMeasureResult.Fail;
                    InsertMeasureLimit(dtSample, _DBUltity);
                }
            }

            if (!_DBUltity.UpdateEndTimeMeasure(_measureId, FormSetting.MeasureEndTime, FormSetting.MeasureResult))
            {
                _hasErrDB = true;
                WriteFileErrors(clsConfig.MEASURE_NAME_FILE, _DBUltity.GetUpdateEndTimeMeasure(_measureId, FormSetting.MeasureEndTime, FormSetting.MeasureResult));
            }

            if (_hasErrDB)
            {
                FormSetting.ShowMsg(MessageBoxIcon.Error, MSG_ERR_HAS_DB);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 系统设定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmSystemSetting_Click(object sender, EventArgs e)
        {
            FormSetting form = new FormSetting();

            form.Home    = home;
            form.Home2   = home2;
            form.Company = company;
            if (form.ShowDialog() == DialogResult.OK)
            {
                if (home != form.Home)
                {
                    home = form.Home;
                    if (File.Exists(home))
                    {
                        pbxMain.Image = new Bitmap(home);
                    }
                }
                home2     = form.Home2;
                company   = form.Company;
                this.Text = company + "-医院知识问答";
                SetConfigValue();
            }
        }
Exemplo n.º 22
0
 public void MyElapsedMethod(object source, ElapsedEventArgs e, FormSetting formSetting, int index)
 {
     GetQuestionnaire(formSetting, index);
 }
Exemplo n.º 23
0
        public string Render(RenderContext context)
        {
            if (this.OwnerObjectId == default(Guid))
            {
                // this should not happen... just in case...
                InitOrgTask();
                string open = Kooboo.Sites.Service.DomService.GenerateOpenTag(this.FormAttributes, "form");
                return(open + RenderHelper.Render(this.BodyTask, context) + "</form>");
            }

            var sitedb = context.WebSite.SiteDb();

            var form = sitedb.Forms.Get(this.FormId);

            FormSetting formsetting = null;

            if (form != null)
            {
                formsetting = sitedb.FormSetting.GetByFormId(form.Id);
            }

            if (form == null || formsetting == null || formsetting.Enable == false || string.IsNullOrEmpty(formsetting.FormSubmitter))
            {
                InitOrgTask();
                string open = Kooboo.Sites.Service.DomService.GenerateOpenTag(this.FormAttributes, "form");
                return(open + RenderHelper.Render(this.BodyTask, context) + "</form>");
            }
            // or else result

            string submiturl = Kooboo.Sites.HtmlForm.FormManager.GetSubmitUrl(form, formsetting, context);



            Dictionary <string, string> attributes = new Dictionary <string, string>(FormAttributes);

            attributes["action"] = submiturl;
            attributes["method"] = string.IsNullOrEmpty(formsetting.Method) ? "post" : formsetting.Method;

            string key = "kform_" + Lib.Security.ShortGuid.GetNewShortId();

            /// append additional koobooform id.....
            //if (form.FormType == FormType.KoobooForm || formsetting.AllowAjax)
            //{
            attributes["id"] = key;
            //}

            string opentag = Kooboo.Sites.Service.DomService.GenerateOpenTag(attributes, "form");

            if (formsetting.IsSelfRefresh)
            {
                opentag = opentag + "<input type='hidden' name=\"" + Sites.HtmlForm.FormManager.FormUrlName + "\" value=\"" + context.Request.RawRelativeUrl + "\" />";
            }


            //if (formsetting.AllowAjax)
            //{
            string addtionalJS = "<script src=\"/_admin/scripts/lib/jquery.min.js\"></script><script src=\"/_admin/scripts/lib/jqBootstrapValidation.js\"></script>";

            opentag += addtionalJS;

            opentag += JsString(key, formsetting.SuccessCallBack, formsetting.FailedCallBack);
            // }


            if (!string.IsNullOrEmpty(form.Body))
            {
                InitFormBodyTask(form.Body);
                return(opentag + RenderHelper.Render(this.BodyTask, context) + "</form>");
            }
            else
            {
                InitOrgTask();
                return(opentag + RenderHelper.Render(this.BodyTask, context) + "</form>");
            }
        }
Exemplo n.º 24
0
 // Отобразить свойства КП
 public override void ShowProps()
 {
     FormSetting.ShowDialog(Number, KPProps, AppDirs);
 }
Exemplo n.º 25
0
        /// <summary>
        /// 메인 폼이 로딩될 때.. 이벤트 처리
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormMain_Load(object sender, EventArgs e)
        {
            try
            {
                #region 로그 출력을 위한 윈폼이 제일 먼저 실행됨

                // 로그 폼 - 제일 먼저 나와야 함
                mfLog           = new FormLog();
                mfLog.Owner     = this;
                mfLog.mFormMain = this;
                mfLog.Show();
                CheckShowFormLog.Checked = true;

                #endregion

                #region 현재 프로그램 정보 확인 및 세팅
                // 프로그램 경로
                setting.program_execute_dir = Util.GetCurrentDirectoryWithPath();

                setting.program_full_name = Environment.GetCommandLineArgs()[0];

                // 프로그램 실행시 받은 파라미터 확인
                if (Environment.GetCommandLineArgs().Length == 1)
                {
                    Log.WriteLine("##### 프로그램 시작 #####");
                }
                else
                {
                    Log.WriteLine("##### 프로그램 재시작 #####");
                }

                #endregion

                #region 서브 윈도우 폼 로딩

                // 환경설정 폼
                mfSetting        = new FormSetting();
                mfSetting.Owner  = this;
                mfSetting.mfMain = this;
                mfSetting.Show();
                CheckShowFormSetting.Checked = true;

                // Trading 폼
                mfTrading        = new FormTrading();
                mfTrading.Owner  = this;
                mfTrading.mfMain = this;
                mfTrading.Show();
                CheckShowFormTrading.Checked = true;

                // 로그인 폼
                mfLogin           = new FormLogin();
                mfLogin.Owner     = this;
                mfLogin.mFormMain = this;
                mfLogin.Show();
                CheckShowFormLogin.Checked = true;

                mfOcr           = new FormOCR();
                mfOcr.Owner     = this;
                mfOcr.mFormMain = this;
                mfOcr.Show();
                CheckShowFormOcr.Checked = true;

                #endregion


                // xing component 로드
                fnLoadXing();

                // 자동 로그인 설정이 되어 있으면...
                if (setting.login_auto_yn)
                {
                    Log.WriteLine("자동 로그인 시작");
                    TimerLogin.Start();
                }
            }
            catch (Exception ex)
            {
                Log.WriteLine(ex.Message);
                Log.WriteLine(ex.StackTrace);
            }
        }               // end function
Exemplo n.º 26
0
        /// <summary>
        /// Sinh ra file csv trong Export Data folder
        /// </summary>
        /// <param name="filePath">danh sách
        /// file csv</param>
        /// <param name="dsThietBi">danh sách thiết bị</param>
        /// <param name="dsDiemDo">danh sách điểm đo</param>
        public static void XuatFileCSV(List <string> filePath, Dictionary <string, ThietBiModel> dsThietBi)
        {
            FormSetting formSetting = new FormSetting();
            int         i           = 0;

            foreach (KeyValuePair <string, ThietBiModel> thietBi in dsThietBi)
            {
                foreach (KeyValuePair <string, SlaveModel> slave in thietBi.Value.dsSlave)
                {
                    foreach (KeyValuePair <string, DiemDoModel> diemDo in slave.Value.dsDiemDoGiamSat)
                    {
                        StringBuilder csvData = new StringBuilder();
                        csvData.Append("[Data]" + "\n" + "Tagname,TimeStamp,Value,DataQuality" + "\n");
                        foreach (KeyValuePair <string, DuLieuModel> duLieu in diemDo.Value.DsDulieu)
                        {
                            if (int.TryParse(duLieu.Value.GiaTri, out _))
                            {
                                csvData.Append(duLieu.Value.DiemDo);
                                csvData.Append(".");
                                csvData.Append(duLieu.Value.Ten);
                                csvData.Append(",");
                                csvData.Append(duLieu.Value.ThoiGianDocGiuLieu.ToString(Service.Json.JsonReader.LayDinhDangThoiGian()));
                                csvData.Append(",");

                                csvData.Append(Convert.ToInt32(duLieu.Value.GiaTri) / Convert.ToDouble(duLieu.Value.Scale));
                                csvData.Append(",");
                                csvData.Append(thietBi.Value.TrangThaiTinHieu);
                                csvData.Append("\n");
                            }
                            else if (duLieu.Value.GiaTri == null)
                            {
                                csvData.Append(duLieu.Value.DiemDo);
                                csvData.Append(".");
                                csvData.Append(duLieu.Value.Ten);
                                csvData.Append(",");
                                csvData.Append(DateTime.Now.ToString(Service.Json.JsonReader.LayDinhDangThoiGian()));
                                csvData.Append(",");
                                csvData.Append("0");
                                csvData.Append(",");
                                csvData.Append(thietBi.Value.TrangThaiTinHieu);
                                csvData.Append("\n");
                            }
                            else if (char.TryParse(duLieu.Value.GiaTri, out _))
                            {
                                csvData.Append(duLieu.Value.DiemDo);
                                csvData.Append(".");
                                csvData.Append(duLieu.Value.Ten);
                                csvData.Append(",");
                                csvData.Append(duLieu.Value.ThoiGianDocGiuLieu.ToString(Service.Json.JsonReader.LayDinhDangThoiGian()));
                                csvData.Append(",");
                                csvData.Append(duLieu.Value.GiaTri);
                                csvData.Append(",");
                                csvData.Append(thietBi.Value.TrangThaiTinHieu);
                                csvData.Append("\n");
                            }
                        }

                        /*if (!File.Exists(filePath[i]))
                         * {
                         *  File.AppendAllText(filePath[i], "[Data]" + "\n" + "Tagname,TimeStamp,Value,DataQuality" + "\n");
                         * }
                         * File.AppendAllText(filePath[i], csvData.ToString());*/
                        File.WriteAllText(filePath[i], csvData.ToString());
                        i++;
                    }
                }
            }
        }
Exemplo n.º 27
0
 // Отобразить свойства КП
 public override void ShowProps()
 {
     FormSetting.ShowDialog(Number, KPProps, AppDirs); // отображение фармы параметров
 }
Exemplo n.º 28
0
        private IEnumerable <Questionnaires> AddQuestionnaireToDatabase(List <Questionnaires> questionnaireList, FormSetting formSetting)
        {
            if (questionnaireList == null)
            {
                return(null);
            }
            try
            {
                var entities = _unitOfWork.QuestionnaireRepository.AddList(questionnaireList);
                if (entities != null)
                {
                    _unitOfWork.Commit();
                }
                else
                {
                    ErrorSignal.FromCurrentContext().Raise(new Exception("Exception Message: " + " ,ErrorType: Entity null references _unitOfWork.QuestionnaireRepository.AddList(questionnaireList)"));
                }
                var resultFormSetting   = _unitOfWork.FormSettingRepository.FindDescriptions(formSetting.Id);
                var logQuestionnaireDto = _logQuestionnaireFactory.CreateLogQuestionnaireDto(resultFormSetting, "Insert");

                var logQuestionnaire = _logQuestionnaireFactory.CreateLogQuestionnaire(logQuestionnaireDto);

                if (logQuestionnaire != null && entities.Count() > 0)
                {
                    _logQuestionnaireService.InsertLogQuestionnaire(logQuestionnaire);
                }

                return(entities);
            }
            catch (Exception e)
            {
                ErrorSignal.FromCurrentContext().Raise(new Exception("Exception Message: " + e.Message + " ,ErrorType: Insert logQuestionnaire"));

                return(null);
            }
        }
Exemplo n.º 29
0
        public IEnumerable <Questionnaires> GetQuestionnaire(FormSetting formSetting, int index)
        {
            if (check)
            {
                if (index > _index)
                {
                    _index = index;
                }
                Thread.Sleep(_index * intevalExternalTime);
            }
            _index = index;

            check = true;
            if (formSetting.FormId < 0 || string.IsNullOrEmpty(formSetting.Token))
            {
                return(null);
            }
            var url         = $"https://survey.porsline.ir/api/surveys/{formSetting.FormId}/responses/";
            var restClient  = new RestClient(url);
            var restRequest = new RestRequest()
            {
                RequestFormat = DataFormat.Json,
                Method        = Method.POST
            };

            restRequest.AddHeader("Authorization", $"Token {formSetting.Token}");
            restRequest.AddHeader("Content-Type", "application/json;charset=UTF-8");
            restRequest.AddBody(new
            {
                from_date  = "2000-10-10",
                to_date    = "2100-10-10",
                page       = 1,
                sort_obj   = new { col_type = 3, id = 6, reverse = false },
                filter_obj = new { },
                pagination = false
            });
            var response         = restClient.Execute(restRequest);
            var questionnaireDto = JsonConvert.DeserializeObject <QuestionnaireDto>(response.Content);
            var result           = _questionnaireFactory.CreateQuestionnaire(questionnaireDto, formSetting.FormId);

            if (result == null)
            {
                ErrorSignal.FromCurrentContext().Raise(new Exception("Exception Message: " + " ,ErrorType: null  _questionnaireFactory.CreateQuestionnaire(questionnaireDto, formSetting.FormId)"));
            }
            var deleteResult = DeleteExistQuestionnaireInDatabase(formSetting);

            if (!deleteResult)
            {
                Key   = true;
                check = false;
                ErrorSignal.FromCurrentContext().Raise(new Exception("Exception Message: " + " ,ErrorType: DeleteExistQuestionnaireInDatabase(formSetting) notDelete"));
                return(null);
            }
            var entity = AddQuestionnaireToDatabase(result, formSetting);

            if (entity == null)
            {
                ErrorSignal.FromCurrentContext().Raise(new Exception("Exception Message: " + " ,ErrorType: null AddQuestionnaireToDatabase(result, formSetting);"));
            }
            Key   = true;
            check = false;
            return(entity);
        }
Exemplo n.º 30
0
 public void UpdateListDevice(List <DeviceInfo> lstDevice)
 {
     clsSuportSerialize.BinSerialize(clsConfig.SQLITE_DB_PATH, lstDevice);
     FormSetting?.LoadInfoDevice();
 }