Пример #1
0
        private string saveScript(string filename, string contents)
        {
            string val         = contents;
            string returnValue = "false";

            try
            {
                string savePath = IOHelper.MapPath(SystemDirectories.Scripts + "/" + filename);

                //Directory check.. only allow files in script dir and below to be edited
                if (savePath.StartsWith(IOHelper.MapPath(SystemDirectories.Scripts + "/")))
                {
                    StreamWriter SW;
                    SW = File.CreateText(IOHelper.MapPath(SystemDirectories.Scripts + "/" + filename));
                    SW.Write(val);
                    SW.Close();
                    returnValue = "true";
                }
                else
                {
                    throw new ArgumentException("Couldnt save to file - Illegal path");
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException(String.Format("Couldnt save to file '{0}'", filename), ex);
            }


            return(returnValue);
        }
Пример #2
0
        private void writeLog(string FullPath, string FileName, string EventType)
        {
            StreamWriter SW;
            string       Logs = ConfigurationManager.AppSettings["Logs"];

            if (Directory.Exists(Logs))
            {
                Logs = System.IO.Path.Combine(Logs, "FaxPDFlog_" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                if (!File.Exists(Logs))
                {
                    SW = File.CreateText(Logs);
                    SW.Close();
                }
            }
            using (SW = File.AppendText(Logs))
            {
                SW.Write("\r\n");
                if ((EventType == "Created" || EventType == "Changed" || EventType == "Renamed" || EventType == "Converted" || EventType == "Mailed"))
                {
                    SW.WriteLine(DateTime.Now.ToString("dd-MM-yyyy H:mm:ss") + ": File " + EventType + " with Name: " + FileName + " at this location: " + FullPath);
                }
                else if ((EventType == "Stopped" || EventType == "Started"))
                {
                    SW.WriteLine("Service " + EventType + " at " + DateTime.Now.ToString("dd -MM-yyyy H:mm:ss"));
                }
                else if (EventType == "Error")
                {
                    SW.WriteLine("ERROR: " + DateTime.Now.ToString("dd-MM-yyyy H:mm:ss") + FullPath + FileName);
                }
                SW.Close();
            }
        }
Пример #3
0
        public static int TabToFile(string filename, int[,] tab)
        {
            StreamWriter SW;
            string       line = "";

            try {
                SW = new StreamWriter(new FileStream(filename, FileMode.CreateNew));
            } catch (Exception) {
                Console.WriteLine("ERROR : File already exists !");
                do
                {
                    Console.WriteLine("Do you want to overrite it ? (y/n) : ");
                    line = Console.ReadLine();
                } while (line != "y" && line != "Y" && line != "n" && line != "N");
                if (line == "n" || line == "N")
                {
                    return(1);
                }
                else
                {
                    SW = new StreamWriter(new FileStream(filename, FileMode.Create));
                }
            }
            for (int i = 0; i < tab.GetLength(0); ++i)
            {
                for (int j = 0; j < tab.GetLength(1); ++j)
                {
                    SW.Write(tab [i, j]);
                }
                SW.Write("\n");
            }
            SW.Close();
            return(0);
        }
        /// <summary>
        /// 1つのフィールドの分析
        /// </summary>
        /// <param name="m">オブジェクト</param>
        /// <param name="nestLevel">整形用</param>
        static void AnalyzeFieldInfo(FieldInfo m, int nestLevel)
        {
            if (!m.IsPublic)
            {
                return;
            }

            var ts = TypeToString(m.FieldType);

            // 複雑過ぎるかどうか
            var  genlist   = m.FieldType.GetGenericArguments();
            bool isComplex = IsGenericAnyCondtion(genlist, (g) => { return(g.ToString().Contains(".")); });

            ts = ModifyType(ts, isComplex);

            SWTabSpace(nestLevel + 1);

            // 読み取り専用
            if (m.IsInitOnly || m.IsLiteral)
            {
                SW.Write("readonly ");
            }

            SW.WriteLine(m.Name + " :" + ts + ";");
        }
Пример #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Exemplo de Assinatura Digital XML\r\r");
            Console.Write("Arquivo xml a ser assinado :");
            string _arquivo = Console.ReadLine();

            if (_arquivo == null)
            {
                Console.WriteLine("\rNome de arquivo não informado...");
            }
            else if (!File.Exists(_arquivo))
            {
                Console.WriteLine("\rArquivo {0} inexistente...", _arquivo);
            }
            else
            {
                Console.Write("URI a ser assinada (Ex.: infCanc, infNFe, infInut, etc.) :");
                string _uri = Console.ReadLine();
                if (_uri == null)
                {
                    Console.WriteLine("\rURI não informada...");
                }
                else
                {
                    //
                    //   le o arquivo xml
                    //
                    StreamReader SR;
                    string       _stringXml;
                    SR         = File.OpenText(_arquivo);
                    _stringXml = SR.ReadToEnd();
                    SR.Close();
                    //
                    //  realiza assinatura
                    //
                    AssinaturaDigital AD = new AssinaturaDigital();
                    //
                    //  cria cert
                    //
                    X509Certificate2 cert = new X509Certificate2();
                    //
                    //  seleciona certificado do repositório MY do windows
                    //
                    Certificado certificado = new Certificado();
                    cert = certificado.BuscaNome("");
                    int resultado = AD.Assinar(_stringXml, _uri, cert);
                    if (resultado == 0)
                    {
                        //
                        //  grava arquivo assinado
                        //
                        StreamWriter SW;
                        SW = File.CreateText(_arquivo.Trim() + "_assinado");
                        SW.Write(AD.XMLStringAssinado);
                        SW.Close();
                    }
                    Console.WriteLine(AD.mensagemResultado);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// purpose of this method is to maintain error log in text file.
        /// </summary>
        /// <param name="exx"></param>
        public static void Create_ErrorFile(Exception exx)
        {
            StreamWriter SW;

            if (!File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "txt_" + DateTime.Now.ToString("yyyyMMdd") + ".txt")))
            {
                SW = File.CreateText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "txt_" + DateTime.Now.ToString("yyyyMMdd") + ".txt"));
                SW.Close();
            }
            using (SW = File.AppendText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "txt_" + DateTime.Now.ToString("yyyyMMdd") + ".txt")))
            {
                string[] str = new string[] { exx.Message == null?"":exx.Message.ToString(), exx.StackTrace == null?"":exx.StackTrace.ToString(),
                                              exx.InnerException == null?"":exx.InnerException.ToString() };
                for (int i = 0; i < str.Length; i++)
                {
                    SW.Write("\r\n\n");
                    if (str[i] == str[0])
                    {
                        SW.WriteLine("Exception Message:" + str[i]);
                    }
                    else if (str[i] == str[1])
                    {
                        SW.WriteLine("StackTrace:" + str[i]);
                    }
                    else if (str[i] == str[2])
                    {
                        SW.WriteLine("InnerException:" + str[i]);
                    }
                }
                SW.Close();
            }
        }
Пример #7
0
        // Write a string to a file
        public static void WriteToFile(string tempFilePath, string stringToWrite)
        {
            StreamWriter SW;

            SW = File.CreateText(tempFilePath);
            SW.Write(stringToWrite);
            SW.Close();
        }
Пример #8
0
        //private void BT_UpLoadData_Click(object sender, RoutedEventArgs e)
        //{
        //   // queryThread.Suspend(); //暂时关闭查询用线程
        //    mdv.pmacCard.SendCMD("LIST GAT");
        //    mdv.PMAC_msg = mdv.pmacCard.m_PMAC_msg;
        //    System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
        //    sfd.InitialDirectory = "E:\\";
        //    sfd.Filter = "m文件(*.m)|*.m|txt文件(*.txt)|*.txt";
        //    if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        //    {
        //        WriteToFile(sfd.FileName, "OriData = {'" + mdv.PMAC_msg.Replace(" ","' , '").Replace("\n", "' ,...\n '") + "'};");
        //        MessageBox.Show("uploaded complete");
        //    }
        //    //queryThread.Resume();
        //}

        #endregion

        static void WriteToFile(string dir, string data)
        {
            StreamWriter SW;

            SW = File.CreateText(dir);
            SW.Write(data);
            SW.Close();
        }
Пример #9
0
        /// <summary>
        /// 1つのコンストラクタの分析
        /// </summary>
        /// <param name="m">オブジェクト</param>
        /// <param name="nestLevel">整形用</param>
        /// <param name="genericParameterTypeStringList">クラス自体のジェネリックパラメータ</param>
        static void AnalyzeConstructorInfo(ConstructorInfo m, int nestLevel, List <string> genericParameterTypeStringList)
        {
            SWTabSpace(nestLevel + 1);

            //メソッド名を表示
            SW.Write("new");

            var prmList = GetMethodGenericTypeList(m, genericParameterTypeStringList);

            if (prmList.Count > 0)
            {
                SW.Write("<" + String.Join(", ", prmList) + ">");
            }

            //パラメータを表示
            ParameterInfo[] prms = m.GetParameters();
            SW.Write("(");
            for (int i = 0; i < prms.Length; i++)
            {
                ParameterInfo p  = prms[i];
                string        ts = TypeToString(p.ParameterType);

                // 複雑過ぎるかどうか
                var  genlist   = p.ParameterType.GetGenericArguments();
                bool isComplex = IsGenericAnyCondtion(genlist,
                                                      (g) =>
                {
                    // 「.」が付いていたら複雑だ
                    return
                    (g.ToString().Contains(".") ||
                     // クラスに無いのに、関数が突然Genericというのは、場合によってはTypeScriptでは無理が出る
                     (!genericParameterTypeStringList.Exists((e) => { return e.ToString() == g.ToString(); })));
                }
                                                      );

                ts = ModifyType(ts, isComplex);

                var varname = ModifyVarName(p);
                if (ts == "any" && IsParams(p))
                {
                    SW.Write(varname + ": " + ts + "[]");
                }
                else
                {
                    SW.Write(varname + ": " + ts);
                }

                // 引数がまだ残ってるなら、「,」で繋げて次へ
                if (prms.Length - 1 > i)
                {
                    SW.Write(", ");
                }
            }

            // 引数が全部終了
            SW.WriteLine(");");
        }
Пример #10
0
        /// <summary>
        /// DataTable to new file each time
        /// </summary>
        /// <param name="aDBTable"></param>
        public static void TableToFileNew(DataTable aDBTable)
        {
            int[] aWidths;
            aWidths = new Int32[aDBTable.Columns.Count];

            //widths
            for (int j = 0; j < aDBTable.Columns.Count; j++)
            {
                aWidths[j] = 0;
                if (aDBTable.Columns[j].Caption.Length >= aWidths[j])
                {
                    aWidths[j] = aDBTable.Columns[j].Caption.Length + 1;
                }

                for (int i = 0; i < aDBTable.Rows.Count; i++)
                {
                    if (aDBTable.Rows[i].ItemArray[j].ToString().Length >= aWidths[j])
                    {
                        aWidths[j] = aDBTable.Rows[i].ItemArray[j].ToString().Length + 1;
                    }
                }
            }

            StreamWriter SW;

            SW = File.CreateText(File4);

            //captions
            for (int j = 0; j < aDBTable.Columns.Count; j++)
            {
                SW.Write(aDBTable.Columns[j].Caption);
                SW.Write(Util.GetNSpaces(aWidths[j] - aDBTable.Columns[j].Caption.Length));
            }
            SW.WriteLine("");
            for (int j = 0; j < aDBTable.Columns.Count; j++)
            {
                for (int i = 0; i < aWidths[j]; i++)
                {
                    SW.Write("-");
                }
            }
            SW.WriteLine("");

            //data
            for (int i = 0; i < aDBTable.Rows.Count; i++)
            {
                for (int j = 0; j < aDBTable.Columns.Count; j++)
                {
                    SW.Write(aDBTable.Rows[i].ItemArray[j].ToString());
                    SW.Write(Util.GetNSpaces(aWidths[j] - aDBTable.Rows[i].ItemArray[j].ToString().Length));
                }
                SW.WriteLine("");
            }
            SW.Flush();
            SW.Close();
        }
Пример #11
0
    /// <summary>
    /// dumps IL code of the caller to file.
    /// </summary>
    internal static void GetThisMethodIL()
    {
        StackTrace   trace         = new StackTrace();
        StackFrame   framePrevious = trace.GetFrame(1);
        StreamWriter SW;

        SW = File.CreateText("IlDUMP_" + framePrevious.GetMethod().Name + ".txt");
        SW.WriteLine("IL-OFFSET:" + framePrevious.GetILOffset());
        SW.Write(OpcodeToIL(framePrevious.GetMethod()));
        SW.Close();
    }
Пример #12
0
 /// <summary>
 /// standard log
 /// </summary>
 /// <param name="s"></param>
 public static void ToFileAppend(string s)
 {
     lock (_lock)
     {
         StreamWriter SW;
         SW = File.AppendText(File1);
         SW.Write(s);
         SW.Flush();
         SW.Close();
     }
 }
Пример #13
0
        public static void WriteStringToFile(string strFilename, string strData)
        {
            if (File.Exists(strFilename))
            {
                File.Delete(strFilename);
            }
            StreamWriter SW;

            SW = File.CreateText(strFilename);
            SW.Write(strData);
            SW.Close();
        }
        protected void PrintClassToClassRelationship(ClassToClassRelationship classToClassRelationship)
        {
            SW.Write("{0} ", classToClassRelationship.Kind.ToString().ToLower());

            SW.WriteLine("object property {0}", classToClassRelationship.Value);
            SW.WriteLine("{");

            //print domain
            SW.WriteLine("\tdomain {0};", classToClassRelationship.Left.Value);

            //print range
            SW.WriteLine("\trange {0};", classToClassRelationship.Right.Value);

            SW.WriteLine("}");
        }
Пример #15
0
        public void saveCssToFile()
        {
            System.IO.StreamWriter SW;
            SW = System.IO.File.CreateText(System.Web.HttpContext.Current.Server.MapPath(GlobalSettings.Path + "/../css/" + this.Text + ".css"));
            string tmpCss;

            tmpCss  = "/* GENERAL STYLES */\n";
            tmpCss += this.Content + "\n\n";
            tmpCss += "/* EDITOR PROPERTIES */\n";
            foreach (StylesheetProperty p in this.Properties)
            {
                tmpCss += p.ToString() + "\n";
            }
            SW.Write(tmpCss);
            SW.Close();
        }
Пример #16
0
        // Create file with default filters for index words
        public static void GenerateDefaultFiltersFile()
        {
            StreamWriter SW;

            SW = File.CreateText(GetFiltersFilePath());
            SW.WriteLine(@"\S{1}-\S{1}");
            SW.WriteLine(@"[IVXCL]{2,8}[ème]*");
            SW.WriteLine(@"[IVXCL]{1,8}-[IVXCL]{1,8}");
            SW.WriteLine(@"[IVXCL]{1,8}e-[IVXCL]{1,8}e");
            SW.WriteLine(@"\S{1,12}er");
            SW.WriteLine(@"\S{1,12}ir");
            SW.WriteLine(@"\S{1,12}tion[s]*");
            SW.WriteLine(@"\S{1,12}sion[s]*");
            SW.Write(@"\S{1,12}ement");
            SW.Close();
        }
Пример #17
0
        public static void WriteTextToFile(string text, string FullFileName)
        {
            StreamWriter SW;

            if (File.Exists(FullFileName))
            {
                SW = File.AppendText(FullFileName);
                SW.Write(text);
                SW.Close();
            }
            else
            {
                SW = File.CreateText(FullFileName);
                SW.Write(text);
                SW.Close();
            }
        }
Пример #18
0
        public void saveCssToFile()
        {
            StreamWriter SW;

            SW = File.CreateText(IOHelper.MapPath(SystemDirectories.Css + "/" + this.Text + ".css"));
            string tmpCss;

            //tmpCss = "/* GENERAL STYLES */\n";
            tmpCss  = this.Content + "\n\n";
            tmpCss += "/* EDITOR PROPERTIES - PLEASE DON'T DELETE THIS LINE TO AVOID DUPLICATE PROPERTIES */\n";
            foreach (StylesheetProperty p in this.Properties)
            {
                tmpCss += p.ToString() + "\n";
            }
            SW.Write(tmpCss);
            SW.Close();
        }
Пример #19
0
        public void write(string format, params object[] args)
        {
            lock (m_lock_object)
            {
                string       log_message = "";
                StreamWriter SW;
                SW = File.AppendText(m_log_path);

                string timeStamp   = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.ff");
                string time_string = string.Format("[{0}]", timeStamp);
                //SW.Write(time_string);
                log_message += time_string;
                if (0 == m_main_stack_count)
                {
                    StackFrame callStack = new StackFrame(1, true);
                    string     file_line = string.Format("[{0}:{1}]: ", callStack.GetFileName(), callStack.GetFileLineNumber());
                    //SW.Write(file_line);
                    log_message += file_line;
                }
                else
                {
                    StackTrace st                  = new StackTrace();
                    int        frame_count         = st.FrameCount;
                    int        current_stack_count = frame_count - m_main_stack_count;
                    ++current_stack_count;
                    for (int i = 1; i < current_stack_count; ++i)
                    {
                        StackFrame callStack = new StackFrame(i, true);
                        string     file_line = string.Format("[{0}:{1}]", callStack.GetFileName(), callStack.GetFileLineNumber());
                        //SW.WriteLine(file_line);
                        log_message += file_line;
                    }
                }
                log_message += string.Format(format, args);
                SW.Write(log_message);
                SW.Close();
                SW.Dispose();

                if (m_message_box)
                {
                    MessageBox.Show(log_message);
                }
            }
        }
        /// <summary>
        /// クラスの説明文のコメント部を出力
        /// </summary>
        /// <param name="t"></param>
        /// <param name="_ns"></param>
        /// <param name="nsList"></param>
        static void PrintClassCommentLabel(Type t, string _ns, List <NameSpaceNested> nsList)
        {
            int nLastNext = 0;

            for (int n = 0; n < nsList.Count; n++)
            {
                if (nsList[n].NameSpace != "any" && nsList[n].NameSpace != "NONE")
                {
                    SWTabSpace(n);
                    if (n == 0)
                    {
                        SW.Write("declare ");
                    }
                    SW.WriteLine("namespace " + nsList[n].NameSpace + " {");

                    // 一番深いネームスペースのところで…
                    if (n == nsList.Count - 1)
                    {
                        PrintClassDetail(t, _ns, n + 1);
                        nLastNext = n;
                        AnalyzeMemberInfo(t, n + 1);
                    }
                }
                else
                {
                    PrintClassDetail(t, _ns, 0);

                    SW.Write("declare ");
                    nLastNext = n;
                    AnalyzeMemberInfo(t, 0);
                }
            }

            for (int n = nLastNext; n >= 0; n--)
            {
                if (nsList[n].NameSpace != "any" && nsList[n].NameSpace != "NONE")
                {
                    SWTabSpace(n);
                    SW.WriteLine("}");
                }
            }
        }
        protected void Print(IPropertyEntity propertyEntity)
        {
            SW.WriteLine("object property {0}", propertyEntity.Identity);
            SW.WriteLine("{");

            //print parents
            foreach (IPropertyEntity parent in Graph.GetParents(propertyEntity).GetItems())
            {
                SW.WriteLine("\tis_subproperty_of  {0};", parent.Identity);
            }

            //print domain
            SW.Write("\tdomain ");
            bool firstEntrance = true;

            foreach (IClassEntity classEntity in Graph.GetClasses(propertyEntity).GetItems())
            {
                if (firstEntrance)
                {
                    firstEntrance = false;
                    SW.Write("{0}", classEntity.Value);
                }
                else
                {
                    SW.Write(", {0}", classEntity.Value);
                }
            }
            SW.WriteLine(";");

            //print range
            if (propertyEntity.Range != null)
            {
                SW.WriteLine("\trange {0};", propertyEntity.Range.Name);
            }
            else
            {
                SW.WriteLine("\trange bool;");
            }

            SW.WriteLine("}");
        }
Пример #22
0
        public void SaveToFile(string FileName)
        {
            StreamWriter SW;

            try
            {
                SW = File.CreateText(FileName);
                SW.Write(OutputString);
                SW.Close();
                MessageBox.Show("File salvato correttamente.");
                this.Close();
                this.Dispose();
            }
            catch (Exception e)
            {
                MessageBox.Show("Problemi con la scrittura del file." + "\r\n" + e.ToString());
                this.Close();
                this.Dispose();
            }
            return;
        }
Пример #23
0
        /// <summary>
        /// The purpose of this method is maintain service stop information in text file.
        /// </summary>
        public static void Create_ServiceStoptextfile()
        {
            string       Destination = "D:\\DemoWebservice\\ServiceStopInforation";
            StreamWriter SW;

            if (Directory.Exists(Destination))
            {
                Destination = System.IO.Path.Combine(Destination, "txtServiceStop_" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                if (!File.Exists(Destination))
                {
                    SW = File.CreateText(Destination);
                    SW.Close();
                }
            }
            using (SW = File.AppendText(Destination))
            {
                SW.Write("\r\n\n");
                SW.WriteLine("Service Stopped at: " + DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"));
                SW.Close();
            }
        }
Пример #24
0
        public static void Create_ServiceStoptextfile()
        {
            string       Destination = "E:\\Projects\\BulK_upload_services\\Excel_upload\\articleimg\\FileWatcherWinService";
            StreamWriter SW;

            if (Directory.Exists(Destination))
            {
                Destination = System.IO.Path.Combine(Destination, "txtServiceStop_" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                if (!File.Exists(Destination))
                {
                    SW = File.CreateText(Destination);
                    SW.Close();
                }
            }
            using (SW = File.AppendText(Destination))
            {
                SW.Write("\r\n\n");
                SW.WriteLine("Service Stopped at: " + DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"));
                SW.Close();
            }
        }
Пример #25
0
        public void WriteLog(string message, string logFileName)
        {
            var          LogDestination = _configuration.GetValue <string>("AppSetings:LogDestination");
            StreamWriter SW;

            if (Directory.Exists(LogDestination))
            {
                var destination = System.IO.Path.Combine(LogDestination, logFileName + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                if (!File.Exists(destination))
                {
                    SW = File.CreateText(destination);
                    SW.Close();
                }

                using (SW = File.AppendText(destination))
                {
                    SW.Write("\r\n\n");
                    SW.WriteLine(DateTime.Now.ToString("dd-MM-yyyy H:mm:ss") + " " + message);
                    SW.Close();
                }
            }
        }
        }/**/

        /*
         * private void CreateTextFile(string FullPath, string FileName)
         * {
         *  StreamWriter SW;
         *  if (!File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
         *      "txtStatus_" + DateTime.Now.ToString("yyyyMMdd") + ".txt")))
         *  {
         *      SW = File.CreateText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
         *          "txtStatus_" + DateTime.Now.ToString("yyyyMMdd") + ".txt"));
         *      SW.Close();
         *  }
         *  using (SW = File.AppendText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
         *      "txtStatus_" + DateTime.Now.ToString("yyyyMMdd") + ".txt")))
         *  {
         *      SW.WriteLine("File Created with Name: " + FileName + " at this location: " + FullPath);
         *      SW.Close();
         *  }
         * }/**/

        public static void CreateLogFile(string content)
        {
            string       Destination = logPath;
            StreamWriter SW;

            if (Directory.Exists(Destination))
            {
                Destination = System.IO.Path.Combine(Destination, "Log_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt");
                if (!File.Exists(Destination))
                {
                    SW = File.CreateText(Destination);
                    SW.Close();
                }
            }
            using (SW = File.AppendText(Destination))
            {
                SW.Write("\r\n\n");
                SW.WriteLine("Error occurs at: " + DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"));
                SW.WriteLine(content);
                SW.Close();
            }
        }/**/
Пример #27
0
        private void DisplayScreenShot(IDisplayItem msg)
        {
            //this.Cursor = Cursors.WaitCursor;
            XslCompiledTransform xsl = new XslCompiledTransform();

            xsl.Load(ApplicationSettings.Instance.AppPath + @"\screenShotTab.xslt");


            XsltArgumentList argList = new XsltArgumentList();

            argList.AddParam("systemPath", "", ApplicationSettings.Instance.AppPath);
            argList.AddParam("dataPath", "", ApplicationSettings.Instance.LocalDataPath);
            //argList.AddParam("contactFilter", "", m_contactFilter);
            //argList.AddParam("scrollTop", "", m_scrollTop.ToString());


            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(msg.XML);

            if (Directory.Exists(ApplicationSettings.Instance.LocalDataPath + @"\debug"))
            {
                StreamWriter SW;
                SW = File.CreateText(ApplicationSettings.Instance.LocalDataPath + @"\debug\DisplayScreenShot.xml");
                SW.Write(msg.XML);
                SW.Close();
            }

            XmlDocument outputDocument = new XmlDocument();

            System.Xml.XPath.XPathNavigator outputNavigator = outputDocument.CreateNavigator();
            using (XmlWriter writer = outputNavigator.AppendChild())
            {
                xsl.Transform(xmlDoc, argList, writer);
            }
            webBrowser.DocumentText = outputDocument.OuterXml;

            this.activeTab = eTabs.eTab_ScreenShot;
        }
Пример #28
0
        public void LogError(string error)
        {
            var          LogDestination = ConfigurationManager.AppSettings["LogDestination"].ToString();
            StreamWriter SW;

            if (Directory.Exists(LogDestination))
            {
                var destination = System.IO.Path.Combine(LogDestination, "LogError_" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                if (!File.Exists(destination))
                {
                    SW = File.CreateText(destination);
                    SW.Close();
                }

                using (SW = File.AppendText(destination))
                {
                    SW.Write("\r\n\n");
                    SW.WriteLine(DateTime.Now.ToString("dd-MM-yyyy H:mm:ss") + " " + error);
                    SW.Close();
                }
            }
        }
Пример #29
0
        /// <summary>
        /// 1つのプロパティの分析
        /// </summary>
        /// <param name="p">オブジェクト</param>
        /// <param name="nestLevel">整形用</param>
        static void AnalyzePropertyInfo(PropertyInfo p, int nestLevel)
        {
            // TypeScript向けに変換
            var ts = TypeToString(p.PropertyType);

            // 引数一覧
            var genlist = p.PropertyType.GetGenericArguments();

            // 「.」があったら、複雑すぎると判断する。
            bool isComplex = IsGenericAnyCondtion(genlist, (g) => { return(g.ToString().Contains(".")); });

            ts = ModifyType(ts, isComplex);

            SWTabSpace(nestLevel + 1);

            // 読み取り専用
            if (p.CanRead && !p.CanWrite)
            {
                SW.Write("readonly ");
            }

            SW.WriteLine(p.Name + " :" + ts + ";");
        }
Пример #30
0
        // 返りの型の分析
        static string AnalyzeResultInfo(MethodInfo m, int nestLevel, List <string> genericParameterTypeStringList)
        {
            //戻り値を表示
            if (m.ReturnType == typeof(void))
            {
                var ts = "void";
                SW.Write(ts);
                FI.Write(ts);

                return(ts);
            }
            else
            {
                var ts = TypeToString(m.ReturnType);

                // 複雑過ぎるかどうか
                var  genlist   = m.ReturnType.GetGenericArguments();
                bool isComplex = IsGenericAnyCondtion(genlist,
                                                      (g) => {
                    // クラスに無いのに、関数が突然Genericというのは、場合によってはTypeScriptでは無理が出る
                    if (!genericParameterTypeStringList.Exists((e) => { return(e.ToString() == g.ToString()); }))
                    {
                        return(true);
                    }
                    return(false);
                }
                                                      );


                ts = ModifyType(ts, isComplex);

                SW.Write(ts + "");
                FI.Write(ts + "");

                return(ts);
            }
        }