1841 lines
66 KiB
C#
1841 lines
66 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Xml.Serialization;
|
|
using System.Xml;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading;
|
|
using System.Globalization;
|
|
using System.Security.Permissions;
|
|
using P4API;
|
|
using System.Security.Cryptography;
|
|
using System.Runtime.InteropServices;
|
|
using CrashDumpSender.BugTrackSystem.Implementations;
|
|
using System.Net.NetworkInformation;
|
|
using System.Collections;
|
|
using System.DirectoryServices;
|
|
using System.Drawing.Imaging;
|
|
using UAF;
|
|
|
|
|
|
namespace CrashDumpSender
|
|
{
|
|
public partial class CrashDumpSenderForm : Form
|
|
{
|
|
enum ReportIssueMode
|
|
{
|
|
CrashDump = 0,
|
|
Trac = 1
|
|
};
|
|
|
|
private bool sendAgain;
|
|
private bool cancelAll;
|
|
private string directoryDump = "";
|
|
private string fileDump = "";
|
|
private string clVersion = "";
|
|
private string serverDumpLocation = Properties.Settings.Default.DumpsLocation;
|
|
private string serverSymbol = Properties.Settings.Default.SymbolStore;
|
|
private string defaultOwner = Properties.Settings.Default.DefaultOwner;
|
|
private string defaultCC = Properties.Settings.Default.DefaultCC;
|
|
private string directoryExe = "";
|
|
private string depotBuildMachine = Properties.Settings.Default.BuildMachineLocalWorkspace;
|
|
private string userName = "";
|
|
private string crcStack = "";
|
|
private string dumpFileStr = "";
|
|
private bool sendDone = false;
|
|
// private string code = "";
|
|
private string screenShot = null;
|
|
Thread trdEncoding = null;
|
|
IntPtr mainEncodingWindow = IntPtr.Zero;
|
|
string aviFilename = "";
|
|
string imageScr = @"";
|
|
string avidemuxDirectory = "";
|
|
string PerforceDepot = Properties.Settings.Default.PerforceDepot;
|
|
string defaultPlatformModule = Properties.Settings.Default.PlatformModule;
|
|
string defaultMilestone = Properties.Settings.Default.Milestone;
|
|
string defaultSeverity = Properties.Settings.Default.Severity;
|
|
string defaultProbability = Properties.Settings.Default.Probability;
|
|
string defaultTechnicalReproducibility = Properties.Settings.Default.TechnicalReproducibility;
|
|
string defaultComponent = Properties.Settings.Default.Component;
|
|
int maxStackLines = Properties.Settings.Default.MaxStackLines;
|
|
|
|
IBugTracksystem BugTracking = null;
|
|
CopyDisplay MyCopyDisplay;
|
|
SourceEncoder m_aviDemuxEncoder = null;
|
|
|
|
public class TracAttributesSaved
|
|
{
|
|
public string summary = "";
|
|
public string Sid_Owner = "";
|
|
public string Sid_CC = "";
|
|
public string component = "";
|
|
public string priority = "";
|
|
public string milestone = "";
|
|
public string type = "";
|
|
};
|
|
|
|
TracAttributesSaved tracAttributesSaved = new TracAttributesSaved();
|
|
|
|
VideoPlayer videoPlayer = null;
|
|
Process processEncoding = null;
|
|
|
|
readonly string AVIDEMUX = "avidemux";
|
|
|
|
ReportIssueMode reportIssueMode = ReportIssueMode.CrashDump;
|
|
|
|
class ThreadEncodingParameters
|
|
{
|
|
public int StartFrame = 0;
|
|
public int EndFrame = 0;
|
|
public int MaxFrame = 0;
|
|
public string encoderProcess = "";
|
|
public string encoderType = "";
|
|
};
|
|
|
|
ThreadEncodingParameters threadEncodingParameters = new ThreadEncodingParameters();
|
|
|
|
public bool checkProcessRunning()
|
|
{
|
|
#if DEBUG
|
|
return true;
|
|
|
|
#else
|
|
String ModuleName = Process.GetCurrentProcess().MainModule.ModuleName;
|
|
String ProcName = System.IO.Path.GetFileNameWithoutExtension(ModuleName);
|
|
Process[] Proc = Process.GetProcessesByName(ProcName);
|
|
return (Proc.Length == 1);
|
|
#endif
|
|
}
|
|
|
|
public class userSettings
|
|
{
|
|
public string mail;
|
|
public bool enable = false;
|
|
}
|
|
|
|
private List<userSettings> userList = new List<userSettings>();
|
|
|
|
public CrashDumpSenderForm()
|
|
{
|
|
|
|
}
|
|
|
|
string GetMyUserLDAPProperty(string Filter)
|
|
{
|
|
DirectoryEntry MyEntry = new DirectoryEntry("LDAP://ubisoft.org");
|
|
DirectorySearcher MyUser = new DirectorySearcher(MyEntry, "(SAMAccountName=" + System.Environment.UserName + ")");
|
|
SearchResult OneResult = MyUser.FindOne();
|
|
MyEntry = OneResult.GetDirectoryEntry();
|
|
object Result = MyEntry.Properties[Filter].Value;
|
|
return (string)Result;
|
|
}
|
|
|
|
public class CopyResultString
|
|
{
|
|
public string aviFilename = null;
|
|
public string serverName = null;
|
|
};
|
|
|
|
public string getTemporaryFolder()
|
|
{
|
|
string tmp = !string.IsNullOrEmpty(EnginePath.BinPath) ? EnginePath.BinPath : Directory.GetCurrentDirectory();
|
|
if (!tmp.Contains("UA_Bin"))
|
|
{
|
|
throw new System.Exception("Please set your working folder properly, it should contain \"UA_Bin\"");
|
|
}
|
|
return tmp.Replace("UA_Bin", @"UA_BinExternal\temp");
|
|
}
|
|
|
|
|
|
public void generateAvidemuxPath()
|
|
{
|
|
string tmp = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
|
|
avidemuxDirectory = tmp.Replace("UA_Bin", "UA_BinExternal");
|
|
avidemuxDirectory += @"\avidemux";
|
|
}
|
|
|
|
private static FileInfo[] GetMergedArray(FileInfo[] originalArray, FileInfo[] newArray)
|
|
{
|
|
int startIndexForNewArray = originalArray.Length;
|
|
Array.Resize<FileInfo>(ref originalArray, originalArray.Length + newArray.Length);
|
|
newArray.CopyTo(originalArray, startIndexForNewArray);
|
|
return originalArray;
|
|
}
|
|
|
|
class SourceEncoder
|
|
{
|
|
public SourceEncoder(string _name,string _encoder)
|
|
{
|
|
name = _name;
|
|
encoderType = _encoder;
|
|
}
|
|
|
|
public override string ToString() { return name; }
|
|
public string getEncoderType() { return encoderType; }
|
|
|
|
protected string name;
|
|
protected string encoderType;
|
|
|
|
}
|
|
|
|
public void initEncoder()
|
|
{
|
|
m_aviDemuxEncoder = new SourceEncoder("x264-MP4", AVIDEMUX);
|
|
}
|
|
|
|
public bool init(string[] args)
|
|
{
|
|
InitializeComponent();
|
|
generateAvidemuxPath();
|
|
|
|
|
|
cleanUpTempDirectories();
|
|
|
|
initEncoder();
|
|
|
|
if (BugTracking == null)
|
|
{
|
|
// BugTracking = new TracImplementation();
|
|
BugTracking = new JiraImplementation();
|
|
}
|
|
|
|
//force the name
|
|
|
|
userName = GetMyUserLDAPProperty("mail");
|
|
|
|
if (File.Exists("CrashDumpSettings.xml"))
|
|
{
|
|
XmlDocument doc = new System.Xml.XmlDocument();
|
|
doc.Load("CrashDumpSettings.xml");
|
|
XmlNode root = doc.ChildNodes[0];
|
|
|
|
XmlNode nodeOptions = root["mail"];
|
|
|
|
if (nodeOptions != null)
|
|
userName = nodeOptions.ChildNodes[0].Value;
|
|
|
|
}
|
|
|
|
if (args.Length>=1)
|
|
{
|
|
string command = args[0];
|
|
if (command == "TRACMODE")
|
|
{
|
|
reportIssueMode = ReportIssueMode.Trac;
|
|
}
|
|
}
|
|
|
|
boxMailUser.Text = userName;
|
|
|
|
directoryExe = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
|
|
directoryExe = directoryExe.Replace("file:\\", "");
|
|
|
|
//open crash dump info;
|
|
|
|
string dst = "";
|
|
|
|
if (File.Exists("dumpInfo.txt"))
|
|
{
|
|
readFromFile(ref dst, "dumpInfo.txt");
|
|
dumpFileStr = dst;
|
|
}
|
|
|
|
string callStackForHash = "";
|
|
if (dumpFileStr == "")
|
|
{
|
|
callStackForHash = DateTime.Now.ToString();
|
|
}
|
|
else
|
|
{
|
|
string[] callstckStrLine = Regex.Split(dumpFileStr, "\n");
|
|
|
|
callStackForHash = "";
|
|
int i = 0;
|
|
if (callstckStrLine.Length >= 1)
|
|
{
|
|
if (callstckStrLine[0].Contains("ITF::AssertManager::Crash")
|
|
&& !string.IsNullOrWhiteSpace(callstckStrLine[1]))
|
|
{
|
|
i++;
|
|
maxStackLines++;
|
|
}
|
|
}
|
|
|
|
// We just look at the first <maxStackLines> lines for hashing it
|
|
while (i < maxStackLines && i < callstckStrLine.Length)
|
|
{
|
|
callStackForHash += CleanStackTrace(callstckStrLine[i]);
|
|
i++;
|
|
}
|
|
|
|
}
|
|
|
|
crcStack = HashWithMD5(callStackForHash);
|
|
|
|
textBoxInfoDump.Text = dst;
|
|
|
|
string tmp = "";
|
|
|
|
for (int index = 0; index < args.Length; ++index)
|
|
{
|
|
tmp += args[index];
|
|
tmp += ";";
|
|
}
|
|
|
|
textBoxArgsList.Text = tmp;
|
|
|
|
if (reportIssueMode == ReportIssueMode.CrashDump)
|
|
{
|
|
if (args.Length >= 3)
|
|
{
|
|
directoryDump = args[0];
|
|
fileDump = args[1];
|
|
clVersion = (int.Parse(args[2]).ToString());
|
|
textBoxChangeList.Text = clVersion;
|
|
}
|
|
|
|
if (args.Length >= 4)
|
|
{
|
|
imageScr = args[3];
|
|
}
|
|
|
|
groupBoxTrac.Visible = false;
|
|
}
|
|
else if (reportIssueMode == ReportIssueMode.Trac)
|
|
{
|
|
getAllUsers();
|
|
GetAllComponents();
|
|
GetAllPriorities();
|
|
getAllTypes();
|
|
GetAllMilestones();
|
|
|
|
if (args.Length >= 2)
|
|
{
|
|
clVersion = (int.Parse(args[1]).ToString());
|
|
textBoxChangeList.Text = clVersion;
|
|
}
|
|
|
|
if (args.Length >= 3)
|
|
{
|
|
imageScr = args[2];
|
|
}
|
|
}
|
|
|
|
if (File.Exists(imageScr) == true)
|
|
{
|
|
/* if (MessageBox.Show("A video is available ,do you want to encode it ?", "Video", MessageBoxButtons.OKCancel) == DialogResult.OK)
|
|
{
|
|
encodeMovie();
|
|
}
|
|
*/
|
|
}
|
|
else
|
|
{
|
|
groupBoxVideo.Visible = false;
|
|
}
|
|
/*
|
|
getCode(ref code);
|
|
|
|
textBoxInfoDump.Text += "\r\n";
|
|
textBoxInfoDump.Text += "----------------------------------------------------------------------------------------------------------------------------------------\r\n";
|
|
textBoxInfoDump.Text += "\r\n";
|
|
textBoxInfoDump.Text += code;
|
|
*/
|
|
switchReportMode(reportIssueMode);
|
|
return true;
|
|
}
|
|
|
|
string CleanStackTrace(string stackline)
|
|
{
|
|
string result = stackline.ToLower();
|
|
int nbchar = depotBuildMachine.Length;
|
|
if (!depotBuildMachine.EndsWith("\\") || !depotBuildMachine.EndsWith("/"))
|
|
{
|
|
nbchar++;
|
|
}
|
|
if (result.StartsWith(depotBuildMachine))
|
|
{
|
|
result = result.Remove(0, nbchar);
|
|
}
|
|
|
|
// We remove the line number, they would easily produce a different hash
|
|
Regex rgStackLine = new Regex(@"([\w\\\.]+)\(\d+\)(.*)");
|
|
Match m = rgStackLine.Match(result);
|
|
if (m.Success)
|
|
return m.Groups[1].Value + m.Groups[2].Value;
|
|
else
|
|
return result;
|
|
}
|
|
|
|
void cleanUpTempDirectories()
|
|
{
|
|
//parse the temp directory and clean according the history
|
|
String temp = getTemporaryFolder();
|
|
DirectoryInfo di = new DirectoryInfo(temp);
|
|
|
|
if (!di.Exists)//nothing to clean
|
|
return;
|
|
|
|
FileInfo[] rgFiles = di.GetFiles("*.*",SearchOption.AllDirectories);
|
|
|
|
//sort them by date
|
|
|
|
Array.Sort(rgFiles, delegate(FileInfo f1, FileInfo f2)
|
|
{
|
|
return f2.LastWriteTime.CompareTo(f1.LastWriteTime);
|
|
});
|
|
|
|
|
|
//keep the last 5
|
|
int count = rgFiles.Length;
|
|
int keepFiles = 5;
|
|
|
|
try
|
|
{
|
|
for (int index = keepFiles; index < count; ++index)
|
|
{
|
|
File.Delete(rgFiles[index].FullName);
|
|
|
|
}
|
|
}
|
|
catch (System.Exception )
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void switchReportMode(ReportIssueMode mode)
|
|
{
|
|
switch (mode)
|
|
{
|
|
case ReportIssueMode.Trac:
|
|
{
|
|
textBoxInfoDump.Visible = false;
|
|
listBoxUser.Visible = false;
|
|
|
|
Text = "Create Trac";
|
|
|
|
ClientSize = new Size(ClientSize.Width,textBoxInfoDump.Top);
|
|
}
|
|
break;
|
|
case ReportIssueMode.CrashDump:
|
|
{
|
|
screenShot = directoryDump + @"/" + fileDump + ".bmp";
|
|
if (File.Exists(screenShot))
|
|
{
|
|
// this.Size = new System.Drawing.Size(1768, this.Height);
|
|
pictureBox1.ImageLocation = screenShot;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void getAllTypes()
|
|
{
|
|
//get all users
|
|
List<String> types = BugTracking.getAllTypes();
|
|
|
|
foreach (string type in types)
|
|
{
|
|
comboBoxType.Items.Add(type);
|
|
}
|
|
|
|
comboBoxType.SelectedIndex = 0;
|
|
}
|
|
|
|
|
|
public void getAllUsers()
|
|
{
|
|
//get all users
|
|
List<String> users = BugTracking.getAllUsers();
|
|
|
|
foreach (string user in users)
|
|
{
|
|
comboBoxOwner.Items.Add(user);
|
|
comboBoxCC.Items.Add(user);
|
|
}
|
|
|
|
comboBoxCC.Text = defaultCC;
|
|
comboBoxOwner.Text = defaultOwner;
|
|
|
|
}
|
|
|
|
public void GetAllComponents()
|
|
{
|
|
List<String> components = BugTracking.GetAllComponents();
|
|
|
|
foreach (string component in components)
|
|
comboBoxComponent.Items.Add(component);
|
|
|
|
comboBoxComponent.SelectedIndex = 0;
|
|
}
|
|
|
|
public void GetAllPriorities()
|
|
{
|
|
//get all priorities
|
|
List<String> priorities = BugTracking.GetAllPriorities();
|
|
|
|
foreach (string priority in priorities)
|
|
comboBoxPriority.Items.Add(priority);
|
|
|
|
comboBoxPriority.SelectedIndex = 0;
|
|
}
|
|
|
|
public void GetAllMilestones()
|
|
{
|
|
//get all milestones
|
|
List<String> milestones = BugTracking.GetAllMilestones();
|
|
|
|
foreach (string milestone in milestones)
|
|
comboBoxMilestone.Items.Add(milestone);
|
|
|
|
int indexVersion = comboBoxMilestone.Items.IndexOf(defaultMilestone);
|
|
if (indexVersion==-1)
|
|
comboBoxMilestone.SelectedIndex = 0;
|
|
else
|
|
comboBoxMilestone.SelectedIndex = indexVersion;
|
|
}
|
|
|
|
static void readFromFile(ref string dst, string filename)
|
|
{
|
|
StreamReader SR;
|
|
string S;
|
|
SR = File.OpenText(filename);
|
|
S = SR.ReadLine();
|
|
while (S != null)
|
|
{
|
|
dst += S;
|
|
dst += "\r\n";
|
|
S = SR.ReadLine();
|
|
}
|
|
SR.Close();
|
|
}
|
|
|
|
|
|
protected string users = "";
|
|
protected string subject = "";
|
|
protected string body = "";
|
|
|
|
public void clean()
|
|
{
|
|
users = "";
|
|
subject = "";
|
|
body = "";
|
|
}
|
|
|
|
public void addUser(string _user)
|
|
{
|
|
if (users.Length > 0)
|
|
users += ";";
|
|
|
|
users += _user;
|
|
|
|
}
|
|
|
|
public void setSubject(string _subject)
|
|
{
|
|
subject = _subject;
|
|
}
|
|
|
|
public void addBody(string _body)
|
|
{
|
|
body += _body;
|
|
}
|
|
|
|
public void addLinkDump(string title,string link)
|
|
{
|
|
body += "\r\n";
|
|
body += title + @": file://" + link;
|
|
body += "\r\n";
|
|
}
|
|
|
|
public void addClVersion(string clVersion)
|
|
{
|
|
body += "\r\n";
|
|
body += @"Change list: " + clVersion;
|
|
body += "\r\n";
|
|
}
|
|
|
|
public void addCrashDump(string crashdump)
|
|
{
|
|
body += "\r\n";
|
|
body += "--------------------------------------------------------------------------------------------\r\n";
|
|
body += "CrashDump:\r\n";
|
|
body += crashdump;
|
|
}
|
|
|
|
public void addComments(string comments)
|
|
{
|
|
body += "\r\n";
|
|
body += "--------------------------------------------------------------------------------------------\r\n";
|
|
body += "Comments:\r\n";
|
|
body += comments;
|
|
}
|
|
|
|
|
|
public void addStepToReproduce(string reproduce)
|
|
{
|
|
body += "\r\n";
|
|
body += "--------------------------------------------------------------------------------------------\r\n";
|
|
body += "StepToReproduce:\r\n";
|
|
body += reproduce;
|
|
}
|
|
|
|
public void send()
|
|
{
|
|
cancelAll = false;
|
|
CopyResultString resultCopied = null;
|
|
|
|
if (reportIssueMode == ReportIssueMode.CrashDump)
|
|
{
|
|
resultCopied = copyFiles();
|
|
}
|
|
else
|
|
{
|
|
resultCopied = copyVideo();
|
|
}
|
|
|
|
if (cancelAll) return ;
|
|
|
|
string ticketId;
|
|
string description;
|
|
|
|
do
|
|
{
|
|
sendAgain = false;
|
|
description = "";
|
|
if (resultCopied != null)
|
|
{
|
|
if (resultCopied.serverName != null)
|
|
{
|
|
addLinkDump("Dump location", resultCopied.serverName);
|
|
|
|
description += "*Crashdump location:* " + "file://" + resultCopied.serverName.Replace(@"\\", "").Replace(@"\", "/");
|
|
description += "\n\n";
|
|
}
|
|
|
|
if (resultCopied.aviFilename != null)
|
|
{
|
|
description += "*Movie location:* " + "file://" + resultCopied.aviFilename.Replace("\\", "/");
|
|
description += "\n\n";
|
|
|
|
addLinkDump("Movie location", resultCopied.aviFilename.Replace("\\", "/"));
|
|
|
|
//check if the file is copied on the server and delete it locally
|
|
//... keep it until version is stable
|
|
}
|
|
}
|
|
ticketId = "";
|
|
BugInfo bug = new BugInfo();
|
|
try
|
|
{
|
|
if (reportIssueMode == ReportIssueMode.Trac)
|
|
{
|
|
description += "\r\n\r\n--Comments:\r\n--";
|
|
description += textBoxComment.Text;
|
|
|
|
description += "\r\n\r\n--Steps to reproduce:\r\n--";
|
|
description += textBoxStepToRepro.Text;
|
|
|
|
bug.changelist = clVersion;
|
|
bug.summary = tracAttributesSaved.summary;
|
|
bug.priority = tracAttributesSaved.priority;
|
|
bug.milestone = tracAttributesSaved.milestone;
|
|
bug.component = tracAttributesSaved.component;
|
|
bug.type = tracAttributesSaved.type;
|
|
bug.description = description;
|
|
bug.assignee = tracAttributesSaved.Sid_Owner;
|
|
|
|
if (bug.assignee == null || bug.assignee == String.Empty)
|
|
bug.assignee = defaultOwner;
|
|
|
|
bug.cc = tracAttributesSaved.Sid_CC;
|
|
ticketId = BugTracking.AddIssue(bug);
|
|
|
|
string tracMsg = "";
|
|
if (!string.IsNullOrEmpty(ticketId))
|
|
tracMsg = "The ticket has been created : " + ticketId.ToString();
|
|
else
|
|
tracMsg = "The ticket creation failed";
|
|
|
|
MessageBox.Show(tracMsg,"Ticket result");
|
|
}
|
|
else
|
|
{
|
|
// The summary will show the deepest function in the callstack, without the file path (but with the path name)
|
|
string deepestFunction = dumpFileStr.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)[0];
|
|
string[] splitLine = deepestFunction.Split('\\');
|
|
string summary = string.Concat("[UAF] [CL", clVersion, "] [CRASH] ", deepestFunction.Split('\\')[splitLine.Length - 1]);
|
|
|
|
description += "*Comments:*\n";
|
|
description += textBoxComment.Text;
|
|
|
|
bug.comments = dumpFileStr + description;
|
|
|
|
// Code blame doesn't work for now
|
|
//description += ("\n\n" + code);
|
|
bug.changelist = clVersion;
|
|
bug.summary = summary;
|
|
bug.MD5 = crcStack;
|
|
bug.reporter = boxMailUser.Text;
|
|
bug.callstack = dumpFileStr;
|
|
bug.severity = defaultSeverity;
|
|
bug.probability = defaultProbability;
|
|
bug.milestone = defaultMilestone;
|
|
bug.component = defaultComponent;
|
|
bug.type = tracAttributesSaved.type;
|
|
bug.description = description;
|
|
bug.platformModule = defaultPlatformModule;
|
|
bug.technicalReproducibility = defaultTechnicalReproducibility;
|
|
bug.stepsToReproduce = textBoxStepToRepro.Text;
|
|
// bug.attachements = new string[] { dumpFileStr };
|
|
bug.attachements = null;
|
|
if (chkAddScreen.Checked && (screenShot != null && File.Exists(screenShot)))
|
|
{
|
|
var qualityEncoder = System.Drawing.Imaging.Encoder.Quality;
|
|
var quality = (long)100;
|
|
var ratio = new EncoderParameter(qualityEncoder, quality );
|
|
var codecParams = new EncoderParameters(1);
|
|
codecParams.Param[0] = ratio;
|
|
var jpegCodecInfo = (from x in ImageCodecInfo.GetImageEncoders() where x.MimeType == "image/jpeg" select x).Single();
|
|
//var jpegCodecInfo = <one of the codec infos from ImageCodecInfo.GetImageEncoders() with mime type = "image/jpeg">;
|
|
|
|
|
|
Bitmap bmp = new Bitmap(screenShot);
|
|
string fileName = screenShot.Replace(".bmp",".jpg");
|
|
bmp.Save(fileName, jpegCodecInfo, codecParams); // Save to JPG
|
|
bug.attachements = new string[] { fileName };
|
|
}
|
|
bug.assignee = defaultOwner;
|
|
bug.cc = tracAttributesSaved.Sid_CC;
|
|
ticketId = BugTracking.AddCrash(bug);
|
|
|
|
if (BugTracking.IssueIsFixed() == null)
|
|
{
|
|
string tracMsg = "";
|
|
if (!string.IsNullOrEmpty(ticketId))
|
|
tracMsg = "An issue has been created : " + ticketId.ToString() + "\n" + BugTracking.GetLinkToIssue(ticketId.ToString());
|
|
else
|
|
tracMsg = "The ticket creation failed";
|
|
MessageBox.Show(tracMsg, "Ticket result");
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
File.WriteAllText("crashdumperror.txt", ex.ToString());
|
|
|
|
Retry RetryForm = new Retry("JIRA sending FAILED");
|
|
RetryForm.ShowDialog();
|
|
sendAgain = RetryForm.bRetry;
|
|
cancelAll = RetryForm.bStop;
|
|
}
|
|
finally { }
|
|
}
|
|
while (sendAgain);
|
|
if (cancelAll) return ;
|
|
|
|
if (reportIssueMode == ReportIssueMode.CrashDump)
|
|
{
|
|
string fixVersion = BugTracking.IssueIsFixed();
|
|
if (fixVersion != null)
|
|
{
|
|
MessageBox.Show("The issue you have reported has been fixed (or will be fixed) in a later version of the engine (Version >=" + fixVersion + ")");
|
|
}
|
|
else
|
|
{
|
|
// E-mail sending is deactivated for the moment
|
|
|
|
/*
|
|
do
|
|
{
|
|
sendAgain = false;
|
|
|
|
addUser(userName);
|
|
|
|
setSubject("CrashDump report with changelist " + textBoxChangeList.Text);
|
|
|
|
addCrashDump(textBoxInfoDump.Text);
|
|
addComments(textBoxComment.Text);
|
|
addStepToReproduce(textBoxStepToRepro.Text);
|
|
string BugTrackName = BugTracking.GetName();
|
|
string message = "";
|
|
message += "to: ";
|
|
message += users;
|
|
message += "\r\n";
|
|
message += "subject: ";
|
|
|
|
message += subject + " " + BugTrackName + " #" + ticketId.ToString();
|
|
message += "\r\n";
|
|
message += "\r\n";
|
|
message += BugTrackName + " #" + ticketId.ToString() + " " + BugTracking.GetLinkToIssue(ticketId);
|
|
message += body;
|
|
|
|
StreamWriter SW;
|
|
SW = File.CreateText("mail.txt");
|
|
SW.Write(message);
|
|
SW.Close();
|
|
|
|
ProcessStartInfo startInfo = new ProcessStartInfo(@"sendmail.bat", "");
|
|
startInfo.UseShellExecute = false;
|
|
|
|
try
|
|
{
|
|
Process process = Process.Start(startInfo);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
Retry RetryForm = new Retry("mail sending FAILED");
|
|
RetryForm.ShowDialog();
|
|
sendAgain = RetryForm.bRetry;
|
|
cancelAll = RetryForm.bStop;
|
|
}
|
|
}
|
|
while (sendAgain);
|
|
*/
|
|
}
|
|
}
|
|
}
|
|
|
|
public CopyResultString copyVideo()
|
|
{
|
|
do
|
|
{
|
|
sendAgain = false;
|
|
try
|
|
{
|
|
string uniquename = System.Guid.NewGuid().ToString();
|
|
|
|
string dumpServerFullPath = serverDumpLocation + @"/" + uniquename;
|
|
Directory.CreateDirectory(dumpServerFullPath + @"/" + fileDump);
|
|
|
|
if (aviFilename != "")
|
|
{
|
|
CopyResultString copyResult = new CopyResultString();
|
|
copyResult.aviFilename = dumpServerFullPath + @"\movieCrash.avi";
|
|
File.Copy(aviFilename, copyResult.aviFilename, true);
|
|
return copyResult;
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
File.WriteAllText("crashdumperror.txt", ex.ToString());
|
|
|
|
Retry RetryForm = new Retry("movieCrash sending FAILED");
|
|
RetryForm.ShowDialog();
|
|
sendAgain = RetryForm.bRetry;
|
|
cancelAll = RetryForm.bStop;
|
|
}
|
|
finally { }
|
|
}
|
|
while (sendAgain);
|
|
|
|
return null;
|
|
}
|
|
|
|
private CopyResultString copyFiles()
|
|
{
|
|
CopyResultString copyResult = new CopyResultString();
|
|
if (serverDumpLocation != null)
|
|
{
|
|
string dumpServerFullPath = Path.Combine(serverDumpLocation, fileDump);
|
|
string currentServerSymbol = Path.Combine(serverSymbol, clVersion.ToString());
|
|
|
|
//copy crash dump file.PDB
|
|
do
|
|
{
|
|
sendAgain = false;
|
|
try
|
|
{
|
|
string src = Path.Combine(directoryDump, fileDump + ".dmp");
|
|
string dst = Path.Combine(dumpServerFullPath, fileDump + ".dmp");
|
|
|
|
Directory.CreateDirectory(Path.Combine(serverDumpLocation, fileDump));
|
|
if (!File.Exists(src) || new FileInfo(src).Length == 0)
|
|
{
|
|
if (File.Exists("dumpInfo.txt"))
|
|
File.Copy("dumpInfo.txt", Path.Combine(dumpServerFullPath, "dumpInfo.txt"));
|
|
}
|
|
|
|
File.Copy(src, dst, true);
|
|
File.Delete(src);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
File.WriteAllText("crashdumperror.txt", ex.ToString());
|
|
|
|
Retry RetryForm = new Retry("crash dump sending FAILED");
|
|
RetryForm.ShowDialog();
|
|
sendAgain = RetryForm.bRetry;
|
|
cancelAll = RetryForm.bStop;
|
|
}
|
|
finally { }
|
|
}
|
|
while (sendAgain);
|
|
|
|
if (cancelAll) return null;
|
|
|
|
//copy win32_ITF_Techno_r.PDB
|
|
do
|
|
{
|
|
sendAgain = false;
|
|
try
|
|
{
|
|
string srcPDB = Path.Combine(currentServerSymbol, "win32_ITF_AppFramework_r.pdb");
|
|
string dstPDB = Path.Combine(dumpServerFullPath, "win32_ITF_AppFramework_r.pdb");
|
|
File.Copy(srcPDB, dstPDB, true);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
File.WriteAllText("crashdumperror.txt", ex.ToString());
|
|
|
|
Retry RetryForm = new Retry("win32_ITF_Techno_r.PDB sending FAILED");
|
|
RetryForm.ShowDialog();
|
|
sendAgain = RetryForm.bRetry;
|
|
cancelAll = RetryForm.bStop;
|
|
}
|
|
finally { }
|
|
}
|
|
while (sendAgain);
|
|
|
|
if (cancelAll) return null;
|
|
|
|
//copy win32_ITF_Techno_r.exe
|
|
do
|
|
{
|
|
sendAgain = false;
|
|
try
|
|
{
|
|
string srcEXE = Path.Combine(currentServerSymbol, "win32_ITF_AppFramework_r.exe");
|
|
string dstEXE = Path.Combine(dumpServerFullPath, "win32_ITF_AppFramework_r.exe");
|
|
File.Copy(srcEXE, dstEXE, true);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
File.WriteAllText("crashdumperror.txt", ex.ToString());
|
|
|
|
Retry RetryForm = new Retry("win32_ITF_Techno_r.exe sending FAILED");
|
|
RetryForm.ShowDialog();
|
|
sendAgain = RetryForm.bRetry;
|
|
cancelAll = RetryForm.bStop;
|
|
}
|
|
finally { }
|
|
}
|
|
while (sendAgain);
|
|
|
|
if (cancelAll) return null;
|
|
|
|
|
|
//copy UA_Engine.exe
|
|
do
|
|
{
|
|
sendAgain = false;
|
|
try
|
|
{
|
|
string srcEXE = Path.Combine(currentServerSymbol, "UA_Engine.exe");
|
|
string dstEXE = Path.Combine(dumpServerFullPath, @"UA_Engine.exe");
|
|
File.Copy(srcEXE, dstEXE, true);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
File.WriteAllText("crashdumperror.txt", ex.ToString());
|
|
|
|
Retry RetryForm = new Retry("UA_Engine.exe sending FAILED");
|
|
RetryForm.ShowDialog();
|
|
sendAgain = RetryForm.bRetry;
|
|
cancelAll = RetryForm.bStop;
|
|
}
|
|
finally { }
|
|
}
|
|
while (sendAgain);
|
|
if (cancelAll) return null;
|
|
|
|
//copy the movie is available
|
|
do
|
|
{
|
|
sendAgain = false;
|
|
try
|
|
{
|
|
if (aviFilename != "")
|
|
{
|
|
copyResult.aviFilename = Path.Combine(dumpServerFullPath, "movieCrash.avi");
|
|
File.Copy(aviFilename, copyResult.aviFilename, true);
|
|
}
|
|
copyResult.serverName = dumpServerFullPath;
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
File.WriteAllText("crashdumperror.txt", ex.ToString());
|
|
|
|
Retry RetryForm = new Retry("movie sending FAILED");
|
|
RetryForm.ShowDialog();
|
|
sendAgain = RetryForm.bRetry;
|
|
cancelAll = RetryForm.bStop;
|
|
}
|
|
finally { }
|
|
}
|
|
while (sendAgain);
|
|
}
|
|
return copyResult;
|
|
}
|
|
|
|
private void getCode(ref string code)
|
|
{
|
|
P4Connection p4 = null;
|
|
string tmpFile = Path.Combine(directoryExe, "0x45487av.tmp");
|
|
int lineNumber = 0;
|
|
|
|
try
|
|
{
|
|
p4 = new P4Connection();
|
|
p4.Port = "10.0.0.20:1744";
|
|
p4.User = "benjamin.calvot";
|
|
p4.Client = "MRC-WKS-038873_VERSIONING";
|
|
|
|
p4.Connect();
|
|
p4.Login("benjamin.calvot_00");
|
|
|
|
|
|
if (File.Exists(tmpFile))
|
|
{
|
|
File.SetAttributes(tmpFile, ~FileAttributes.ReadOnly);
|
|
File.Delete(tmpFile);
|
|
}
|
|
|
|
if (textBoxInfoDump.TextLength > 0)
|
|
{
|
|
string[] lines = Regex.Split(textBoxInfoDump.Text, "\r\n");
|
|
string IncriminatedUser = "";
|
|
if (lines.Length > 0)
|
|
{
|
|
string fileToSync = "";
|
|
string lineCall = "";
|
|
if (lines.Length >= 1)
|
|
{
|
|
if (lines[0].Contains("ITF::AssertManager::Crash")
|
|
&& !string.IsNullOrWhiteSpace(lines[1]))
|
|
lineCall = lines[1];
|
|
else
|
|
lineCall = lines[0];
|
|
|
|
}
|
|
|
|
|
|
string cl = textBoxChangeList.Text;
|
|
|
|
string clLastFile = "";//debug
|
|
|
|
int indexLine = lineCall.IndexOf("(");
|
|
|
|
|
|
if (indexLine != -1)
|
|
{
|
|
int endLine = lineCall.IndexOf(")");
|
|
string slinenumber = lineCall.Substring(indexLine + 1, endLine - indexLine - 1);
|
|
lineNumber = int.Parse(slinenumber) - 1;//-1 because line start at 1er
|
|
}
|
|
|
|
|
|
int index = lineCall.IndexOf(" ");
|
|
if (index != -1)
|
|
{
|
|
fileToSync = lineCall.Substring(0, indexLine);
|
|
fileToSync = fileToSync.ToLower();
|
|
fileToSync = fileToSync.Replace(depotBuildMachine.ToLower(), PerforceDepot.Replace("/...", ""));
|
|
fileToSync = fileToSync.Replace("\\", "/");
|
|
fileToSync = fileToSync.ToLower();
|
|
|
|
string extension = Path.GetExtension(fileToSync);
|
|
|
|
string fullStat = PerforceDepot+"/*" + extension;
|
|
|
|
P4RecordSet fstats = p4.Run("files", fullStat);
|
|
|
|
bool found = false;
|
|
foreach (P4Record stat in fstats)
|
|
{
|
|
{
|
|
string tmp = stat["depotFile"].ToLower();
|
|
|
|
if (tmp == fileToSync)
|
|
{
|
|
string filename = stat["depotFile"];
|
|
Console.WriteLine(filename);
|
|
fileToSync = filename;
|
|
clLastFile = stat["change"];
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (found)
|
|
{
|
|
//P4RecordSet changes =
|
|
p4.Run("print", "-o", tmpFile, "-q", fileToSync + "@" + cl);
|
|
|
|
try
|
|
{
|
|
string IncriminatedCL = "";
|
|
Process p4Annotate = new Process();
|
|
p4Annotate.StartInfo.UseShellExecute = false;
|
|
p4Annotate.StartInfo.FileName = "p4.exe";
|
|
p4Annotate.StartInfo.Arguments = string.Format("annotate -q -c \"{0}@{1}\"", fileToSync, cl);
|
|
p4Annotate.StartInfo.RedirectStandardError = true;
|
|
p4Annotate.StartInfo.RedirectStandardOutput = true;
|
|
p4Annotate.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
p4Annotate.StartInfo.CreateNoWindow = true;
|
|
if (p4Annotate.StartInfo.EnvironmentVariables.ContainsKey("P4PORT"))
|
|
p4Annotate.StartInfo.EnvironmentVariables["P4PORT"] = p4.Port;
|
|
else
|
|
p4Annotate.StartInfo.EnvironmentVariables.Add("P4PORT", p4.Port);
|
|
if (p4Annotate.StartInfo.EnvironmentVariables.ContainsKey("P4USER"))
|
|
p4Annotate.StartInfo.EnvironmentVariables["P4USER"] = p4.User;
|
|
else
|
|
p4Annotate.StartInfo.EnvironmentVariables.Add("P4USER", p4.User);
|
|
if (p4Annotate.StartInfo.EnvironmentVariables.ContainsKey("P4PASSWD"))
|
|
p4Annotate.StartInfo.EnvironmentVariables["P4PASSWD"] = "Password";
|
|
else
|
|
p4Annotate.StartInfo.EnvironmentVariables.Add("P4PASSWD", "Password");
|
|
bool b = p4Annotate.Start();
|
|
if (b)
|
|
{
|
|
string Errors = "";
|
|
List<string> Info = new List<string>();
|
|
while (!p4Annotate.StandardOutput.EndOfStream)
|
|
{
|
|
Info.Add(p4Annotate.StandardOutput.ReadLine());
|
|
}
|
|
Errors += p4Annotate.StandardError.ReadToEnd();
|
|
if (String.IsNullOrWhiteSpace(Errors))
|
|
{
|
|
if (Info.Count > lineNumber)
|
|
{
|
|
IncriminatedCL = Info[lineNumber].Substring(0, Info[lineNumber].IndexOf(':'));
|
|
P4Form frm = p4.Fetch_Form("change", IncriminatedCL);
|
|
IncriminatedUser = string.Format("\r\n\r\nLine {2} last changed by {0} with cl {1}", frm["User"], IncriminatedCL, lineNumber+1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
}
|
|
|
|
//debug purpose
|
|
/*
|
|
foreach (P4Record change in changes)
|
|
{
|
|
Console.WriteLine(stat["depotFile"]);
|
|
}*/
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (File.Exists(tmpFile))
|
|
{
|
|
File.SetAttributes(tmpFile, ~FileAttributes.ReadOnly);
|
|
|
|
string dst = "";
|
|
readFromFile(ref dst, tmpFile);
|
|
|
|
string[] mylines = Regex.Split(dst, "\r\n");
|
|
|
|
int minIndex = lineNumber - 5;
|
|
if (minIndex < 0) minIndex = 0;
|
|
|
|
int maxIndex = lineNumber + 5;
|
|
if (maxIndex >= mylines.Length)
|
|
maxIndex = mylines.Length - 1;
|
|
|
|
string tmp = "...\t|\r\n";
|
|
|
|
for (int index = minIndex; index < maxIndex; index++)
|
|
{
|
|
int v = index + 1;
|
|
tmp += v.ToString() + "\t|";
|
|
tmp += mylines[index];
|
|
|
|
if (index == lineNumber)
|
|
tmp += " ==> SUSPICIOUS CODE HERE";
|
|
tmp += "\r\n";
|
|
}
|
|
tmp += "...\t|";
|
|
|
|
if (!string.IsNullOrWhiteSpace(IncriminatedUser))
|
|
{
|
|
tmp += IncriminatedUser;
|
|
}
|
|
code = tmp;
|
|
File.Delete(tmpFile);
|
|
}
|
|
else
|
|
{
|
|
//MessageBox.Show("Issue with preview p4 file");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
finally
|
|
{
|
|
p4.Disconnect();
|
|
}
|
|
}
|
|
|
|
private void ThreadTask()
|
|
{
|
|
CultureInfo tmp_ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();
|
|
tmp_ci.NumberFormat.NumberDecimalSeparator = ".";
|
|
System.Threading.Thread.CurrentThread.CurrentCulture = tmp_ci;
|
|
|
|
send();
|
|
sendDone = true && !cancelAll;
|
|
}
|
|
|
|
public void restoreSending()
|
|
{
|
|
timerCopy.Stop();
|
|
sendDone = false;
|
|
btnSend.Enabled = true;
|
|
}
|
|
|
|
public string HashWithMD5(string stringToHash)
|
|
{
|
|
|
|
MD5 md5HashAlgo = MD5.Create();
|
|
|
|
byte[] byteArrayToHash = Encoding.UTF8.GetBytes(stringToHash);
|
|
|
|
byte[] hashResult = md5HashAlgo.ComputeHash(byteArrayToHash);
|
|
|
|
StringBuilder result = new StringBuilder();
|
|
|
|
for (int i = 0; i < hashResult.Length; i++)
|
|
{
|
|
result.Append(hashResult[i].ToString("X2"));
|
|
}
|
|
|
|
return result.ToString();
|
|
}
|
|
|
|
public delegate void ClickSendbyThread();
|
|
|
|
|
|
private void btnSend_Click(object sender, EventArgs e)
|
|
{
|
|
if (textBoxSummary.Text == "" && reportIssueMode == ReportIssueMode.Trac)
|
|
{
|
|
MessageBox.Show("Trac must contain a summary","Error");
|
|
return;
|
|
}
|
|
|
|
tracAttributesSaved.summary = textBoxSummary.Text;
|
|
|
|
if (comboBoxOwner.SelectedIndex != -1)
|
|
tracAttributesSaved.Sid_Owner = comboBoxOwner.Items[comboBoxOwner.SelectedIndex].ToString();
|
|
|
|
if (comboBoxCC.SelectedIndex != -1)
|
|
tracAttributesSaved.Sid_CC = comboBoxCC.Items[comboBoxCC.SelectedIndex].ToString();
|
|
|
|
if (comboBoxComponent.SelectedIndex != -1)
|
|
tracAttributesSaved.component = comboBoxComponent.Items[comboBoxComponent.SelectedIndex].ToString();
|
|
|
|
if (comboBoxPriority.SelectedIndex != -1)
|
|
tracAttributesSaved.priority = comboBoxPriority.Items[comboBoxPriority.SelectedIndex].ToString();
|
|
|
|
if (comboBoxMilestone.SelectedIndex != -1)
|
|
tracAttributesSaved.milestone = comboBoxMilestone.Items[comboBoxMilestone.SelectedIndex].ToString();
|
|
|
|
if (comboBoxType.SelectedIndex != -1)
|
|
tracAttributesSaved.type = comboBoxType.Items[comboBoxType.SelectedIndex].ToString();
|
|
|
|
clean();
|
|
addClVersion(clVersion);
|
|
|
|
if (listBoxUser.SelectedIndices != null)
|
|
{
|
|
foreach (int index in listBoxUser.SelectedIndices)
|
|
{
|
|
addUser(userList[index].mail);
|
|
}
|
|
}
|
|
|
|
//could take time:
|
|
|
|
MyCopyDisplay = new CopyDisplay(this);
|
|
|
|
//start a thread for the copy
|
|
Thread trd = new Thread(new ThreadStart(this.ThreadTask));
|
|
trd.IsBackground = true;
|
|
trd.Start();
|
|
timerCopy.Start();
|
|
MyCopyDisplay.Show();
|
|
btnSend.Enabled = false;
|
|
}
|
|
|
|
private void timerCopy_Tick(object sender, EventArgs e)
|
|
{
|
|
if (sendDone)
|
|
{
|
|
Close();
|
|
}
|
|
if (cancelAll)
|
|
{
|
|
MyCopyDisplay.Close();
|
|
}
|
|
}
|
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
static extern int GetWindowTextLength(IntPtr hWnd);
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
|
|
|
|
|
public static string GetText(IntPtr hWnd)
|
|
{
|
|
// Allocate correct string length first
|
|
int length = GetWindowTextLength(hWnd);
|
|
StringBuilder sb = new StringBuilder(length + 1);
|
|
GetWindowText(hWnd, sb, sb.Capacity);
|
|
return sb.ToString();
|
|
}
|
|
|
|
|
|
private void btnSaveSettings_Click(object sender, EventArgs e)
|
|
{
|
|
XmlDocument doc = new System.Xml.XmlDocument();
|
|
doc.LoadXml("<item><name>settings</name></item>");
|
|
|
|
XmlElement newElem = doc.CreateElement("mail");
|
|
newElem.InnerText = boxMailUser.Text;
|
|
doc.DocumentElement.AppendChild(newElem);
|
|
doc.Save("CrashDumpSettings.xml");
|
|
}
|
|
|
|
private void btnWatchMovie_Click(object sender, EventArgs e)
|
|
{
|
|
if (videoPlayer != null)
|
|
{
|
|
videoPlayer.Play(aviFilename, this.labelVideo,false);
|
|
}
|
|
}
|
|
|
|
private void btnUnattachMovie_Click(object sender, EventArgs e)
|
|
{
|
|
if (videoPlayer != null)
|
|
{
|
|
VideoPlayerView videoPlayerView = new VideoPlayerView();
|
|
videoPlayerView.Show();
|
|
videoPlayer.unAttach(videoPlayerView);
|
|
}
|
|
|
|
}
|
|
|
|
private void ThreadTaskEncoding()
|
|
{
|
|
|
|
string directory;
|
|
string uniqueDirectory;
|
|
bool useSound = false;
|
|
string sourceImage = imageScr;
|
|
string sourceWave = "";
|
|
createTemporaryDirectory(out directory, out uniqueDirectory);
|
|
prepareIndexation(directory, uniqueDirectory, ref sourceImage, ref sourceWave, ref useSound);
|
|
|
|
ProcessStartInfo startInfo = null;
|
|
if (threadEncodingParameters.encoderType == AVIDEMUX)
|
|
{
|
|
string scripFile = createAvidemuxScript(directory, uniqueDirectory, sourceImage, sourceWave, useSound);
|
|
|
|
startInfo = new ProcessStartInfo(avidemuxDirectory + @"\avidemux2.exe", "");
|
|
startInfo.WorkingDirectory = avidemuxDirectory;
|
|
startInfo.Arguments = @"--run " + scripFile;
|
|
}
|
|
else
|
|
{
|
|
//just do nothing
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
processEncoding = Process.Start(startInfo);
|
|
|
|
while (processEncoding.MainWindowHandle == IntPtr.Zero)
|
|
{
|
|
processEncoding.Refresh();
|
|
}
|
|
|
|
mainEncodingWindow = processEncoding.MainWindowHandle;
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
|
|
}
|
|
|
|
public void encodeMovie(int FrameStart,int FrameEnd,int MaxFrame)
|
|
{
|
|
btnSend.Enabled = false;
|
|
|
|
threadEncodingParameters.StartFrame = FrameStart;
|
|
threadEncodingParameters.EndFrame = FrameEnd;
|
|
threadEncodingParameters.MaxFrame = MaxFrame;
|
|
|
|
SourceEncoder sourceEncoder = m_aviDemuxEncoder;
|
|
threadEncodingParameters.encoderProcess = sourceEncoder.ToString();
|
|
threadEncodingParameters.encoderType = sourceEncoder.getEncoderType();
|
|
|
|
trdEncoding = new Thread(new ThreadStart(this.ThreadTaskEncoding));
|
|
trdEncoding.Start();
|
|
timerEncoding.Enabled = true;
|
|
}
|
|
|
|
private void btnEncodeMovie_Click(object sender, EventArgs e)
|
|
{
|
|
encodeMovie(0,0,0);
|
|
}
|
|
|
|
public string processNewIndexation(int indexStart,int indexEnd,string directory,string uniquedirectory)
|
|
{
|
|
try
|
|
{
|
|
Directory.Delete(uniquedirectory, true);
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
|
|
}
|
|
|
|
Directory.CreateDirectory(uniquedirectory);
|
|
|
|
try
|
|
{
|
|
for (int index = 0; index < indexEnd - indexStart; index++)
|
|
{
|
|
string src = directory + @"";
|
|
string keySrc = String.Format("{0:00000000}", index + indexStart);
|
|
string keyDst = String.Format("{0:00000000}", index);
|
|
|
|
string srcName = directory + @"/screenITF" + keySrc + ".jpg";
|
|
string dstName = uniquedirectory + @"/screenITF" + keyDst + ".jpg";
|
|
|
|
File.Copy(srcName, dstName, true);
|
|
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
|
|
|
|
return uniquedirectory + @"/screenITF00000000.jpg";
|
|
}
|
|
|
|
|
|
public string generateNewSoundFile(int indexStart, int indexEnd, string wavefile)
|
|
{
|
|
//WaveFileReader
|
|
WaveFileReader file = new WaveFileReader(wavefile);
|
|
file.read();
|
|
|
|
//1 seconds in your format is
|
|
uint oneSecond = file.m_format.dwAvgBytesPerSec;
|
|
float oneFrame = 33.33333f / 1000.0f;//seconds
|
|
|
|
uint start = (uint)((indexStart * oneFrame) * oneSecond);
|
|
start = (start / 8) * 8;
|
|
|
|
uint size = (uint)(((indexEnd - indexStart) * oneFrame) * oneSecond);
|
|
size = (size / 8) * 8;
|
|
if (size > file.getDataSize())
|
|
size = file.getDataSize();
|
|
|
|
file.seek( file.getHeaderOffset() );
|
|
byte[] header = file.copyData( file.getHeaderSize() );
|
|
|
|
//file.seek(file.getDataOffset() );
|
|
file.seek(file.getDataOffset() + start);
|
|
byte[] dataraw = file.copyData(size);
|
|
|
|
//writer
|
|
riffChunk mainfile = file.m_mainfile;
|
|
fmtChunk format = file.m_format;
|
|
dataChunk data = file.m_data;
|
|
|
|
///////////
|
|
mainfile.dwFileLength = file.getHeaderSize() + size;
|
|
data.dwChunkSize = size;
|
|
|
|
string filename = Path.GetDirectoryName(wavefile) + "/tempStream.wav";
|
|
filename = filename.Replace("\\", "/");
|
|
|
|
WaveFileWriter fileWriter = new WaveFileWriter(filename);
|
|
fileWriter.writeRiffChunck(mainfile);
|
|
fileWriter.writeFormatHeader(format);
|
|
fileWriter.writeDataHeader(data);
|
|
fileWriter.write(dataraw);
|
|
|
|
fileWriter.close();
|
|
|
|
return filename;
|
|
}
|
|
|
|
public void prepareIndexation(string directory, string uniqueDirectory, ref string fileSource,ref string sourceWave, ref bool useSound)
|
|
{
|
|
bool useFrame = true;
|
|
|
|
//check sound
|
|
sourceWave = getSoundFile(fileSource);
|
|
useSound = File.Exists(sourceWave);
|
|
|
|
if (threadEncodingParameters.StartFrame == 0 && threadEncodingParameters.EndFrame == 0)
|
|
useFrame = false;
|
|
|
|
if (useFrame)
|
|
{
|
|
fileSource = processNewIndexation(threadEncodingParameters.StartFrame, threadEncodingParameters.EndFrame, directory,uniqueDirectory);
|
|
if (useSound)
|
|
sourceWave = generateNewSoundFile(threadEncodingParameters.StartFrame, threadEncodingParameters.EndFrame, sourceWave);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public void createTemporaryDirectory(out string directory,out string uniqueDirectory)
|
|
{
|
|
string tempDirectory = getTemporaryFolder();
|
|
Directory.CreateDirectory(tempDirectory);
|
|
|
|
directory = Path.GetDirectoryName(imageScr);
|
|
uniqueDirectory = Path.Combine(tempDirectory, Guid.NewGuid().ToString());
|
|
Directory.CreateDirectory(uniqueDirectory);
|
|
|
|
}
|
|
|
|
//kind of duplicate of virtual dub script
|
|
public string createAvidemuxScript(string directory, string uniqueDirectory, string fileSource, string sourceWave, bool useSound)
|
|
{
|
|
aviFilename = uniqueDirectory + ".mp4";
|
|
|
|
string filename = avidemuxDirectory + @"\" + threadEncodingParameters.encoderProcess+"."+threadEncodingParameters.encoderType;
|
|
if (File.Exists(filename))
|
|
{
|
|
StreamReader SR;
|
|
string S;
|
|
SR = File.OpenText(filename);
|
|
S = SR.ReadToEnd();
|
|
S = S.Replace("$USESOUND", useSound.ToString().ToLower());
|
|
S = S.Replace("$JPGSOURCE",fileSource.Replace("\\", "/"));
|
|
S = S.Replace("$OUTPUTFILE", aviFilename.Replace("\\", "/"));
|
|
|
|
//
|
|
DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(fileSource));
|
|
FileInfo[] rgFiles = di.GetFiles("*.jpg");
|
|
|
|
int frameCount = rgFiles.Length;
|
|
int frameCountMinus = frameCount-1;
|
|
|
|
S = S.Replace("$FRAMECOUNTMINUSONE", frameCountMinus.ToString());
|
|
S = S.Replace("$FRAMECOUNT", frameCount.ToString());
|
|
|
|
string exePath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
|
|
|
|
if (useSound)
|
|
{
|
|
string convertedSound = exePath + @"\"+ Path.GetDirectoryName(sourceWave) + @"\" + Path.GetFileNameWithoutExtension(sourceWave) + ".wav";
|
|
|
|
ProcessStartInfo startInfo = null;
|
|
startInfo = new ProcessStartInfo(avidemuxDirectory + @"\sox.exe", "");
|
|
startInfo.WorkingDirectory = avidemuxDirectory;
|
|
startInfo.Arguments = sourceWave + " -b 16 -e signed " +convertedSound;
|
|
|
|
try
|
|
{
|
|
Process.Start(startInfo);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
|
|
// rewrite path for script
|
|
|
|
S = S.Replace("$WAVSOURCE", sourceWave);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SR.Close();
|
|
|
|
//generate the pattern file
|
|
string scriptFile = uniqueDirectory+@"\temp.script";
|
|
|
|
System.IO.StreamWriter file = new System.IO.StreamWriter(scriptFile, false);
|
|
file.Write(S);
|
|
|
|
file.Close();
|
|
|
|
|
|
return scriptFile;
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
private void timerEncoding_Tick(object sender, EventArgs e)
|
|
{
|
|
if (processEncoding != null)
|
|
{
|
|
if (processEncoding.HasExited == false)
|
|
{
|
|
try
|
|
{string title = GetText(mainEncodingWindow);
|
|
int index = title.IndexOf('%');
|
|
if (index != -1)
|
|
{
|
|
string percentString = title.Substring(0, index);
|
|
int percent = int.Parse(percentString);
|
|
progressBarEncoding.Value = percent;
|
|
}
|
|
}
|
|
catch (System.Exception)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
btnSend.Enabled = true;
|
|
timerEncoding.Enabled = false;
|
|
//file exists ?
|
|
progressBarEncoding.Value = 100;
|
|
videoPlayer = new VideoPlayer();
|
|
videoPlayer.Play(aviFilename, this.labelVideo,true);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void labelComment_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
string getSoundFile(string imageScr)
|
|
{
|
|
string sourceWav = Path.GetDirectoryName(imageScr) + @"\sound\stream.wav";
|
|
return sourceWav;
|
|
}
|
|
|
|
private void btnPreview_Click(object sender, EventArgs e)
|
|
{
|
|
PreviewForm previewForm = new PreviewForm(this);
|
|
previewForm.init(imageScr, getSoundFile(imageScr));
|
|
previewForm.Show();
|
|
}
|
|
|
|
private void btnSaveAs_Click(object sender, EventArgs e)
|
|
{
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
saveFileDialog.Filter = "Avi|*.avi";
|
|
saveFileDialog.Title = "Save a video File";
|
|
saveFileDialog.ShowDialog();
|
|
|
|
if (saveFileDialog.FileName != "")
|
|
{
|
|
|
|
try
|
|
{
|
|
if (aviFilename!="")
|
|
{
|
|
File.Copy(aviFilename, saveFileDialog.FileName, true);
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
MessageBox.Show(ex.ToString());
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void comboBoxCC_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void comboBoxVCF_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void ReadOptions(XmlNode root)
|
|
{
|
|
XmlNode nodeOptions = root["options"];
|
|
if (nodeOptions != null)
|
|
{
|
|
XmlAttribute att;
|
|
att = nodeOptions.Attributes["ServerDump"];
|
|
if(att!=null)
|
|
serverDumpLocation = att.Value;
|
|
|
|
att = nodeOptions.Attributes["ServerSymbol"];
|
|
if (att != null)
|
|
serverSymbol = att.Value;
|
|
|
|
att = nodeOptions.Attributes["DefaultOwner"];
|
|
if (att != null)
|
|
defaultOwner = att.Value;
|
|
|
|
att = nodeOptions.Attributes["DefaultCC"];
|
|
if (att != null)
|
|
defaultCC = att.Value;
|
|
}
|
|
|
|
XmlNode nodeUsers = root["Users"];
|
|
if (nodeUsers != null)
|
|
{
|
|
for (int index = 0; index < nodeUsers.ChildNodes.Count; ++index)
|
|
{
|
|
string mail = nodeUsers.ChildNodes[index].Attributes["mail"].Value;
|
|
userSettings userSettings = new userSettings();
|
|
userSettings.mail = mail;
|
|
userSettings.enable = bool.Parse(nodeUsers.ChildNodes[index].Attributes["enable"].Value);
|
|
userList.Add(userSettings);
|
|
listBoxUser.Items.Add(mail);
|
|
if (userSettings.enable)
|
|
listBoxUser.SelectedIndices.Add(index);
|
|
}
|
|
}
|
|
XmlNode nodeBugTrackSystem = root["BugTrackSystem"];
|
|
if (nodeBugTrackSystem != null)
|
|
{
|
|
string value = nodeBugTrackSystem.ChildNodes[0].Value;
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
switch (value)
|
|
{
|
|
case "trac":
|
|
BugTracking = new TracImplementation();
|
|
break;
|
|
case "jira":
|
|
BugTracking = new JiraImplementation();
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
XmlNode nodePerforceDepot = root["PerforceDepot"];
|
|
if (nodePerforceDepot != null)
|
|
{
|
|
PerforceDepot = nodePerforceDepot.ChildNodes[0].Value;
|
|
}
|
|
XmlNode nodeDefaultMilestone = root["DefaultVersion"];
|
|
if (nodeDefaultMilestone != null)
|
|
{
|
|
defaultMilestone = nodeDefaultMilestone.ChildNodes[0].Value;
|
|
}
|
|
|
|
}
|
|
|
|
private string GetCurrentIp()
|
|
{
|
|
NetworkInterface[] NetInfo =
|
|
NetworkInterface.GetAllNetworkInterfaces();
|
|
|
|
foreach (NetworkInterface info in NetInfo)
|
|
{
|
|
if (info.OperationalStatus == OperationalStatus.Up)
|
|
{
|
|
IPInterfaceProperties prop = info.GetIPProperties();
|
|
if (!string.IsNullOrEmpty(prop.DnsSuffix))
|
|
{
|
|
if (prop.DnsSuffix.ToLower().Contains("ubisoft.org"))
|
|
{
|
|
foreach (UnicastIPAddressInformation uip in prop.UnicastAddresses)
|
|
{
|
|
if (!uip.Address.IsIPv6LinkLocal)
|
|
return uip.Address.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
private void CrashDumpSenderForm_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
if (!directoryDump.Equals(string.Empty))
|
|
{
|
|
int nbDump = Directory.GetFiles(directoryDump).Count();
|
|
if (nbDump > 10)
|
|
{
|
|
//nettoyage !
|
|
string[] Filelist = new string[nbDump];
|
|
Filelist = Directory.GetFiles(directoryDump);
|
|
|
|
var OrderedList = from x in Filelist orderby File.GetCreationTime(x) ascending select x;
|
|
|
|
foreach (string s in OrderedList.ToArray())
|
|
{
|
|
File.Delete(s);
|
|
nbDump--;
|
|
if (nbDump == 10)
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CrashDumpSenderForm_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|