Beispiel #1
0
        public void Save(string fileSpec)
        {
            StreamWriter sw = null;

            try
            {
                Administrator.Tracer.WriteLine();
                Administrator.Tracer.WriteMsg("I", String.Format(@"Exporting to file ""{0}""", fileSpec));
                ExportedRowCount = 0;
                if (this.Count > 0)
                {
                    ProfileData.Models.Helpers.FileHelper.PathCheck(fileSpec);
                    ProfileData.Models.Helpers.FileHelper.Delete(fileSpec);
                    sw = File.CreateText(fileSpec);
                    string line = string.Empty;
                    line = "StdHlq,StdDir,StdFile,StdSize,StdDate,SourceDate,TargetDate,SourceHlq,SourceFile,TargetHlq,TargetFile,StdType,CtlComparison";
                    sw.WriteLine(line);
                    foreach (var entry in this)
                    {
                        ExportedRowCount++;
                        StringBuilder sb = new StringBuilder();
                        sb.Append(String.Format(@"""{0}"",", entry.StdHlq));
                        sb.Append(String.Format(@"""{0}"",", entry.StdDir));
                        sb.Append(String.Format(@"""{0}"",", entry.StdFile));
                        sb.Append(String.Format(@"""{0}"",", entry.StdSize));
                        sb.Append(String.Format(@"""{0}"",", entry.StdDate.ToString(DATE_TIME_FORMAT)));
                        sb.Append(String.Format(@"""{0}"",", entry.SourceDate.ToString(DATE_TIME_FORMAT)));
                        sb.Append(String.Format(@"""{0}"",", entry.TargetDate.ToString(DATE_TIME_FORMAT)));
                        sb.Append(String.Format(@"""{0}"",", entry.SourceHlq));
                        sb.Append(String.Format(@"""{0}"",", entry.SourceFile));
                        sb.Append(String.Format(@"""{0}"",", entry.TargetHlq));
                        sb.Append(String.Format(@"""{0}"",", entry.TargetFile));
                        sb.Append(String.Format(@"""{0}"",", entry.StdType));
                        sb.Append(String.Format(@"""{0}"",", entry.CtlComparison));
                        line = sb.ToString();
                        sw.WriteLine(line.ToString());
                    }
                    sw.Flush();
                }
            }
            catch (Exception ex)
            {
                Administrator.Tracer.WriteTimedMsg("E", String.Format(@"Exception in method ""{0}"" : {1}", MethodBase.GetCurrentMethod().Name, ex.Message));
            }
            finally
            {
                Administrator.Tracer.WriteTimedMsg("I", String.Format("Exported Rows: {0}", ExportedRowCount.ToString().PadLeft(9)));
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }
Beispiel #2
0
        public void Save_Old_NotUsed(string fileSpec)
        {
            StringBuilder sb = new StringBuilder();
            StreamWriter  sw = null;

            try
            {
                Administrator.Tracer.WriteLine();
                Administrator.Tracer.WriteMsg("I", String.Format(@"Exporting to comparisons file ""{0}""", fileSpec));
                ExportedRowCount = 0;
                int sameCount = 0;
                if (Comparisons.Count > 0)
                {
                    ProfileData.Models.Helpers.FileHelper.PathCheck(fileSpec);
                    ProfileData.Models.Helpers.FileHelper.Delete(fileSpec);
                    sw = File.CreateText(fileSpec);
                    string line = string.Empty;
                    line = "SortOrder,Action,Command,DisplayCommand,Outcome,SourceType,SourceEntry,SourceDate,SourceSize,TargetType,TargetEntry,TargetDate,TargetSize";
                    sw.WriteLine(line);
                    for (int index = 0; index < Comparisons.Count; index++)
                    {
                        Comparison entry = Comparisons[index];
                        if (entry.Command == "Same")
                        {
                            sameCount++;
                        }
                        else
                        {
                            ExportedRowCount++;
                            sb = new StringBuilder();
                            sb.Append(String.Format(@"""{0}"",", entry.SortOrder));
                            sb.Append(String.Format(@"""{0}"",", entry.Action));
                            sb.Append(String.Format(@"""{0}"",", entry.Command));
                            sb.Append(String.Format(@"""{0}"",", entry.DisplayCommand));
                            sb.Append(String.Format(@"""{0}"",", entry.Outcome));
                            sb.Append(String.Format(@"""{0}"",", entry.SourceType));
                            sb.Append(String.Format(@"""{0}"",", entry.SourceEntry));
                            sb.Append(String.Format(@"""{0}"",", entry.SourceDate.ToString(DATE_TIME_FORMAT)));
                            sb.Append(String.Format(@"{0},", entry.SourceSize));
                            sb.Append(String.Format(@"""{0}"",", entry.TargetType));
                            sb.Append(String.Format(@"""{0}"",", entry.TargetEntry));
                            sb.Append(String.Format(@"""{0}"",", entry.TargetDate.ToString(DATE_TIME_FORMAT)));
                            sb.Append(String.Format(@"{0},", entry.TargetSize));
                            line = sb.ToString();
                            sw.WriteLine(line.ToString());
                        }
                    }
                    ExportedRowCount++;
                    sb = new StringBuilder();
                    sb.Append(String.Format(@"""{0}"",", "Same"));
                    sb.Append(String.Format(@"""{0}"",", "Same"));
                    sb.Append(String.Format(@"""{0}"",", "Same"));
                    sb.Append(String.Format(@"""{0}"",", "Same"));
                    sb.Append(String.Format(@"""{0}"",", "Same"));
                    sb.Append(String.Format(@"""{0}"",", "Same"));
                    sb.Append(String.Format(@"""{0}"",", "Same"));
                    sb.Append(String.Format(@"""{0}"",", DateTime.MinValue.ToString(DATE_TIME_FORMAT)));
                    sb.Append(String.Format(@"{0},", sameCount));
                    sb.Append(String.Format(@"""{0}"",", "Same"));
                    sb.Append(String.Format(@"""{0}"",", "Same"));
                    sb.Append(String.Format(@"""{0}"",", DateTime.MinValue.ToString(DATE_TIME_FORMAT)));
                    sb.Append(String.Format(@"{0},", sameCount));
                    line = sb.ToString();
                    sw.WriteLine(line.ToString());
                    sw.Flush();
                }
            }
            catch (Exception ex)
            {
                Administrator.Tracer.WriteTimedMsg("E", String.Format(@"Exception in method ""{0}"" : {1}", MethodBase.GetCurrentMethod().Name, ex.Message));
            }
            finally
            {
                Administrator.Tracer.WriteTimedMsg("I", String.Format("Exported Rows: {0}", ExportedRowCount.ToString().PadLeft(9)));
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }