/// <summary>
        /// Архивация логов.
        /// ВНИМАНИЕ!!!
        /// При архивации используется пароль, равный User ID.
        /// </summary>
        public void ArchiveLogs()
        {
            try
            {
                if (Properties.Resources.Default_Debug_Archive == "1")
                {
                    if (File.Exists("Ionic.Zip.dll"))
                    {
                        if (Directory.Exists(MainWindow.SettingsDir + "temp"))
                        {
                            if (!Directory.Exists(MainWindow.SettingsDir + "debug"))
                            {
                                Directory.CreateDirectory(MainWindow.SettingsDir + "debug");
                            }

                            using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
                            {
                                string uid     = new Classes.Variables().GetUserID();
                                string version = Application.Current.GetType().Assembly.GetName().Version.ToString();

                                zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;
                                zip.Password         = uid;
                                zip.AddDirectory(MainWindow.SettingsDir + "temp");
                                zip.Save(MainWindow.SettingsDir + @"debug\" + String.Format("{0}_{1}_{2}.zip", uid, version, DateTime.Now.ToString("yyyy-MM-dd h-m-s.ffffff")));
                            }

                            Directory.Delete(MainWindow.SettingsDir + "temp", true);
                        }
                    }
                }
            }
            catch (Exception ex) { Save("Debugging.Class", "ArchiveLogs()", ex.Message, ex.StackTrace); }
        }
        public void Save(string module, string func, params string[] args)
        {
            try
            {
                string UserID  = new Classes.Variables().GetUserID();
                string version = Application.Current.GetType().Assembly.GetName().Version.ToString();

                JObject json = new JObject(
                    new JProperty("uid", new Classes.Variables().GetUserID()),
                    new JProperty("version", version),
                    new JProperty("date", DateTime.Now.ToString("yyyy-MM-dd h-m-s")),
                    new JProperty("module", module),
                    new JProperty("function", func)
                    );

                for (int i = 0; i < args.Length; i++)
                {
                    json.Add(new JProperty("param" + i.ToString(), args[i]));
                }

                if (!Directory.Exists(MainWindow.SettingsDir + @"temp"))
                {
                    Directory.CreateDirectory(MainWindow.SettingsDir + @"temp");
                }

                string filename = String.Format("{0}_{1}_{2}.debug", version, ErrorCode(module, func), DateTime.Now.ToString("yyyy-MM-dd h-m-s.ffffff"));

                if (Properties.Resources.Default_Debug_Crypt == "1")
                {
                    string encoded = new Crypt().Encrypt(json.ToString(), UserID, true);
                    if (encoded != "FAIL")
                    {
                        File.WriteAllText(MainWindow.SettingsDir + @"temp\" + filename, encoded, Encoding.UTF8);
                    }
                }
                else
                {
                    File.WriteAllText(MainWindow.SettingsDir + @"temp\" + filename, json.ToString(), Encoding.UTF8);
                }
            }
            catch (IOException) { Thread.Sleep(3000); Save(module, func, args); }
            catch (Exception) { }
            finally { }
        }
Esempio n. 3
0
        public string Send(string Url, JObject json, string encoded_string = null, bool manual_enc = true)
        {
            string Data = String.Empty;
            string Out  = String.Empty;

            try
            {
                string UserID = new Classes.Variables().GetUserID();

                if (encoded_string == null)
                {
                    Data = "data=" + json.ToString();
                }
                else
                {
                    Data = "data=" + encoded_string + "&u=" + UserID + "&e=" + Properties.Resources.API_DEV_CRYPT;
                }

                WebRequest req = WebRequest.Create(Url);
                req.Method      = "POST";
                req.Timeout     = 100000;
                req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
                byte[] sentData = Encoding.GetEncoding("Utf-8").GetBytes(Data);
                req.ContentLength = sentData.Length;
                Stream sendStream = req.GetRequestStream();
                sendStream.Write(sentData, 0, sentData.Length);
                sendStream.Close();
                WebResponse  res           = req.GetResponse();
                Stream       ReceiveStream = res.GetResponseStream();
                StreamReader sr            = new StreamReader(ReceiveStream, Encoding.UTF8);
                Char[]       read          = new Char[256];
                int          count         = sr.Read(read, 0, 256);
                while (count > 0)
                {
                    String str = new String(read, 0, count);
                    Out  += str;
                    count = sr.Read(read, 0, 256);
                }

                return(Out);
            }
            catch (WebException we) { Debugging.Save("POST.Class", "Send()", "URL: " + Url, "Data: " + Data, "Out: " + Out, we.Message, we.StackTrace); return("FAIL"); }
            catch (Exception ex) { Debugging.Save("POST.Class", "Send()", "URL: " + Url, "Data: " + Data, "Out: " + Out, ex.Message, ex.StackTrace); return("FAIL"); }
        }