void InitUserListTable()
        {
            try
            {
                string[] lans           = "3603T00018,3603T00019,3603T00020,3603T00021,3603T00022,3603T00023,3603T00024,3603T00025,3603T00026".Split(',');
                string[] cols           = "LongTestNum,LongTestUserNum,StrTestUserName,LongPaperNum,StrPaperName,IntScore,StrStartTime,StrEndTime,StrTestStatue".Split(',');
                int[]    colwidths      = { 150, 150, 150, 100, 60, 180, 80, 100, 100, 100, 100 };
                var      columnGridView = new GridView();

                for (int i = 0; i < cols.Length; i++)
                {
                    var gvc = new GridViewColumn
                    {
                        Header = UMPApp.GetLanguageInfo(lans[i], cols[i]),
                        Width  = colwidths[i],
                        DisplayMemberBinding = new Binding(cols[i])
                    };
                    columnGridView.Columns.Add(gvc);
                }
                TestUserListTable.View = columnGridView;
            }
            catch (Exception ex)
            {
                UMPApp.ShowExceptionMessage(ex.Message);
            }
        }
 private void CreateToolBarButtons()
 {
     try
     {
         PanelToolButton.Children.Clear();
         CToolButtonItem toolItem;
         ToggleButton    toggleBtn;
         for (int i = 0; i < _mListPanels.Count; i++)
         {
             PanelItem item = _mListPanels[i];
             if (!item.CanClose)
             {
                 continue;
             }
             toolItem              = new CToolButtonItem();
             toolItem.Name         = "TB" + item.Name;
             toolItem.Display      = item.Title;
             toolItem.Tip          = item.Title;
             toolItem.Icon         = item.Icon;
             toggleBtn             = new ToggleButton();
             toggleBtn.Click      += PanelToggleButton_Click;
             toggleBtn.DataContext = toolItem;
             toggleBtn.IsChecked   = item.IsVisible;
             toggleBtn.SetResourceReference(StyleProperty, "ToolBarToggleBtnStyle");
             PanelToolButton.Children.Add(toggleBtn);
         }
     }
     catch (Exception ex)
     {
         UMPApp.ShowExceptionMessage(ex.Message);
     }
 }
        private void InitPanels()
        {
            try
            {
                _mListPanels.Clear();
                PanelItem panelItem = new PanelItem();
                panelItem.PanelId   = S3603Consts.PANEL_ID_EXAMINFO;
                panelItem.Name      = S3603Consts.PANEL_NAME_EXAMINFO;
                panelItem.ContentId = S3603Consts.PANEL_CONTENTID_EXAMINFO;
                panelItem.Title     = "Question Category";
                panelItem.Icon      = "Images/00005.png";
                panelItem.IsVisible = true;
                panelItem.CanClose  = true;
                _mListPanels.Add(panelItem);

                panelItem           = new PanelItem();
                panelItem.PanelId   = S3603Consts.PANEL_ID_PAPER;
                panelItem.Name      = S3603Consts.PANEL_NAME_PAPER;
                panelItem.ContentId = S3603Consts.PANEL_CONTENTID_PAPER;
                panelItem.Title     = "Question Category";
                panelItem.Icon      = "Images/00005.png";
                panelItem.IsVisible = true;
                panelItem.CanClose  = true;
                _mListPanels.Add(panelItem);
            }
            catch (Exception ex)
            {
                UMPApp.ShowExceptionMessage(ex.Message);
            }
        }
        void InitTestListTable()
        {
            try
            {
                string[] lans           = "3603T00009,3603T00010,3603T00011,3603T00012,3603T00013,3603T00014,3603T00015,3603T00016,3603T00017".Split(',');
                string[] cols           = "LongTestNum,LongPaperNum,StrPaperName,StrExplain,StrTestTime,LongEditorId,StrEditor,StrDateTime,StrTestStatue".Split(',');
                int[]    colwidths      = { 150, 150, 150, 100, 60, 180, 80, 100, 100, 100, 100 };
                var      columnGridView = new GridView();

                for (int i = 0; i < cols.Length; i++)
                {
                    var gvc = new GridViewColumn
                    {
                        Header = UMPApp.GetLanguageInfo(lans[i], cols[i]),
                        Width  = colwidths[i],
                        DisplayMemberBinding = new Binding(cols[i])
                    };
                    columnGridView.Columns.Add(gvc);
                }
                TestInfoListTable.View = columnGridView;
            }
            catch (Exception ex)
            {
                UMPApp.ShowExceptionMessage(ex.Message);
            }
        }
Example #5
0
        public static AlarmInfomationItem CreateItem(AlarmInfomationInfo info, UMPApp currentApp)
        {
            if (info == null)
            {
                return(null);
            }
            AlarmInfomationItem item = new AlarmInfomationItem();

            item.CurrentApp = currentApp;
            item.SerialID   = info.SerialID;
            item.MessageID  = info.MessageID;
            item.Level      = info.Level;
            item.IsEnabled  = info.IsEnabled;
            item.CreateTime = info.CreateTime;
            item.Name       = info.Name;
            item.Info       = info;

            item.StrIsEnabled = currentApp.GetLanguageInfo(item.IsEnabled ? "2501001" : "2501000",
                                                           item.IsEnabled ? "Enabled" : "Disabled");
            item.StrType =
                currentApp.GetLanguageInfo(string.Format("{0}{1}", S2501Consts.BID_ALARM_TYPE, item.Type.ToString("000")),
                                           item.Type.ToString());
            item.StrLevel =
                currentApp.GetLanguageInfo(string.Format("{0}{1}", S2501Consts.BID_ALARM_LEVEL, item.Level.ToString("000")),
                                           item.Level.ToString());
            item.StrCreateTime = item.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
            return(item);
        }
 private void InitLanguage()
 {
     BsExpandStyleOpt.Header        = UMPApp.GetLanguageInfo("3603T00001", "Basic Setting");
     DeleteExpandStyleOpt.Header    = UMPApp.GetLanguageInfo("3603T00002", "Delete Setting");
     TestInformationTable.Title     = UMPApp.GetLanguageInfo("3603T00004", "Test Information");
     ExamineeInformationTable.Title = UMPApp.GetLanguageInfo("3603T00005", "Examinee Information");
     PanelObjectPaper.Title         = UMPApp.GetLanguageInfo("3603T00036", "Paper");
 }
Example #7
0
 protected override void OnExit(ExitEventArgs e)
 {
     if (Current != null)
     {
         CurrentApp.Exit();
     }
     CurrentApp = null;
     base.OnExit(e);
 }
        private void GetTestUserInfo(TestInfoParam testInfoTemp)
        {
            _mlstTestUserParam.Clear();
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Session = App.Session;
                webRequest.Code    = (int)S3603Codes.OptGetTestUserInfo;
                Service36031Client client = new Service36031Client(WebHelper.CreateBasicHttpBinding(App.Session),
                                                                   WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service36031"));
                //var client = new Service36031Client();
                OperationReturn optReturn = XMLHelper.SeriallizeObject(testInfoTemp);
                if (!optReturn.Result)
                {
                    UMPApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return;
                }
                webRequest.ListData.Add(optReturn.Data.ToString());
                WebReturn webReturn = client.UmpTaskOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    App.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                    return;
                }
                App.WriteLog("GetTestUserInfo", webReturn.Data);

                if (webReturn.ListData.Count <= 0)
                {
                    _mObservableCollectionTestUser.Clear();
                    return;
                }
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    optReturn = XMLHelper.DeserializeObject <TestUserParam>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        UMPApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        continue;
                    }
                    var testInfo = optReturn.Data as TestUserParam;
                    if (testInfo == null)
                    {
                        UMPApp.ShowExceptionMessage("Fail. filesItem is null");
                        return;
                    }

                    _mlstTestUserParam.Add(testInfo);
                }
                SetObservableCollectionTestUser();
            }
            catch (Exception ex)
            {
                UMPApp.ShowExceptionMessage(ex.Message);
            }
        }
        private void AddTestInfo_Click(object sender, RoutedEventArgs e)
        {
            App.GQueryModify = false;
            PaperInfo newPage = new PaperInfo();

            newPage.ParentPage      = this;
            PopupCreateTest.Content = newPage;
            PopupCreateTest.Title   = UMPApp.GetLanguageInfo("3603T00055", "Paper Information");
            PopupCreateTest.IsOpen  = true;
        }
        public void OpenTestInfo()
        {
            App.GQueryModify = false;
            AddTestInfo newPage = new AddTestInfo();

            newPage.ParentPage      = this;
            PopupCreateTest.Content = newPage;
            PopupCreateTest.Title   = UMPApp.GetLanguageInfo("3603T00055", "Paper Information");
            PopupCreateTest.IsOpen  = true;
        }
        private bool GetPaperInfo(string strSql, out CPaperParam paperParam)
        {
            paperParam = new CPaperParam();
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Session = UMPApp.Session;
                webRequest.Code    = (int)S3603Codes.OptSearchPapers;
                OperationReturn optReturn = XMLHelper.SeriallizeObject(strSql);
                if (!optReturn.Result)
                {
                    UMPApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return(false);
                }
                webRequest.ListData.Add(optReturn.Data.ToString());
                Service36031Client client = new Service36031Client(WebHelper.CreateBasicHttpBinding(App.Session),
                                                                   WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service36031"));
                //var client = new Service36031Client();
                WebReturn webReturn = client.UmpTaskOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    UMPApp.ShowExceptionMessage(string.Format("{0}: {1}",
                                                              UMPApp.GetLanguageInfo("3603T00065", "Search Failed"), webReturn.Message));
                    return(false);
                }

                if (webReturn.ListData.Count <= 0)
                {
                    return(true);
                }
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    optReturn = XMLHelper.DeserializeObject <CPaperParam>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        UMPApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        continue;
                    }
                    var paperInfo = optReturn.Data as CPaperParam;
                    if (paperInfo == null)
                    {
                        UMPApp.ShowExceptionMessage("Fail. filesItem is null");
                        return(false);
                    }

                    paperParam = paperInfo;
                }
            }
            catch (Exception ex)
            {
                UMPApp.ShowExceptionMessage(ex.Message);
            }
            return(true);
        }
        public override void ChangeLanguage()
        {
            base.ChangeLanguage();

            InitButton();
            InitTestListTable();
            InitUserListTable();
            InitLanguage();

            if (PageHead != null)
            {
                PageHead.AppName = UMPApp.GetLanguageInfo("3603T00003", "Examination Management");
            }
        }
        private void AddTestUser_Click(object sender, RoutedEventArgs e)
        {
            TestInfoParam item = _mTestInfoTemp;

            if (item != null)
            {
                UserManagement newpage = new UserManagement();
                newpage.PageParent      = this;
                newpage._mTestInfoParam = item;
                PopupTestUser.Content   = newpage;
                PopupTestUser.Title     = UMPApp.GetLanguageInfo("3603T00007", "ScoreSheet User Management");
                PopupTestUser.IsOpen    = true;
            }
        }
        private void InitDeleteBut()
        {
            DeleteSetBut.Children.Clear();
            Button        btn;
            OperationInfo opt;

            btn             = new Button();
            btn.Click      += DeleteTestInfo_Click;
            opt             = new OperationInfo();
            opt.Display     = UMPApp.GetLanguageInfo("3603T00008", "Delete Test");
            opt.Icon        = "Images/Delete.png";
            btn.DataContext = opt;
            btn.SetResourceReference(StyleProperty, "OptButtonStyle");
            DeleteSetBut.Children.Add(btn);
        }
Example #15
0
        public ConditionItemItem(CustomConditionItem conditionItem, UMPApp currentApp)
        {
            ID            = conditionItem.ID;
            Name          = conditionItem.Name;
            Display       = conditionItem.Name;
            TabIndex      = conditionItem.TabIndex;
            TabName       = conditionItem.TabName;
            SortID        = conditionItem.SortID;
            Format        = conditionItem.Format;
            Type          = conditionItem.Type;
            ConditionItem = conditionItem;

            IsUserItem = false;
            CurrentApp = currentApp;
        }
 public CombinedParamItemModel(StatisticalParamItem paramItem, UMPApp currentApp)
 {
     ID = paramItem.StatisticalParamID;
     StatisticalParamItemID = paramItem.StatisticalParamItemID.ToString();
     Name        = paramItem.StatisticalParamItemName;
     Display     = paramItem.StatisticalParamItemName;
     TabIndex    = paramItem.TabIndex;
     TabName     = paramItem.TabName;
     SortID      = paramItem.SortID;
     Format      = paramItem.Formart;
     Type        = paramItem.Type;
     ParamItem   = paramItem;
     CurrentApp  = currentApp;
     IsAddedItem = false;
 }
        private void InitTestInfoBut()
        {
            TestInfoBut.Children.Clear();
            Button        btn;
            OperationInfo opt;

            btn             = new Button();
            btn.Click      += AddTestUser_Click;
            opt             = new OperationInfo();
            opt.Display     = UMPApp.GetLanguageInfo("3603T00007", "Set Test User");
            opt.Icon        = "Images/add.png";
            btn.DataContext = opt;
            btn.SetResourceReference(StyleProperty, "OptButtonStyle");
            TestInfoBut.Children.Add(btn);
        }
        private void GetAllTestInfos()
        {
            try
            {
                _mlstTestInformations.Clear();
                var webRequest            = new WebRequest();
                Service36031Client client = new Service36031Client(WebHelper.CreateBasicHttpBinding(App.Session), WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service36031"));
                //var client = new Service36031Client();
                webRequest.Session = UMPApp.Session;
                webRequest.Code    = (int)S3603Codes.OptGetTestInfo;

                WebReturn webReturn = client.UmpTaskOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    UMPApp.ShowExceptionMessage(UMPApp.GetLanguageInfo("3603T00015", "Insert data failed"));
                    return;
                }

                if (webReturn.ListData.Count <= 0)
                {
                    return;
                }
                for (int i = 0; i < webReturn.ListData.Count; i++)
                {
                    OperationReturn optReturn = XMLHelper.DeserializeObject <TestInfoParam>(webReturn.ListData[i]);
                    if (!optReturn.Result)
                    {
                        UMPApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        continue;
                    }
                    var testInfo = optReturn.Data as TestInfoParam;
                    if (testInfo == null)
                    {
                        UMPApp.ShowExceptionMessage("Fail. filesItem is null");
                        return;
                    }

                    _mlstTestInformations.Add(testInfo);
                }
                SetObservableCollectionTestInfo();
            }
            catch (Exception ex)
            {
                UMPApp.ShowExceptionMessage(ex.Message);
            }
        }
        private void SetPanelVisible()
        {
            try
            {
                for (int i = 0; i < _mListPanels.Count; i++)
                {
                    var item  = _mListPanels[i];
                    var panel = PanelManager.Layout.Descendents().OfType <LayoutAnchorable>().FirstOrDefault(p => p.ContentId == item.ContentId);
                    if (panel != null)
                    {
                        switch (item.PanelId)
                        {
                        case 1:
                            panel.Title = UMPApp.GetLanguageInfo("3603T00005", item.Name);
                            break;

                        case 2:
                            panel.Title = UMPApp.GetLanguageInfo("3603T00036", item.Name);
                            break;
                        }

                        if (item.IsVisible)
                        {
                            panel.Show();
                        }
                        else
                        {
                            panel.Hide();
                        }
                        LayoutAnchorable panel1 = panel;
                        panel.IsVisibleChanged += (s, e) =>
                        {
                            item.IsVisible = panel1.IsVisible;
                            SetViewStatus();
                        };
                        panel.Closing += PanelDocument_Closing;
                    }
                }
            }
            catch (Exception ex)
            {
                UMPApp.ShowExceptionMessage(ex.Message);
            }
        }
        protected override void Init()
        {
            try
            {
                PageHead.AppName = UMPApp.GetLanguageInfo("3603T00003", "Examination Management");
                StylePath        = "UMPS3603/MainPageStyle.xmal";
                base.Init();

                InitPanels();
                CreateToolBarButtons();
                SendLoadedMessage();
                ChangeTheme();
                ChangeLanguage();
            }
            catch (Exception ex)
            {
                UMPApp.ShowExceptionMessage(ex.Message);
            }
        }
 void TestInformationTable_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     try
     {
         _mTestInfoTemp = null;
         var item = TestInfoListTable.SelectedItem as TestInfoParam;
         _mTestInfoTemp = item;
         if (item != null)
         {
             InitTestInfoBut();
             GetTestUserInfo(_mTestInfoTemp);
             InitDeleteBut();
         }
     }
     catch (Exception ex)
     {
         UMPApp.ShowExceptionMessage(ex.Message);
     }
 }
        protected override void PageHead_PageHeadEvent(object sender, PageHeadEventArgs e)
        {
            base.PageHead_PageHeadEvent(sender, e);

            switch (e.Code)
            {
            //切换主题
            case 100:
                ThemeInfo themeInfo = e.Data as ThemeInfo;
                if (themeInfo != null)
                {
                    ThemeInfo = themeInfo;
                    UMPApp.Session.ThemeInfo = themeInfo;
                    UMPApp.Session.ThemeName = themeInfo.Name;
                    ChangeTheme();
                    SendThemeChangeMessage();
                }
                break;

            //切换语言
            case 110:
                LangTypeInfo langType = e.Data as LangTypeInfo;
                if (langType != null)
                {
                    LangTypeInfo = langType;
                    UMPApp.Session.LangTypeInfo = langType;
                    UMPApp.Session.LangTypeID   = langType.LangID;
                    MyWaiter.Visibility         = Visibility.Visible;
                    _mWorker                     = new BackgroundWorker();
                    _mWorker.DoWork             += (s, de) => UMPApp.InitAllLanguageInfos();
                    _mWorker.RunWorkerCompleted += (s, re) =>
                    {
                        _mWorker.Dispose();
                        MyWaiter.Visibility = Visibility.Hidden;
                        ChangeLanguage();
                        PopupCreateTest.ChangeLanguage();
                        SendLanguageChangeMessage();
                    };
                    _mWorker.RunWorkerAsync();
                }
                break;
            }
        }
 public StatisticalParamItemModel(StatisticalParamItem paramItem, UMPApp currentApp)
 {
     StatisticDuration        = paramItem.StatisticDuration;
     StatisticUnit            = paramItem.StatisticUnit;
     IsCombine                = paramItem.IsCombine;
     IsUsed                   = paramItem.IsUsed;
     Description              = paramItem.Description;
     StatisticalParamID       = paramItem.StatisticalParamID;
     StatisticalParamItemID   = paramItem.StatisticalParamItemID;
     StatisticalParamItemName = paramItem.StatisticalParamItemName;
     TabIndex                 = paramItem.TabIndex;
     TabName                  = paramItem.TabName;
     SortID                   = paramItem.SortID;
     Formart                  = paramItem.Formart;
     Type          = paramItem.Type;
     ConditionItem = paramItem;
     Value         = paramItem.Value;
     ValueType     = paramItem.ValueType;
     CurrentApp    = currentApp;
 }
 private bool DeleteTest(TestInfoParam testInfoParam)
 {
     try
     {
         WebRequest webRequest = new WebRequest();
         webRequest.Session = UMPApp.Session;
         webRequest.Code    = (int)S3603Codes.OptDeleteTestInfo;
         Service36031Client client = new Service36031Client(WebHelper.CreateBasicHttpBinding(App.Session),
                                                            WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service36031"));
         //var client = new Service36031Client();
         OperationReturn optReturn = XMLHelper.SeriallizeObject(testInfoParam);
         if (!optReturn.Result)
         {
             UMPApp.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
             return(false);
         }
         webRequest.ListData.Add(optReturn.Data.ToString());
         //Service36031Client client = new Service36031Client();
         WebReturn webReturn = client.UmpTaskOperation(webRequest);
         client.Close();
         if (!webReturn.Result)
         {
             UMPApp.ShowExceptionMessage(UMPApp.GetLanguageInfo("3603T00083", "Delete Failed"));
             return(false);
         }
         if (webReturn.Message == S3603Consts.HadUse)// 该查询条件被使用无法删除
         {
             UMPApp.ShowInfoMessage(UMPApp.GetLanguageInfo("3603T00011", "Can't Delete"));
             return(false);
         }
     }
     catch (Exception ex)
     {
         UMPApp.ShowExceptionMessage(ex.Message);
         return(false);
     }
     return(true);
 }
        private void DeleteTestInfo_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result1 =
                MessageBox.Show(
                    UMPApp.GetLanguageInfo("3603T00066",
                                           "Sure you want to delete?"),
                    UMPApp.GetLanguageInfo("3603T00090", "Warning"),
                    MessageBoxButton.OKCancel);

            if (result1 == MessageBoxResult.Cancel)
            {
                return;
            }

            TestInfoParam item = _mTestInfoTemp;

            if (item != null)
            {
                if (item.StrTestStatue == TestStratue.USED)
                {
                    MessageBoxResult result =
                        MessageBox.Show(
                            UMPApp.GetLanguageInfo("3603T00094",
                                                   "The examination paper is already in use cannot be deleted!"),
                            UMPApp.GetLanguageInfo("3603T00090", "Warning"),
                            MessageBoxButton.OKCancel);
                    return;
                }

                if (DeleteTest(item))
                {
                    UMPApp.ShowInfoMessage(UMPApp.GetLanguageInfo("3603T00054", "Success!"));
                    _mlstTestInformations.Remove(_mlstTestInformations.FirstOrDefault(p => p.LongTestNum == item.LongTestNum));
                    SetObservableCollectionTestInfo();
                    _mObservableCollectionTestUser.Clear();
                }
            }
        }
Example #26
0
 protected override void OnStartup(StartupEventArgs e)
 {
     CurrentApp = new S3101App(false);
     CurrentApp.Startup();
     base.OnStartup(e);
 }
        protected override void App_NetPipeEvent(WebRequest webRequest)
        {
            base.App_NetPipeEvent(webRequest);

            Dispatcher.Invoke(new Action(() =>
            {
                try
                {
                    var code    = webRequest.Code;
                    var strData = webRequest.Data;
                    switch (code)
                    {
                    case (int)RequestCode.SCLanguageChange:
                        LangTypeInfo langTypeInfo = UMPApp.Session.SupportLangTypes.FirstOrDefault(l => l.LangID.ToString() == strData);
                        if (langTypeInfo != null)
                        {
                            LangTypeInfo = langTypeInfo;
                            UMPApp.Session.LangTypeInfo = langTypeInfo;
                            UMPApp.Session.LangTypeID   = langTypeInfo.LangID;
                            if (MyWaiter != null)
                            {
                                MyWaiter.Visibility = Visibility.Visible;
                            }
                            _mWorker                     = new BackgroundWorker();
                            _mWorker.DoWork             += (s, de) => UMPApp.InitAllLanguageInfos();
                            _mWorker.RunWorkerCompleted += (s, re) =>
                            {
                                _mWorker.Dispose();
                                if (MyWaiter != null)
                                {
                                    MyWaiter.Visibility = Visibility.Hidden;
                                }
                                if (PopupCreateTest != null)
                                {
                                    PopupCreateTest.ChangeLanguage();
                                }
                                if (PageHead != null)
                                {
                                    PageHead.SessionInfo = UMPApp.Session;
                                    PageHead.InitInfo();
                                }
                            };
                            _mWorker.RunWorkerAsync();
                        }
                        break;

                    case (int)RequestCode.SCThemeChange:
                        ThemeInfo themeInfo = UMPApp.Session.SupportThemes.FirstOrDefault(t => t.Name == strData);
                        if (themeInfo != null)
                        {
                            ThemeInfo = themeInfo;
                            UMPApp.Session.ThemeInfo = themeInfo;
                            UMPApp.Session.ThemeName = themeInfo.Name;
                            ChangeTheme();
                            PageHead.SessionInfo = UMPApp.Session;
                            PageHead.InitInfo();
                        }
                        break;
                    }
                }
                catch (Exception ex)
                {
                    UMPApp.ShowExceptionMessage(ex.Message);
                }
            }));
        }
Example #28
0
        public OperationReturn ExportDataToExecel <T>(List <T> listData, List <ViewColumnInfo> listColumns, UMPApp currentApp)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listData == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("ListData is null");
                    return(optReturn);
                }
                if (listData.Count <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_NOT_EXIST;
                    optReturn.Message = string.Format("No Record Data");
                    return(optReturn);
                }
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.DefaultExt       = "xls";
                dialog.Filter           = "Excel Files  (*.xls)|*.xls";
                dialog.FilterIndex      = 1;
                dialog.RestoreDirectory = true;
                if (dialog.ShowDialog() != true)
                {
                    optReturn.Code = Defines.RET_ALREADY_EXIST;
                    return(optReturn);
                }
                StringBuilder sb          = new StringBuilder();
                List <string> listFields  = new List <string>();
                int           intColCount = listColumns.Count;
                //列标题
                for (int i = 0; i < intColCount; i++)
                {
                    string strTitle =
                        currentApp.GetLanguageInfo(
                            string.Format("COL{0}{1}", listColumns[i].ViewID, listColumns[i].ColumnName),
                            listColumns[i].ColumnName);
                    listFields.Add(FormatField(strTitle));
                }
                BuildStringToRow(sb, listFields);
                //列数据
                PropertyInfo[] listProperty;
                PropertyInfo   property;
                for (int i = 0; i < listData.Count; i++)
                {
                    T item = listData[i];
                    listFields.Clear();
                    listProperty = item.GetType().GetProperties();
                    for (int j = 0; j < intColCount; j++)
                    {
                        ViewColumnInfo column = listColumns[j];
                        property = listProperty.FirstOrDefault(p => p.Name == column.ColumnName);
                        if (property != null)
                        {
                            var temp = property.GetValue(item, null);
                            if (temp != null)
                            {
                                string strValue;
                                switch (column.ColumnName)
                                {
                                case "Duration":
                                    strValue = Converter.Second2Time(Convert.ToDouble(temp));
                                    break;

                                case "StartRecordTime":
                                case "StopRecordTime":
                                    strValue = Convert.ToDateTime(temp).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
                                    break;

                                case "Direction":
                                    strValue = currentApp.GetLanguageInfo(string.Format("3102TIP001{0}", temp), temp.ToString());
                                    break;

                                default:
                                    strValue = temp.ToString();
                                    break;
                                }
                                listFields.Add(FormatField(strValue));
                            }
                            else
                            {
                                listFields.Add(FormatField(String.Empty));
                            }
                        }
                        else
                        {
                            listFields.Add(FormatField(string.Empty));
                        }
                    }
                    BuildStringToRow(sb, listFields);
                }

                StreamWriter streamWriter = new StreamWriter(dialog.OpenFile());
                streamWriter.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                streamWriter.WriteLine("<?mso-application progid=\"Excel.Sheet\"?>");
                streamWriter.WriteLine("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\">");
                streamWriter.WriteLine("<DocumentProperties xmlns=\"urn:schemas-microsoft-com:office:office\">");
                streamWriter.WriteLine("<Author>" + currentApp.Session.UserInfo.Account + "</Author>");
                streamWriter.WriteLine("<Created>" + DateTime.Now.ToLocalTime().ToLongDateString() + "</Created>");
                streamWriter.WriteLine("<LastSaved>" + DateTime.Now.ToLocalTime().ToLongDateString() + "</LastSaved>");
                streamWriter.WriteLine("<Company>" + "VoiceCyber" + "</Company>");
                streamWriter.WriteLine("<Version>1.00</Version>");
                streamWriter.WriteLine("</DocumentProperties>");
                streamWriter.WriteLine("<Worksheet ss:Name=\"UMP Export\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\">");
                streamWriter.WriteLine("<Table>");
                streamWriter.WriteLine(sb);
                streamWriter.WriteLine("</Table>");
                streamWriter.WriteLine("</Worksheet>");
                streamWriter.WriteLine("</Workbook>");

                streamWriter.Close();
                optReturn.Data = dialog.FileName;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }