Exemplo n.º 1
0
        internal static void SaveLogging(LoggingInfo logging)
        {
            try
            {
                if (logging.Value != null)
                {
                    using (var sqlCommand = new SqlCommand())
                    {
                        GenerateSqlConnection();

                        sqlCommand.CommandText = string.Format("insert into Logging(Text) values({0})", "\'" + logging.Value + "\'");
                        sqlCommand.Connection  = _sqlConnection;
                        sqlCommand.CommandType = CommandType.Text;
                        _sqlConnection.Open();
                        sqlCommand.ExecuteNonQuery();
                        _sqlConnection.Close();
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                LoggingManager.WriteToLog("SQL", "SaveLogging", exc);
            }
        }
Exemplo n.º 2
0
        static void _tmrReadLogging_Tick(object sender, EventArgs e)
        {
            try
            {
                using (var streamReader = new System.IO.StreamReader(string.Format(@"\\{0}\logging$\verbose.log", _remoteIP)))
                {
                    if (streamReader.BaseStream.Length < LastStreamOffset)
                    {
                        LastStreamOffset = 0;
                    }
                    streamReader.BaseStream.Seek(LastStreamOffset, SeekOrigin.Begin);

                    //read out of the file until the EOF
                    string line = "";
                    while ((line = streamReader.ReadLine()) != null)
                    {
                        var logLine = line.Split(';');
                        var logging = new LoggingInfo(logLine[0], logLine[1], logLine[2], logLine[3]);

                        Lines.Add(logging);
                    }

                    //update the last max offset
                    LastStreamOffset = streamReader.BaseStream.Position;
                }
            }
            catch (Exception exc)
            {
            }
        }
Exemplo n.º 3
0
        private static async void Bot_OnMessage(object sender, MessageEventArgs e)
        {
            if (e.Message.Text != null)
            {
                var ratingRetrieved = GetMaximumRating(e.Message.Text);
                var resultAnswer    = $"По вашему запросу получен рейтинг: *{ratingRetrieved}*";
                await _botClient.SendTextMessageAsync(
                    chatId : e.Message.Chat,
                    text : resultAnswer,
                    ParseMode.Markdown
                    );

                var logInfo = new LoggingInfo
                {
                    ChatId    = e.Message.Chat.Id,
                    FirstName = e.Message.Chat.FirstName,
                    LastName  = e.Message.Chat.LastName,
                    UserName  = e.Message.Chat.Username,
                    Question  = e.Message.Text,
                    Answer    = resultAnswer,
                    Date      = e.Message.Date
                };
                _logger.OutputWriter(logInfo);
            }
        }
        public void OnActionExecuted(ActionExecutedContext context)
        {
            //try
            //{
            var controllerName = ((ControllerBase)context?.Controller)?.ControllerContext?.ActionDescriptor?.ControllerName;
            var actionName     = ((ControllerBase)context?.Controller)?.ControllerContext?.ActionDescriptor?.ActionName;

            LoggingInfo info = new LoggingInfo()
            {
                ActionName      = actionName,
                ControllerName  = controllerName,
                Description     = "action executed at:" + DateTime.Now.ToString(),
                RecordTimeStamp = DateTime.Now,
            };

            foreach (ParameterDescriptor item
                     in ((ControllerBase)context.Controller).ControllerContext.ActionDescriptor.Parameters)
            {
                //print item.Key
                //print item.Value
            }
            this._logging.CaptureLogs(info);



            //code to insert into the log table
            //}
            //catch
            //{
            //    throw new NotImplementedException();
            //}
        }
Exemplo n.º 5
0
        protected bool DoAllPairedColumnsInsideExist(LoggingInfo logInfo, DataTable schemaTable, List <List <string> > pairedColumnsInside)
        {
            if (pairedColumnsInside == null)
            {
                return(true);
            }

            if (pairedColumnsInside.Count == 0)
            {
                return(true);
            }

            var pairedColumns = pairedColumnsInside.SelectMany(pd => pd, (listOfLists, list) => list).Distinct();

            var allColumns = schemaTable
                             .Columns;

            bool doAllColumnsExist = true;

            foreach (var column in pairedColumns)
            {
                if (allColumns[column] == null)
                {
                    Log.Error($"The column {column} doesn't exist in the table {logInfo.TableNameWithSchema}. " +
                              $"Connection string: {logInfo.ConnectionString}.", logInfo);
                    doAllColumnsExist = false;
                }
            }

            return(doAllColumnsExist);
        }
Exemplo n.º 6
0
        public void Start()
        {
            try
            {
                EventLog.Source = Name;

                string portSetting = ConfigurationManager.AppSettings["port"];

                if (int.TryParse(portSetting, out int port))
                {
                    BaseAddress = $"http://localhost:{port}/";
                }
                else
                {
                    LoggingInfo?.Invoke($"Port is not configured or incorrect value '{portSetting}'");
                    return;
                }

                AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

                _server = WebApp.Start <Startup>(url: BaseAddress);

                LoggingInfo?.Invoke($"Listen at: {BaseAddress}");
            }
            catch (Exception exc)
            {
                LoggingError?.Invoke(exc.ToString());
            }
        }
Exemplo n.º 7
0
        protected void OnButtonOkClicked(object sender, EventArgs e)
        {
            string feedText = "";

            switch (notb.Page)
            {
            case 0:
                feedText = feedbackIssue.GetData();
                break;

            case 1:
                feedText = feedbackQuestion.GetData();
                break;

            case 2:
                feedText = feedbackSuggestion.GetData();
                break;
            }
            Console.WriteLine(feedText);

            if (MainClass.Settings.Account == null)
            {
                Console.WriteLine("Account IS NULL");
            }

            if (String.IsNullOrEmpty(MainClass.Settings.Account.Token))
            {
                Console.WriteLine("Token IS NULL");
            }

            if ((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token)))
            {
                MessageDialogs md =
                    new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_login_f1"), "", Gtk.MessageType.Error, this);
                md.ShowDialog();
                Console.WriteLine("IS NULL");
                return;
            }

            buttonOk.Sensitive = false;

            if (string.IsNullOrEmpty(feedText))
            {
                return;
            }

            lblStatus.LabelProp = "Sending...";
            while (Gtk.Application.EventsPending())
            {
                Gtk.Application.RunIteration();
            }

            LoggingInfo log = new LoggingInfo();

            log.SendFeedback(feedText, LoginYesWrite, LoginNoWrite);

            //this.Respond(Gtk.ResponseType.Ok);
        }
Exemplo n.º 8
0
 private void WriteToFile(LoggingInfo info)
 {
     using (StreamWriter file = File.AppendText(FileAddressPath))
     {
         file.WriteLine($"Received a text message in chat {info.ChatId}.");
         file.WriteLine($"Received message from {info.FirstName} {info.LastName}.");
         file.WriteLine($"Received message at {info.Date}.");
         file.WriteLine($"Sender user name @{info.UserName}.");
         file.WriteLine($"Input was: \"{info.Question}\".");
         file.WriteLine($"Output was: \"{info.Answer}\".");
         file.WriteLine("");
     }
 }
Exemplo n.º 9
0
        public override bool AreTheParamsValid(string connectionString, TableConfig tableConfig)
        {
            bool doConstantScrambledDuplicatesExist;
            bool doAllColumnsExist;
            bool doAllPairedColumnsInsideExist;
            bool doAllPairedColumnsOutsideExist;
            bool isThereAPrimaryKeyConflict;
            bool isThereAUniqueConstraintConflict;

            DataTable schemaTable;

            try
            {
                schemaTable = GetTableSchema(connectionString, tableConfig.FullTableName);
            }
            catch (SqlException ex)
            {
                Log.Error($"Error while checking the parameters of table: {tableConfig.FullTableName}. " +
                          $"Connection string: {connectionString}. " +
                          $"The mapped database {connectionString} or table {tableConfig.FullTableName} doesn't exist or it is unreachable. " +
                          $"Error message: {ex.Message}");
                return(false);
            }


            var loggingInfo = new LoggingInfo {
                ConnectionString = connectionString, TableNameWithSchema = tableConfig.FullTableName
            };

            var constantColumns = tableConfig.ConstantColumns?.Select(c => c.Name)
                                  .Select(c => ParameterNameHelper.RemoveParenthesises(c)) ?? new List <string>();

            var scrambledColumns = tableConfig.ScrambledColumns?.Select(c => c.Name)
                                   .Select(c => ParameterNameHelper.RemoveParenthesises(c)) ?? new List <string>();

            var pairedColumns = tableConfig.PairedColumnsInsideTable?
                                .Select(cl =>
                                        cl.Select(c => ParameterNameHelper.RemoveParenthesises(c)).ToList()).ToList() ?? new List <List <string> >();

            var allColumns = constantColumns.Concat(scrambledColumns);

            doConstantScrambledDuplicatesExist = DoConstantScrambledDuplicatesExist(loggingInfo, scrambledColumns, constantColumns);
            doAllColumnsExist                = DoAllColumnsExist(schemaTable, loggingInfo, allColumns);
            doAllPairedColumnsInsideExist    = DoAllPairedColumnsInsideExist(loggingInfo, schemaTable, pairedColumns);
            doAllPairedColumnsOutsideExist   = DoAllPairedColumnsOutsideExist(connectionString, tableConfig);
            isThereAPrimaryKeyConflict       = IsThereAPrimaryKeyConflict(schemaTable, loggingInfo, allColumns);
            isThereAUniqueConstraintConflict = IsThereAUniqueConstraintConflict(schemaTable, loggingInfo, allColumns);

            return(!doConstantScrambledDuplicatesExist && doAllColumnsExist && doAllPairedColumnsInsideExist &&
                   doAllPairedColumnsOutsideExist && !isThereAPrimaryKeyConflict && !isThereAUniqueConstraintConflict);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the logging information.
        /// </summary>
        /// <returns>Returns a instace of the formating options</returns>
        private LoggingInfo GetLoggingInfo()
        {
            LoggingInfo info = new LoggingInfo
            {
                LogParameters    = LogParameters,
                LogReturnValue   = LogReturnValue,
                LogExecutionTime = LogExecutionTime,
                MethodName       = _methodName,
                DeclaringType    = _declaringType,
                Stopwatch        = Stopwatch
            };

            return(info);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Method executed <b>after</b> the body of methods to which this aspect is applied,
        /// but only when the method successfully returns (i.e. when no exception flies out
        /// the method.).
        /// </summary>
        /// <param name="args">Event arguments specifying which method
        /// is being executed and which are its arguments.</param>
        /// <exception cref="System.ArgumentNullException">args</exception>
        public override void OnSuccess(MethodExecutionArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            if (!_shouldLog)
            {
                return;
            }

            LoggingInfo info = GetLoggingInfo();

            string message = MessageFormatter.FormatMessage(Output, args, "Success", info);

            Logger.Debug(message);
        }
Exemplo n.º 12
0
        private void RunPublishTask(List <CombinePublish> list)
        {
            LoggingInfo log = new LoggingInfo();

            log.LoggWebThread(LoggingInfo.ActionId.IDEEnd, project.ProjectName);

            if ((!MainClass.Workspace.SignApp))
            {
                TaskList tlpublish = new TaskList();
                tlpublish.TasksList = new System.Collections.Generic.List <Moscrif.IDE.Task.ITask>();

                PublishTask pt = new PublishTask();
                pt.ParentWindow = this;
                pt.Initialize(list);

                tlpublish.TasksList.Add(pt);
                MainClass.MainWindow.RunTaskList(tlpublish, true);
            }
            else
            {
                if (MainClass.User == null)
                {
                    LoginRegisterDialog ld = new LoginRegisterDialog(this);
                    int res = ld.Run();

                    if (res == (int)Gtk.ResponseType.Cancel)
                    {
                        ld.Destroy();
                        return;
                    }
                    ld.Destroy();
                }

                TaskList tl = new TaskList();
                tl.TasksList = new System.Collections.Generic.List <Moscrif.IDE.Task.ITask>();
                SignPublishTask ct = new SignPublishTask();
                ct.Initialize(list);
                ct.ParentWindow = this;

                tl.TasksList.Add(ct);

                MainClass.MainWindow.RunTaskList(tl, false);
            }
        }
Exemplo n.º 13
0
        protected bool DoAllColumnsExist(DataTable schemaTable, LoggingInfo logInfo, IEnumerable <string> columns)
        {
            var allColumns = schemaTable
                             .Columns;

            bool doAllColumnsExist = true;

            foreach (var column in columns)
            {
                if (allColumns[column] == null)
                {
                    Log.Error($"The column {column} doesn't exist in the table {logInfo.TableNameWithSchema}. " +
                              $"Connection string: {logInfo.ConnectionString}.", logInfo);
                    doAllColumnsExist = false;
                }
            }

            return(doAllColumnsExist);
        }
Exemplo n.º 14
0
        protected bool IsThereAPrimaryKeyConflict(DataTable schemaTable, LoggingInfo logInfo, IEnumerable <string> columns)
        {
            var primaryKeys = schemaTable.PrimaryKey.Select(c => c.ColumnName);

            bool isThereAPrimaryKeyConflict = false;

            foreach (var primaryKey in primaryKeys)
            {
                if (columns.Contains(primaryKey))
                {
                    Log.Error($"The following column is part of a primary key: {primaryKey} in the table {logInfo.TableNameWithSchema}." +
                              $" Connection string: {logInfo.ConnectionString}",
                              logInfo);
                    isThereAPrimaryKeyConflict = true;
                }
            }

            return(isThereAPrimaryKeyConflict);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Method executed <b>after</b> the body of methods to which this aspect is applied,
        /// in case that the method resulted with an exception.
        /// </summary>
        /// <param name="args">Event arguments specifying which method
        /// is being executed and which are its arguments.</param>
        /// <exception cref="System.ArgumentNullException">args</exception>
        public override void OnException(MethodExecutionArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            if (!_shouldLog)
            {
                return;
            }

            args.FlowBehavior = FlowBehavior.RethrowException;

            LoggingInfo info = GetLoggingInfo();

            string message = MessageFormatter.FormatMessage(Output, args, "Exception", info);

            Logger.Error(message, args.Exception);
        }
Exemplo n.º 16
0
        public void SuccessLog(IDbConnection c, LoggingInfo l)
        {
            IDbCommand     logger         = c.CreateCommand();
            IDbTransaction logTransaction = c.BeginTransaction();

            logger.Connection  = c;
            logger.Transaction = logTransaction;

            try
            {
                logger.CommandText = "SET LogEnd = CURRENT_TIMESTAMP;";
                logger.ExecuteReader();
                logger.CommandText = "SET TimeDiff = (SELECT DATEDIFF(second, $Logstart, CURRENT_TIMESTAMP));";
                logger.ExecuteReader();
                logger.CommandText = "INSERT INTO Log.TransactionJobTracking " +
                                     "Values(" +
                                     GetBatchDay() + ", " +
                                     "CURRENT_DATABASE(), " +
                                     "'" + l.JobName + "', " +
                                     "$Jobstart, " +
                                     "'" + l.Step + "', " +
                                     "'" + l.StepLabel + "', " +
                                     "'" + l.StepDescription + "', " +
                                     "'" + l.StepTargetSchema + "', " +
                                     "'" + l.StepTargetTable + "', " +
                                     "" + l.StepRowsAffected + ", " +
                                     "'Success', " +
                                     "$Logstart, " +
                                     "$LogEnd," +
                                     "$TimeDiff);";

                logger.ExecuteReader();
                logTransaction.Commit();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                logTransaction.Rollback();
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Formats the output message.
        /// </summary>
        /// <param name="output">The output pattern.</param>
        /// <param name="args">The method execution arguments.</param>
        /// <param name="action">The logging action.</param>
        /// <param name="info">The logging options.</param>
        /// <returns>Retuns a formate output message</returns>
        /// <exception cref="System.ArgumentNullException"> args or info</exception>
        /// <exception cref="System.ArgumentException">Value for "action" cannot be null or whitespace.</exception>
        public static string FormatMessage(string output, MethodExecutionArgs args, string action, LoggingInfo info)
        {
            if (args == null) throw new ArgumentNullException("args");
            if (info == null) throw new ArgumentNullException("info");
            if (string.IsNullOrWhiteSpace(action))
                throw new ArgumentException("Value cannot be null or whitespace.", "action");

            string message = string.IsNullOrWhiteSpace(output) ? DefaultOutputFormat : output;
            message = message.Replace(DateTimeElement, DateTime.Now.ToString("u", CultureInfo.InvariantCulture));
            message = message.Replace(ActionElement, action);
            message = message.Replace(DeclaringTypeElement, info.DeclaringType.FullName);
            message = message.Replace(MethodNameElement, info.MethodName);

            if (info.LogParameters)
            {
                IDictionary<string, object> arguments = GetArguments(args);
                string formatArguments = FormatArguments(arguments);
                string value = formatArguments.Equals("NULL", StringComparison.OrdinalIgnoreCase) ? string.Empty : formatArguments;
                message = message.Replace(ArgumentsElement, value);
            }
            else
            {
                message = message.Replace(ArgumentsElement, string.Empty);
            }

            if (info.LogReturnValue)
            {
                string returnValue = FormatObject(args.ReturnValue);
                message = message.Replace(ReturnValueElement, returnValue);
            }
            else
            {
                message = message.Replace(ReturnValueElement, string.Empty);
            }

            string elapsedTimeString = info.LogExecutionTime ? info.Stopwatch.Elapsed.ToString() : string.Empty;
            message = message.Replace(ElapsedTimeElement, elapsedTimeString);

            return message;
        }
Exemplo n.º 18
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            //try
            //{
            var         controllerName = ((ControllerBase)context?.Controller)?.ControllerContext?.ActionDescriptor?.ControllerName;
            var         actionName     = ((ControllerBase)context?.Controller)?.ControllerContext?.ActionDescriptor?.ActionName;
            var         controller     = context.Controller as Controller;
            LoggingInfo info           = new LoggingInfo()
            {
                ActionName      = actionName,
                ControllerName  = controllerName,
                Description     = "action executed at:" + DateTime.Now.ToString(),
                RecordTimeStamp = DateTime.Now,
            };

            this._logging.CaptureLogs(info);
            //}
            //catch
            //{
            //    throw new NotImplementedException();
            //}
        }
Exemplo n.º 19
0
        protected bool DoConstantScrambledDuplicatesExist(LoggingInfo logInfo, IEnumerable <string> scrambledColumns, IEnumerable <string> constantColumns)
        {
            if (scrambledColumns == null && constantColumns == null)
            {
                Log.Error($"There are no constant or scrambled columns in the table to scramble/set. " +
                          $"{logInfo.TableNameWithSchema}. Connection string: {logInfo.ConnectionString}", logInfo);
                throw new ArgumentNullException("Constant and scrambled column lists can not be both empty.");
            }

            if ((scrambledColumns == null || constantColumns == null))
            {
                return(false);
            }

            if (scrambledColumns.Count() == 0 || constantColumns.Count() == 0)
            {
                return(false);
            }

            bool isThereADuplicationConflict    = false;
            var  normalizedScrambledColumnsCopy = GetNormalizedColumnListCopy(scrambledColumns);
            var  normalizedConstantColumnsCopy  = GetNormalizedColumnListCopy(constantColumns);

            foreach (var scrambledColumn in normalizedScrambledColumnsCopy)
            {
                var scrambledColumnCopy = String.Copy(scrambledColumn);
                foreach (var constantColumn in normalizedConstantColumnsCopy)
                {
                    if (constantColumn.ToLower() == scrambledColumn.ToLower())
                    {
                        Log.Error($"The column {constantColumn} appears both at the constant and scrambled columns in table " +
                                  $"{logInfo.TableNameWithSchema}. Connection string: {logInfo.ConnectionString}", logInfo);
                        isThereADuplicationConflict = true;
                    }
                }
            }

            return(isThereADuplicationConflict);
        }
Exemplo n.º 20
0
        public override void OnException(ExceptionContext context)
        {
            try
            {
                var exception = context.Exception;

                LoggingInfo info = new LoggingInfo()
                {
                    ActionName      = string.Empty,
                    ControllerName  = string.Empty,
                    Description     = exception.InnerException != null ? exception.InnerException.Message + exception.InnerException.StackTrace : exception.Message + exception.StackTrace,
                    RecordTimeStamp = DateTime.Now,
                };
                this._logging.CaptureLogs(info);

                HandleExceptionAsync(context);
                context.ExceptionHandled = true;
            }
            catch
            {
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Method executed <b>after</b> the body of methods to which this aspect is applied,
        /// even when the method exists with an exception (this method is invoked from
        /// the <c>finally</c> block).
        /// </summary>
        /// <param name="args">Event arguments specifying which method
        /// is being executed and which are its arguments.</param>
        /// <exception cref="System.ArgumentNullException">args</exception>
        public override void OnExit(MethodExecutionArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            if (!_shouldLog)
            {
                return;
            }

            LoggingInfo info = GetLoggingInfo();

            string message = MessageFormatter.FormatMessage(Output, args, "Exited", info);

            if (LogExecutionTime)
            {
                Stopwatch.Stop();
            }

            Logger.Debug(message);
        }
Exemplo n.º 22
0
        protected bool IsThereAUniqueConstraintConflict(DataTable schemaTable, LoggingInfo logInfo, IEnumerable <string> columns)
        {
            var allColumns = schemaTable
                             .Columns;

            bool isThereAUniqueConstraintConflict = false;

            foreach (var column in columns)
            {
                if (allColumns[column] == null)
                {
                    continue;
                }

                if (allColumns[column].Unique)
                {
                    Log.Error($"The column {column} is part of a unique constraint in table {logInfo.TableNameWithSchema}. " +
                              $"Connection string: {logInfo.ConnectionString}. ", logInfo);
                    isThereAUniqueConstraintConflict = true;
                }
            }

            return(isThereAUniqueConstraintConflict);
        }
Exemplo n.º 23
0
        protected void OnButtonOkClicked(object sender, EventArgs e)
        {
            if ((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token)))
            {
                this.Respond(Gtk.ResponseType.Ok);
            }

            lblStatus.LabelProp = "Sending...";
            buttonOk.Sensitive  = false;
            while (Gtk.Application.EventsPending())
            {
                Gtk.Application.RunIteration();
            }

            string logFile = System.IO.Path.Combine(MainClass.Paths.SettingDir, "moscrif-ide.log");

            Tool.Logger.Close();
            LoggingInfo log = new LoggingInfo();

            log.LoggWebFile(LoggingInfo.ActionId.IDECrush, logFile, LoginYesWrite, LoginNoWrite);
            //this.Respond(Gtk.ResponseType.Ok);
            //string log2 ="C:/moscrif-ide.log";
            //string text = "";

            /*try{
             *      File.Copy(log,log2);
             * } catch{
             *
             * }
             * this.Respond(Gtk.ResponseType.Ok);*/
            /*using (StreamReader sr = new StreamReader(log)){
             *      text = sr.ReadToEnd();
             * }*/

            //throw new System.NotImplementedException ();
        }
Exemplo n.º 24
0
        public Project CreateProject(string filename, string projectName, string projectLocation, string projectDir, string aplicationFile, string skin, string theme)
        {
            Project p = FindProject(filename);

            if (p == null)
            {
                p = new Project();
                if (!System.IO.File.Exists(filename))
                {
                    string projectWorkingDir = System.IO.Path.Combine(projectLocation, projectDir);

                    if (!System.IO.File.Exists(aplicationFile))
                    {
                        AppFile appFile = new AppFile(aplicationFile, projectName);                        //, projectDir);
                        appFile.Uses        = "core ui uix uix-skin media sqlite net game2d crypto box2d graphics sensor";
                        appFile.Main        = "main.ms";
                        appFile.Author      = "Generated by Moscrif-Ide";
                        appFile.Title       = projectName;
                        appFile.Copyright   = " ";
                        appFile.Version     = "1.0";
                        appFile.Orientation = "portrait";
                        try{
                            appFile.Save();
                        } catch (Exception ex) {
                            throw new Exception(MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile) + "\n" + ex.Message);

                            /*MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error);
                             * ms.ShowDialog();
                             * return null;*/
                        }
                    }

                    string mainFile = System.IO.Path.Combine(projectWorkingDir, "main.ms");
                    try {
                        Directory.CreateDirectory(projectWorkingDir);

                        using (StreamWriter file = new StreamWriter(mainFile)) {
                            file.Write("// TODO: Add your code here.");
                            file.Close();
                            file.Dispose();
                        }
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "core"));
                        //Directory.CreateDirectory(System.IO.Path.Combine(projectWorkingDir, "ui"));
                    } catch {
                    }

                    p = new Project(filename);
                    //p.ProjectDir = GetRelativePath(projectWorkingDir);
                    //p.ProjectName = projectName;
                    p.AppFilePath = GetRelativePath(aplicationFile);
                    p.StartFile   = GetRelativePath(mainFile);

                    p.NewSkin = true;
                    p.GenerateDevices(skin, theme);

                    SaveProject(p);
                    Projects.Add(p);
                    ProjectsFile.Add(GetRelativePath(filename));

                    LoggingInfo log = new LoggingInfo();
                    log.LoggWebThread(LoggingInfo.ActionId.IDENewProject, p.ProjectName);

                    return(p);
                }
                else
                {
                    throw new Exception(MainClass.Languages.Translate("project_is_exist", filename));

                    /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_exist",filename), "", Gtk.MessageType.Error);
                     * md.ShowDialog();
                     * return null;*/
                }
            }
            else
            {
                throw new Exception(MainClass.Languages.Translate("project_is_opened", p.ProjectName));

                /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_opened",p.ProjectName), null, Gtk.MessageType.Error);
                 * md.ShowDialog();
                 * return null;*/
            }
        }
Exemplo n.º 25
0
 /// <summary>
 /// Gets the logging information.
 /// </summary>
 /// <returns>Returns a instace of the formating options</returns>
 private LoggingInfo GetLoggingInfo()
 {
     LoggingInfo info = new LoggingInfo
     {
         LogParameters = LogParameters, 
         LogReturnValue = LogReturnValue, 
         LogExecutionTime = LogExecutionTime, 
         MethodName = _methodName, 
         DeclaringType = _declaringType, 
         Stopwatch = Stopwatch
     };
     return info;
 }
Exemplo n.º 26
0
        public static void Main(string[] args)
        {
            //foreach(string str in args)
            //	Logger.Log("arg ->{0}",str);

            Application.Init();
            Logger.Log(Languages.Translate("start_app"));

            ExceptionManager.UnhandledException += delegate(UnhandledExceptionArgs argsum)
            {
                StringBuilder sb = new StringBuilder();

                Exception ex = (Exception)argsum.ExceptionObject;

                sb.AppendLine(ex.Message);
                sb.AppendLine(ex.StackTrace);
                Logger.Error(ex.Message);
                Logger.Error(ex.StackTrace);
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);

                if (ex.InnerException != null)
                {
                    Logger.Error(ex.InnerException.Message);
                    Logger.Error(ex.InnerException.StackTrace);
                    Logger.Error(ex.InnerException.Source);
                    Console.WriteLine(ex.InnerException.Message);
                    Console.WriteLine(ex.InnerException.StackTrace);
                    Console.WriteLine(ex.InnerException.Source);
                    sb.AppendLine(ex.InnerException.Message);
                    sb.AppendLine(ex.InnerException.StackTrace);
                    sb.AppendLine(ex.InnerException.Source);
                }

                ErrorDialog ed = new ErrorDialog();
                ed.ErrorMessage = sb.ToString();
                ed.Run();
                ed.Destroy();

                argsum.ExitApplication = true;
            };

            Gdk.Global.InitCheck(ref args);
            if (Platform.IsWindows)
            {
                string themePath = Paths.DefaultTheme;
                if (System.IO.File.Exists(themePath))
                {
                    Gtk.Rc.AddDefaultFile(themePath);
                    Gtk.Rc.Parse(themePath);
                }
            }

            mainWindow = new MainWindow(args);
            MainWindow.Show();

            if ((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token)))
            {
                LoginRegisterDialog ld = new LoginRegisterDialog(null);
                ld.Run();
                ld.Destroy();
            }
            else
            {
                LoggingInfo log = new LoggingInfo();
                log.LoggWebThread(LoggingInfo.ActionId.IDEStart);
            }

            if (!String.IsNullOrEmpty(Paths.TempDir))
            {
                Application.Run();
            }
        }
Exemplo n.º 27
0
        private void RunPublishTask(List <CombinePublish> list)
        {
            LoggingInfo log = new LoggingInfo();

            log.LoggWebThread(LoggingInfo.ActionId.IDEPublish, project.ProjectName);

            int selectTyp = (int)ddbTypPublish.CurrentItem;

            if ((selectTyp == 0) || (!MainClass.Workspace.SignApp))
            {
                tlpublish           = new TaskList();
                tlpublish.TasksList = new System.Collections.Generic.List <Moscrif.IDE.Task.ITask>();

                string selectRemote = (string)ddbTypRemote.CurrentItem;
                Console.WriteLine("selectRemote-" + selectRemote);
                if (selectRemote != "0")
                {
                    AppFile appF = MainClass.Workspace.ActualProject.AppFile;
                    appF.Remote_Console = selectRemote + ":" + MainClass.Settings.SocetServerPort;
                    appF.Save();
                    Console.WriteLine("MainClass.Workspace.ActualProject.AppFile.Remote_Console-" + MainClass.Workspace.ActualProject.AppFile.Remote_Console);
                }
                else
                {
                    AppFile appF = MainClass.Workspace.ActualProject.AppFile;
                    appF.Remote_Console = "";
                    appF.Save();
                }

                PublishAsynchronTask pt = new PublishAsynchronTask();
                pt.ParentWindow  = this;
                pt.EndTaskWrite += MainClass.MainWindow.EndTaskWritte;

                pt.EndTaskWrite += delegate(object sender, string name, string status, List <TaskMessage> errors) {
                    runningPublish  = false;
                    btnCancel.Label = "_Close";
                    if (selectRemote != "0")
                    {
                        AppFile appF = MainClass.Workspace.ActualProject.AppFile;
                        appF.Remote_Console = "";
                        appF.Save();
                    }
                };

                pt.ErrorWrite += MainClass.MainWindow.ErrorTaskWritte;
                pt.LogWrite   += MainClass.MainWindow.LogTaskWritte;
                pt.WriteStep  += delegate(object sender, StepEventArgs e) {
                    storeOutput.AppendValues(e.Message1, e.Message2, null, e.IsError);

                    if (status != 1)
                    {
                        status = e.Status;
                    }
                    while (Gtk.Application.EventsPending())
                    {
                        Gtk.Application.RunIteration();
                    }
                };
                pt.Initialize(list);

                tlpublish.TasksList.Add(pt);

                secondTaskThread              = new Thread(new ThreadStart(tlpublish.ExecuteTaskOnlineWrite));
                secondTaskThread.Name         = "Publish Second Task";
                secondTaskThread.IsBackground = true;
                runningPublish  = true;
                btnCancel.Label = "_Cancel";
                secondTaskThread.Start();
            }
            else
            {
                tlpublish           = new TaskList();
                tlpublish.TasksList = new System.Collections.Generic.List <Moscrif.IDE.Task.ITask>();

                SignPublishAsynchronTask pt = new SignPublishAsynchronTask();
                pt.ParentWindow  = this;
                pt.EndTaskWrite += MainClass.MainWindow.EndTaskWritte;
                pt.EndTaskWrite += delegate(object sender, string name, string status, List <TaskMessage> errors) {
                    runningPublish  = false;
                    btnCancel.Label = "_Close";
                };
                pt.ErrorWrite += MainClass.MainWindow.ErrorTaskWritte;
                pt.LogWrite   += MainClass.MainWindow.LogTaskWritte;
                pt.WriteStep  += delegate(object sender, StepEventArgs e) {
                    storeOutput.AppendValues(e.Message1, e.Message2, null, e.IsError);
                    if (status != 1)
                    {
                        status = e.Status;
                    }
                    while (Gtk.Application.EventsPending())
                    {
                        Gtk.Application.RunIteration();
                    }
                };
                pt.Initialize(list);

                tlpublish.TasksList.Add(pt);

                secondTaskThread              = new Thread(new ThreadStart(tlpublish.ExecuteTaskOnlineWrite));
                secondTaskThread.Name         = "Publish Second Task";
                secondTaskThread.IsBackground = true;
                runningPublish  = true;
                btnCancel.Label = "_Cancel";
                secondTaskThread.Start();
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Formats the output message.
        /// </summary>
        /// <param name="output">The output pattern.</param>
        /// <param name="args">The method execution arguments.</param>
        /// <param name="action">The logging action.</param>
        /// <param name="info">The logging options.</param>
        /// <returns>Retuns a formate output message</returns>
        /// <exception cref="System.ArgumentNullException"> args or info</exception>
        /// <exception cref="System.ArgumentException">Value for "action" cannot be null or whitespace.</exception>
        public static string FormatMessage(string output, MethodExecutionArgs args, string action, LoggingInfo info)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            if (string.IsNullOrWhiteSpace(action))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", "action");
            }

            string message = string.IsNullOrWhiteSpace(output) ? DefaultOutputFormat : output;

            message = message.Replace(DateTimeElement, DateTime.Now.ToString("u", CultureInfo.InvariantCulture));
            message = message.Replace(ActionElement, action);
            message = message.Replace(DeclaringTypeElement, info.DeclaringType.FullName);
            message = message.Replace(MethodNameElement, info.MethodName);

            if (info.LogParameters)
            {
                IDictionary <string, object> arguments = GetArguments(args);
                string formatArguments = FormatArguments(arguments);
                string value           = formatArguments.Equals("NULL", StringComparison.OrdinalIgnoreCase) ? string.Empty : formatArguments;
                message = message.Replace(ArgumentsElement, value);
            }
            else
            {
                message = message.Replace(ArgumentsElement, string.Empty);
            }

            if (info.LogReturnValue)
            {
                string returnValue = FormatObject(args.ReturnValue);
                message = message.Replace(ReturnValueElement, returnValue);
            }
            else
            {
                message = message.Replace(ReturnValueElement, string.Empty);
            }

            string elapsedTimeString = info.LogExecutionTime ? info.Stopwatch.Elapsed.ToString() : string.Empty;

            message = message.Replace(ElapsedTimeElement, elapsedTimeString);

            return(message);
        }
Exemplo n.º 29
0
        private Project ImportProject(string appPath, string projectName, string newLibs, string newOrientation)
        {
            //TreeIter ti =  AddMessage("Create Project ","....",null);
            if (entrPage2PrjName.Text == prjDefaultName)
            {
                MainClass.Settings.ProjectCount = MainClass.Settings.ProjectCount + 1;
            }

            string oldName = System.IO.Path.GetFileNameWithoutExtension(appPath);

            if (String.IsNullOrEmpty(MainClass.Workspace.FilePath))
            {
                return(null);
            }

            string destinationDir = System.IO.Path.GetDirectoryName(appPath);             // aka workspace from
            string projectDir     = System.IO.Path.Combine(destinationDir, oldName);      // aka project dir from

            string mspPath = System.IO.Path.Combine(destinationDir, oldName + ".msp");

            if (!File.Exists(appPath) || !File.Exists(mspPath))
            {
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"), MainClass.Languages.Translate("invalid_zip"), null);
                //UpdateMessage(ti,1,MainClass.Languages.Translate("invalid_zip"));
                return(null);
            }
            if (!System.IO.Directory.Exists(projectDir))
            {
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"), MainClass.Languages.Translate("invalid_project"), null);
                //UpdateMessage(ti,1,MainClass.Languages.Translate("invalid_project"));
                return(null);
            }

            string newApp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, projectName + ".app");
            string newMsp = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, projectName + ".msp");

            if (File.Exists(newApp) || File.Exists(newMsp))
            {
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"), MainClass.Languages.Translate("project_exist"), null);

                //UpdateMessage(ti,1,MainClass.Languages.Translate("project_exist"));
                return(null);
            }

            FileInfo     fi = new FileInfo(appPath);
            FileTemplate ft = new FileTemplate(fi, false);

            atrApplication.Value = projectName;
            ft.Attributes.Add(atrApplication);

            string contentApp = FileTemplateUtilities.Apply(ft.Content, ft.GetAttributesAsDictionary());

            string contentMsp = "";

            if (System.IO.File.Exists(mspPath))
            {
                try {
                    using (StreamReader file = new StreamReader(mspPath)) {
                        string text = file.ReadToEnd();
                        contentMsp = text;
                    }
                } catch {
                }
            }
            contentMsp = Regex.Replace(contentMsp, oldName, System.IO.Path.GetFileNameWithoutExtension(newApp));

            Project prj = null;

            try {
                FileUtility.CreateFile(newApp, contentApp);
                AppFile app = null;
                if (!String.IsNullOrEmpty(newLibs))
                {
                    app             = new AppFile(newApp);
                    app.Uses        = newLibs;
                    app.Orientation = newOrientation;
                    app.Save();
                }

                FileUtility.CreateFile(newMsp, contentMsp);

                string newPrjDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, projectName);

                TreeIter ti = AddMessage(MainClass.Languages.Translate("wizzard_copying"), "....", null);

                MainClass.Tools.CopyDirectory(projectDir, newPrjDir, true, true);
                //string[] dirNew = System.IO.Directory.GetDirectories(newPrjDir,"*.*",SearchOption.AllDirectories);

                string[] filesNew = System.IO.Directory.GetFiles(newPrjDir, "*.ms", SearchOption.AllDirectories);
                foreach (string file in filesNew)
                {
                    FileInfo     fiNew = new FileInfo(file);
                    FileTemplate ftNew = new FileTemplate(fiNew, false);
                    atrApplication.Value = projectName;
                    ftNew.Attributes.Add(atrApplication);

                    string contentNew = FileTemplateUtilities.Apply(ftNew.Content, ftNew.GetAttributesAsDictionary());

                    try{
                        using (StreamWriter fileSW = new StreamWriter(file)) {
                            fileSW.Write(contentNew);
                            fileSW.Close();
                            fileSW.Dispose();
                        }
                    }catch (Exception ex) {
                        Tool.Logger.Error(ex.Message);
                        continue;
                    }
                }
                UpdateMessage(ti, 1, "OK");

                prj = MainClass.Workspace.OpenProject(newMsp, false, true);               //Project.OpenProject(newMsp,false,true);

                LoggingInfo log = new LoggingInfo();
                log.LoggWebThread(LoggingInfo.ActionId.IDENewProject, prj.ProjectName);
            } catch {
                AddMessage(MainClass.Languages.Translate("wizzard_create_project"), MainClass.Languages.Translate("error_creating_project"), null);
                //UpdateMessage(ti,1,MainClass.Languages.Translate("error_creating_project"));
                return(null);
            }
            AddMessage(MainClass.Languages.Translate("wizzard_create_project"), "OK", null);
            //UpdateMessage(ti,1,"OK");
            return(prj);
        }
Exemplo n.º 30
0
 /// <summary>
 /// Catpures the logs
 /// </summary>
 /// <param name="loggingInfo"></param>
 public void CaptureLogs(LoggingInfo loggingInfo)
 {
     context.Set <LoggingInfo>().Add(loggingInfo);
     context.SaveChanges();
 }