Exemple #1
0
        public void Save(UserAccount item)
        {
            if (item == null)
            {
                throw new ArgumentException("Null item");
            }
            DateTime now = DateTime.Now;
            string   id  = null;

#if DEBUG
            if (item.NaasAccount.StartsWith("uid="))
            {
                DebugUtils.CheckDebuggerBreak();
            }
#endif // DEBUG
            // Check to see if this user already exists
            if (string.IsNullOrEmpty(item.Id))
            {
                string existingUserId = GetUserIdByName(item.NaasAccount);
                if (existingUserId != null)
                {
                    item.Id = existingUserId;
                }
            }

            TransactionTemplate.Execute(delegate
            {
                // Update user account table
                if (string.IsNullOrEmpty(item.Id))
                {
                    id = IdProvider.Get();
                    DoInsert(TABLE_NAME, "Id;NAASAccount;IsActive;SystemRole;ModifiedBy;ModifiedOn;IsDeleted",
                             id, item.NaasAccount, DbUtils.ToDbBool(item.IsActive),
                             item.Role.ToString(), item.ModifiedById, now, DbUtils.ToDbBool(false));
                }
                else
                {
                    id = item.Id;
                    DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(),
                                      "NAASAccount;IsActive;SystemRole;ModifiedBy;ModifiedOn",
                                      item.NaasAccount, DbUtils.ToDbBool(item.IsActive),
                                      item.Role.ToString(), item.ModifiedById, now);
                }
                // Update policies
                DeleteAllPoliciesForUser(id);
                if (item.Role != SystemRoleType.Admin)
                {
                    SavePoliciesForUser(id, item.Policies);
                }
                return(null);
            });
            if (string.IsNullOrEmpty(item.Id))
            {
                item.Id = id;
            }
            item.ModifiedOn = now;
        }
Exemple #2
0
        static void BuildDeployPackage()
        {
            string versionMinusSvnVersion =
                Windsor.Commons.AssemblyInfo.AssemblyInfo.cAssemblyVersion.Substring(0,
                                                                                     Windsor.Commons.AssemblyInfo.AssemblyInfo.cAssemblyVersion.LastIndexOf('.'));
            string zipFile = Path.Combine(PackagesFolderPath, "DotNET v4.6.2 OpenNode2 v" +
                                          versionMinusSvnVersion + ".zip");

            zipFile = AdjustDeploymentName(zipFile);
            RemoveVSHostFiles(Path.Combine(BuildFolderPath, "Server"));
            UpdateMaxNumConcurrentThreads();
            FileUtils.SafeDeleteFile(zipFile);
            DotNetZipHelper zipHelper = new DotNetZipHelper();

            zipHelper.CompressDirectory(zipFile, Path.Combine(BuildFolderPath, "Config"), "Config");
            zipHelper.CompressDirectory(zipFile, Path.Combine(BuildFolderPath, "Logs"), "Logs");
            zipHelper.CompressDirectory(zipFile, Path.Combine(BuildFolderPath, "Repository"), "Repository");
            zipHelper.CompressDirectory(zipFile, Path.Combine(BuildFolderPath, "Server"), "Server");
            zipHelper.CompressDirectory(zipFile, Path.Combine(BuildFolderPath, "Sql"), "Sql");
            zipHelper.CompressDirectory(zipFile, Path.Combine(BuildFolderPath, "Temp"), "Temp");
            zipHelper.CompressDirectory(zipFile, Path.Combine(BuildFolderPath, "www"), "www");

            string pluginsFolder = Path.Combine(BuildFolderPath, "Plugins");

            string[] pluginFilePaths = Directory.GetFiles(pluginsFolder, "*.dll", SearchOption.AllDirectories);
            CollectionUtils.ForEach(pluginFilePaths, delegate(string pluginFilePath)
            {
                try
                {
                    Assembly loadedAssembly = Assembly.LoadFile(pluginFilePath);
                    Attribute[] standardPluginAttributes = Attribute.GetCustomAttributes(loadedAssembly, typeof(StandardPluginAttribute));
                    Attribute[] publicPluginAttributes   = Attribute.GetCustomAttributes(loadedAssembly, typeof(PublicPluginAttribute));
                    if (!CollectionUtils.IsNullOrEmpty(standardPluginAttributes) || !CollectionUtils.IsNullOrEmpty(publicPluginAttributes))
                    {
                        // This is a standard or public plugin that is included with the default deployment package
                        string includeFolder = Path.GetDirectoryName(pluginFilePath);
                        string zipFolderName = includeFolder.Substring(includeFolder.LastIndexOf("Plugins\\", StringComparison.InvariantCultureIgnoreCase));
                        zipHelper.CompressDirectory(zipFile, includeFolder, zipFolderName);
                    }
                }
                catch (BadImageFormatException)
                {
                    DebugUtils.CheckDebuggerBreak();
                    throw;
                }
                catch (Exception)
                {
                    DebugUtils.CheckDebuggerBreak();
                    throw;
                }
            });
        }
 protected virtual bool GetDataServiceImplementers(PluginInstanceFinder pluginFinder, string inAssemblyPath,
                                                   ref OrderedSet <SimpleDataService> ioImplementers)
 {
     try
     {
         return(pluginFinder.FindPluginInstances(inAssemblyPath, ref ioImplementers));
     }
     catch (Exception)
     {
         DebugUtils.CheckDebuggerBreak();
         return(false);
     }
 }
Exemple #4
0
        static int Main(string[] args)
        {
            try
            {
                string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string trunkFolder  = Path.GetFullPath(assemblyPath + @"\..\..\..\..");

                CreateZipPackages = (args.Length > 0) && (args[0] == "/CreatePackages");
                string trunkParent = Path.GetDirectoryName(trunkFolder);
                DBScriptsParentFolderPath = Path.Combine(trunkParent, "database-scripts");
                PackagesFolderPath        = Path.Combine(trunkFolder, "Packages");
                BuildFolderPath           = Path.Combine(trunkFolder, BUILD_FOLDER_NAME);

                if ((args.Length > 0) && (args[0] == "/TestZip"))
                {
                    if (File.Exists(@"D:\TEMP\ICISSubmission.zip"))
                    {
                        File.Delete(@"D:\TEMP\ICISSubmission.zip");
                    }
                    DotNetZipHelper zipHelper = new DotNetZipHelper();
                    zipHelper.CompressFile(@"D:\TEMP\ICISSubmission.xml", @"D:\TEMP\ICISSubmission.zip");
                }

                if (CreateZipPackages)
                {
                    FileUtils.SafeDeleteDirectory(PackagesFolderPath);
                    Directory.CreateDirectory(PackagesFolderPath);
                }

                CreateDefaultFolders(trunkFolder);

                CopyPluginsToBuildFolder(trunkFolder);

                CopyConfigFilesToBuildFolder(trunkFolder);

                if (CreateZipPackages)
                {
                    BuildDeployPackage();
                }

                return(0);
            }
            catch (Exception e)
            {
                DebugUtils.CheckDebuggerBreak();
                Console.WriteLine(ExceptionUtils.ToShortString(e));
                Console.ReadKey();
                return(1);
            }
        }
 public override void SetValue(object value)
 {
     try
     {
         Value = (T)Convert.ChangeType(value, typeof(T));
         //Value = (T)value;
     }
     catch (Exception ex)
     {
         DebugUtils.CheckDebuggerBreak();
         throw new ArgException("Failed to convert the database value \"{0}\" to type \"{1}\" with exception: {2}",
                                value, typeof(T).Name, ExceptionUtils.GetDeepExceptionMessage(ex));
     }
 }
Exemple #6
0
        public static void Main(string[] args)
        {
            try
            {
                //var exception =
                //     AFXQuerySolicitProcessor.GenerateSubmissionFile("server= SQL2008;User ID=AFX_NODE_FLOW;Password=M3morial!;database = NWIFC_ADULT_FISH",
                //                                                     "System.Data.SqlClient", null, true, "NWIFC_AFX", false, (string message) =>
                //                                                     {
                //                                                         Console.WriteLine(message);
                //                                                     },
                //                                                     out string outSubmissionFilePath, out string outValidationErrorsFilePath);
                //var exception =
                //    AFXSubmissionProcessor.ImportFile("server= SQL2008;User ID=AFX_NODE_FLOW;Password=M3morial!;database = NWIFC_ADULT_FISH",
                //                                      "System.Data.SqlClient", null, @"D:\PROJECTS\OpenNode2-git\prod-opennode2-net\private\AFX_10\AFX.xml", true, (string message) =>
                //                                      {
                //                                          Console.WriteLine(message);
                //                                      },
                //                                      out string[] importedPrimaryKeys, out string outValidationErrorsFilePath);
                Console.WriteLine("Starting server...");
                WNOSController.Start("WNOS");
                Console.WriteLine("Server started");
                Console.WriteLine();

                Console.WriteLine("Press <return> to stop server...");
                Console.ReadKey();

                Console.WriteLine();
                Console.WriteLine("Stopping server...");
                WNOSController.Stop();
                Console.WriteLine("Server stopped");
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                DebugUtils.CheckDebuggerBreak();
                Console.WriteLine("\n\n\n***************************\n\n"
                                  + ex.Message
                                  + "\n\n***************************\n\n\n", ex);

                Console.WriteLine("\n\n\nERROR *********************\n\n");
            }
            finally
            {
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }
Exemple #7
0
 protected virtual void SetActualMemberValue(object instance, object value)
 {
     try
     {
         if (m_MemberFieldInfo != null)
         {
             m_MemberFieldInfo.SetValue(instance, value);
         }
         else
         {
             m_MemberPropertyInfo.SetValue(instance, value, null);
         }
     }
     catch (Exception)
     {
         DebugUtils.CheckDebuggerBreak();
         throw;
     }
 }
        private bool IsFlowPermitted(IList <UserAccessPolicy> policies,
                                     string flowName, string flowId,
                                     FlowRoleType flowRole)
        {
            if ((flowRole != FlowRoleType.None) && !CollectionUtils.IsNullOrEmpty(policies))
            {
                if (string.IsNullOrEmpty(flowName))
                {
                    ExceptionUtils.ThrowIfEmptyString(flowId, "flowId");
                    flowName = GetFlowNameFromId(flowId);
                    if (flowName == null)
                    {
                        return(false);
                    }
                }
                foreach (UserAccessPolicy policy in policies)
                {
                    if ((policy.PolicyType == ServiceRequestAuthorizationType.Flow) &&
                        string.Equals(policy.TypeQualifier, flowName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        switch (flowRole)
                        {
                        case FlowRoleType.Endpoint:
                            return((policy.FlowRoleType == FlowRoleType.Endpoint) ||
                                   (policy.FlowRoleType == FlowRoleType.View) ||
                                   (policy.FlowRoleType == FlowRoleType.Modify));

                        case FlowRoleType.View:
                            return((policy.FlowRoleType == FlowRoleType.View) ||
                                   (policy.FlowRoleType == FlowRoleType.Modify));

                        case FlowRoleType.Modify:
                            return((policy.FlowRoleType == FlowRoleType.Modify));

                        default:
                            DebugUtils.CheckDebuggerBreak();
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }
Exemple #9
0
        public UserAccount GetOrCreate(string username, bool alwaysCreateUserInDb,
                                       out bool wasCreated)
        {
            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentException("Null username");
            }
#if DEBUG
            if (username.StartsWith("uid="))
            {
                DebugUtils.CheckDebuggerBreak();
            }
#endif // DEBUG
            UserAccount usr = _accountDao.GetByName(username);

            if (usr == null)
            {
                if (alwaysCreateUserInDb)
                {
                    usr = new UserAccount();
                    usr.ModifiedById = _adminAccount.Id;
                    usr.IsActive     = true;
                    usr.NaasAccount  = username;
                    usr.Role         = SystemRoleType.Authed;

                    _accountDao.Save(usr);
                    wasCreated = true;
                }
                else
                {
                    throw new UnauthorizedAccessException(string.Format("The user \"{0}\" does not have an account on this node.",
                                                                        username));
                }
            }
            else
            {
                wasCreated = false;
            }

            return(usr);
        }
Exemple #10
0
        public override object GetInsertColumnValue(object parentOfObjectToSave, object objectToSave, ColumnCachedValues cachedValues)
        {
            object pkGuid;

            if (Utils.IsValidColumnType(objectToSave.GetType()))
            {
                // This is a virtual table for string[], int[], enum[], etc.
                pkGuid = StringUtils.CreateSequentialGuid();
            }
            else
            {
                if (!cachedValues.ObjectToPrimaryKeyMap.TryGetValue(objectToSave, out pkGuid))
                {
                    pkGuid = StringUtils.CreateSequentialGuid();
                    cachedValues.ObjectToPrimaryKeyMap[objectToSave] = pkGuid;
                }
                else
                {
                    DebugUtils.CheckDebuggerBreak();
                }
            }
            return(pkGuid);
        }
 public WorkflowStatusFailedException(Exception innerException, string format, params object[] args) :
     base(string.Format(format, args), innerException)
 {
     DebugUtils.CheckDebuggerBreak();
 }
        protected virtual void BuildTables(IDictionary <string, DataTable> existingTableSchemas,
                                           MappingContext mappingContext,
                                           SpringBaseDao baseDao, bool createdDatabase)
        {
            IDictionary <string, Table> tables = mappingContext.Tables;

            if (CollectionUtils.IsNullOrEmpty(tables))
            {
                return;
            }
            string        commandSeparator   = "!!!";
            List <Column> descriptionColumns = new List <Column>();
            StringBuilder sqlString          = new StringBuilder();
            List <string> postCommands       = new List <string>();
            List <string> primaryKeyCommands = new List <string>();
            List <string> indexNames         = new List <string>();
            List <Table>  descriptionTables  = new List <Table>();

            foreach (Table table in tables.Values)
            {
                ICollection <Column> columns     = table.AllColumns;
                DataTable            tableSchema = existingTableSchemas[table.TableName];
                if (tableSchema == null)
                {
                    bool firstColumn = true;
                    // This table is not in the database
                    sqlString.AppendFormat("CREATE TABLE {0} (", table.TableName);
                    foreach (Column column in columns)
                    {
                        if (!firstColumn)
                        {
                            sqlString.Append(',');
                        }
                        firstColumn = false;
                        string addString = GetAddColumnString(column, mappingContext, baseDao, primaryKeyCommands, postCommands,
                                                              descriptionColumns, indexNames);
                        sqlString.Append(addString);
                    }
                    sqlString.AppendFormat(") {0} ", commandSeparator);
                    descriptionTables.Add(table);
                }
                else
                {
                    // This table is in the database, check columns
                    foreach (Column column in columns)
                    {
                        DataColumn columnSchema = tableSchema.Columns[column.ColumnName];
                        if (columnSchema == null)
                        {
                            // Column does not exist
                            string addString = GetAddColumnString(column, mappingContext, baseDao, primaryKeyCommands, postCommands,
                                                                  descriptionColumns, indexNames);
                            sqlString.Append(string.Format("ALTER TABLE {0} ADD {1} {2} ", table.TableName, addString, commandSeparator));
                        }
                    }
                }
            }
            string pkFormat  = baseDao.IsOracleDatabase ? ORA_SERVER_NOT_EXISTS_PK_FORMAT_STRING : SQL_SERVER_NOT_EXISTS_PK_FORMAT_STRING;
            string fkFormat  = baseDao.IsOracleDatabase ? ORA_SERVER_NOT_EXISTS_FK_FORMAT_STRING : SQL_SERVER_NOT_EXISTS_FK_FORMAT_STRING;
            string idxFormat = baseDao.IsOracleDatabase ? ORA_SERVER_NOT_EXISTS_INDEX_FORMAT_STRING : SQL_SERVER_NOT_EXISTS_INDEX_FORMAT_STRING;

            CollectionUtils.ForEach(mappingContext.AdditionalCreateIndexAttributes,
                                    delegate(AdditionalCreateIndexAttribute indexAttribute)
            {
                string indexColumnName = StringUtils.RemoveAllWhitespace(indexAttribute.ColumnName.Replace(",", "_"));
                string idxName         =
                    string.Format("IX_{0}_{1}", Utils.RemoveTableNamePrefix(indexAttribute.ParentTable, indexAttribute.ParentTablePrefix, mappingContext.DefaultTableNamePrefix),
                                  indexColumnName);
                idxName = Utils.ShortenDatabaseName(idxName, Utils.MAX_INDEX_NAME_CHARS, mappingContext.ShortenNamesByRemovingVowelsFirst,
                                                    mappingContext.FixShortenNameBreakBug, null);
                idxName    = CheckDatabaseNameDoesNotExist(idxName, indexNames);
                string cmd = string.Format("CREATE {0} INDEX {1} ON {2}({3})", indexAttribute.IsUnique ? "UNIQUE" : "",
                                           idxName, indexAttribute.ParentTable,
                                           indexAttribute.ColumnName);
                cmd = string.Format(idxFormat, idxName, indexAttribute.ParentTable, cmd);
                postCommands.Add(cmd);
            });

            if (primaryKeyCommands.Count > 0)
            {
                sqlString.Append(string.Format(" {0} ", commandSeparator));
                sqlString.Append(StringUtils.Join(string.Format(" {0} ", commandSeparator), primaryKeyCommands));
            }
            if (postCommands.Count > 0)
            {
                sqlString.Append(string.Format(" {0} ", commandSeparator));
                sqlString.Append(StringUtils.Join(string.Format(" {0} ", commandSeparator), postCommands));
            }
            if (sqlString.Length > 0)
            {
                string        sqlStringText  = sqlString.ToString();
                List <string> commands       = StringUtils.SplitAndReallyRemoveEmptyEntries(sqlStringText, commandSeparator, StringComparison.Ordinal);
                long          timeoutTicks   = DateTime.Now.Ticks + TimeSpan.FromSeconds(CREATE_DATABASE_WAIT_SECONDS).Ticks;
                bool          isFirstCommand = true;
                // Database still may not be ready to create tables if we just created the database,
                // so give it some time
                for (; ;)
                {
                    try
                    {
                        baseDao.TransactionTemplate.Execute(delegate
                        {
                            baseDao.AdoTemplate.ClassicAdoTemplate.Execute(delegate(IDbCommand dbCommand)
                            {
                                dbCommand.CommandType = CommandType.Text;
                                int curIndex          = 0;
                                foreach (string command in commands)
                                {
                                    dbCommand.CommandText = command;
                                    try
                                    {
                                        dbCommand.ExecuteNonQuery();
                                        ++curIndex;
                                    }
                                    catch (Exception)
                                    {
                                        DebugUtils.CheckDebuggerBreak();
                                        throw;
                                    }
                                    if (isFirstCommand)
                                    {
                                        isFirstCommand = false;
                                    }
                                }
                                return(null);
                            });
                            AddTableDescriptions(descriptionTables, baseDao);
                            AddColumnDescriptions(descriptionColumns, mappingContext, baseDao);
                            return(null);
                        });
                        break;
                    }
                    catch (DataAccessException)
                    {
                        if (!isFirstCommand || (timeoutTicks < DateTime.Now.Ticks))
                        {
                            throw;
                        }
                    }
                    catch (TransactionException)
                    {
                        if (!isFirstCommand || (timeoutTicks < DateTime.Now.Ticks))
                        {
                            throw;
                        }
                    }
                    Thread.Sleep(300);
                }
            }
        }
        protected virtual void SaveToDatabase(object parentOfObjectToSave, object objectToSave,
                                              Table tableOfObjectToSave, ColumnCachedValues cachedValues, MappingContext mappingContext,
                                              Dictionary <string, int> insertRowCounts, IDbCommand command)
        {
            if (objectToSave == null)
            {
                return;
            }

            Type objectToSaveType = objectToSave.GetType();

            if (tableOfObjectToSave == null)
            {
                tableOfObjectToSave = mappingContext.GetTableForType(objectToSaveType);
            }

            Table parentTable = null;

            if (parentOfObjectToSave != null)
            {
                parentTable = mappingContext.GetTableForType(parentOfObjectToSave.GetType());
            }

            if (tableOfObjectToSave.PopulateInsertValues(command, parentOfObjectToSave, parentTable, objectToSave, cachedValues))
            {
                DebugUtils.AssertDebuggerBreak(command.Parameters.Count == tableOfObjectToSave.AllColumns.Count);
                try
                {
                    command.ExecuteNonQuery();
                }
                catch (Exception)
                {
                    DebugUtils.CheckDebuggerBreak();
                    throw;
                }
                if (insertRowCounts != null)
                {
                    int value;
                    if (insertRowCounts.TryGetValue(tableOfObjectToSave.TableName, out value))
                    {
                        value++;
                    }
                    else
                    {
                        value = 1;
                    }
                    insertRowCounts[tableOfObjectToSave.TableName] = value;
                }
            }
            // Save children
            if (tableOfObjectToSave.ChildRelationMembers != null)
            {
                try
                {
                    Dictionary <object, bool> alreadyProcessedMemberValues = new Dictionary <object, bool>(tableOfObjectToSave.ChildRelationMembers.Count);

                    foreach (ChildRelationInfo childRelation in tableOfObjectToSave.ChildRelationMembers)
                    {
                        object relationMember = objectToSave;
                        if (childRelation.ParentToMemberChain != null)
                        {
                            foreach (SameTableElementInfo sameTableElementInfo in childRelation.ParentToMemberChain)
                            {
                                relationMember = sameTableElementInfo.GetMemberValue(relationMember);
                                if (relationMember == null)
                                {
                                    break;
                                }
                            }
                        }

                        if (relationMember != null)
                        {
                            if (childRelation.IsOneToMany)
                            {
                                IEnumerable memberEnumerable = childRelation.GetMemberEnumerable(relationMember);
                                if (memberEnumerable != null)
                                {
                                    if (alreadyProcessedMemberValues.ContainsKey(memberEnumerable))
                                    {
                                        // This is for object[] members that may be mapped to multiple types
                                    }
                                    else
                                    {
                                        bool insertedAny = false;
                                        alreadyProcessedMemberValues[memberEnumerable] = true;
                                        Table elementTable = null;
                                        if (Utils.IsValidColumnType(childRelation.ValueType))
                                        {
                                            elementTable = childRelation.ChildTable;
                                        }
                                        foreach (object element in memberEnumerable)
                                        {
                                            if (element != null)
                                            {
                                                SaveToDatabase(objectToSave, element, elementTable, cachedValues, mappingContext,
                                                               insertRowCounts, command);
                                                insertedAny = true;
                                            }
                                        }
                                        if (!insertedAny)
                                        {
                                        }
                                    }
                                }
                            }
                            else // One to one
                            {
                                object element = childRelation.GetMemberValue(relationMember);
                                if (element != null)
                                {
                                    if (alreadyProcessedMemberValues.ContainsKey(element))
                                    {
                                        // This is for object members that may be mapped to multiple types
                                    }
                                    else
                                    {
                                        alreadyProcessedMemberValues[element] = true;
                                        Table elementTable = null;
                                        if (Utils.IsValidColumnType(childRelation.ValueType))
                                        {
                                            elementTable = childRelation.ChildTable;
                                        }
                                        if (element != null)
                                        {
                                            SaveToDatabase(objectToSave, element, elementTable, cachedValues, mappingContext,
                                                           insertRowCounts, command);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    DebugUtils.CheckDebuggerBreak();
                    throw;
                }
            }
        }
 public BaseException(ICollection appendToMessageItems, string formatString,
                      params object[] args)
     : base(string.Format(formatString, args) + GetAppendToMessageLines(appendToMessageItems))
 {
     DebugUtils.CheckDebuggerBreak();
 }
 public BaseException(string formatString, params object[] args)
     : base(string.Format(formatString, args))
 {
     DebugUtils.CheckDebuggerBreak();
 }
 public BaseException()
 {
     DebugUtils.CheckDebuggerBreak();
 }
        public void Save(Activity item)
        {
            if (item == null)
            {
                throw new ArgumentException("Null item");
            }
            DateTime now = DateTime.Now;
            string   id  = null;

#if DEBUG
            if (CollectionUtils.IsNullOrEmpty(item.Entries))
            {
                DebugUtils.CheckDebuggerBreak();
            }
#endif // DEBUG
            if (!string.IsNullOrEmpty(item.TransactionId))
            {
                if (string.IsNullOrEmpty(item.FlowName) || string.IsNullOrEmpty(item.Operation) ||
                    (item.Method == NodeMethod.None))
                {
                    NodeMethod method;
                    string     operation;
                    string     flowName = _transactionDao.GetTransactionFlowName(item.TransactionId, out method, out operation);
                    if (string.IsNullOrEmpty(item.FlowName))
                    {
                        item.FlowName = flowName;
                    }
                    if (string.IsNullOrEmpty(item.Operation))
                    {
                        item.Operation = operation;
                    }
                    if (item.Method == NodeMethod.None)
                    {
                        item.Method = method;
                    }
                }
            }
            TransactionTemplate.Execute(delegate
            {
                // Update user account table
                if (string.IsNullOrEmpty(item.Id))
                {
                    id = IdProvider.Get();
                    DoInsert(TABLE_NAME, "Id;Type;TransactionId;IP;ModifiedBy;ModifiedOn;WebMethod;FlowName;Operation",
                             id, item.Type.ToString(), item.TransactionId, item.IP, item.ModifiedById, now,
                             item.Method.ToString(), item.FlowName, item.Operation);
                }
                else
                {
                    id = item.Id;
                    DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(),
                                      "Type;TransactionId;IP;ModifiedBy;ModifiedOn;WebMethod;FlowName;Operation",
                                      item.Type.ToString(), item.TransactionId, item.IP, item.ModifiedById, now,
                                      item.Method.ToString(), item.FlowName, item.Operation);
                    DeleteAllEntriesForActivity(id);
                }
                // Update policies
                SaveEntriesForActivity(id, item.Entries);
                return(null);
            });
            if (string.IsNullOrEmpty(item.Id))
            {
                item.Id = id;
            }
            item.ModifiedOn = now;
        }
Exemple #18
0
        public static bool ProcessNextInputFile()
        {
            StringBuilder message = new StringBuilder();
            bool          success = false, foundFile = false;

            try
            {
                ProcessDBImportCSVFiles.OutputStatus(message, "Start CameoInputFileProcessor...");

                CreateApplicationEventLog();

                string             importFolder = Settings.Default.ImportFolder;
                string             importCSVFileSearchPattern           = Settings.Default.ImportCSVFileSearchPattern;
                string             importFileSearchToDBTableNamePattern = Settings.Default.ImportFileSearchToDBTableNamePattern;
                string             tempFolderPath              = Settings.Default.TempFolderPath;
                string             dbProviderType              = Settings.Default.DBProviderType;
                string             dbConnectionString          = Settings.Default.DBConnectionString;
                string             archiveFolder               = Settings.Default.ArchiveFolder;
                string             errorFolder                 = Settings.Default.ErrorFolder;
                string             cleanupTablesStoredProcName = Settings.Default.CleanupTablesStoredProcName;
                string             endProcessingStoredProcName = Settings.Default.EndProcessingStoredProcName;
                ICompressionHelper compressionHelper           = new CompressionHelper();

                Spring.Data.Common.IDbProvider dbProvider = Spring.Data.Common.DbProviderFactory.GetDbProvider(dbProviderType);
                dbProvider.ConnectionString = dbConnectionString;
                SpringBaseDao springBaseDao = new SpringBaseDao(dbProvider);

                ProcessDBImportCSVFiles.OutputStatus(message, "ImportFolder ({0}), ArchiveFolder ({1}), ErrorFolder ({2}), ImportCSVFileSearchPattern ({3}), ImportFileSearchToDBTableNamePattern ({4}), EndProcessingStoredProcName ({5}), TempFolderPath ({6}), DBProviderType ({7}), DBConnectionString ({8})",
                                                     importFolder, archiveFolder, errorFolder, importCSVFileSearchPattern,
                                                     importFileSearchToDBTableNamePattern, endProcessingStoredProcName, tempFolderPath,
                                                     dbProviderType, dbConnectionString);

                message.Append(ProcessDBImportCSVFiles.ProcessImportFile(importFolder, archiveFolder, errorFolder,
                                                                         importCSVFileSearchPattern, importFileSearchToDBTableNamePattern,
                                                                         cleanupTablesStoredProcName, endProcessingStoredProcName,
                                                                         springBaseDao, tempFolderPath,
                                                                         compressionHelper, out success, out foundFile));
                ProcessDBImportCSVFiles.OutputStatus(message, "Stop CameoInputFileProcessor...");
            }
            catch (Exception ex)
            {
                DebugUtils.CheckDebuggerBreak();
                message.Append(string.Format("\n\n\nERROR *********************\n\n"
                                             + ex.Message
                                             + "\n\n***************************\n\n\n{0}",
                                             ExceptionUtils.ToLongString(ex)));
            }
            finally
            {
                string messageOut = message.ToString();
                if (success)
                {
                    LogInfo(messageOut);
                }
                else
                {
                    LogError(messageOut);
                }
                Console.WriteLine(messageOut);
            }
            return(foundFile);
        }