// Warning - will not work - see comment above ProblemFour method invokation in Main()
        public static void Main()
        {
            var mongoHandler = new MongoDbHandler();
            var sqlHandler = new SqlServerHandler();
            var mySqlHandler = new MySqlHandler();
            var pdfHandler = new PdfHandler();
            var xmlToSql = new XmlToSqlServerLoader();
            var excellHandler = new ExcellHandler();
            var mongoToSql = new MongoToSqlServerLoader();
            var zipExtractor = new ZipExtractor();
            var jsonHandler = new JsonHandler();
            var sqliteHandler = new SqliteHandler();
            var xmlHandler = new XmlHandler();

            if (!Directory.Exists(OutputDirectory))
            {
                Directory.CreateDirectory(OutputDirectory);
            }

            //// Mongolab.com credentials - Username: TeamXenon , Passsword: xenon123

            ProblemOne(mongoHandler, mongoToSql, zipExtractor, excellHandler);

            ProblemTwo(pdfHandler);

            ProblemThree(xmlHandler);

            //// NOTE!!! - you need to go to CarParts.Data.MySql project and in its App.config file
            //// you should change the password in the connectionString tag with which you connect to your localhost instance of the MySQL Workbench server.
            ProblemFour(sqlHandler, mySqlHandler, jsonHandler);

            ProblemFive(mongoHandler, xmlToSql);

            ProblemSix(excellHandler, sqlHandler, sqliteHandler, mySqlHandler);
        }
Ejemplo n.º 2
0
        public void GetAllIdsTest()
        {
            XmlHandler handler = new XmlHandler();


            List<string> results = handler.GetAllIds("Lectures");

            Console.WriteLine(ObjectDumper.Dump(results));
        }
Ejemplo n.º 3
0
        public void Get2ndList()
        {
            string file = "VEMFK12.xml";
            string node = "students";
            string attr = "id";

            XmlHandler handler = new XmlHandler();

            XmlReader xmlReader = XmlReader.Create(dir+"/"+file);
            //List<string> result = handler.GetList(ref xmlReader, node, attr);

            xmlReader.Dispose();
            //Console.WriteLine(ObjectDumper.Dump(result));
        }
Ejemplo n.º 4
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            if (mTutorsListModified)
            {
                if (MessageBox.Show("Save changes made to tutors list?", "Save confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    XmlHandler iXMLHandler = new XmlHandler();
                    iXMLHandler.SaveTutorList(mUserManager.Tutors);
                    Close();
                }
            }

            Close();
        }
Ejemplo n.º 5
0
        public void GetEmptyList()
        {
            
            string file = "EmptyList.xml";
            string node = "lectures";
            string attr = "id";

            XmlHandler handler = new XmlHandler();

            XmlReader xmlReader = XmlReader.Create(dir + "/" + file);
            List<string> empty = new List<string>();
            //List<string> result = handler.GetList(ref xmlReader, node, attr);

            //Console.WriteLine(ObjectDumper.Dump(result));
            //Assert.IsTrue(result.Count == 0);
         
            xmlReader.Dispose();
        }
        private static void ProblemFive(MongoDbHandler mongoHandler, XmlToSqlServerLoader xmlToSql)
        {
            var xmlHandler = new XmlHandler();
            var countries = xmlHandler.GetCountries();

            // If these are runned before they will throw because coutries are already added to the cloud and have unique constraint to their name in sql server.
            // You can delete physically the data and run the method if you like.
            xmlToSql.LoadCountries(countries);

            /*try // Just in case :)
            {
                mongoHandler.WriteCollection<XmlCountry>("Countries", countries);
            }
            catch (Exception ex)
            {
            }*/

            Console.WriteLine("Successfully write down countries from XML to MongoDB and SqlServer databases");
        }
Ejemplo n.º 7
0
        public static string GetIpPort()
        {
            var ipPort = XmlHandler.GrabXmlValue(GrabSettingFile(), "ipPort");

            return(ipPort);
        }
Ejemplo n.º 8
0
        public void TestMultipleConnections_Success()
        {
            // TestBase Connection
            PublicConnection.Authentication.Authenticate();
            PublicConnection.URLParameters = new Dictionary <string, object>()
            {
                { "partition", AuthenticationInfoProvider.Current.DefaultPartition }
            };

            PublicConnection.ServerURL   = PublicAPIConfig.ServerURL;
            PublicConnection.RequestType = TestLibrary.Enums.SupportedHttpMethod.Get;
            PublicConnection.RelativeURL = API_URL;

            XmlHandler handler = PublicConnection.SendRequest() as XmlHandler;

            Assert.NotNull(handler);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);
            Assert.NotNull(handler.XML);

            XElement xmlCode = handler.XML.Descendants("Code").First();

            Assert.NotNull(xmlCode);
            Assert.AreEqual("0", xmlCode.Value);

            // Connection #1 : PublicAPIConnection Class
            PublicAPIConnection conn1 = new PublicAPIConnection(TestConfig.GetValueFromConfig("AppID1"),
                                                                TestConfig.GetValueFromConfig("AppSecret1"));

            conn1.URLParameters = new Dictionary <string, object>()
            {
                { "partition", TestConfig.GetValueFromConfig("Partition1") }
            };
            conn1.ServerURL   = PublicAPIConfig.ServerURL;
            conn1.RequestType = TestLibrary.Enums.SupportedHttpMethod.Get;
            conn1.RelativeURL = API_URL;

            // Authenticate using Connection #1
            conn1.Authentication.Authenticate();

            handler = conn1.SendRequest() as XmlHandler;
            Assert.NotNull(handler);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);
            Assert.NotNull(handler.XML);

            xmlCode = handler.XML.Descendants("Code").First();
            Assert.NotNull(xmlCode);
            Assert.AreEqual("0", xmlCode.Value);

            // Connection #2 : PublicAPIConnection Class
            PublicAPIConnection conn2 = new PublicAPIConnection();

            conn2.URLParameters = new Dictionary <string, object>()
            {
                { "partition", TestConfig.GetValueFromConfig("Partition2") }
            };
            conn2.ServerURL   = PublicAPIConfig.ServerURL;
            conn2.RequestType = TestLibrary.Enums.SupportedHttpMethod.Get;
            conn2.RelativeURL = API_URL;

            // Authenticate using Connection #2
            conn2.Authentication.Authenticate(TestConfig.GetValueFromConfig("AppID2"), TestConfig.GetValueFromConfig("AppSecret2"));

            handler = conn2.SendRequest() as XmlHandler;
            Assert.NotNull(handler);
            Assert.AreEqual(HttpStatusCode.OK, handler.HttpCode);
            Assert.NotNull(handler.XML);

            xmlCode = handler.XML.Descendants("Code").First();
            Assert.NotNull(xmlCode);
            Assert.AreEqual("0", xmlCode.Value);
        }
Ejemplo n.º 9
0
 public void XmlHandler_LoadFromTest()
 {
     List <Player> players = XmlHandler.LoadFrom("", typeof(List <Player>)) as List <Player>;
 }
Ejemplo n.º 10
0
 private void BooksView_Activated(object sender, EventArgs e)
 {
     booksDataView = BooksViewDisplay.ShowBooksGrid(booksDataView, XmlHandler.GetDB());
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Call the web service function with an Xml payload to add a crash to the database.
        /// </summary>
        /// <param name="Payload">Xml representation of a new crash to upload.</param>
        /// <returns>The database id of the newly added row.</returns>
        private int UploadCrash(string Payload)
        {
            int NewID = -1;

            try
            {
                // Simple suppression by blanking out the URL for local testing
                if (Config.Default.CrashReportWebSite.Length > 0)
                {
                    bool   bDebug = false;
                    string RequestString;
                    if (!bDebug)
                    {
                        RequestString = "http://" + Config.Default.CrashReportWebSite + ":80/Crashes/AddCrash/-1";
                    }
                    else
                    {
                        RequestString = "http://localhost:80/Crashes/AddCrash/-1";
                    }


                    Action <UploadRetryState> TryUpload = InRetryState =>
                    {
                        string ResponseString = SimpleWebRequest.GetWebServiceResponse(RequestString, Payload, Config.Default.AddCrashRequestTimeoutSeconds * 1000);
                        if (ResponseString.Length > 0)
                        {
                            // Convert response into a string
                            CrashReporterResult Result = XmlHandler.FromXmlString <CrashReporterResult>(ResponseString);
                            if (!Result.bSuccess || Result.ID <= 0)
                            {
                                if (Result.bTimeout)
                                {
                                    // Website responded - website->DB connection timeout
                                    InRetryState.Timeouts++;
                                }
                                else
                                {
                                    // Website responded - fail condition
                                    InRetryState.BadResponses++;
                                    CrashReporterProcessServicer.WriteEvent(string.Format("PROC-{0} UploadCrash response invalid. FailedResponses={1} Response={2}",
                                                                                          ProcessorIndex, InRetryState.BadResponses, Result.Message));
                                    if (InRetryState.BadResponses > Config.Default.AddCrashRejectedRetries)
                                    {
                                        InRetryState.bShouldRetry = false;
                                        CrashReporterProcessServicer.WriteEvent(string.Format("PROC-{0} UploadCrash abandoned. FailedResponses={1}",
                                                                                              ProcessorIndex, InRetryState.BadResponses));
                                    }
                                }
                            }
                            else
                            {
                                // Website responded - success
                                NewID = Result.ID;
                                InRetryState.bUploaded = true;
                                return;
                            }
                        }
                        else
                        {
                            // No response
                            InRetryState.Timeouts++;
                        }
                        InRetryState.bUploaded = false;
                    };
                    Action <UploadRetryState> OnRetry = InRetryState =>
                    {
                        if (!InRetryState.bUploaded)
                        {
                            Thread.Sleep(Config.Default.AddCrashRetryDelaySeconds * 1000);
                            CrashReporterProcessServicer.WriteEvent(string.Format("PROC-{0} UploadCrash retrying upload. Timeouts={1} FailedResponses={2}", ProcessorIndex, InRetryState.Timeouts, InRetryState.BadResponses));
                        }
                    };

                    UploadRetryState RetryState = new UploadRetryState();

                    for (; !RetryState.bUploaded && RetryState.bShouldRetry && !CancelSource.IsCancellationRequested; OnRetry(RetryState))
                    {
                        TryUpload(RetryState);
                        CrashReporterProcessServicer.StatusReporter.AlertOnConsecutiveFails("AddCrash",
                                                                                            "Cannot contact CR website. CRP is paused!",
                                                                                            "Contact with CR website restored.",
                                                                                            TimeSpan.FromSeconds(Config.Default.FailedWebAddAlertTimeSeconds), RetryState.bUploaded);
                    }
                }
#if DEBUG
                else
                {
                    // No website set - simulate successful upload
                    var Rnd = new Random();
                    NewID = Rnd.Next(1, 99999999);
                }
#endif
            }
            catch (Exception Ex)
            {
                CrashReporterProcessServicer.WriteException(string.Format("PROC-{0} ", ProcessorIndex) + "UploadCrash: " + Ex, Ex);
            }

            return(NewID);
        }
Ejemplo n.º 12
0
        private void WriteSettingsFile(object sender, EventArgs e)
        {
            StringWriter writer = new StringWriter();

            XmlHandler.Serializer(Settings.Instance).Serialize(writer, Settings.Instance, XmlHandler.Namespaces());
            FileHandler.WriteAllText(Constants.SettingsFilename, writer.ToString());
        }
Ejemplo n.º 13
0
        //#GetText
        public static string GetText(string funcName, string[] funcParamArray)
        {
            try
            {
                //common
                if (funcName.ToLower() == "empty" | funcName.ToLower() == "null")
                {
                    return(string.Empty);
                }


                else if (funcName.ToLower() == "GetInputText".ToLower())
                {
                    var dlg          = new TextInputDialog();
                    var verifyRule   = funcParamArray.Length > 0 ? funcParamArray[0] : "";
                    var verifyParams = funcParamArray.Length > 1 ? funcParamArray[1] : "";
                    dlg.VerificationRule   = verifyRule;
                    dlg.VerificationParams = verifyParams;
                    dlg.ShowDialog();
                    return(dlg.InputText);
                }

                else if (funcName.ToLower() == "GetInputDateTime".ToLower())
                {
                    var dlg          = new DateTimeInputDialog();
                    var customFormat = funcParamArray.Length > 0 ? funcParamArray[0] : "";
                    var verifyRule   = funcParamArray.Length > 1 ? funcParamArray[1] : "";
                    var verifyParams = funcParamArray.Length > 2 ? funcParamArray[2] : "";

                    dlg.VerificationRule   = verifyRule;
                    dlg.VerificationParams = verifyParams;
                    dlg.CustomFormat       = customFormat;
                    dlg.ShowDialog();
                    return(dlg.InputText);
                }

                else if (funcName.ToLower() == "LineQty".ToLower())
                {
                    int qty = funcParamArray[0].Split('\n').Length;
                    return(Convert.ToString(qty));
                }
                else if (funcName.ToLower() == "LinesBySearch".ToLower())
                {
                    var strArry    = funcParamArray[0].Split('\n');
                    var schStrArry = funcParamArray[1].Split(',');
                    var strList    = new List <string>();
                    foreach (var v in strArry)
                    {
                        foreach (var s in schStrArry)
                        {
                            if (v.ToLower().Contains(s.ToLower()))
                            {
                                strList.Add(v);
                            }
                        }
                    }

                    var strList1 = strList.Distinct();
                    var strBlder = new StringBuilder();
                    foreach (var v in strList1)
                    {
                        if (!string.IsNullOrEmpty(v))
                        {
                            strBlder.AppendLine(v);
                        }
                    }

                    return(strBlder.ToString());
                }

                else if (funcName.ToLower() == "DateTime".ToLower())
                {
                    var customFormat = "yyyy-MM-dd HH:mm:ss";
                    if (funcParamArray[0].ToLower() == "UtcNow".ToLower())
                    {
                        var time = SystemTimeHelper.UtcNow(); //
                        return(time.ToString(customFormat, DateTimeFormatInfo.InvariantInfo));
                    }
                    else if (funcParamArray[0].ToLower() == "Now".ToLower())
                    {
                        var time = SystemTimeHelper.Now(); //
                        return(time.ToString(customFormat, DateTimeFormatInfo.InvariantInfo));
                    }
                    else
                    {
                        throw new ArgumentException("funcName: " + funcName + " has no param " + funcParamArray[0] + "! ");
                    }
                }
                else if (funcName.ToLower() == "UniqueString".ToLower())
                {
                    if (funcParamArray[0] == "ByNow")
                    {
                        var seperator = funcParamArray[1];
                        return(funcParamArray[2].ToUniqueStringByNow(seperator));
                    }
                    else
                    {
                        throw new ArgumentException("funcName: " + funcName + " has no param '" + funcParamArray[0] + "'! ");
                    }
                }

                else if (funcName.ToLower() == "Format".ToLower())
                {
                    if (funcParamArray[0].ToLower() == "upper")
                    {
                        return(funcParamArray[1].ToUpper());
                    }
                    else if (funcParamArray[0].ToLower() == "lower")
                    {
                        return(funcParamArray[1].ToLower());
                    }
                    else if (funcParamArray[0].ToLower() == "timespan")
                    {
                        return(SystemTimeHelper.GetTimeSpanString(Convert.ToDouble(funcParamArray[1]), funcParamArray[2],
                                                                  false));
                    }
                    else if (funcParamArray[0].ToLower() == "real")
                    {
                        return(string.Format(funcParamArray[2], Convert.ToDouble(funcParamArray[1])));
                    }

                    else if (funcParamArray[0].ToLower() == "FormatString")
                    {
                        return(string.Format(funcParamArray[1], funcParamArray[2]));
                    }
                    else
                    {
                        throw new ArgumentException(funcName + " has no param '" + funcParamArray[0] + "'! ");
                    }
                }
                else if (funcName.ToLower() == "Replace".ToLower())
                {
                    return(funcParamArray[1].Length == 0 ? funcParamArray[0]
                        : funcParamArray[0].Replace(funcParamArray[1], funcParamArray[2]));
                }

                else if (funcName.ToLower() == "Split".ToLower())
                {
                    var seperator   = funcParamArray[1][0];
                    var tmpStrArray = funcParamArray[0].Split(seperator);
                    var index       = Convert.ToInt16(funcParamArray[2]);
                    if (index > tmpStrArray.Length || index == tmpStrArray.Length)
                    {
                        return("");
                    }
                    else
                    {
                        return(tmpStrArray[index]);
                    }
                }
                else if (funcName.ToLower() == "Combine".ToLower())
                {
                    var separator   = funcParamArray[0].GetSubParamSeparator();
                    var tmpStrArray = funcParamArray[0].Split(separator);
                    var rtStr       = "";
                    var i           = 0;
                    foreach (var tmpStr in tmpStrArray)
                    {
                        rtStr = rtStr + tmpStr;
                    }
                    return(rtStr);
                }
                else if (funcName.ToLower() == "SubString".ToLower())
                {
                    var   tmStr    = funcParamArray[0];
                    Int16 sttIndex = Convert.ToInt16(funcParamArray[1]);
                    Int16 len      = Convert.ToInt16(funcParamArray[2]);
                    return(tmStr.Substring(sttIndex, len));
                }

                //file
                else if (funcName.ToLower() == "FileDetail".ToLower())
                {
                    if (funcParamArray[1].IsNullOrEmpty())
                    {
                        throw new ArgumentException("file path can't be empty! ");
                    }
                    if (funcParamArray[0].ToLower() == "Directory".ToLower())
                    {
                        return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.Directory));
                    }
                    else if (funcParamArray[0].ToLower() == "FileName".ToLower())
                    {
                        return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.FileName));
                    }
                    else if (funcParamArray[0].ToLower() == "FileTitle".ToLower())
                    {
                        return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.FileTitle));
                    }
                    else if (funcParamArray[0].ToLower() == "Suffix".ToLower())
                    {
                        return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.Suffix));
                    }
                    else if (funcParamArray[0].ToLower() == "Postfix".ToLower())
                    {
                        return(FileHelper.GetFileDetailByOption(funcParamArray[1], FilePathComposition.Postfix));
                    }
                    else
                    {
                        throw new ArgumentException("funcName: " + funcName + " has no param '" + funcParamArray[0] + "'! ");
                    }
                }
                else if (funcName.ToLower() == "ChooseFile".ToLower())
                {
                    var dlg = new OpenFileDialog();
                    dlg.Title = "Choose File";
                    if (!string.IsNullOrEmpty(funcParamArray[0]))
                    {
                        dlg.InitialDirectory = funcParamArray[0];
                    }
                    if (!string.IsNullOrEmpty(funcParamArray[1]))
                    {
                        dlg.Filter = funcParamArray[1];
                    }

                    dlg.Multiselect      = false;
                    dlg.RestoreDirectory = true;
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if (dlg.FileNames.Count() > 0)
                        {
                            var firstFilePath = dlg.FileNames[0];
                            return(firstFilePath);
                        }
                    }
                    return(string.Empty);
                }

                //no use yet
                else if (funcName.ToLower() == "CompareFile".ToLower())
                {
                    //var result = FileHelper.Compare2Files(funcParamArray[1], funcParamArray[2]).ToString();
                    return(string.Empty);
                }

                //dir
                else if (funcName.ToLower() == "ChooseDirectory".ToLower())
                {
                    var dlg = new FolderBrowserDialog();
                    dlg.Description  = @"Choose Directory";
                    dlg.SelectedPath = funcParamArray[0];
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        return(dlg.SelectedPath);
                    }
                    return(string.Empty);
                }

                //calc
                else if (funcName.ToLower() == "Calc".ToLower())
                {
                    if (funcParamArray[0].ToLower() == "add".ToLower())
                    {
                        return((Convert.ToDouble(funcParamArray[1]) + Convert.ToDouble(funcParamArray[2])).ToString());
                    }
                    else if (funcParamArray[0].ToLower() == "sub".ToLower())
                    {
                        return((Convert.ToDouble(funcParamArray[1]) - Convert.ToDouble(funcParamArray[2])).ToString());
                    }
                    else if (funcParamArray[0].ToLower() == "mtp".ToLower())
                    {
                        return((Convert.ToDouble(funcParamArray[1]) * Convert.ToDouble(funcParamArray[2])).ToString());
                    }
                    else if (funcParamArray[0].ToLower() == "div".ToLower())
                    {
                        return((Convert.ToDouble(funcParamArray[1]) / Convert.ToDouble(funcParamArray[2])).ToString());
                    }
                    else if (funcParamArray[0].ToLower() == "rnd".ToLower())
                    {
                        return((Math.Round(Convert.ToDouble(funcParamArray[1]))).ToString());
                    }
                    else if (funcParamArray[0].ToLower() == "spls".ToLower())
                    {
                        return((Convert.ToDouble(funcParamArray[1]) % (Convert.ToDouble(funcParamArray[2]))).ToString());
                    }
                    else
                    {
                        throw new ArgumentException("funcName: " + funcName + " has no param: " + funcParamArray[0] + "! ");
                    }
                }
                //ifelse
                else if (funcName.ToLower() == "IfElse".ToLower())
                {
                    var con         = funcParamArray[0];
                    var returnVal   = funcParamArray[1];
                    var returnVal1  = funcParamArray[2];
                    var conArry     = con.Split(con.GetSubParamSeparator());
                    var compareVar  = conArry[0];
                    var compareFlag = conArry[1];
                    var compareVal  = "";
                    if (conArry.Length > 2)
                    {
                        compareVal = conArry[2];
                    }
                    if (compareFlag.ToLower().Trim() == "Contain".ToLower().Trim())
                    {
                        if (compareVar.Contains(compareVal))
                        {
                            if (!string.IsNullOrEmpty(compareVal))
                            {
                                return(returnVal);
                            }
                        }
                    }
                    else if (compareFlag.ToLower().Trim() == "Equal".ToLower().Trim())
                    {
                        if (compareVar == compareVal)
                        {
                            return(returnVal);
                        }
                    }
                    else if (compareFlag.ToLower() == "VEqual".ToLower())
                    {
                        if (Convert.ToDouble(compareVar) == Convert.ToDouble(compareVal))
                        {
                            return(returnVal);
                        }
                    }
                    else if (compareFlag.ToLower() == "VGreater".ToLower())
                    {
                        if (Convert.ToDouble(compareVar) > Convert.ToDouble(compareVal))
                        {
                            return(returnVal);
                        }
                    }
                    else if (compareFlag.ToLower() == "VGreaterEqual".ToLower())
                    {
                        if (Convert.ToDouble(compareVar) >= Convert.ToDouble(compareVal))
                        {
                            return(returnVal);
                        }
                    }
                    else if (compareFlag.ToLower() == "VLess".ToLower())
                    {
                        if (Convert.ToDouble(compareVar) < Convert.ToDouble(compareVal))
                        {
                            return(returnVal);
                        }
                    }
                    else if (compareFlag.ToLower() == "VLessEqual".ToLower())
                    {
                        if (Convert.ToDouble(compareVar) <= Convert.ToDouble(compareVal))
                        {
                            return(returnVal);
                        }
                    }
                    else if (compareFlag.ToLower() == "NotEqual".ToLower())
                    {
                        if (compareVar.Trim() != compareVal.Trim())
                        {
                            return(returnVal);
                        }
                    }
                    else if (compareFlag.ToLower() == "IsNull".ToLower())
                    {
                        if (compareVar.IsNullOrEmpty())
                        {
                            return(returnVal);
                        }
                    }
                    else if (compareFlag.ToLower() == "IsNotNull".ToLower())
                    {
                        if (!compareVar.IsNullOrEmpty())
                        {
                            return(returnVal);
                        }
                    }
                    else
                    {
                        throw new ArgumentException("funcName: " + funcName + " has no compare Flag: '" + compareFlag + "'! ");
                    }

                    return(returnVal1);
                } //IfElse ends

                //Status
                else if (funcName.ToLower() == "GetFinalStatus".ToLower())
                {
                    if (funcParamArray.All(v => v.ToLower() == "true"))
                    {
                        return("true");
                    }
                    if (funcParamArray.Any(v => v.ToLower() == "unknown"))
                    {
                        return("unknown");
                    }
                    return("false");
                }

                //getbool
                else if (funcName.ToLower() == "GetBool".ToLower())
                {
                    if (funcParamArray[0].ToLower() == "TotalStatus".ToLower())
                    {
                        var returnStr         = "true";
                        var subfuncParamArray = funcParamArray[1].Split(',');
                        if (subfuncParamArray.Any(v => v.ToLower() != "1"))
                        {
                            returnStr = "false";
                        }
                        return(returnStr);
                    }
                    else if (funcParamArray[0].ToLower() == "And".ToLower())
                    {
                        var returnStr         = "true";
                        var subfuncParamArray = funcParamArray[1].Split(',');
                        if (subfuncParamArray.Any(v => v.ToLower() != "true"))
                        {
                            returnStr = "false";
                        }
                        return(returnStr);
                    }
                    else if (funcParamArray[0].ToLower() == "Or".ToLower())
                    {
                        var returnStr         = "false";
                        var subfuncParamArray = funcParamArray[1].Split(',');
                        if (subfuncParamArray.Any(v => v.ToLower() == "true"))
                        {
                            returnStr = "true";
                        }
                        return(returnStr);
                    }
                    else if (funcParamArray[0].ToLower() == "Not".ToLower())
                    {
                        var returnStr = "true";
                        if (funcParamArray[1].ToLower() == "true")
                        {
                            returnStr = "false";
                        }
                        return(returnStr);
                    }

                    else if (funcParamArray[0].ToLower() == "JudgeStringIsNull".ToLower())
                    {
                        var returnStr = "false";
                        if (string.IsNullOrEmpty(funcParamArray[1]))
                        {
                            returnStr = "true";
                        }
                        return(returnStr);
                    }
                    else if (funcParamArray[0].ToLower() == "JudgeStringIsNotNull".ToLower())
                    {
                        var returnStr = "false";
                        if (!string.IsNullOrEmpty(funcParamArray[1]))
                        {
                            returnStr = "true";
                        }
                        return(returnStr);
                    }
                    else if (funcParamArray[0].ToLower() == "JudgeIfDirectoryExists".ToLower())
                    {
                        var returnStr = "false";
                        if (Directory.Exists(funcParamArray[1]))
                        {
                            returnStr = "true";
                        }
                        return(returnStr);
                    }
                    else if (funcParamArray[0].ToLower() == "JudgeIsDirectoryHidden".ToLower())
                    {
                        if (!Directory.Exists(funcParamArray[1]))
                        {
                            return("false");
                        }
                        var returnStr = "false";
                        var di        = new DirectoryInfo(funcParamArray[1]);
                        if ((di.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                        {
                            returnStr = "true";
                        }
                        return(returnStr);
                    }

                    else if (funcParamArray[0].ToLower() == "VerifyInput".ToLower())
                    {
                        var returnStr    = "false";
                        var dlg          = new TextInputDialog();
                        var verifyRule   = funcParamArray[1];
                        var verifyParams = funcParamArray.Length > 2 ? funcParamArray[2] : "";
                        dlg.VerificationRule   = verifyRule;
                        dlg.VerificationParams = verifyParams;
                        dlg.ShowDialog();
                        returnStr = dlg.IsOk.ToString().ToLower();
                        return(returnStr);
                    }
                    else
                    {
                        throw new ArgumentException("funcName: " + funcName + " has no param: " + funcParamArray[0] + "! ");
                    }
                }

                else if (funcName.ToLower() == "GetEncryptedText".ToLower())
                {
                    if (funcParamArray[0].ToLower() == "Md5".ToLower())
                    {
                        //return EncryptionHelper.Md5Encrypt(funcParamArray[1]);
                        return(string.Empty);
                    }
                    else if (funcParamArray[0].ToLower() == "Rsa".ToLower())
                    {
                        //return EncryptionHelper.RsaEncrypt(funcParamArray[1]);
                        return(string.Empty);
                    }
                    else if (funcParamArray[0].ToLower() == "Bitwise".ToLower())
                    {
                        //return EncryptionHelper.BitwiseEncrypt(funcParamArray[1]);
                        return(string.Empty);
                    }
                    else if (funcParamArray[0].ToLower() == "Symmetric".ToLower())
                    {
                        return(EncryptionHelper.SmEncrypt(funcParamArray[1]));
                    }
                    else if (funcParamArray[0].ToLower() == "TimeDynamic".ToLower())
                    {
                        return(string.Empty);
                    }
                    else
                    {
                        throw new ArgumentException("funcName: " + funcName + " has no param: " + funcParamArray[0] + "! ");
                    }
                }

                else if (funcName.ToLower() == "GetDecryptedText".ToLower())
                {
                    if (funcParamArray[0].ToLower() == "Rsa".ToLower())
                    {
                        //return EncryptionHelper.RsaDecrypt(funcParamArray[1]);
                        return(string.Empty);
                    }
                    if (funcParamArray[0].ToLower() == "Symmetric".ToLower())
                    {
                        //return EncryptionHelper.SmDecrypt(funcParamArray[1]);
                        return(string.Empty);
                    }
                    else
                    {
                        throw new ArgumentException("funcName: " + funcName + " has no param: " + funcParamArray[0] + "! ");
                    }
                }

                //xml
                else if (funcName.ToLower() == "GetTableXmlNodeVal".ToLower())
                {
                    var path   = funcParamArray[0];
                    var xmlMgr = new XmlHandler(path);
                    return(xmlMgr.GetNodeInnerTextByTagName(funcParamArray[1], 0));
                }

                //following can be extended to impl in AdapterGetHelper
                else if (funcName.ToLower() == "GetValidationResult".ToLower())
                {
                    var retStr = TextValidationHelper.Validate(funcParamArray[0], funcParamArray[1]);
                    if (retStr == "OutOfScopeOfTextValidationHelper")
                    {
                        return("OutOfScope");
                    }
                    else
                    {
                        return(retStr);
                    }
                }

                else if (funcName.ToLower() == "GetJson".ToLower())
                {
                    return("OutOfScope");
                }

                else
                {
                    return("OutOfScope");
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("\n>> " + TypeName + ".GetText error: " + ex.Message);
            }
        }
Ejemplo n.º 14
0
 public void SendStarSystem(StarSystems system)
 {
     XmlHandler.SerializeSystem(system);
 }
Ejemplo n.º 15
0
        // From CrashUpload.cpp

        /*
         * struct FCompressedCrashFile : FNoncopyable
         * {
         *      int32 CurrentFileIndex; // 4 bytes for file index
         *      FString Filename; // 4 bytes for length + 260 bytes for char data
         *      TArray<uint8> Filedata; // 4 bytes for length + N bytes for data
         * }
         */

        /// <summary> Enqueues a new crash. </summary>
        private bool EnqueueNewReport(string NewReportPath)
        {
            string ReportName = Path.GetFileName(NewReportPath);

            string CompressedReportPath = Path.Combine(NewReportPath, ReportName + ".ue4crash");
            string MetadataPath         = Path.Combine(NewReportPath, ReportName + ".xml");
            bool   bIsCompressed        = File.Exists(CompressedReportPath) && File.Exists(MetadataPath);

            if (bIsCompressed)
            {
                FCompressedCrashInformation CompressedCrashInformation = XmlHandler.ReadXml <FCompressedCrashInformation>(MetadataPath);
                bool bResult = DecompressReport(CompressedReportPath, CompressedCrashInformation);
                if (!bResult)
                {
                    ReportProcessor.MoveReportToInvalid(NewReportPath, "DECOMPRESSION_FAIL_" + DateTime.Now.Ticks + "_" + ReportName);
                    return(false);
                }
                else
                {
                    // Rename metadata file to not interfere with the WERReportMetadata.
                    File.Move(MetadataPath, Path.ChangeExtension(MetadataPath, "processed_xml"));
                }
            }

            // Unified crash reporting
            FGenericCrashContext GenericContext = FindCrashContext(NewReportPath);
            FGenericCrashContext Context        = GenericContext;

            bool bContextDirty         = false;
            WERReportMetadata MetaData = FindMetadata(NewReportPath);

            if (MetaData != null)
            {
                if (Context == null)
                {
                    // Missing crash context
                    FReportData ReportData = new FReportData(MetaData, NewReportPath);
                    ConvertMetadataToCrashContext(ReportData, NewReportPath, ref Context);
                    bContextDirty = true;
                }
                else if (!Context.HasProcessedData())
                {
                    // Missing data - try to get from WER metadata
                    FReportData ReportData = new FReportData(MetaData, NewReportPath);
                    GetErrorMessageFromMetadata(ReportData, Context);
                    bContextDirty = true;
                }
            }

            if (Context == null)
            {
                CrashReporterProcessServicer.WriteFailure("! NoCntx  : Path=" + NewReportPath);
                ReportProcessor.CleanReport(new DirectoryInfo(NewReportPath));
                return(false);
            }

            Context.CrashDirectory = NewReportPath;
            Context.PrimaryCrashProperties.SetPlatformFullName();

            // Added data from WER, save to the crash context file.
            if (bContextDirty)
            {
                Context.ToFile();
            }

            FEngineVersion EngineVersion = new FEngineVersion(Context.PrimaryCrashProperties.EngineVersion);

            uint BuiltFromCL = EngineVersion.Changelist;

            string BranchName = EngineVersion.Branch;

            if (string.IsNullOrEmpty(BranchName))
            {
                CrashReporterProcessServicer.WriteEvent("% Warning NoBranch: BuiltFromCL=" + string.Format("{0,7}", BuiltFromCL) + " Path=" + NewReportPath + " EngineVersion=" + Context.PrimaryCrashProperties.EngineVersion);
                Context.PrimaryCrashProperties.ProcessorFailedMessage = "Engine version has no branch name. EngineVersion=" + Context.PrimaryCrashProperties.EngineVersion;
                Context.ToFile();
            }
            else if (BranchName.Equals(CrashReporterConstants.LicenseeBranchName, StringComparison.InvariantCultureIgnoreCase))
            {
                CrashReporterProcessServicer.WriteEvent("% Warning branch is UE4-QA  : BuiltFromCL=" + string.Format("{0,7}", BuiltFromCL) + " Path=" + NewReportPath);
                Context.PrimaryCrashProperties.ProcessorFailedMessage = "Branch was the forbidden LicenseeBranchName=" + BranchName;
                Context.ToFile();
            }

            // Look for the Diagnostics.txt, if we have a diagnostics file we can continue event if the CL is marked as broken.
            bool bHasDiagnostics = FindDiagnostics(NewReportPath);

            if (BuiltFromCL == 0 && (!bHasDiagnostics && !Context.HasProcessedData()))
            {
                // For now ignore all locally made crashes.
                CrashReporterProcessServicer.WriteEvent("% Warning CL=0 and no useful data : BuiltFromCL=" + string.Format("{0,7}", BuiltFromCL) + " Path=" + NewReportPath);
                Context.PrimaryCrashProperties.ProcessorFailedMessage = "Report from CL=0 has no diagnostics, callstack or error msg";
                Context.ToFile();
            }

            // Check static reports index for duplicated reports
            // This WILL happen when running multiple, non-mutually exclusive crash sources (e.g. Receiver + Data Router)
            // This can be safely discontinued when all crashes come from the same SQS
            // This DOES NOT scale to multiple CRP instances
            // ReportIndex can be disabled by leaving the path empty in config
            lock (ReportIndexLock)
            {
                if (!CrashReporterProcessServicer.ReportIndex.TryAddNewReport(ReportName))
                {
                    // Crash report not accepted by index
                    CrashReporterProcessServicer.WriteEvent(string.Format(
                                                                "EnqueueNewReport: Duplicate report skipped {0} in queue {1}", NewReportPath, QueueName));
                    CrashReporterProcessServicer.StatusReporter.IncrementCount(StatusReportingEventNames.DuplicateRejected);
                    ReportProcessor.CleanReport(new DirectoryInfo(NewReportPath));
                    return(false);
                }
            }

            if (ShouldDecimateNextReport())
            {
                CrashReporterProcessServicer.WriteEvent(string.Format("EnqueueNewReport: Discarding Report due to backlog of {0} in queue {1}: Path={2}", GetTotalWaitingCount(), QueueName, NewReportPath));
                CrashReporterProcessServicer.StatusReporter.IncrementCount(StatusReportingEventNames.ReportDiscarded);
                ReportProcessor.CleanReport(new DirectoryInfo(NewReportPath));
                return(false);
            }

            lock (NewReportsLock)
            {
                NewCrashContexts.Enqueue(Context);
            }
            EnqueueCounter.AddEvent();
            CrashReporterProcessServicer.StatusReporter.IncrementCount(StatusReportingEventNames.QueuedEvent);
            CrashReporterProcessServicer.WriteEvent("+ Enqueued: BuiltFromCL=" + string.Format("{0,7}", BuiltFromCL) + " Path=" + NewReportPath);
            return(true);
        }
Ejemplo n.º 16
0
 private void StudentsView_Activated(object sender, EventArgs e)
 {
     studentsDataView = StudentsViewDisplay.ShowStudentsGrid(studentsDataView, XmlHandler.GetDB());
 }
 private static void ProblemThree(XmlHandler xmlHandler)
 {
     xmlHandler.GenerateSalesReport();
     Console.WriteLine("Successfully generated xml sales report file.");
 }
Ejemplo n.º 18
0
 private void button1_Click(object sender, EventArgs e)
 {
     studentsDataView = StudentsViewDisplay.ShowStudentsGrid(studentsDataView, XmlHandler.GetDB());
 }
Ejemplo n.º 19
0
 private void StudentsView_Load(object sender, EventArgs e)
 {
     DBHandler.CheckIntegrity();
     studentsDataView = StudentsViewDisplay.ShowStudentsGrid(studentsDataView, XmlHandler.GetDB());
 }
Ejemplo n.º 20
0
 public void CreateXMLFiles()
 {
     XmlHandler.CreateGradesFile(exam);
     XmlHandler.CreateQuestionsFile(exam);
 }
Ejemplo n.º 21
0
 public static void SetIpPort(string ipPort)
 {
     XmlHandler.SetXmlValue(GrabSettingFile(), "ipPort", ipPort);
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Call the web service function with an Xml payload to add a crash to the database.
        /// </summary>
        /// <param name="Payload">Xml representation of a new crash to upload.</param>
        /// <returns>The database id of the newly added row.</returns>
        private int UploadCrash(string Payload)
        {
            int NewID = -1;

            try
            {
                // Simple suppression by blanking out the URL for local testing
                if (Config.Default.CrashReportWebSite.Length > 0)
                {
                    bool   bDebug = false;
                    string RequestString;
                    if (!bDebug)
                    {
                        RequestString = "http://" + Config.Default.CrashReportWebSite + ":80/Crashes/AddCrash/-1";
                    }
                    else
                    {
                        RequestString = "http://localhost:80/Crashes/AddCrash/-1";
                    }

                    string ErrorMessage = string.Empty;

                    const int MaxRetries = 1;
                    for (int AddCrashTry = 0; AddCrashTry < MaxRetries + 1; ++AddCrashTry)
                    {
                        string ResponseString = SimpleWebRequest.GetWebServiceResponse(RequestString, Payload, Config.Default.AddCrashRequestTimeoutMillisec);
                        if (ResponseString.Length > 0)
                        {
                            // Convert response into a string
                            CrashReporterResult Result = XmlHandler.FromXmlString <CrashReporterResult>(ResponseString);
                            if (Result.ID > 0)
                            {
                                NewID = Result.ID;
                                break;
                            }
                            CrashReporterProcessServicer.WriteEvent(string.Format("PROC-{0} UploadCrash response timeout (attempt {1} of {2}): {3}", ProcessorIndex, AddCrashTry + 1, MaxRetries + 1, ErrorMessage));
                            ErrorMessage = Result.Message;
                        }
                        Thread.Sleep(Config.Default.AddCrashRetryDelayMillisec);
                    }

                    if (NewID == -1)
                    {
                        CrashReporterProcessServicer.WriteFailure(string.Format("PROC-{0} ", ProcessorIndex) + "UploadCrash failed: " + ErrorMessage);
                    }
                }
#if DEBUG
                else
                {
                    // No website set - simulate successful upload
                    var Rnd = new Random();
                    NewID = Rnd.Next(1, 99999999);
                }
#endif
            }
            catch (Exception Ex)
            {
                CrashReporterProcessServicer.WriteException(string.Format("PROC-{0} ", ProcessorIndex) + "UploadCrash: " + Ex, Ex);
            }

            return(NewID);
        }
Ejemplo n.º 23
0
    /// <summary>
    /// Generates the bytes to be sent to the client.
    /// </summary>
    void ProcessRequest()
    {
        try
        {
            mime = request.Mimes[0];

            if (request.dataHandler.closeAfterResponse)
            {
                connection = "close";
            }
            else
            {
                connection = "keep-alive";
            }

            XmlContent xmlContent;

            switch (request.Type)
            {
            case RequestType.GET:
                string file = Environment.CurrentDirectory + HttpServer.WEB_D + request.Url;

                if (HttpServer.DebugLevel <= 1)
                {
                    Console.WriteLine("Requested File: " + file);
                }

                if (File.Exists(file))
                {
                    if (HttpServer.DebugLevel <= 1)
                    {
                        Console.WriteLine("Specified file exists.");
                    }
                    bytedata = File.ReadAllBytes(file);
                    status   = "200";
                }
                else
                {
                    if (request.ApiRequest)
                    {
                        xmlContent = XmlHandler.HandleXmlGet(request);
                        bytedata   = xmlContent.ByteData;
                        status     = xmlContent.Status;
                    }
                    else if (request.Url.StartsWith("/cgi-bin"))
                    {
                        Console.WriteLine("Running CGI Script.");
                        GetCGIResult();
                    }
                    else
                    {
                        Console.WriteLine("Specified file doesn't exist, sending Error 404. Requested File: " + request.Url);

                        file     = Environment.CurrentDirectory + HttpServer.MSG_D + "/404.html";
                        bytedata = File.ReadAllBytes(file);
                        status   = "404";
                    }
                }

                if (HttpServer.DebugLevel <= 1)
                {
                    Console.WriteLine("Bytes gotten from file.");
                }
                break;

            case RequestType.POST:
                xmlContent = XmlHandler.HandleXmlPost(request.Url, request.Content);
                bytedata   = xmlContent.ByteData;
                status     = xmlContent.Status;
                break;

            case RequestType.DELETE:
                xmlContent = XmlHandler.HandleXmlRemove(request);
                bytedata   = xmlContent.ByteData;
                status     = xmlContent.Status;
                break;

            case RequestType.PUT:
                xmlContent = XmlHandler.HandleXmlPut(request);
                bytedata   = xmlContent.ByteData;
                status     = xmlContent.Status;
                break;
            }
        }
        catch (Exception e)
        {
            SendInternErrorPage(e);
        }
    }
Ejemplo n.º 24
0
 public ActionResult EditSettings(string key, string configFile)
 {
     ViewBag.configFile = configFile;
     return(View(XmlHandler.ConsultarNoXml(key, configFile)));
 }
Ejemplo n.º 25
0
        //#GetValueTextDataTable
        public static DataTable GetValueTextDataTable(string funcName, string[] funcParamArray)
        {
            try
            {
                var dt         = new DataTable();
                var valueTexts = new List <ValueText>();
                if (funcName.ToLower() == ("FromXmlByNodeNames".ToLower()))
                {
                    var xmlMgr = new XmlHandler(funcParamArray[0].ToLower());
                    valueTexts = xmlMgr.GetNodeInnerTextsToValueTextList(funcParamArray[1], funcParamArray[2]);
                }
                else if (funcName.ToLower() == ("FromIdLinkedAnnexesXmlByTextTypeByLang".ToLower()))
                {
                    var xmlMgr  = new XmlHandler(funcParamArray[0]);                         //path
                    var enumInt = EnumHelper.GetIdByName <AnnexTextType>(funcParamArray[1]); //type
                    var enum1   = (AnnexTextType)Enum.ToObject(typeof(AnnexTextType), enumInt);
                    valueTexts = xmlMgr.GetTextsToValueTextListByTextTypeByLangFromIdLinkedAnnexesXml(enum1, funcParamArray[2]);
                }
                else if (funcName.ToLower() == ("SplitBySeperator".ToLower()))
                {
                    var strArray = funcParamArray[1].Split(Convert.ToChar(funcParamArray[0]));
                    var i        = 0;
                    foreach (var v in strArray)
                    {
                        var valueText = new ValueText();
                        valueText.Value = i.ToString();
                        valueText.Text  = v;
                        valueTexts.Add(valueText);
                        i++;
                    }
                }
                else if (funcName.ToLower() == ("SplitBySeperators".ToLower()))
                {
                    var seperator0 = Convert.ToChar(funcParamArray[0]);
                    var seperator1 = Convert.ToChar(funcParamArray[1]);
                    var strArray   = funcParamArray[2].Split(seperator0);
                    var i          = 0;
                    foreach (var v in strArray)
                    {
                        var arry      = v.Split(seperator1);
                        var valueText = new ValueText();
                        valueText.Value = arry[0];
                        valueText.Text  = arry[1];
                        valueTexts.Add(valueText);
                        i++;
                    }
                }
                else
                {
                    return(null);
                }

                dt.Columns.Add("Value");
                dt.Columns.Add("Text");

                foreach (var vt in valueTexts)
                {
                    DataRow dr;
                    dr          = dt.NewRow();
                    dr["Value"] = vt.Value;
                    dr["Text"]  = vt.Text;
                    dt.Rows.Add(dr);
                }
                return(dt);
            }
            catch (Exception ex)
            {
                throw new ArgumentException("\n>> " + TypeName + ".GetValueTextDataTable error: " + ex.Message);
            }
        }
        private void botonBuscar_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            if (File.Exists(openFileDialog1.FileName))
            {
                txtFilePath.Text = openFileDialog1.FileName;
                aut            = XmlHandler.DeserializeRaw <Autorizacion>(openFileDialog1.FileName);
                aut.CAF.IdCAF  = 1;
                textFecha.Text = aut.CAF.Datos.FechaAutorizacion.ToShortDateString();
                textRango.Text = aut.CAF.Datos.RangoAutorizado.Desde.ToString() + " - " + aut.CAF.Datos.RangoAutorizado.Hasta.ToString();
                string tipo = string.Empty;
                switch (aut.CAF.Datos.TipoDTE)
                {
                case TipoDTE.DTEType.FacturaCompraElectronica:
                    tipo = "FACTURA DE COMPRA ELECTRÓNICA";
                    break;

                case TipoDTE.DTEType.FacturaElectronica:
                    tipo = "FACTURA ELECTRÓNICA";
                    break;

                case TipoDTE.DTEType.FacturaElectronicaExenta:
                    tipo = "FACTURA ELECTRÓNICA EXENTA";
                    break;

                case TipoDTE.DTEType.GuiaDespachoElectronica:
                    tipo = "GUIA DE DESPACHO ELECTRÓNICA";
                    break;

                case TipoDTE.DTEType.NotaCreditoElectronica:
                    tipo = "NOTA DE CRÉDITO ELECTRÓNICA";
                    break;

                case TipoDTE.DTEType.NotaDebitoElectronica:
                    tipo = "NOTA DE DÉBITO ELECTRÓNICA";
                    break;

                case TipoDTE.DTEType.BoletaElectronica:
                    tipo = "BOLETA ELECTRÓNICA";
                    break;

                case TipoDTE.DTEType.BoletaElectronicaExenta:
                    tipo = "BOLETA ELECTRÓNICA EXENTA";
                    break;

                case TipoDTE.DTEType.FacturaExportacionElectronica:
                    tipo = "FACTURA DE EXPORTACIÓN ELECTRÓNICA";
                    break;

                case TipoDTE.DTEType.NotaCreditoExportacionElectronica:
                    tipo = "NOTA DE CRÉDITO DE EXPORTACIÓN ELECTRÓNICA";
                    break;

                case TipoDTE.DTEType.NotaDebitoExportacionElectronica:
                    tipo = "NOTA DE DÉBITO DE EXPORTACIÓN ELECTRÓNICA";
                    break;
                }
                textTipoCAF.Text = tipo;
                // xml = File.ReadAllBytes(openFileDialog1.FileName);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Get the information for a studio from Giantbomb's API.
        /// </summary>
        /// <returns>An array of studio information, where [[0] - [n - 2]) are years
        /// of game releases, [n - 2] is the studio's ID, and [n - 1] is the name.</returns>
        /// <param name="name">Name.</param>
        public static string[] GetGBInfo(string name, string wikiName)
        {
            name = name.Replace("(company)", "").TrimEnd(new char[] { ' ' });

            //A request to the Giantbomb API to search for the studio.
            string url = "https://www.giantbomb.com/api/companies/?api_key=" +
                         API_KEY + "&filter=name:" + Uri.EscapeDataString(name);

            //Make a web request and get the result.
            string text = MakeRequest(url);

            //Deserialize the result from XML.
            Companies[] companies = XmlHandler.DeserializeCompanies(text);

            //If no companies were returned, try some aliases.
            if (companies.Length == 0)
            {
                List <string> aliases = Extensions.Extensions.CreateAliasList(name);
                aliases.Insert(0, wikiName);

                foreach (string alias in aliases)
                {
                    url = "https://www.giantbomb.com/api/companies/?api_key=" +
                          API_KEY + "&filter=name:" + Uri.EscapeDataString(alias);

                    //Make a web request and get the result.
                    text = MakeRequest(url);
                    //Deserialize the result from XML.
                    companies = XmlHandler.DeserializeCompanies(text);

                    if (companies.Length > 0)
                    {
                        break;
                    }
                }

                if (companies.Length == 0)
                {
                    throw new Exception(name + " doesn't exist on Giantbomb!");
                }
            }

            //Handles an edge case where the first company listed in the Giantbomb response is not the actual company.
            int index = 0;

            for (int a = 0; a < companies.Length; a++)
            {
                if (companies[a].name.ToLower() == name.ToLower())
                {
                    index = a;
                }
            }

            /*int lowestDistance = int.MaxValue;
             * int lowestIndex = 0;
             * for (int a = 0; a < companies.Length; a++)
             * {
             *      int diff = Extensions.Extensions.LevenshteinDistance(name, companies[a].name);
             *      if (diff < lowestDistance)
             *      {
             *              lowestDistance = diff;
             *              lowestIndex = a;
             *      }
             * }*/

            //A request to the Giantbomb API for the studio's specifics.
            url = "https://www.giantbomb.com/api/company/" +
                  companies[index].guid +
                  "/?api_key=" +
                  API_KEY;

            //Make a request and store the result.
            text = MakeRequest(url);
            //Deserialize the result from XML.
            Company company = XmlHandler.DeserializeCompany(text);



            //A request to the Giantbomb API for the game release years.
            url = "https://www.giantbomb.com/api/games/?api_key=" +
                  API_KEY + "&filter=id:";

            //Add in all of the necessary game IDs.
            List <string> addedIDs = new List <string>();

            foreach (string id in company.developed_games)
            {
                if (!addedIDs.Contains(id))
                {
                    url += id + "|";
                    addedIDs.Add(id);
                }

                //Giantbomb API restricts requests to 100 results.
                if (addedIDs.Count >= 100)
                {
                    break;
                }
            }

            //Giantbomb API resitricts requests to 100 results.
            if (addedIDs.Count < 100)
            {
                foreach (string id in company.published_games)
                {
                    if (!addedIDs.Contains(id))
                    {
                        url += id + "|";
                        addedIDs.Add(id);
                    }

                    //Giantbomb API restricts requests to 100 results.
                    if (addedIDs.Count >= 100)
                    {
                        break;
                    }
                }
            }
            url = url.Substring(0, url.Length - 1);

            //Make the request.
            text = MakeRequest(url);
            //Deserialize the result from XML.
            Games[] games = XmlHandler.DeserializeGames(text);

            //Get all games and add them, taking care to not repeat any.
            List <string> usedGames = new List <string>();
            List <string> result    = new List <string>();

            for (int a = 0; a < games.Length; a++)
            {
                if (!usedGames.Contains(games[a].name))
                {
                    //This is because sometimes the release year is "expected release year"
                    //and sometimes it's "original release date".
                    if (games[a].expected_release_year.ToString().Length >= 4)
                    {
                        result.Add(games[a].expected_release_year.ToString());
                    }
                    else
                    {
                        result.Add(games[a].original_release_date.Year.ToString());
                    }
                    usedGames.Add(games[a].name);
                }
            }

            result.Add(company.guid);

            result.Add(company.name.removeCompanySuffix());
            result.Add(company.name);
            Console.WriteLine(company.name.removeCompanySuffix());

            //Return the game information, including the years, ID, and studio name.
            return(result.ToArray());
        }
Ejemplo n.º 28
0
 private void refreshButton_Click(object sender, EventArgs e)
 {
     booksDataView = BooksViewDisplay.ShowBooksGrid(booksDataView, XmlHandler.GetDB());
 }
Ejemplo n.º 29
0
        public void Initia(PRINT_TYPE pType, string printingXML, int productID)
        {
            //if (!File.Exists(file))
            //{
            //    File.Copy(Path.Combine(Application.StartupPath, "PrinterDesign.default"), file);
            //}

            m_hander = new XmlHandler();

            try
            {
                //if (File.Exists(file))
                //    m_hander.LoadXml(File.ReadAllText(file, Encoding.UTF8));
                //else
                {
                    string fileProduct = "Pt" + productID.ToString() + ".xml";
                    if (File.Exists(fileProduct))
                    {
                        m_hander.LoadXml(File.ReadAllText(fileProduct, Encoding.UTF8));
                    }
                    else
                    {
                        m_hander.LoadXml(printingXML);//2010.08.11 打印配置文件保存到数据库了
                    }
                }
            }
            catch
            {
                throw new Exception("打印格式信息有错误,请连续管理员!");
            }

            m_pType = pType;
            //m_iType = iType;
            switch (pType)
            {
            case PRINT_TYPE.INSURANCE:
                //if (File.Exists(file))
                //{
                //    m_root = m_hander.root.SelectSingleNode("insurrances");
                //    for (int i = 0; i < m_root.ChildNodes.Count; ++i)
                //    {
                //        if (m_hander.FindXnByNameAndValue(m_root.ChildNodes[i].ChildNodes, "code", Options.GlobalVar.IACode) != null)
                //        {
                //            m_root = m_root.ChildNodes[i];
                //            break;
                //        }
                //        if (i == m_root.ChildNodes.Count) m_root = null;
                //    }
                //}
                //else
                m_root = m_hander.root.SelectSingleNode("/insurrance");
                if (m_root == null)
                {
                    throw new Exception("打印格式信息有错误,请连续管理员!");
                }
                break;

            case PRINT_TYPE.RECEIPT:
                m_root = m_hander.root.SelectSingleNode("tickets/receipt");
                break;
            }
            m_pInfo = new PRINT_INFO();
            m_pInfo.FromXmlNode(m_root);
            int iItem = m_root.SelectSingleNode("items").ChildNodes.Count;

            m_pItem = new PRINT_ITEM[iItem];
            for (int i = 0; i < iItem; ++i)
            {
                m_pItem[i].FromXmlNode(m_root.SelectSingleNode("items").ChildNodes[i], m_pInfo.m_font);
            }
            int iFix = m_root.SelectSingleNode("fixdata").ChildNodes.Count;

            m_pFix = new PRINT_FIX[iFix];
            for (int i = 0; i < iFix; ++i)
            {
                m_pFix[i].FromXmlNode(m_root.SelectSingleNode("fixdata").ChildNodes[i], m_pInfo.m_font);
            }
            //m_pInfo.m_password = (m_pInfo.m_password);
            ptDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(ptDoc_PrintPage);
        }
Ejemplo n.º 30
0
 public void LoadXml(XElement InputXml)
 {
     this.StartupLocation = XmlHandler.GetWindowStartupLocationFromXElement(InputXml, "StartupLocation", this.StartupLocation);
     this.Left            = XmlHandler.GetDoubleFromXElement(InputXml, "Left", this.Left);
     this.Top             = XmlHandler.GetDoubleFromXElement(InputXml, "Top", this.Top);
 }
Ejemplo n.º 31
0
 public new void LoadXml(XElement InputXml)
 {
     base.LoadXml(InputXml);
     this.ControlText = XmlHandler.GetStringFromXElement(InputXml, "AltLabel", this.ControlText);
 }
Ejemplo n.º 32
0
 public ActionResult Index()
 {
     XmlHandler xmlHandler = new XmlHandler();
     xmlHandler.FindFile();
     return View(xmlHandler.GetPrograms());         
 }
Ejemplo n.º 33
0
 public ActionResult EditSettings(string key, string value, string configFile)
 {
     XmlHandler.EditarChaveValorArquivoConfiguracao(key, value, configFile);
     ViewBag.Mensagem = "Registro alterado com sucesso.";
     return(View());
 }
        /// <summary>
        /// Receive a file and write it to a temporary folder.
        /// </summary>
        /// <param name="Request">A request containing the file details in the headers (DirectoryName/FileName/FileLength).</param>
        /// <returns>true if the file is received successfully.</returns>
        /// <remarks>There is an arbitrary file size limit of CrashReporterConstants.MaxFileSizeToUpload as a simple exploit prevention method.</remarks>
        private CrashReporterResult ReceiveFile(HttpListenerRequest Request)
        {
            CrashReporterResult ReportResult = new CrashReporterResult();

            if (!Request.HasEntityBody)
            {
                return(ReportResult);
            }

            // Take this opportunity to clean out folders for reports that were never completed
            CheckForAbandonedReports();

            // Make sure we have a sensible file size
            long BytesToReceive = 0;

            if (long.TryParse(Request.Headers["FileLength"], out BytesToReceive))
            {
                if (BytesToReceive >= CrashReporterConstants.MaxFileSizeToUpload)
                {
                    return(ReportResult);
                }
            }

            string DirectoryName = Request.Headers["DirectoryName"];
            string FileName      = Request.Headers["FileName"];
            var    T             = Request.ContentLength64;
            bool   bIsOverloaded = false;

            if (!UploadsInProgress.TryReceiveFile(DirectoryName, FileName, BytesToReceive, ref ReportResult.Message, ref bIsOverloaded))
            {
                CrashReporterReceiverServicer.WriteEvent(ReportResult.Message);
                ReportResult.bSuccess = false;
                return(ReportResult);
            }

            string PathName = Path.Combine(FileReceiptPath, DirectoryName, FileName);

            // Recreate the file receipt directory, just in case.
            Directory.CreateDirectory(FileReceiptPath);

            // Create the folder to save files to
            DirectoryInfo DirInfo = new DirectoryInfo(Path.GetDirectoryName(PathName));

            DirInfo.Create();

            // Make sure the file doesn't already exist. If it does, delete it.
            if (File.Exists(PathName))
            {
                File.Delete(PathName);
            }

            FileInfo   Info       = new FileInfo(PathName);
            FileStream FileWriter = Info.OpenWrite();

            // Read in the input stream from the request, and write to a file
            long OriginalBytesToReceive = BytesToReceive;

            try
            {
                using (BinaryReader Reader = new BinaryReader(Request.InputStream))
                {
                    byte[] Buffer = new byte[CrashReporterConstants.StreamChunkSize];

                    while (BytesToReceive > 0)
                    {
                        int BytesToRead = Math.Min((int)BytesToReceive, CrashReporterConstants.StreamChunkSize);
                        Interlocked.Add(ref UploadsInProgress.CurrentReceivedData, BytesToRead);

                        int ReceivedChunkSize = Reader.Read(Buffer, 0, BytesToRead);

                        if (ReceivedChunkSize == 0)
                        {
                            ReportResult.Message  = string.Format("Partial file \"{0}\" received", FileName);
                            ReportResult.bSuccess = false;
                            CrashReporterReceiverServicer.WriteEvent(ReportResult.Message);

                            return(ReportResult);
                        }

                        BytesToReceive -= ReceivedChunkSize;
                        FileWriter.Write(Buffer, 0, ReceivedChunkSize);
                    }
                }
            }
            finally
            {
                FileWriter.Close();
                Request.InputStream.Close();

                UploadsInProgress.FileUploadAttemptDone(OriginalBytesToReceive, bIsOverloaded);

                bool bWriteMetadata = Path.GetExtension(FileName) == ".ue4crash";
                if (bWriteMetadata)
                {
                    string CompressedSize   = Request.Headers["CompressedSize"];
                    string UncompressedSize = Request.Headers["UncompressedSize"];
                    string NumberOfFiles    = Request.Headers["NumberOfFiles"];

                    string MetadataPath = Path.Combine(FileReceiptPath, DirectoryName, Path.GetFileNameWithoutExtension(FileName) + ".xml");
                    XmlHandler.WriteXml <FCompressedCrashInformation>(new FCompressedCrashInformation(CompressedSize, UncompressedSize, NumberOfFiles), MetadataPath);
                }
            }

            ReportResult.bSuccess = true;
            return(ReportResult);
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Create an Xml payload representing a new crash.
        /// </summary>
        /// <param name="DirInfo">The DirectoryInfo of the report folder.</param>
        /// <param name="NewContext">The generic crash context.</param>
        /// <param name="bHasVideoFile">Whether the report contains a video file.</param>
        /// <param name="bHasLog">Whether the report contains a log file.</param>
        /// <param name="bHasMinidump">Whether the report contains a minidump.</param>
        /// <returns>A string of Xml payload representing the newly found crash report.</returns>
        private string CreateCrash(DirectoryInfo DirInfo, FGenericCrashContext NewContext, bool bHasVideoFile, bool bHasLog, bool bHasMinidump)
        {
            string XmlPayload = "";

            try
            {
                FEngineVersion EngineVersion = new FEngineVersion(NewContext.PrimaryCrashProperties.EngineVersion);

                // Create a new crash description for uploading
                var NewCrash = new CrashDescription();

                NewCrash.CrashType     = NewContext.PrimaryCrashProperties.GetCrashType();
                NewCrash.BranchName    = EngineVersion.GetCleanedBranch();
                NewCrash.GameName      = NewContext.PrimaryCrashProperties.GameName;
                NewCrash.Platform      = NewContext.PrimaryCrashProperties.PlatformFullName;
                NewCrash.EngineMode    = NewContext.PrimaryCrashProperties.EngineMode;
                NewCrash.EngineModeEx  = NewContext.PrimaryCrashProperties.GetEngineModeEx();
                NewCrash.EngineVersion = EngineVersion.VersionNumber;
                NewCrash.BuildVersion  = NewContext.PrimaryCrashProperties.BuildVersion;

                NewCrash.CommandLine      = NewContext.PrimaryCrashProperties.CommandLine;
                NewCrash.BaseDir          = NewContext.PrimaryCrashProperties.BaseDir;
                NewCrash.bProcessorFailed = !string.IsNullOrWhiteSpace(NewContext.PrimaryCrashProperties.ProcessorFailedMessage);
                NewCrash.Language         = NewContext.PrimaryCrashProperties.AppDefaultLocale;

//              // Create a locate and get the system language.
//              int SystemLanguageCode = 0;
//              int.TryParse( ReportData.SystemLanguage, out SystemLanguageCode );
//              try
//              {
//                  if( SystemLanguageCode > 0 )
//                  {
//                      CultureInfo SystemLanguageCI = new CultureInfo( SystemLanguageCode );
//                      NewCrash.SystemLanguage = SystemLanguageCI.Name;
//                  }
//              }
//              catch( System.Exception )
//              {
//                  // Default to en-US
//                  NewCrash.SystemLanguage = "en-US";
//              }

                NewCrash.MachineGuid      = NewContext.PrimaryCrashProperties.MachineId;        // Valid for all kind of builds, previously only for UE4 releases.
                NewCrash.UserName         = NewContext.PrimaryCrashProperties.UserName;         // Only valid for non-UE4 releases.
                NewCrash.EpicAccountId    = NewContext.PrimaryCrashProperties.EpicAccountId;    // Only valid for UE4 releases.
                NewCrash.CallStack        = NewContext.PrimaryCrashProperties.GetCallstack();
                NewCrash.SourceContext    = NewContext.PrimaryCrashProperties.GetSourceContext();
                NewCrash.ErrorMessage     = NewContext.PrimaryCrashProperties.GetErrorMessage();
                NewCrash.UserDescription  = NewContext.PrimaryCrashProperties.GetUserDescription();
                NewCrash.UserActivityHint = NewContext.PrimaryCrashProperties.UserActivityHint;
                NewCrash.CrashGUID        = NewContext.PrimaryCrashProperties.CrashGUID;

                // Iterate through all files and find a file with the earliest date.
                DateTime TimeOfCrash = DateTime.UtcNow;
                foreach (var File in DirInfo.GetFiles())
                {
                    if (File.CreationTimeUtc < TimeOfCrash)
                    {
                        TimeOfCrash = File.CreationTimeUtc;
                    }
                }

                //NewCrash.TimeofCrash = NewContext.PrimaryCrashProperties.TimeofCrash;
                NewCrash.TimeofCrash = TimeOfCrash;

                NewCrash.bHasMiniDump        = bHasMinidump;
                NewCrash.bHasLog             = bHasLog;
                NewCrash.bHasVideo           = bHasVideoFile;
                NewCrash.BuiltFromCL         = (int)EngineVersion.Changelist;
                NewCrash.bAllowToBeContacted = NewContext.PrimaryCrashProperties.bAllowToBeContacted;

                // Ignore any callstack that is shorter than expected, usually the callstack is invalid.
                if (NewCrash.CallStack.Length <= CrashReporterConstants.MinCallstackDepth)
                {
                    CrashReporterProcessServicer.WriteEvent(string.Format("PROC-{0} ", ProcessorIndex) + "! BadStack: BuiltFromCL=" + string.Format("{0,7}", NewContext.PrimaryCrashProperties.EngineVersion) + " Path=" + NewContext.CrashDirectory);
                    NewContext.PrimaryCrashProperties.ProcessorFailedMessage = string.Format("Callstack was too small. {0} lines (minimum {1})", NewCrash.CallStack.Length, CrashReporterConstants.MinCallstackDepth);
                    NewContext.ToFile();
                }

                XmlPayload = XmlHandler.ToXmlString <CrashDescription>(NewCrash);
            }
            catch (Exception Ex)
            {
                CrashReporterProcessServicer.WriteException(string.Format("PROC-{0} ", ProcessorIndex) + "CreateCrash: " + Ex, Ex);
            }

            return(XmlPayload);
        }
        /// <summary>
        /// The main listener callback to handle client requests.
        /// </summary>
        /// <param name="ClientRequest">The request from the client.</param>
        private void AsyncHandleHttpRequest(IAsyncResult ClientRequest)
        {
            try
            {
                HttpListenerContext Context = ServiceHttpListener.EndGetContext(ClientRequest);
                ServiceHttpListener.BeginGetContext(AsyncHandleHttpRequest, null);
                HttpListenerRequest Request = Context.Request;
                bool bIgnorePerfData        = false;

                using (HttpListenerResponse Response = Context.Response)
                {
                    // Extract the URL parameters
                    string[] UrlElements = Request.RawUrl.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                    // http://*:57005/CrashReporter/CheckReport
                    // http://*:57005/CrashReporter/CheckReportDetail
                    CrashReporterResult ReportResult = new CrashReporterResult();
                    if (UrlElements[0].ToLower() == "crashreporter")
                    {
                        switch (UrlElements[1].ToLower())
                        {
                        case "ping":
                            ReportResult.bSuccess = true;
                            break;

                        case "checkreport":
                            ReportResult = CheckReport(Context.Request);
                            break;

                        case "checkreportdetail":
                            ReportResult = CheckReportDetail(Context.Request);
                            break;

                        case "uploadreportfile":
                            ReportResult    = ReceiveFile(Context.Request);
                            bIgnorePerfData = true;
                            break;

                        case "uploadcomplete":
                            ReportResult = UploadComplete(Context.Request);
                            break;

                        default:
                            ReportResult.bSuccess = false;
                            ReportResult.Message  = "Invalid command: " + UrlElements[1];
                            break;
                        }
                    }
                    else
                    {
                        ReportResult.bSuccess = false;
                        ReportResult.Message  = "Invalid application: " + UrlElements[0] + " (expecting CrashReporter)";
                    }

                    string ResponseString = XmlHandler.ToXmlString <CrashReporterResult>(ReportResult);

                    Response.SendChunked = true;
                    Response.ContentType = "text/xml";

                    byte[] Buffer = Encoding.UTF8.GetBytes(ResponseString);
                    Response.ContentLength64 = Buffer.Length;
                    Response.OutputStream.Write(Buffer, 0, Buffer.Length);

                    Response.StatusCode = ( int )HttpStatusCode.OK;

                    if (!bIgnorePerfData)
                    {
                        // Update the overhead data.
                        Int64 ContentLenght = Response.ContentLength64 + Request.ContentLength64;
                        Interlocked.Add(ref UploadsInProgress.CurrentReceivedData, ContentLenght);
                    }
                }
            }
            catch (Exception Ex)
            {
                CrashReporterReceiverServicer.WriteEvent("Error during async listen: " + Ex.Message);
            }
        }
Ejemplo n.º 37
0
        public UserManager(MessageLogger prMessageLogger)
        {
            mUsersOnline = new Dictionary<int, userDetails>();
            mMessageLogger = prMessageLogger;

            mXmlHandler = new XmlHandler();
        }
Ejemplo n.º 38
0
        /// <summary>
        /// Add a crash passed in the payload as Xml to the database.
        /// </summary>
        /// <param name="id">Unused.</param>
        /// <returns>The row id of the newly added crash.</returns>
        public ActionResult AddCrash(int id)
        {
            var newCrashResult = new CrashReporterResult();
            CrashDescription newCrash;

            newCrashResult.ID = -1;
            string payloadString;

            //Read the request payload
            try
            {
                using (var reader = new StreamReader(Request.InputStream, Request.ContentEncoding))
                {
                    payloadString = reader.ReadToEnd();
                    if (string.IsNullOrEmpty(payloadString))
                    {
                        FLogger.Global.WriteEvent(string.Format("Add Crash Failed : Payload string empty"));
                    }
                }
            }
            catch (Exception ex)
            {
                var messageBuilder = new StringBuilder();
                messageBuilder.AppendLine("Error Reading Crash Payload");
                messageBuilder.AppendLine("Exception was:");
                messageBuilder.AppendLine(ex.ToString());

                FLogger.Global.WriteException(messageBuilder.ToString());

                newCrashResult.Message  = messageBuilder.ToString();
                newCrashResult.bSuccess = false;

                return(Content(XmlHandler.ToXmlString <CrashReporterResult>(newCrashResult), "text/xml"));
            }

            // De-serialize the payload string
            try
            {
                newCrash = XmlHandler.FromXmlString <CrashDescription>(payloadString);
            }
            catch (Exception ex)
            {
                var messageBuilder = new StringBuilder();
                messageBuilder.AppendLine("Error Reading CrashDescription XML");
                messageBuilder.AppendLine("Exception was: ");
                messageBuilder.AppendLine(ex.ToString());

                FLogger.Global.WriteException(messageBuilder.ToString());

                newCrashResult.Message  = messageBuilder.ToString();
                newCrashResult.bSuccess = false;

                return(Content(XmlHandler.ToXmlString <CrashReporterResult>(newCrashResult), "text/xml"));
            }

            //Add crash to database
            try
            {
                var crash = CreateCrash(newCrash);
                newCrashResult.ID       = crash.Id;
                newCrashResult.bSuccess = true;
            }
            catch (DbEntityValidationException dbentEx)
            {
                var messageBuilder = new StringBuilder();
                messageBuilder.AppendLine("Exception was:");
                messageBuilder.AppendLine(dbentEx.ToString());

                var innerEx = dbentEx.InnerException;
                while (innerEx != null)
                {
                    messageBuilder.AppendLine("Inner Exception : " + innerEx.Message);
                    innerEx = innerEx.InnerException;
                }

                if (dbentEx.EntityValidationErrors != null)
                {
                    messageBuilder.AppendLine("Validation Errors : ");
                    foreach (var valErr in dbentEx.EntityValidationErrors)
                    {
                        messageBuilder.AppendLine(valErr.ValidationErrors.Select(data => data.ErrorMessage).Aggregate((current, next) => current + "; /n" + next));
                    }
                }

                messageBuilder.AppendLine("Received payload was:");
                messageBuilder.AppendLine(payloadString);

                FLogger.Global.WriteException(messageBuilder.ToString());
                _slackWriter.Write(messageBuilder.ToString());

                newCrashResult.Message  = messageBuilder.ToString();
                newCrashResult.bSuccess = false;
            }
            catch (SqlException sqlExc)
            {
                if (sqlExc.Number == -2)                //If this is an sql timeout log the timeout and try again.
                {
                    FLogger.Global.WriteEvent(string.Format("AddCrash: Timeout"));
                }
                else
                {
                    var messageBuilder = new StringBuilder();
                    messageBuilder.AppendLine("Exception was:");
                    messageBuilder.AppendLine(sqlExc.ToString());
                    messageBuilder.AppendLine("Received payload was:");
                    messageBuilder.AppendLine(payloadString);

                    FLogger.Global.WriteException(messageBuilder.ToString());

                    newCrashResult.Message  = messageBuilder.ToString();
                    newCrashResult.bSuccess = false;
                }
            }
            catch (Exception ex)
            {
                var messageBuilder = new StringBuilder();
                messageBuilder.AppendLine("Exception was:");
                messageBuilder.AppendLine(ex.ToString());
                messageBuilder.AppendLine("Received payload was:");
                messageBuilder.AppendLine(payloadString);

                FLogger.Global.WriteException(messageBuilder.ToString());

                newCrashResult.Message  = messageBuilder.ToString();
                newCrashResult.bSuccess = false;
            }

            var returnResult = XmlHandler.ToXmlString <CrashReporterResult>(newCrashResult);

            return(Content(returnResult, "text/xml"));
        }