protected void SACheckEncoderReflect(SAMachine sam) { try { var checkedCheckbox = new[] { panel2 } .SelectMany(g => g.Controls.OfType <CheckBox>() .Where(r => r.Checked)); foreach (var c in checkedCheckbox) { c.Checked = false; } // Encoder[] grEncodes = sam.Encoders; foreach (Encoder item in grEncodes) { CheckBox ckButton = Controls.Find(item.Name, true).FirstOrDefault() as CheckBox; if (ckButton != null) { ckButton.Checked = Enabled; } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
protected void SARadioAdobeVersionReflect(SAMachine sam) { try { string radioName = SADefination.GetAdobeVersionByValue(sam.AdobeVersion); RadioButton rdButton = Controls.Find(radioName, true).FirstOrDefault() as RadioButton; if (rdButton != null) { rdButton.Checked = Enabled; } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void btnExport_Click(object sender, EventArgs e) { XmlRawTextWriter writer = new XmlRawTextWriter(FileName, Encoding.UTF8); try { XmlSerializer serializer = new XmlSerializer(typeof(ConfigInfo)); ConfigInfo ci = new ConfigInfo(); // create window server credential ServerInfo si = new ServerInfo(); si.IP = txtSCIPAddress.Text; si.IPAddress = txtSCIPAddress.Text; si.UserName = txtSCUserName.Text; si.Password = txtSCPassword.Text; si.ServicePath = txtSVServicePath.Text; SVServiceFolder[] svServiceFolderPaths = new SVServiceFolder[3]; int i = 0; foreach (string path in SVServiceFolderPaths) { SVServiceFolder svsf = new SVServiceFolder(); svsf.Path = Path.Combine(txtSVServicePath.Text, path); svServiceFolderPaths[i++] = svsf; } si.SVServicePaths = svServiceFolderPaths; // set ServerInfo and si to the same values ci.ServerInfo = si; // create SQL Server info SQLServer ss = new SQLServer(); ss.DataSource = txtDataSource.Text; ss.Catalog = txtCatalog.Text; ss.UserID = txtUserID.Text; ss.Password = txtPassword.Text; ss.ConnectionString = ""; ss.ConnectionStringStandardDataLibraryEntities = ""; ss.ConnectionStringTemplateEntities = ""; ss.ConnectionStringEmailConfigEntities = ""; ss.ConnectionStringResolution = ""; ss.ConnectionStringGMA_CategoryEntities = ""; ss.ConnectionStringEmailTemplateEntities = ""; ss.AppSettingValue = ""; ss.SessionState = ""; // set SQLServer and ss to the same values si.SQLServer = ss; // create Stand Alone Info StandAloneInfo sa = new StandAloneInfo(); sa.IP = txtSAIPAddress.Text; sa.IPAddress = txtSAIPAddress.Text; sa.UserName = txtSAUserName.Text; sa.Password = txtSAPassword.Text; sa.ServicePath = txtSAServicePath.Text; sa.WatchFolderRoot = txtWatchFolderRoot.Text; sa.SAWatchFolderPath = Path.Combine("\\\\", txtSAIPAddress.Text, "AE_PROCESSING\\AE_RENDER"); sa.SATempFolderPath = Path.Combine("\\\\", txtSAIPAddress.Text, "AE_PROCESSING\\TEMP_IMPORT"); sa.SATempFolderLocalPath = Path.Combine("\\\\", txtSAIPAddress.Text, "AE_PROCESSING\\TEMP_IMPORT");; WatchFolder[] watchFolderPaths = new WatchFolder[8]; i = 0; foreach (string path in WatchFolderPaths) { WatchFolder wf = new WatchFolder(); wf.Path = Path.Combine(txtWatchFolderRoot.Text, path); wf.NetworkPath = Path.Combine("\\", txtSAIPAddress.Text, path); watchFolderPaths[i++] = wf; } sa.WatchFolderPaths = watchFolderPaths; SAServiceFolder[] saServiceFolderPaths = new SAServiceFolder[5]; i = 0; foreach (string path in SAServiceFolderPaths) { SAServiceFolder sasf = new SAServiceFolder(); sasf.Path = Path.Combine(txtSAServicePath.Text, path); saServiceFolderPaths[i++] = sasf; } sa.SAServicePaths = saServiceFolderPaths; // create mission for Stand Alone Machine SAMachine sam = new SAMachine(); SADefination saDefine = new SADefination(); var checkedRadio = new[] { panel1 } .SelectMany(g => g.Controls.OfType <RadioButton>() .Where(r => r.Checked)); foreach (var c in checkedRadio) { saDefine.Mission = c.Name; saDefine.Type = c.Name; } var checkedCheckbox = new[] { panel2 } .SelectMany(g => g.Controls.OfType <CheckBox>() .Where(r => r.Checked)); Encoder[] grEncoders = new Encoder[6]; i = 0; foreach (var c in checkedCheckbox) { Encoder en = new Encoder(); en.ID = SADefination.GetResolutionByKey(c.Name, 1); en.Name = c.Name; en.WatchFolderName = SADefination.GetResolutionByKey(c.Name, 2); grEncoders[i++] = en; } sam.Encoders = grEncoders; if (rdAE.Checked == true) { sam.AEFQDN = txtAEfqdn.Text; } else if (rdME.Checked == true) { sam.MEFQDN = txtMEfqdn.Text; } else { sam.AEFQDN = txtAEfqdn.Text; sam.MEFQDN = txtMEfqdn.Text; } checkedRadio = new[] { panel3 } .SelectMany(g => g.Controls.OfType <RadioButton>() .Where(r => r.Checked)); foreach (var c in checkedRadio) { saDefine.AdobeVersion = c.Name; } sam.MachineName = Environment.MachineName; sam.Author = Environment.UserName; sam.Mission = saDefine.Mission; sam.Type = saDefine.Type; sam.AdobeVersion = saDefine.AdobeVersion; string tmpAEPath = GetPathNoneExe("AfterFX.exe"); if (!String.IsNullOrEmpty(tmpAEPath) && tmpAEPath.Contains(sam.AdobeVersion)) { sam.AEPath = tmpAEPath; sam.AEPathExe = GetPathForExe("AfterFX.exe"); sam.AEProcessName = Path.GetFileName(sam.AEPathExe).Replace(".exe", ""); sam.AEScriptPath = Path.Combine(sam.AEPath, "Scripts"); } string tmpMEPath = GetPathNoneExe("Adobe Media Encoder.exe"); if (!String.IsNullOrEmpty(tmpMEPath) && tmpMEPath.Contains(sam.AdobeVersion)) { sam.MEPath = tmpMEPath; sam.MEPathExe = GetPathForExe("Adobe Media Encoder.exe"); sam.MEProcessName = Path.GetFileName(sam.MEPathExe).Replace(".exe", ""); } List <string> listTemp; DBProcess db = new DBProcess(txtDataSource.Text, txtCatalog.Text, txtUserID.Text, txtPassword.Text); List <KeyValuePair <string, string> > listTempKeyValue = db.GetTempPath(); listTemp = listTempKeyValue.Where(x => x.Key == "TempFilePathExport").Select(x => x.Value).ToList(); sam.AEExportProjectPath = txtSAServicePath.Text + @"\\WindowsService\\GMA_SA_AE_ExportTemplateService\\" + listTemp[0].ToString(); listTemp = listTempKeyValue.Where(x => x.Key == "TempFilePathImport").Select(x => x.Value).ToList(); sam.AEProjectPath = txtSAServicePath.Text + @"\\WindowsService\\GMA_SA_AfterEffectService\\" + listTemp[0].ToString(); sa.SAMachine = sam; // set StandAloneInfo and sa to the same values ci.StandAloneInfo = sa; writer.Formatting = Formatting.Indented; writer.Indentation = 1; writer.IndentChar = '\t'; // Serialize the Configuration Information serializer.Serialize(writer, ci); MessageBox.Show("Export XML Done!"); } catch (Exception ex) { MessageBox.Show("Export Fail!"); AppEventLog.SALog(ex.Message); Console.WriteLine(ex.Message); } finally { writer.Close(); } }