コード例 #1
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public override void Load(IDictionary <string, string> parameters)
        {
            if (parameters == null)
            {
                return;
            }

            if (!parameters.ContainsKey("basePath"))
            {
                return;
            }

            var filePath = Path.Combine(parameters["basePath"], this.FileName);

            this.Loaded = true;

            if (File.Exists(filePath))
            {
                var dt = ObjectXMLSerializer <ContextDataType> .Load(filePath);

                this.Contexts = dt.Contexts;

                this.AdditionalNamespaces.Clear();
                this.AdditionalNamespaces.AddRange(dt.AdditionalNamespaces);
            }
        }
コード例 #2
0
        /// <summary>
        ///     Load ProjectDefinition.
        /// </summary>
        public void Load()
        {
            Logger.Trace($"Started Load() - Path: {FilePersistenceOptions.Path}");
            ProjectDefinition = ObjectXMLSerializer <ProjectDefinition> .Load(FilePersistenceOptions.Path);

            Logger.Trace($"Completed Load() - Path: {FilePersistenceOptions.Path}");
        }
コード例 #3
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public override void Load(IDictionary <string, string> parameters)
        {
            var filePath = Path.Combine(parameters["basePath"], this.FileName);

            this.Loaded = true;

            if (File.Exists(filePath))
            {
                var dto = ObjectXMLSerializer <DtoDataType> .Load(filePath);

                if (dto != null)
                {
                    this.Namespace            = dto.Namespace;
                    this.OutputFolder         = dto.OutputFolder;
                    this.OutputPath           = dto.OutputPath;
                    this.InheritFrom          = dto.InheritFrom;
                    this.UseInterface         = dto.UseInterface;
                    this.AddInjectConstructor = dto.AddInjectConstructor;
                    this.UseGenerics          = dto.UseGenerics;

                    this.AdditionalNamespaces.Clear();
                    this.AdditionalNamespaces.AddRange(dto.AdditionalNamespaces);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public override object Load(object parameters)
        {
            Logger.Trace("Started Import()");

            string path = this.ReturnFilePath(parameters as string);

            Logger.Debug($"Path: {path}");
            AdoSourceOptions result = null;

            if (File.Exists(path))
            {
                Logger.Trace("Path Exists");
                result = ObjectXMLSerializer <AdoSourceOptions> .Load(path);
            }
            else
            {
                Logger.Trace("Path Doesn't Exist");
                result = new AdoSourceOptions
                {
                    ProviderName     = "Oracle.ManagedDataAccess.Client",
                    ConnectionString =
                        @"DATA SOURCE=localhost:1521/xe;PERSIST SECURITY INFO=True;USER ID=dbo;PASSWORD=Password123#"
                };
            }

            Logger.Trace("Completed Import()");

            return(result);
        }
コード例 #5
0
        /// <summary>
        /// Load Data
        /// </summary>
        /// <param name="parameters">
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public object Load(object parameters)
        {
            Logger.Trace("Started Import()");

            string path = this.ReturnFilePath(parameters as string);

            Logger.Debug($"Path: {path}");
            FileSourceOptions result = null;

            if (File.Exists(path))
            {
                Logger.Trace("Path Exists");
                result = ObjectXMLSerializer <FileSourceOptions> .Load(path);
            }
            else
            {
                result = new FileSourceOptions();

                Logger.Trace("Path Doesn't Exist");
            }

            Logger.Trace("Completed Import()");

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public override void Load(IDictionary <string, string> parameters)
        {
            if (parameters == null)
            {
                return;
            }

            if (!parameters.ContainsKey("basePath"))
            {
                return;
            }

            var filePath = Path.Combine(parameters["basePath"], this.FileName);

            this.Loaded = true;

            if (File.Exists(filePath))
            {
                var entity = ObjectXMLSerializer <DtoInterfaceDataType> .Load(filePath);

                if (entity != null)
                {
                    this.Namespace    = entity.Namespace;
                    this.OutputFolder = entity.OutputFolder;
                    this.OutputPath   = entity.OutputPath;
                    this.InheritFrom  = entity.InheritFrom;

                    this.AdditionalNamespaces.Clear();
                    this.AdditionalNamespaces.AddRange(entity.AdditionalNamespaces);
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public override object Load(object parameters)
        {
            Logger.Trace("Started Import()");

            string path = this.ReturnFilePath(parameters as string);

            Logger.Debug($"Path: {path}");
            AdoSourceOptions result = null;

            if (File.Exists(path))
            {
                Logger.Trace("Path Exists");
                result = ObjectXMLSerializer <AdoSourceOptions> .Load(path);
            }
            else
            {
                Logger.Trace("Path Doesn't Exist");
                result = new AdoSourceOptions
                {
                    ProviderName     = "MySql.Data.MySqlClient",
                    ConnectionString =
                        @"server=localhost;userid=test;password=password;database=test;SslMode=none"
                };
            }

            Logger.Trace("Completed Import()");

            return(result);
        }
コード例 #8
0
ファイル: Diagnostics.cs プロジェクト: uon-crissp/IQTools
        /// <summary>
        /// Overloaded method to load in a file which in turn calls
        /// Load(fileStream)
        /// </summary>
        /// <param name="filename">File to load</param>
        /// <returns>Diagnostics class</returns>
        public static CheckSums Load(string Filename)
        {
            return((CheckSums)ObjectXMLSerializer <CheckSums> .Load(Filename));

            // System.IO.Stream stream = new System.IO.FileStream(filename, FileMode.Open, FileAccess.Read);
            //return Load(stream);
        }
コード例 #9
0
        private async Task XMLPaser()
        {
            DUT dut = new DUT();

            dut.SerialNumber = "1030030011111111";

            dut.RawCount.Add("100");

            dut.RawCount.Add("102");

            dut.IDAC.Add("98");

            ObjectXMLSerializer <DUT> .Save(dut, @"D:\test.xml");

            //Task t = new Task(() => ObjectXMLSerializer<DUT_Str>.Save(dut, "D:\test.xml"));

            //await t;


            dut = ObjectXMLSerializer <DUT> .Load(@"D:\test.xml");

            MessageBox.Show(dut.SerialNumber);

            foreach (string rc in dut.RawCount)
            {
                MessageBox.Show(rc);
            }
        }
コード例 #10
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <returns>
        /// The <see cref="object"/>.
        /// </returns>
        public override object Load(object parameters)
        {
            Logger.Trace("Started Import()");

            string path = this.ReturnFilePath(parameters as string);

            Logger.Debug($"Path: {path}");
            AdoSourceOptions result = null;

            if (File.Exists(path))
            {
                Logger.Trace("Path Exists");
                result = ObjectXMLSerializer <AdoSourceOptions> .Load(path);
            }
            else
            {
                Logger.Trace("Path Doesn't Exist");
                result = new AdoSourceOptions
                {
                    ProviderName     = "System.Data.SqlClient",
                    ConnectionString =
                        @"Data Source=.\SQLEXPRESS;Integrated Security=true;Initial Catalog=BankingDesign"
                };
            }

            Logger.Trace("Completed Import()");

            return(result);
        }
コード例 #11
0
        public static Rendiconto CreateRendiconto(string template)
        {
            Rendiconto r = ObjectXMLSerializer <Rendiconto> .Load(template);

            r.Bilancio.CalculateParentName();
            r.Preventivo.CalculateParentName();

            return(r);
        }
コード例 #12
0
        private void LoadQuestionFromXml(string FileName)
        {
            resultQuestions      = null;
            groupBox1.GroupTitle = FileName;
            if (Utility.IsAdmin())
            {
                FileName = Application.StartupPath + Utility.FolderType() + @"QuestionBank\" + FileName + ".txt";
            }
            else
            {
                FileName = Application.StartupPath + Utility.FolderType() + @"QuestionPaper\" + FileName + ".txt";
            }


            if (File.Exists(FileName))
            {
                resultQuestions = ObjectXMLSerializer <QuestionDetailData> .Load(FileName);

                resultQuestions.objQuestionDetail = (from QuestionDetailData in resultQuestions.objQuestionDetail
                                                     where (QuestionDetailData.ModuleName == Utility.MOD_ALL || QuestionDetailData.ModuleName == Utility.MOD_MOCK_TST)
                                                     select QuestionDetailData).ToList();

                resultQuestionsFltr = ObjectXMLSerializer <QuestionDetailData> .Load(FileName);

                resultQuestionsFltr.objQuestionDetail = (from QuestionDetailData in resultQuestionsFltr.objQuestionDetail
                                                         where (QuestionDetailData.ModuleName == Utility.MOD_ALL || QuestionDetailData.ModuleName == Utility.MOD_MOCK_TST)
                                                         select QuestionDetailData).ToList();
            }
            //Apply Filter
            if (resultQuestionsFltr != null && resultQuestionsFltr.objQuestionDetail.Count() > 0)
            {
                //QUestion Type
                // resultQuestionsFltr = resultQuestions;
                //   if (comboBox1.Text == "" && comboBox2.Text == "")
                //   resultQuestionsFltr.objQuestionDetail.Clear();

                if (comboBox1.Text != "ALL")
                {
                    resultQuestionsFltr.objQuestionDetail =
                        (from QuestionDetail in resultQuestionsFltr.objQuestionDetail
                         where QuestionDetail.AnswerType == comboBox1.Text
                         select QuestionDetail).ToList();
                }

                //Question Complexity
                if (comboBox2.Text != "ALL")
                {
                    resultQuestionsFltr.objQuestionDetail =
                        (from QuestionDetail in resultQuestionsFltr.objQuestionDetail
                         where QuestionDetail.Complexity.ToLower() == comboBox2.Text.ToLower()
                         select QuestionDetail).ToList();
                }
            }
            Utility.XML_FILE_NAME = FileName;

            //resultQuestions = ObjectXMLSerializer<QuestionDetailData>.Load(XML_FILE_NAME);
        }
コード例 #13
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public void Load(IDictionary <string, string> parameters)
        {
            var filePath = Path.Combine(parameters["basePath"], FILE_NAME);

            if (File.Exists(filePath))
            {
                var appService = ObjectXMLSerializer <EntityDataType> .Load(filePath);

                if (appService != null)
                {
                }
            }
        }
コード例 #14
0
ファイル: Diagnostics.cs プロジェクト: uon-crissp/IQTools
        public void Load()
        {
            if (m_filename == string.Empty)
            {
                throw new ArgumentNullException("Filename cannot be empty");
            }
            CheckSums dgs = ObjectXMLSerializer <CheckSums> .Load(m_filename);

            //Diagnostics dgs = Diagnostics.Load(m_filename);
            this.m_checksumfiles = dgs.Files;
            OnFileLoaded(new CheckSumEventArgs(m_filename));
            ////this.m_checksumfiles = dgs.m_checksumfiles;
            dgs = null;
        }
コード例 #15
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //Filter based on the treeView1.SelectedNode.Text
            Clear();
            grouper1.GroupTitle = treeView1.SelectedNode.Text;
            if (treeView1.SelectedNode.Level == 2)
            {
                objeTutorCollData = ObjectXMLSerializer <eTutorCollData> .Load(Application.StartupPath + Utility.FolderType() + @"eTutor\" + treeView1.SelectedNode.Parent.Parent.Text + ".txt");

                //Locate using the tag
                if (objeTutorCollData != null)
                {
                    List <eTutorMast> objeTutorMast =
                        (from eTutorMast in objeTutorCollData.eTutorlst
                         where eTutorMast.QuesNo == Convert.ToInt32(treeView1.SelectedNode.Tag)
                         select eTutorMast).ToList();
                    if (objeTutorMast != null && objeTutorMast.Count > 0)
                    {
                        setTextForRich(exRichTextBox1, objeTutorMast[0].Summary);
                        setTextForRich(exRichTextBox2, objeTutorMast[0].Description);
                        isDataEdited = false;
                        if (string.IsNullOrEmpty(objeTutorMast[0].Status))
                        {
                            btnLaunch.Visible = true;
                        }
                        else
                        {
                            btnRelaunch.Visible = true;
                            label4.Text         = objeTutorMast[0].Status + " Test percentage is –" + objeTutorMast[0].Result;
                        }
                    }
                    else
                    {
                        Clear();
                    }
                }
                else
                {
                    objeTutorCollData = new eTutorCollData();
                    ObjectXMLSerializer <eTutorCollData> .Save(objeTutorCollData, Application.StartupPath + Utility.FolderType() + @"eTutor\" + treeView1.SelectedNode.Parent.Parent.Text + ".txt");

                    Clear();
                }
            }
            else
            {
                Clear();
            }
        }
        public void Load(string dllPath = "")
        {
            Logger.Trace($"Started Load() - Path: {this.FilePersistenceOptions.Path}");
            this.ProjectDefinition = ObjectXMLSerializer <ProjectDefinition> .Load(this.FilePersistenceOptions.Path);

            ScaffoldConfig.Load(dllPath);
            foreach (var domain in this.ProjectDefinition.Domains)
            {
                // Todo: The fix shouldn't come from the SourceType
                var sourceType = ScaffoldConfig.ReturnSourceType(domain.SourceTypeId);
                sourceType.Fix(domain.Tables);
            }

            Logger.Trace($"Completed Load() - Path: {this.FilePersistenceOptions.Path}");
        }
コード例 #17
0
 /// <summary>
 /// Зарежда конфигурационния файл
 /// </summary>
 private void LoadConfig()
 {
     if (File.Exists(_ConfigFSynchrPath))
     {
         try
         { _ConfigFSynchr = ObjectXMLSerializer <ConfigFSynchronizer> .Load(_ConfigFSynchrPath); }
         catch (Exception ex)
         {
             throw new Exception("Грешен формат на '" + _ConfigFSynchrPath + "'! " + ex.Message + ex.StackTrace);
         }
     }
     else
     {
         _ConfigFSynchr = new ConfigFSynchronizer();
     }
 }
コード例 #18
0
        public void DocGhi(string rTenFile)
        {
            Transactions transactions = null;

            try
            {
                transactions = ObjectXMLSerializer <Transactions> .Load(rTenFile, SerializedFormat.Binary);
            }
            catch
            {
                transactions             = new Transactions();
                transactions.Transaction = new PAYPOST.LOG.Transaction[0];
            }
            Transaction[] array = new Transaction[transactions.Transaction.Length];
            transactions.Transaction.CopyTo(array, 0);
        }
コード例 #19
0
        public static void Load()
        {
            if (!File.Exists(_defaultCfgFile))
            {
                _current = new PersistedDockStateData();
            }
            else
            {
                _current = ObjectXMLSerializer <PersistedDockStateData> .Load(_defaultCfgFile);

                if (_current == null)
                {
                    _current = new PersistedDockStateData();
                }
            }
        }
コード例 #20
0
        public static void Load()
        {
            if (!File.Exists(_defaultCfgFile))
            {
                _current = new DxRendererOption();
            }
            else
            {
                _current = ObjectXMLSerializer <DxRendererOption> .Load(_defaultCfgFile);

                if (_current == null)
                {
                    _current = new DxRendererOption();
                }
            }
        }
コード例 #21
0
ファイル: Helpers.cs プロジェクト: Eisai/pragmasql
        public static void Load()
        {
            if (!File.Exists(_defaultCfgFile))
            {
                _current = new List <ExternalToolDef>();
            }
            else
            {
                _current = ObjectXMLSerializer <List <ExternalToolDef> > .Load(_defaultCfgFile);

                if (_current == null)
                {
                    _current = new List <ExternalToolDef>();
                }
            }
        }
コード例 #22
0
        void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 6)
            {
                if (DialogResult.Yes == MessageBox.Show("Are you sure to delete from list?", "Delete", MessageBoxButtons.YesNo))
                {
                    File.Delete(objQuestionManagementColl.objQuestionManagement[e.RowIndex].FileName);
                    objQuestionManagementColl.objQuestionManagement.RemoveAt(e.RowIndex);
                    ObjectXMLSerializer <QuestionManagementColl> .Save(objQuestionManagementColl, Application.StartupPath + Utility.FolderType() + @"QuestionPaper\QuestionInfo.txt");

                    LoadTextData();
                }
            }
            else if (e.ColumnIndex > 1 && (e.ColumnIndex < 6))
            {
                QuestionDetailData objQuestions = ObjectXMLSerializer <QuestionDetailData> .Load(objQuestionManagementColl.objQuestionManagement[e.RowIndex].FileName);

                FrmQuestionsDisplay obj = new FrmQuestionsDisplay();
                //obj.resultQuestions.objQuestionDetail.Clear();
                obj.resultQuestions.objQuestionDetail = objQuestions.objQuestionDetail;
                obj.strSubject    = objQuestionManagementColl.objQuestionManagement[e.RowIndex].Subject;
                obj.strQuestTopic = objQuestionManagementColl.objQuestionManagement[e.RowIndex].QuestionTopic;
                if (e.ColumnIndex == 2)
                {
                    obj.printAnswer   = false;
                    obj.printQuestion = true;
                }
                else if (e.ColumnIndex == 3)
                {
                    obj.printAnswer   = true;
                    obj.printQuestion = true;
                }
                else if (e.ColumnIndex == 4)
                {
                    obj.printAnswer   = true;
                    obj.printQuestion = false;
                }
                else if (e.ColumnIndex == 5)
                {
                    obj.printAnswer   = false;
                    obj.printQuestion = false;
                }
                obj.ShowDialog();
            }
        }
コード例 #23
0
        public static List <WorkspaceItem> LoadWorkspaceFrom(string fileName)
        {
            List <WorkspaceItem> result = null;

            if (!File.Exists(fileName))
            {
                Items = new List <WorkspaceItem>();
                return(Items);
            }

            result = ObjectXMLSerializer <List <WorkspaceItem> > .Load(fileName);

            if (result == null)
            {
                result = new List <WorkspaceItem>();
            }
            Items = result;
            return(result);
        }
コード例 #24
0
        public static ConfigurationContent LoadCurrentConfiguration(string fileName)
        {
            ConfigurationContent result = null;

            if (!File.Exists(fileName))
            {
                _currentConfig = new ConfigurationContent();
                return(_currentConfig);
            }

            result = ObjectXMLSerializer <ConfigurationContent> .Load(fileName);

            if (result == null)
            {
                result = new ConfigurationContent();
            }
            _currentConfig = result;
            return(result);
        }
コード例 #25
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public void Load(IDictionary <string, string> parameters)
        {
            if (parameters == null)
            {
                return;
            }

            if (!parameters.ContainsKey("basePath"))
            {
                return;
            }

            var filePath = Path.Combine(parameters["basePath"], FILE_NAME);

            if (File.Exists(filePath))
            {
                Contexts = ObjectXMLSerializer <List <ContextData> > .Load(filePath);
            }
        }
コード例 #26
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public override void Load(IDictionary <string, string> parameters)
        {
            if (parameters == null)
            {
                return;
            }

            if (!parameters.ContainsKey("basePath"))
            {
                return;
            }

            var filePath = Path.Combine(parameters["basePath"], this.FileName);

            this.Loaded = true;

            if (File.Exists(filePath))
            {
                var dt = ObjectXMLSerializer <ApplicationServiceDataType> .Load(filePath);

                this.ApplicationServiceData = dt.ApplicationServiceData;

                this.AdditionalNamespaces.Clear();
                this.AdditionalNamespaces.AddRange(dt.AdditionalNamespaces);

                this.AdditionalNamespacesInterfaces.Clear();
                this.AdditionalNamespacesInterfaces.AddRange(dt.AdditionalNamespacesInterfaces);


                // Ensure tables are up to date
                foreach (ApplicationServiceData applicationServiceData in this.ApplicationServiceData)
                {
                    for (int i = 0; i < applicationServiceData.Models.Count; i++)
                    {
                        var model = applicationServiceData.Models[i];
                        applicationServiceData.Models[i] = DomainDefinition.Tables.FirstOrDefault(t =>
                                                                                                  t.SchemaName == model.SchemaName && t.TableName == model.TableName);
                    }
                }
            }
        }
コード例 #27
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public override void Load(IDictionary <string, string> parameters)
        {
            var filePath = Path.Combine(parameters["basePath"], this.FileName);

            this.Loaded = true;

            if (File.Exists(filePath))
            {
                var appService = ObjectXMLSerializer <MappingDataType> .Load(filePath);

                if (appService != null)
                {
                    this.Namespace    = appService.Namespace;
                    this.OutputFolder = appService.OutputFolder;
                    this.PostFix      = appService.PostFix;

                    this.AdditionalNamespaces.Clear();
                    this.AdditionalNamespaces.AddRange(appService.AdditionalNamespaces);
                }
            }
        }
コード例 #28
0
ファイル: MultiExecSpec.cs プロジェクト: Eisai/pragmasql
        public static SerializableDictionary <string, ConnectionParams> Load(string path)
        {
            SerializableDictionary <string, ConnectionParams> result = null;

            if (!File.Exists(path))
            {
                result = new SerializableDictionary <string, ConnectionParams>();
            }
            else
            {
                result = ObjectXMLSerializer <SerializableDictionary <string, ConnectionParams> > .Load(path);

                if (result == null)
                {
                    result = new SerializableDictionary <string, ConnectionParams>();
                }
            }

            result = PrepareConnectionParams(result, false);
            return(result);
        }
コード例 #29
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public override void Load(IDictionary <string, string> parameters)
        {
            var filePath = Path.Combine(parameters["basePath"], this.FileName);

            this.Loaded = true;

            if (File.Exists(filePath))
            {
                var dt = ObjectXMLSerializer <StructureMapDataType> .Load(filePath);

                if (dt != null)
                {
                    this.Namespace    = dt.Namespace;
                    this.OutputFolder = dt.OutputFolder;
                    this.OutputPath   = dt.OutputPath;

                    this.AdditionalNamespaces.Clear();
                    this.AdditionalNamespaces.AddRange(dt.AdditionalNamespaces);
                }
            }
        }
コード例 #30
0
 public void LoadTextData()
 {
     if (File.Exists(Application.StartupPath + Utility.FolderType() + @"QuestionPaper\QuestionInfo.txt"))
     {
         objQuestionManagementColl = ObjectXMLSerializer <QuestionManagementColl> .Load(Application.StartupPath + Utility.FolderType() + @"QuestionPaper\QuestionInfo.txt");
     }
     if (objQuestionManagementColl != null)
     {
         dataGridView1.RowCount = objQuestionManagementColl.objQuestionManagement.Count;
         for (int i = 0; i < objQuestionManagementColl.objQuestionManagement.Count; i++)
         {
             dataGridView1.Rows[i].Cells["Answer"].Value   = "Generate";
             dataGridView1.Rows[i].Cells["QandA"].Value    = "Generate";
             dataGridView1.Rows[i].Cells["Question"].Value = "Generate";
             dataGridView1.Rows[i].Cells["OMR"].Value      = "Generate";
             dataGridView1.Rows[i].Cells["Delete"].Value   = "Delete";
             dataGridView1.Rows[i].Cells["ExamName"].Value = objQuestionManagementColl.objQuestionManagement[i].ExamName;
             dataGridView1.Rows[i].Cells["Subject"].Value  = objQuestionManagementColl.objQuestionManagement[i].TotalQuestions;
         }
     }
 }
コード例 #31
0
ファイル: Empresa.cs プロジェクト: akretion/uninfe
        public void BuscaConfiguracao()
        {
            if (!Directory.Exists(this.PastaEmpresa))
                Directory.CreateDirectory(this.PastaEmpresa);

            LimparPropriedades(this);

            if (File.Exists(this.NomeArquivoConfig))
            {
                try
                {
                    ObjectXMLSerializer objObjectXMLSerializer = new ObjectXMLSerializer();
                    ///
                    /// verifica se precisa de conversao para que a Deserializacao funcione
                    string temp = File.ReadAllText(this.NomeArquivoConfig, Encoding.UTF8);

                    if (temp.Contains("<nfe_configuracoes>") || temp.Contains("<CertificadoDigital>"))
                    {
                        File.WriteAllText(this.NomeArquivoConfig + ".old", temp);

                        //this.BuscaConfiguracao(this);
                        //objObjectXMLSerializer.Save(this, this.NomeArquivoConfig);

                        temp = temp.Replace("<nfe_configuracoes>", "<Empresa xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
                        temp = temp.Replace("</nfe_configuracoes>", "</Empresa>");
                        temp = temp.Replace(">False<", ">false<").Replace(">True<", ">true<");
                        if (!temp.Contains("<diretorioSalvarComo>"))
                        {
                            temp = temp.Replace("<DiretorioSalvarComo>", "<diretorioSalvarComo>").Replace("</DiretorioSalvarComo>", "</diretorioSalvarComo>");
                        }
                        temp = temp.Replace("<CertificadoDigital>", "<Certificado>").Replace("</CertificadoDigital>", "</Certificado>");
                        File.WriteAllText(this.NomeArquivoConfig, temp);
                    }
                    Empresa t = new Empresa();
                    t = (Empresa)objObjectXMLSerializer.Load(typeof(Empresa), this.NomeArquivoConfig);

                    if (!temp.Contains("<UsaCertificado>"))
                        t.UsaCertificado = true;
                    if (!temp.Contains("<FTPPassivo>"))
                        t.FTPPassivo = false;

                    if (t.UsaCertificado)
                    {
                        if (!t.CertificadoInstalado && !string.IsNullOrEmpty(t.CertificadoSenha))
                            t.CertificadoSenha = Criptografia.descriptografaSenha(t.CertificadoSenha);
                    }

                    t.CertificadoPIN = Criptografia.descriptografaSenha(t.CertificadoPIN);

                    t.Nome = this.Nome;
                    t.CNPJ = this.CNPJ;
                    t.Servico = this.Servico;
                    if (t.Servico != TipoAplicativo.Nfse)
                        t.UsaCertificado = true;

                    t.CopyObjectTo(this);

                    this.CriarPastasDaEmpresa();

                    this.X509Certificado = this.BuscaConfiguracaoCertificado();
                }
                catch (Exception ex)
                {
                    //Não vou mais fazer isso pois estava gerando problemas com Certificados A3 - Renan 18/06/2013
                    //empresa.Certificado = string.Empty;
                    //empresa.CertificadoThumbPrint = string.Empty;
                    throw new Exception("Ocorreu um erro ao efetuar a leitura das configurações da empresa " + this.Nome.Trim() + ". Por favor entre na tela de configurações desta empresa e reconfigure.\r\n\r\nErro: " + ex.Message);
                }
            }
        }