Exemple #1
0
        private void ExportModules(string fileName)
        {
            try
            {
                var generatedModules = new List <string>();
                foreach (ImageListBoxItem item in lstModule.SelectedItems)
                {
                    using (var ctrlSA = new SAController())
                    {
                        string generatedModule;
                        if (item.Value is CodeInfo)
                        {
                            var code = item.Value as CodeInfo;
                            ctrlSA.ExecuteGenerateModulePackage(code.CodeValue, out generatedModule);
                            generatedModules.Add(generatedModule);
                        }
                        if (item.Value is ModuleInfo)
                        {
                            var module = item.Value as ModuleInfo;
                            ctrlSA.ExecuteGenerateModulePackage(module.ModuleID, out generatedModule);
                            generatedModules.Add(generatedModule);
                        }
                    }
                }

                var serilizer = new XmlSerializer(typeof(List <string>));
                var stream    = File.Open(fileName, FileMode.Create, FileAccess.Write);
                serilizer.Serialize(stream, generatedModules);
                stream.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateModule())
            {
                new WorkerThread(
                    delegate
                {
                    try
                    {
                        LockUserAction();

                        using (var client = new SAController())
                        {
                            string generatedPackage;
                            client.ExecuteGenerateModulePackage((string)this["C01"], out generatedPackage);

                            File.WriteAllText((string)this["C02"], generatedPackage, Encoding.UTF8);
                        }

                        CloseModule();
                    }
                    catch (Exception ex)
                    {
                        ShowError(ex);
                        UnLockUserAction();
                    }
                }
                    , this).Start();
            }
        }