예제 #1
0
        /// <summary>
        /// If the request parameters other than @InCaller & @InCallerversion are null, returns a list of entries, otherwise returns a list of one entry.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static ApplicationsGetReplyDC ApplicationsGet(ApplicationsGetRequestDC request)
        {
            var reply = new ApplicationsGetReplyDC();
            var status = new StatusReplyDC();
            ApplicationGetBase app = null;
            var list = new List<ApplicationGetBase>();
            Database db = null;
            DbCommand cmd = null;
            int retValue = 0;
            string outErrorString = string.Empty;

            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.ApplicationGet);
                db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                db.AddParameter(cmd, "@InId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InId);
                db.AddParameter(cmd, "@InName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InName);
                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);

                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        app = new ApplicationGetBase();
                        app.Guid = (Guid)reader["GUID"];
                        app.Description = Convert.ToString(reader["Description"]) ?? string.Empty;
                        app.Id = Convert.ToInt32(reader["Id"]);
                        app.Name = Convert.ToString(reader["Name"]);
                        list.Add(app);
                    }

                    reply.List = list;
                }

                retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);
                outErrorString = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                if (retValue != 0)
                {
                    status.ErrorMessage = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                    status.Errorcode = retValue;
                    Logging.Log(retValue,
                                EventLogEntryType.Error,
                                SprocValues.APPLICATIONS_GET_CALL_ERROR_MSG,
                                outErrorString);
                }
            }
            catch (Exception ex)
            {
                status = Logging.Log(SprocValues.GENERIC_CATCH_ID,
                                     EventLogEntryType.Error,
                                     SprocValues.APPLICATIONS_GET_CALL_ERROR_MSG,
                                     ex);
            }

            reply.StatusReply = status;
            return reply;
        }
예제 #2
0
        /// <summary>
        /// gets all StoreActivities rows that are of template type and not marked softdelete
        /// </summary>
        /// <param name="request">RequestHeader object</param>
        /// <param name="categoryType">categoryType string</param>
        /// <returns>List of StoreActivitiesDC type</returns>
        public static StatusReplyDC CheckActivityExists(StoreActivitiesDC request)
        {
            var reply = new StatusReplyDC();

            Database db = null;
            DbCommand cmd = null;
            string outErrorString = string.Empty;
            int retValue = 0;
            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.ActivityCheckExists);
                db.AddParameter(cmd, "@InName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Name);
                db.AddParameter(cmd, "@InVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Version);

                reply.Output = Convert.ToString(false);

                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    if (reader.Read())
                    {
                        reply.Output = Convert.ToString(true);
                    }
                }
            }
            catch (SqlException ex)
            {
                ex.HandleException();
            }

            return reply;
        }
예제 #3
0
 public RequestReplyCommonHeader()
 {
     statusReply = new StatusReplyDC();
     statusReply.Errorcode = 0;
     statusReply.ErrorGuid = string.Empty;
     statusReply.ErrorMessage = string.Empty;
 }
        /// <summary>
        /// Get an activity library by ID if a positive ID value is provided.  Otherwise, gets by GUID
        /// if a non-empty GUID is provided.  If the ID is not positive and the GUID is empty, then 
        /// a list of activity libraries matching the name and version combination.
        /// </summary>
        /// <param name="request">ActivityLibraryDC</param>
        /// <param name="includeDll">Flag that indicates whether the DLL binaries should be included in the response.</param>
        /// <returns>List of activity libraries.</returns>
        public static List<ActivityLibraryDC> GetActivityLibraries(ActivityLibraryDC request, bool includeDll)
        {
            var reply = new List<ActivityLibraryDC>();
            var status = new StatusReplyDC();
            Database database = null;
            DbCommand command = null;
            string outErrorString = string.Empty;
            try
            {
                database = DatabaseFactory.CreateDatabase();
                command = database.GetStoredProcCommand(StoredProcNames.ActivityLibraryGet);
                database.AddParameter(command, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                database.AddParameter(command, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                database.AddParameter(command, "@InId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.Id);
                database.AddParameter(command, "@InGuid", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, Convert.ToString(request.Guid));
                database.AddParameter(command, "@InName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, Convert.ToString(request.Name));
                database.AddParameter(command, "@InVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, Convert.ToString(request.VersionNumber));
                database.AddParameter(command, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);

                using (IDataReader reader = database.ExecuteReader(command))
                {
                    while (reader.Read())
                    {
                        var activeLibraryDCreply = new ActivityLibraryDC();
                        activeLibraryDCreply.AuthGroupId = Convert.ToInt32(reader["AuthGroupId"]);
                        activeLibraryDCreply.AuthGroupName = Convert.ToString(reader["AuthGroupName"]);
                        activeLibraryDCreply.Category = (reader["Category"] == DBNull.Value) ? Guid.Empty : new Guid(Convert.ToString(reader["Category"]));
                        activeLibraryDCreply.CategoryId = (reader["CategoryId"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["CategoryId"]);
                        activeLibraryDCreply.Description = Convert.ToString(reader["Description"]) ?? string.Empty;
                        activeLibraryDCreply.Guid = (reader["Guid"] == DBNull.Value) ? Guid.Empty : new Guid(Convert.ToString(reader["Guid"]));
                        activeLibraryDCreply.HasActivities = (reader["HasActivities"] == DBNull.Value) ? false : Convert.ToBoolean(reader["HasActivities"]);
                        activeLibraryDCreply.Id = Convert.ToInt32(reader["Id"]);
                        activeLibraryDCreply.ImportedBy = Convert.ToString(reader["ImportedBy"]);
                        activeLibraryDCreply.MetaTags = Convert.ToString(reader["MetaTags"]) ?? string.Empty;
                        activeLibraryDCreply.Name = Convert.ToString(reader["Name"]);
                        activeLibraryDCreply.Status = (reader["Status"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["Status"]);
                        activeLibraryDCreply.StatusName = Convert.ToString(reader["StatusName"]);
                        activeLibraryDCreply.VersionNumber = Convert.ToString(reader["VersionNumber"]);
                        activeLibraryDCreply.FriendlyName = Convert.ToString(reader["FriendlyName"]);
                        activeLibraryDCreply.ReleaseNotes = Convert.ToString(reader["ReleaseNotes"]);
                        activeLibraryDCreply.HasExecutable = reader["Executable"] != DBNull.Value;

                        if (includeDll)
                        {
                            activeLibraryDCreply.Executable = (reader["Executable"] == DBNull.Value) ? null : (byte[])reader["Executable"];
                        }

                        reply.Add(activeLibraryDCreply);
                    }
                }
            }
            catch (SqlException e)
            {
                e.HandleException();
            }

            return reply;
        }
예제 #5
0
 /// <summary>
 /// This method attaches additional properties to the workflow and saves it to Database
 /// </summary>
 /// <param name="WorkFlow"></param>
 /// <returns></returns>
 public static StatusReplyDC CreateAndUploadWorkFlow(StoreLibraryAndActivitiesRequestDC workflow)
 {
     workflow.Incaller = Environment.UserName;
     workflow.IncallerVersion = incallerversion;
     workflow.InInsertedByUserAlias = Environment.UserName;
     workflow.InUpdatedByUserAlias = Environment.UserName;
     var result = new StatusReplyDC();
     //Save WF
     result = CWF.BAL.Services.UploadActivityLibraryAndDependentActivities(workflow)[0].StatusReply;
     return result;
 }
예제 #6
0
        /// <summary>
        /// Creates or updates an mtblActivityLibraryDependencies entry
        /// </summary>
        /// <param name="request">request object</param>
        /// <returns>StoreActivityLibrariesDependenciesDC object</returns>
        public static StoreActivityLibrariesDependenciesDC StoreActivityLibraryDependenciesCreateOrUpdate(StoreActivityLibrariesDependenciesDC request)
        {
            var reply = new StoreActivityLibrariesDependenciesDC();
            var status = new StatusReplyDC();
            Database db = null;
            DbCommand cmd = null;
            int retValue = 0;
            string outErrorString = string.Empty;

            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.ActivityLibraryDependencyCreateOrUpdate);
                db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                db.AddParameter(cmd, "@inActivityLibraryName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StoreDependenciesRootActiveLibrary.ActivityLibraryName);
                db.AddParameter(cmd, "@inActivityLibraryVersionNumber", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StoreDependenciesRootActiveLibrary.ActivityLibraryVersionNumber);
                db.AddParameter(cmd, "@inActivityLibraryDependentName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StoreDependenciesDependentActiveLibraryList[0].ActivityLibraryDependentName);
                db.AddParameter(cmd, "@inActivityLibraryDependentVersionNumber", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StoreDependenciesDependentActiveLibraryList[0].ActivityLibraryDependentVersionNumber);
                db.AddParameter(cmd, "@InInsertedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InsertedByUserAlias);
                db.AddParameter(cmd, "@InUpdatedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.UpdatedByUserAlias);
                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);

                db.ExecuteScalar(cmd);
                retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);
                outErrorString = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                if (retValue != 0)
                {
                    status.ErrorMessage = outErrorString;
                    status.Errorcode = retValue;
                    Logging.Log(retValue,
                                EventLogEntryType.Error,
                                SprocValues.ACTIVITY_LIBRARY_DEPENDENCIES_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                                outErrorString);
                }
            }
            catch (Exception ex)
            {
                status.ErrorMessage = SprocValues.ACTIVITY_LIBRARY_DEPENDENCIES_CREATE_OR_UPDATE_CALL_ERROR_MSG + ex.Message;
                status.Errorcode = SprocValues.GENERIC_CATCH_ID;
                Logging.Log(SprocValues.GENERIC_CATCH_ID,
                            EventLogEntryType.Error,
                            SprocValues.ACTIVITY_LIBRARY_DEPENDENCIES_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                            ex);
            }

            reply.StatusReply = status;
            return reply;
        }
예제 #7
0
        /// <summary>
        /// Performs input validation and checks if an activity exists in the data store
        /// </summary>
        /// <param name="request">Request that specifies activity identifier info.</param>
        /// <returns>Result of the operation.</returns>
        public static StatusReplyDC CheckActivityExists(StoreActivitiesDC request)
        {
            var reply = new StatusReplyDC();

            try
            {
                // Validates the input and throws ValidationException for any issues found.
                request.ValidateRequest();

                reply = ActivityRepositoryService.CheckActivityExists(request);
            }
            catch (ValidationException e)
            {
                e.HandleException();
            }
            catch (DataAccessException e)
            {
                e.HandleException();
            }

            return reply;
        }
        public void CreateNewProjectWithExistingName()
        {
            //Create WF with private AL, private SA
            var workflow = new StoreLibraryAndActivitiesRequestDC();
            workflow.ActivityLibrary = VersionControlHelper.GetActivityLibraryDC(privatestate, privatestatusid);
            var StoreActList = new System.Collections.Generic.List<StoreActivitiesDC>();
            var storeAct = VersionControlHelper.GetStoreActivitiesDC(workflow.ActivityLibrary, 1);
            StoreActList.Add(storeAct);
            workflow.StoreActivitiesList = StoreActList;

            var result = VersionControlHelper.CreateAndUploadWorkFlow(workflow);
            Assert.AreEqual(0, result.Errorcode);
            //get WF, check version for both SA and AL
            var reply = VersionControlHelper.GetProjectInfo(workflow.ActivityLibrary, workflow.StoreActivitiesList);
            //Check status and version
            VersionControlHelper.CheckOutput(reply, privatestate, "0.0.0.1", privatestatusid);
            //Create again with similar name as previous one
            //Create WF with private AL, private SA
            var newworkflow = new StoreLibraryAndActivitiesRequestDC();
            newworkflow.ActivityLibrary = VersionControlHelper.GetActivityLibraryDCWithName(privatestate, privatestatusid, workflow.ActivityLibrary.Name);
            List<StoreActivitiesDC> NewStoreActList = new System.Collections.Generic.List<StoreActivitiesDC>();
            StoreActivitiesDC NewstoreAct = VersionControlHelper.GetStoreActivitiesDC(newworkflow.ActivityLibrary, 1);
            StoreActList.Add(NewstoreAct);
            newworkflow.StoreActivitiesList = NewStoreActList;

            newworkflow.Incaller = Environment.UserName;
            newworkflow.IncallerVersion = incallerversion;
            newworkflow.InInsertedByUserAlias = Environment.UserName;
            newworkflow.InUpdatedByUserAlias = Environment.UserName;
            StatusReplyDC Newresult = new StatusReplyDC();
            //Save WF
            string version = CWF.BAL.Versioning.VersionHelper.GetNextVersion(NewstoreAct).ToString();
            newworkflow.ActivityLibrary.VersionNumber = version;
            Newresult = CWF.BAL.Services.UploadActivityLibraryAndDependentActivities(newworkflow)[0].StatusReply;
            //Expect error
            Assert.AreEqual(0, Newresult.Errorcode);
        }
예제 #9
0
        /// <summary>
        /// Gets the ActivityLibrary and associated StoreActivity entries as a unit. A transaction is used here
        /// to eliminate getting caught in the middle of a multi row update.
        /// </summary>
        /// <param name="request">GetLibraryAndActivitiesDC</param>
        /// <returns>either List<GetLibraryAndActivitiesDC>, or a fault</returns>
        public static List<GetLibraryAndActivitiesDC> GetLibraryAndActivities(GetLibraryAndActivitiesDC request)
        {
            List<GetLibraryAndActivitiesDC> reply = new List<GetLibraryAndActivitiesDC>();
            StatusReplyDC statusReply = new StatusReplyDC();
            //// ActivityLibraryDC alDC = request.ActivityLibrary;
            List<ActivityLibraryDC> activityLibraryDClist = null;
            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    //// Get StoreActivities
                    reply = DAL.Activities.GetActivityLibraryAndStoreActivities(request);
                    if (reply[0].StatusReply.Errorcode != 0)
                        throw new Exception(reply[0].StatusReply.ErrorMessage);
                    //// Get ActivityLibrary
                    activityLibraryDClist = DAL.Activities.ActivityLibraryGet(request.ActivityLibrary);
                    if (activityLibraryDClist.Count == 1 && activityLibraryDClist[0].StatusReply.Errorcode == 0)
                        reply[0].ActivityLibrary = activityLibraryDClist[0];
                    else
                       throw new FaultException();
                    ts.Complete();
                    reply[0].StatusReply = statusReply;
                }
                catch (TransactionAbortedException)
                {
                    statusReply.ErrorMessage = reply[0].StatusReply.ErrorMessage;
                    statusReply.Errorcode = reply[0].StatusReply.Errorcode;
                }
                catch (Exception)
                {
                    statusReply.ErrorMessage = reply[0].StatusReply.ErrorMessage;
                    statusReply.Errorcode = reply[0].StatusReply.Errorcode;
                }
            }

            return reply;
        }
예제 #10
0
        /// <summary>
        /// Verify lock store activity
        /// </summary>
        /// <param name="name">name of row to do a get on</param>
        /// <param name="version">version of name to do a get on</param>
        private void VerifySetLockTrueForStoreActivity(string name, string version)
        {
            bool tryToLock = true;
            string lockedBy = "TestAuthor01";
            statusReplyDC = SetLockForStoreActivity(name, version, tryToLock, lockedBy);

            //Clear the lock field for test activity, this will allow
            //other test case to use the same test data
            ClearLockForActivity(name, version);

            Assert.AreEqual(statusReplyDC.Errorcode, 0, "Failed to lock store activity");
        }
        /// <summary>
        /// Stores the list of library dependencies
        /// </summary>
        /// <param name="request">request object</param>
        /// <returns>StoreActivityLibrariesDependenciesDC with StatusReply</returns>
        public static StoreActivityLibrariesDependenciesDC StoreActivityLibraryDependencyList(StoreActivityLibrariesDependenciesDC request)
        {
            StatusReplyDC statusReply = new StatusReplyDC();
            //// StoreDependenciesDependentActiveLibrary  dal = null;
            StoreActivityLibrariesDependenciesDC storeActivityLibrariesDependenciesDC = new StoreActivityLibrariesDependenciesDC();
            storeActivityLibrariesDependenciesDC.StoreDependenciesDependentActiveLibraryList = new List<StoreDependenciesDependentActiveLibrary>();
            storeActivityLibrariesDependenciesDC.StoreDependenciesRootActiveLibrary = request.StoreDependenciesRootActiveLibrary;
            StoreActivityLibrariesDependenciesDC reply = null;

            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    if (request == null)
                    {
                        statusReply.Errorcode = Constants.SprocValues.REQUEST_OBJECT_IS_NULL_ID;
                        statusReply.ErrorMessage = Constants.SprocValues.REQUEST_OBJECT_IS_NULL_MSG;
                        throw new Exception(statusReply.ErrorMessage);
                    }

                    if (request.StoreDependenciesRootActiveLibrary == null)
                    {
                        statusReply.Errorcode = Constants.SprocValues.REQUEST_ACTION_STORE_DEPENDENCIES_ROOTACTIVITY_LIBRARY_IS_NULL_ID;
                        statusReply.ErrorMessage = Constants.SprocValues.REQUEST_ACTION_STORE_DEPENDENCIES_ROOTACTIVITY_LIBRARY_IS_NULL_MSG;
                        throw new Exception(statusReply.ErrorMessage);
                    }

                    if (request.StoreDependenciesDependentActiveLibraryList == null)
                    {
                    statusReply.Errorcode = Constants.SprocValues.REQUEST_ACTION_STORE_DEPENDENCIES_DEPENDENT_ACTIVITY_LIBRARY_IS_NULL_ID;
                        statusReply.ErrorMessage = Constants.SprocValues.REQUEST_ACTION_STORE_DEPENDENCIES_DEPENDENT_ACTIVITY_LIBRARY_IS_NULL_MSG;
                        throw new Exception(statusReply.ErrorMessage);
                    }

                    storeActivityLibrariesDependenciesDC.StoreDependenciesRootActiveLibrary = request.StoreDependenciesRootActiveLibrary;
                    //// CreateOrUpdate ActivityLibraryDependencies
                    foreach (var dependentLibrary in request.StoreDependenciesDependentActiveLibraryList)
                    {
                        storeActivityLibrariesDependenciesDC.StoreDependenciesDependentActiveLibraryList.Add(dependentLibrary);
                        storeActivityLibrariesDependenciesDC.Incaller = request.Incaller;
                        storeActivityLibrariesDependenciesDC.IncallerVersion = request.IncallerVersion;
                        storeActivityLibrariesDependenciesDC.InsertedByUserAlias = request.InsertedByUserAlias;
                        storeActivityLibrariesDependenciesDC.UpdatedByUserAlias = request.UpdatedByUserAlias;
                        reply = DAL.Activities.StoreActivityLibraryDependenciesCreateOrUpdate(storeActivityLibrariesDependenciesDC);
                        if (reply.StatusReply.Errorcode != 0)
                            throw new Exception(reply.StatusReply.ErrorMessage);
                        storeActivityLibrariesDependenciesDC.StoreDependenciesDependentActiveLibraryList.Remove(dependentLibrary);
                    }
                }
                catch (TransactionAbortedException)
                {
                    //// TODO temp removal of faults tex case
                    //// throw new FaultException(new FaultReason(Convert.ToString(reply.StatusReply.Errorcode) + "|" + reply.StatusReply.ErrorMessage));
                    statusReply.ErrorMessage = reply.StatusReply.ErrorMessage;
                    statusReply.Errorcode = reply.StatusReply.Errorcode;
                }
                catch (Exception)
                {
                    //// TODO temp removal of faults ex case
                    //// throw new FaultException(new FaultReason(Convert.ToString(reply.StatusReply.Errorcode) + "|" + reply.StatusReply.ErrorMessage));
                    statusReply.ErrorMessage = reply.StatusReply.ErrorMessage;
                    statusReply.Errorcode = reply.StatusReply.Errorcode;
                }

                ts.Complete();
            }

            return reply;
        }
예제 #12
0
        /// <summary>
        /// If the parameter request.InId is valid, it is an update, otherwise it is a create operation.
        /// </summary>
        /// <param name="request">request object</param>
        /// <returns>ActivityLibraryDC object</returns>
        public static ActivityLibraryDC ActivityLibraryCreateOrUpdate(ActivityLibraryDC request)
        {
            var reply = new ActivityLibraryDC();
            var status = new StatusReplyDC();
            int retValue = 0;
            Database db = null;
            DbCommand cmd = null;
            string outErrorString = string.Empty;
            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.ActivityLibraryCreateOrUpdate);
                db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                db.AddParameter(cmd, "@InId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.Id);
                db.AddParameter(cmd, "@InGUID", DbType.Guid, ParameterDirection.Input, null, DataRowVersion.Default, request.Guid);
                db.AddParameter(cmd, "@InName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Name);
                db.AddParameter(cmd, "@InAuthGroup", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.AuthGroupName);
                db.AddParameter(cmd, "@InCategoryGUID", DbType.Guid, ParameterDirection.Input, null, DataRowVersion.Default, request.Category);
                db.AddParameter(cmd, "@InCategoryName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.CategoryName);
                db.AddParameter(cmd, "@InExecutable", DbType.Binary, ParameterDirection.Input, null, DataRowVersion.Default, request.Executable);
                db.AddParameter(cmd, "@InHasActivities", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.HasActivities);
                db.AddParameter(cmd, "@InDescription", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Description);
                db.AddParameter(cmd, "@InImportedBy", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.ImportedBy);
                db.AddParameter(cmd, "@InVersionNumber", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.VersionNumber);
                db.AddParameter(cmd, "@InMetaTags", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.MetaTags);
                db.AddParameter(cmd, "@InInsertedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InsertedByUserAlias);
                db.AddParameter(cmd, "@InUpdatedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.UpdatedByUserAlias);
                db.AddParameter(cmd, "@InFriendlyName", DbType.String, ParameterDirection.Input, null,
                                DataRowVersion.Default, request.FriendlyName);
                db.AddParameter(cmd, "@InReleaseNotes", DbType.String, ParameterDirection.Input, null,
                               DataRowVersion.Default, request.ReleaseNotes);
                db.AddParameter(cmd, "@inStatusName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StatusName);
                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);

                db.ExecuteScalar(cmd);
                retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);
                outErrorString = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                if (retValue != 0)
                {
                    status.ErrorMessage = outErrorString;
                    status.Errorcode = retValue;
                    Logging.Log(retValue,
                                EventLogEntryType.Error,
                                SprocValues.ACTIVITY_LIBRARY_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                                outErrorString);
                }
            }
            catch (Exception ex)
            {
                status.ErrorMessage = SprocValues.ACTIVITY_LIBRARY_CREATE_OR_UPDATE_CALL_ERROR_MSG + ex.Message;
                status.Errorcode = SprocValues.GENERIC_CATCH_ID;
                Logging.Log(SprocValues.GENERIC_CATCH_ID,
                            EventLogEntryType.Error,
                            SprocValues.ACTIVITY_LIBRARY_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                            ex);
            }

            reply.StatusReply = status;
            return reply;
        }
예제 #13
0
파일: Logging.cs 프로젝트: barbarossia/CWF
        /// <summary>
        /// Write an event to the log.
        /// </summary>
        /// <param name="eventSourceName">Event source name</param>
        /// <param name="eventId">Event id</param>
        /// <param name="eventLevel">Severity level of the event</param>
        /// <param name="eventCategory">Event category. Possible values are in EventCategory enumeration - Administrative, Operational, Analytic, Debug, APIUsage</param>
        /// <param name="description">The list of messages to be logged.</param>
        /// <returns>a Status Reply object suitable for being returned from the WCF service, giving info about the event written</returns>
        private static StatusReplyDC WriteEvent(string eventSourceName, int eventId, EventLogEntryType eventLevel, EventCategory eventCategory, object[] insertionStrings)
        {
            StatusReplyDC result = new StatusReplyDC
            {
                Errorcode = eventId,
                ErrorGuid = string.Format("{0}\r\n\r\n{1}",
                                        SprocValues.LOG_LOCATION + ":" + eventSourceName,
                                          insertionStrings.ToList()
                                                          .Aggregate((first, last) => string.Format("{0}\r\n{1}", first, last))
                                                          .ToString()),
            };

            LogClient.Source = SprocValues.DAL_CALLER_INFO;
            LogClient.Log = SprocValues.LOG_LOCATION;
            LogClient.WriteEvent(new EventInstance(eventId, (int)eventCategory, eventLevel), insertionStrings);

            return result;
        }
        /// <summary>
        /// If the parameter request.InId is valid, it is an update, otherwise it is a create operation.
        /// </summary>
        /// <param name="request">WorkFlowTypeCreateOrUpdateRequestDC object</param>
        /// <returns>WorkFlowTypeCreateOrUpdateReplyDC object</returns>
        public static WorkFlowTypeCreateOrUpdateReplyDC WorkflowTypeCreateOrUpdate(WorkFlowTypeCreateOrUpdateRequestDC request)
        {
            var reply = new WorkFlowTypeCreateOrUpdateReplyDC();
            var status = new StatusReplyDC();
            reply.StatusReply = status;
            Database db = null;
            DbCommand cmd = null;
            int retValue = 0;
            string outErrorString = string.Empty;
            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.WorkflowTypeCreateOrUpdate);
                db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                db.AddParameter(cmd, "@InHandleVariable", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InHandleVariable);
                db.AddParameter(cmd, "@InId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InId);
                db.AddParameter(cmd, "@InGuid", DbType.Guid, ParameterDirection.Input, null, DataRowVersion.Default, request.InGuid);
                db.AddParameter(cmd, "@InName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InName);
                db.AddParameter(cmd, "@InPageViewVariable", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InPageViewVariable);

                db.AddParameter(cmd, "@InPublishingWorkflowId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InPublishingWorkflowId);
                db.AddParameter(cmd, "@InSelectionWorkflowId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InSelectionWorkflowId);
                db.AddParameter(cmd, "@InWorkflowTemplateId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InWorkflowTemplateId);
                db.AddParameter(cmd, "@InAuthGroupId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InAuthGroupId);
                db.AddParameter(cmd, "@InSoftDelete", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.IsDeleted);

                db.AddParameter(cmd, "@InInsertedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InInsertedByUserAlias);
                db.AddParameter(cmd, "@InUpdatedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InUpdatedByUserAlias);

                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);

                db.ExecuteScalar(cmd);
                retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);
                outErrorString = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                if (retValue != 0)
                {
                    status.ErrorMessage = outErrorString;
                    status.Errorcode = retValue;
                    Logging.Log(retValue,
                                EventLogEntryType.Error,
                                SprocValues.WORKFLOW_TYPE_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                                outErrorString);
                }
            }
            catch (Exception ex)
            {
                status.ErrorMessage = SprocValues.WORKFLOW_TYPE_CREATE_OR_UPDATE_CALL_ERROR_MSG + ex.Message;
                status.Errorcode = SprocValues.GENERIC_CATCH_ID;
                Logging.Log(SprocValues.GENERIC_CATCH_ID,
                            EventLogEntryType.Error,
                            SprocValues.WORKFLOW_TYPE_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                            ex);
            }

            reply.StatusReply = status;
            return reply;
        }
예제 #15
0
        /// <summary>
        /// Get all records for a workflow name that are public or retired, plus all workflows with that 
        /// name that are private and owned by the specified user.
        /// </summary>
        /// <param name="activityName">the name of the workflow we are looking for</param>
        /// <param name="userName">the user who owns the private records</param>
        /// <returns></returns>
        public static List<StoreActivitiesDC> StoreActivitiesGetByName(string activityName, string userName)
        {
            List<StoreActivitiesDC> reply = new List<StoreActivitiesDC>();
            Database db = null;
            DbCommand cmd = null;
            StatusReplyDC status = new StatusReplyDC();
            StoreActivitiesDC sat;
            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.ActivityGetByName);
                db.AddParameter(cmd, "@Name", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, activityName);
                db.AddParameter(cmd, "@UserName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, userName);

                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        sat = new StoreActivitiesDC();
                        sat.ActivityCategoryName = reader["ActivityCategoryName"].ToString();
                        sat.ActivityLibraryVersion = reader["ActivityLibraryVersion"].ToString();
                        sat.AuthGroupName = reader["AuthgroupName"].ToString();
                        sat.Name = reader["Name"].ToString();
                        sat.ShortName = reader["ShortName"].ToString();
                        sat.Description = Convert.ToString(reader["Description"]);
                        sat.DeveloperNotes = Convert.ToString(reader["DeveloperNotes"]);
                        sat.Id = Convert.ToInt32(reader["Id"]);
                        sat.IsService = Convert.ToBoolean(reader["IsService"]);
                        sat.LockedBy = Convert.ToString(reader["LockedBy"]);
                        sat.MetaTags = Convert.ToString(reader["MetaTags"]);
                        sat.Namespace = Convert.ToString(reader["Namespace"]);
                        sat.Guid = new Guid(Convert.ToString(reader["Guid"]));
                        sat.Version = reader["Version"].ToString();
                        sat.WorkflowTypeName = reader["WorkFlowTypeName"].ToString();
                        sat.Xaml = Convert.ToString(reader["XAML"]);

                        sat.ActivityLibraryName = (reader["ActivityLibraryName"] == DBNull.Value)
                                        ? string.Empty
                                        : Convert.ToString(reader["ActivityLibraryName"]);

                        sat.ActivityLibraryId = (reader["ActivityLibraryId"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["ActivityLibraryId"]);
                        sat.IsCodeBeside = reader["IsCodeBeside"] != DBNull.Value && Convert.ToBoolean(reader["IsCodeBeside"]);
                        sat.Locked = reader["Locked"] != DBNull.Value && Convert.ToBoolean(reader["Locked"]);
                        sat.ToolBoxtab = (reader["ToolBoxtab"] == DBNull.Value) ? 0 : Convert.ToInt32(reader["ToolBoxtab"]);
                        sat.InsertedByUserAlias = Convert.ToString(reader["InsertedByUserAlias"]);
                        sat.InsertedDateTime = Convert.ToDateTime(reader["InsertedDateTime"]);
                        reply.Add(sat);
                    }
                }
            }
            catch (Exception ex)
            {
                status = Logging.Log(SprocValues.GENERIC_CATCH_ID,
                                     EventLogEntryType.Error,
                                     "Activity_GetByName",
                                     ex);
            }
            return reply;
        }
예제 #16
0
        /// <summary>
        /// Stores the ActivityLibrary and associated StoreActivity entries as a unit.
        /// </summary>
        /// <param name="request">List of ActivityLibrary and StoreActivity members to remove and add</param>
        /// <returns>either a null List, or a fault</returns>
        public static StoreLibraryAndActivitiesDC StoreLibraryAndActivities(List<StoreLibraryAndActivitiesDC> request)
        {
            StoreLibraryAndActivitiesDC reply = new StoreLibraryAndActivitiesDC();

            StatusReplyDC statusReply = new StatusReplyDC();
            reply.StatusReply = statusReply;

            StoreActivitiesDC removedSALreply = null;
            ActivityLibraryDC removedALreply = null;
            ActivityLibraryDC createALreply = null;
            StoreActivitiesDC createSAreply = null;

            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    List<StoreActivitiesDC> currentSAL = request[0].StoreActivitiesList;
                    ActivityLibraryDC currentAL = request[0].ActivityLibrary;
                    //// Check if the library is in production first. If so bail.
                    if (IsLibraryInProduction(request[0].ActivityLibrary))
                    {
                        reply.StatusReply = SetUpReplyStatus(Constants.SprocValues.ACTIVITYLIBRARY_MARKED_FOR_PRODUCTION_ID, Constants.SprocValues.ACTIVITYLIBRARY_MARKED_FOR_PRODUCTION_MSG, Convert.ToString(Guid.Empty));
                        throw new Exception(Constants.SprocValues.ACTIVITYLIBRARY_MARKED_FOR_PRODUCTION_MSG);
                    }
                    //// Check if all StoreActivity entries point to the ActivityLibrary being created. If not bail.
                    ////if (request[0].StoreActivitiesList.Count > 0)
                    ////{
                    ////    if (CheckActivityLibraryAndStoreActivityRelationship(request).Count != 0)
                    ////    {
                    ////        reply.StatusReply = SetUpReplyStatus(Constants.Constants.ACTIVITYLIBRARY_NAME_DOES_NOT_MATCH_STOREACTIVITY_ID, Constants.Constants.ACTIVITYLIBRARY_NAME_DOES_NOT_MATCH_STOREACTIVITY_MSG, Convert.ToString(Guid.Empty));
                    ////        throw (new Exception(Constants.Constants.ACTIVITYLIBRARY_NAME_DOES_NOT_MATCH_STOREACTIVITY_MSG));
                    ////    }
                    ////}
                    //// Remove all activities associated with this library GUID
                    foreach (var storeActivity in currentSAL)
                    {
                        storeActivity.ActivityLibraryName = request[0].ActivityLibrary.Name;
                        storeActivity.ActivityLibraryVersion = request[0].ActivityLibrary.VersionNumber;
                        removedSALreply = DAL.Activities.StoreActivitiesDelete(storeActivity);
                    }
                    //// remove the library
                    removedALreply = DAL.Activities.ActivityLibraryDelete(currentAL);
                    //// Call the DAL and create a library from the requestDC
                    createALreply = DAL.Activities.ActivityLibraryCreateOrUpdate(currentAL);
                    if (createALreply.StatusReply.Errorcode < 0)
                    {
                        reply.StatusReply = SetUpReplyStatus(createALreply.StatusReply.Errorcode, createALreply.StatusReply.ErrorMessage, Convert.ToString(Guid.Empty));
                        throw new Exception(createALreply.StatusReply.ErrorMessage);
                    }
                    //// Call the DAL multiple times exhausting the list of Activities and do an activities create
                    foreach (var activity in currentSAL)
                    {
                        activity.ActivityLibraryName = request[0].ActivityLibrary.Name;
                        activity.ActivityLibraryVersion = request[0].ActivityLibrary.VersionNumber;
                        activity.AuthgroupName = request[0].ActivityLibrary.AuthGroupName;
                        createSAreply = DAL.Activities.StoreActivitiesCreateOrUpdate(activity);
                        if (createSAreply.StatusReply.Errorcode < 0)
                        {
                            reply.StatusReply = SetUpReplyStatus(createALreply.StatusReply.Errorcode, createALreply.StatusReply.ErrorMessage, Convert.ToString(Guid.Empty));
                            throw new Exception(createSAreply.StatusReply.ErrorMessage);
                        }
                    }

                    statusReply.Errorcode = 0;
                    statusReply.ErrorMessage = string.Empty;
                    ts.Complete();
                }
                catch (TransactionAbortedException tex)
                {
                    statusReply.ErrorMessage = tex.Message;
                }
                catch (Exception ex)
                {
                    statusReply.ErrorMessage = ex.Message;
                }
            }

            reply.StatusReply = statusReply;
            return reply;
        }
 public static TaskActivityDC TaskActivity_SetStatus(TaskActivityDC request)
 {
     TaskActivityDC reply = new TaskActivityDC();
     StatusReplyDC status = new StatusReplyDC();
     string outErrorString = string.Empty;
     Database db = null;
     DbCommand cmd = null;
     int retValue = 0;
     try
     {
         db = DatabaseFactory.CreateDatabase();
         cmd = db.GetStoredProcCommand(StoredProcNames.TaskActivityUpdateStatus);
         db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
         db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
         db.AddParameter(cmd, "@InTaskActivityGUID", DbType.Guid, ParameterDirection.Input, null, DataRowVersion.Default, request.Guid);
         db.AddParameter(cmd, "@InId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.Id);
         db.AddParameter(cmd, "@InStatus", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Status.ToString());
         db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
         db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);
         db.ExecuteNonQuery(cmd);
         retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);
         outErrorString = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
         if (retValue != 0)
         {
             status.ErrorMessage = outErrorString;
             status.Errorcode = retValue;
             Logging.Log(retValue,
                         EventLogEntryType.Error,
                         "Update TaskActivity Status Error",
                         outErrorString);
         }
     }
     catch (Exception ex)
     {
         status.ErrorMessage = "Update TaskActivity Status Error: " + ex.Message;
         status.Errorcode = SprocValues.GENERIC_CATCH_ID;
         status = Logging.Log(SprocValues.GENERIC_CATCH_ID,
                              EventLogEntryType.Error,
                              "TaskActivity_UpdateStatus_ERROR_MSG",
                              ex);
     }
     reply.StatusReply = status;
     return reply;
 }
예제 #18
0
        /// <summary>
        /// Update the activity locked and lockedby feild
        /// </summary>
        /// <param name="request">request  object</param>
        /// <returns>StoreActivitiesDC object</returns>
        public static StoreActivitiesDC StoreActivitiesUpdateLock(StoreActivitiesDC request, DateTime lockedTime)
        {
            var reply = new StoreActivitiesDC();
            var status = new StatusReplyDC();
            Database db = null;
            DbCommand cmd = null;
            int retValue = 0;
            string outErrorString = string.Empty;

            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.ActivityUpdateLock);
                db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                db.AddParameter(cmd, "@InName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Name);
                db.AddParameter(cmd, "@InVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Version);
                db.AddParameter(cmd, "@InLocked", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.Locked);
                db.AddParameter(cmd, "@InOperatorUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.LockedBy);
                db.AddParameter(cmd, "@InLockedTime", DbType.DateTime2, ParameterDirection.Input, null, DataRowVersion.Default, lockedTime);
                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);

                db.ExecuteNonQuery(cmd);
                retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);
                outErrorString = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                if (retValue != 0)
                {
                    status.ErrorMessage = outErrorString;
                    status.Errorcode = retValue;
                    Logging.Log(retValue,
                                EventLogEntryType.Error,
                                SprocValues.STORE_ACTIVITIES_DELETE_CALL_ERROR_MSG,
                                outErrorString);
                }
            }
            catch (Exception ex)
            {
                status.ErrorMessage = SprocValues.STORE_ACTIVITIES_DELETE_CALL_ERROR_MSG + ex.Message;
                status.Errorcode = SprocValues.GENERIC_CATCH_ID;
                Logging.Log(SprocValues.GENERIC_CATCH_ID,
                            EventLogEntryType.Error,
                            SprocValues.STORE_ACTIVITIES_DELETE_CALL_ERROR_MSG,
                            ex);
            }

            reply.StatusReply = status;
            return reply;
        }
예제 #19
0
        /// <summary>
        /// If the parameter request.InId is valid, it is an update, otherwise it is a create operation.
        /// </summary>
        /// <param name="request">request  object</param>
        /// <returns>StoreActivitiesDC object</returns>
        public static StoreActivitiesDC StoreActivitiesCreateOrUpdate(StoreActivitiesDC request)
        {
            var reply = new StoreActivitiesDC();
            var status = new StatusReplyDC();
            Database db = null;
            DbCommand cmd = null;
            int retValue = 0;
            string outErrorString = string.Empty;

            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.ActivityCreateOrUpdate);
                db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                db.AddParameter(cmd, "@InId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.Id);
                db.AddParameter(cmd, "@InGuid", DbType.Guid, ParameterDirection.Input, null, DataRowVersion.Default, request.Guid);
                db.AddParameter(cmd, "@InName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Name);
                db.AddParameter(cmd, "@InShortName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.ShortName);
                db.AddParameter(cmd, "@InDescription", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Description);
                db.AddParameter(cmd, "@InAuthGroupName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.AuthGroupName);
                db.AddParameter(cmd, "@InMetaTags", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.MetaTags);
                db.AddParameter(cmd, "@InIsService", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.IsService);
                db.AddParameter(cmd, "@InActivityLibraryName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.ActivityLibraryName);
                db.AddParameter(cmd, "@InActivityLibraryVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.ActivityLibraryVersion);
                db.AddParameter(cmd, "@InCategoryName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.ActivityCategoryName);
                db.AddParameter(cmd, "@InVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Version);
                db.AddParameter(cmd, "@InStatusName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.StatusCodeName);
                db.AddParameter(cmd, "@InWorkflowTypeName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.WorkflowTypeName);
                db.AddParameter(cmd, "@InLocked", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.Locked);
                db.AddParameter(cmd, "@InLockedBy", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.LockedBy);
                db.AddParameter(cmd, "@InIsCodeBeside", DbType.Boolean, ParameterDirection.Input, null, DataRowVersion.Default, request.IsCodeBeside);
                db.AddParameter(cmd, "@InXAML", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Xaml);
                db.AddParameter(cmd, "@InDeveloperNotes", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.DeveloperNotes);
                db.AddParameter(cmd, "@InNamespace", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Namespace);
                db.AddParameter(cmd, "@InInsertedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InsertedByUserAlias);
                db.AddParameter(cmd, "@InUpdatedByUserAlias", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.UpdatedByUserAlias);
                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);

                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        reply = new StoreActivitiesDC();
                        reply.ActivityCategoryName = Convert.ToString(reader["ActivityCategoryName"]);

                        if (reader["ActivityLibraryName"] == DBNull.Value)
                            reply.ActivityLibraryName = string.Empty;
                        else
                            reply.ActivityLibraryName = Convert.ToString(reader["ActivityLibraryName"]);

                        if (reader["ActivityLibraryId"] == DBNull.Value)
                            reply.ActivityLibraryId = 0;
                        else
                            reply.ActivityLibraryId = Convert.ToInt32(reader["ActivityLibraryId"]);
                        reply.ActivityLibraryVersion = Convert.ToString(reader["ActivityLibraryVersion"]);
                        reply.Name = Convert.ToString(reader["Name"]);
                        reply.ShortName = Convert.ToString(reader["ShortName"]);
                        reply.Description = Convert.ToString(reader["Description"]) ?? string.Empty;
                        reply.DeveloperNotes = Convert.ToString(reader["DeveloperNotes"]) ?? string.Empty;
                        reply.Id = Convert.ToInt32(reader["Id"]);
                        if (reader["IsCodeBeside"] == DBNull.Value)
                            reply.IsCodeBeside = false;
                        else
                            reply.IsCodeBeside = Convert.ToBoolean(reader["IsCodeBeside"]);
                        reply.IsService = Convert.ToBoolean(reader["IsService"]);
                        if (reader["Locked"] == DBNull.Value)
                            reply.Locked = false;
                        else
                            reply.Locked = Convert.ToBoolean(reader["Locked"]);
                        reply.LockedBy = Convert.ToString(reader["LockedBy"]) ?? string.Empty;
                        reply.MetaTags = Convert.ToString(reader["MetaTags"]) ?? string.Empty;
                        reply.Name = Convert.ToString(reader["Name"]);
                        reply.Namespace = Convert.ToString(reader["Namespace"]) ?? string.Empty;
                        reply.Guid = new Guid(Convert.ToString(reader["Guid"]));
                        if (reader["ToolBoxtab"] == DBNull.Value)
                            reply.ToolBoxtab = 0;
                        else
                            reply.ToolBoxtab = Convert.ToInt32(reader["ToolBoxtab"]);
                        reply.Version = Convert.ToString(reader["Version"]);
                        reply.WorkflowTypeName = Convert.ToString(reader["WorkFlowTypeName"]);
                        reply.Xaml = Convert.ToString(reader["XAML"]) ?? string.Empty;
                        reply.InsertedByUserAlias = Convert.ToString(reader["InsertedByUserAlias"]);
                        reply.InsertedDateTime = Convert.ToDateTime(reader["InsertedDateTime"]);
                        reply.UpdatedByUserAlias = Convert.ToString(reader["UpdatedByUserAlias"]);
                        reply.UpdatedDateTime = Convert.ToDateTime(reader["UpdatedDateTime"]);
                    }
                }
                retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);

                if (retValue != 0)
                {
                    status.ErrorMessage = outErrorString;
                    status.Errorcode = retValue;
                    Logging.Log(retValue,
                                EventLogEntryType.Error,
                                SprocValues.STORE_ACTIVITIES_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                                outErrorString);
                }
            }
            catch (Exception ex)
            {
                status.ErrorMessage = SprocValues.STORE_ACTIVITIES_CREATE_OR_UPDATE_CALL_ERROR_MSG + ex.Message;
                status.Errorcode = SprocValues.GENERIC_CATCH_ID;
                Logging.Log(SprocValues.GENERIC_CATCH_ID,
                            EventLogEntryType.Error,
                            SprocValues.STORE_ACTIVITIES_CREATE_OR_UPDATE_CALL_ERROR_MSG,
                            ex);
            }

            reply.StatusReply = status;
            return reply;
        }
        public static TaskActivityDC TaskActivityGet(TaskActivityDC request)
        {
            TaskActivityDC reply = new TaskActivityDC();
            StatusReplyDC status = new StatusReplyDC();
            string outErrorString = string.Empty;
            Database db = null;
            DbCommand cmd = null;
            int retValue = 0;
            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.TaskActivityGet);
                db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                db.AddParameter(cmd, "@InId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.Id);
                db.AddParameter(cmd, "@InTaskActivityGUID", DbType.Guid, ParameterDirection.Input, null, DataRowVersion.Default, request.Guid);
                db.AddParameter(cmd, "@InActivityId", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.ActivityId);
                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);
                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        reply = new TaskActivityDC();
                        StoreActivitiesDC sab = new StoreActivitiesDC();
                        sab.ActivityCategoryName = Convert.ToString(reader["ActivityCategoryName"]);

                        if (reader["ActivityLibraryName"] == DBNull.Value)
                            sab.ActivityLibraryName = string.Empty;
                        else
                            sab.ActivityLibraryName = Convert.ToString(reader["ActivityLibraryName"]);

                        if (reader["ActivityLibraryId"] == DBNull.Value)
                            sab.ActivityLibraryId = 0;
                        else
                            sab.ActivityLibraryId = Convert.ToInt32(reader["ActivityLibraryId"]);
                        sab.ActivityLibraryVersion = Convert.ToString(reader["ActivityLibraryVersion"]);
                        sab.AuthGroupName = Convert.ToString(reader["AuthgroupName"]);
                        sab.Name = Convert.ToString(reader["Name"]);
                        sab.ShortName = Convert.ToString(reader["ShortName"]);
                        sab.Description = Convert.ToString(reader["Description"]);
                        sab.DeveloperNotes = Convert.ToString(reader["DeveloperNotes"]);
                        sab.Id = Convert.ToInt32(reader["Id"]);
                        if (reader["IsCodeBeside"] == DBNull.Value)
                            sab.IsCodeBeside = false;
                        else
                            sab.IsCodeBeside = Convert.ToBoolean(reader["IsCodeBeside"]);
                        sab.IsService = Convert.ToBoolean(reader["IsService"]);
                        if (reader["Locked"] == DBNull.Value)
                            sab.Locked = false;
                        else
                            sab.Locked = Convert.ToBoolean(reader["Locked"]);
                        sab.LockedBy = Convert.ToString(reader["LockedBy"]) ?? string.Empty;
                        sab.MetaTags = Convert.ToString(reader["MetaTags"]) ?? string.Empty;
                        sab.Xaml = Convert.ToString(reader["XAML"]) ?? string.Empty;
                        sab.Name = Convert.ToString(reader["Name"]);
                        sab.Namespace = Convert.ToString(reader["Namespace"]) ?? string.Empty;
                        sab.Guid = new Guid(Convert.ToString(reader["Guid"]));
                        sab.ToolBoxtab = reader["ToolBoxtab"] == DBNull.Value ? 0 : Convert.ToInt32(reader["ToolBoxtab"]);
                        sab.Version = Convert.ToString(reader["Version"]);
                        sab.WorkflowTypeName = Convert.ToString(reader["WorkFlowTypeName"]);
                        sab.InsertedByUserAlias = Convert.ToString(reader["InsertedByUserAlias"]);
                        sab.InsertedDateTime = Convert.ToDateTime(reader["InsertedDateTime"]);
                        sab.UpdatedByUserAlias = Convert.ToString(reader["UpdatedByUserAlias"]);
                        sab.UpdatedDateTime = Convert.ToDateTime(reader["UpdatedDateTime"]);
                        sab.StatusCodeName = Convert.ToString(reader["StatusCodeName"]);
                        reply.Id = Convert.ToInt32(reader["TaskActivityId"]);
                        reply.ActivityId = Convert.ToInt32(reader["ActivityId"]);
                        if (reader["AssignedTo"] != DBNull.Value)
                            reply.AssignedTo = Convert.ToString(reader["AssignedTo"]);
                        if (reader["Status"] != DBNull.Value)
                            reply.Status = (TaskActivityStatus)Enum.Parse(typeof(TaskActivityStatus), Convert.ToString(reader["Status"]));
                        reply.Guid = new Guid(Convert.ToString(reader["TaskActivityGuid"]));
                        reply.Activity = sab;
                    }

                    retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);
                    outErrorString = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                    if (retValue != 0)
                    {
                        status.ErrorMessage = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                        status.Errorcode = retValue;
                        Logging.Log(retValue,
                                    EventLogEntryType.Error,
                                    "TaskActivity_Get_ERROR_MSG",
                                    outErrorString);
                    }
                }
            }
            catch (Exception ex)
            {
                status = Logging.Log(SprocValues.GENERIC_CATCH_ID,
                                     EventLogEntryType.Error,
                                     "TaskActivity_Get_ERROR_MSG",
                                     ex);
            }
            reply.StatusReply = status;
            return reply;
        }
        /// <summary>
        /// Get a list of activity libraries that don't exist in the repository based on an initial list to check.
        /// </summary>
        /// <param name="request">ActivityLibraryDC</param>
        /// <returns>List of activity libraries.</returns>
        public static List<ActivityLibraryDC> GetMissingActivityLibraries(GetMissingActivityLibrariesRequest request)
        {
            var resultCollection = new List<ActivityLibraryDC>();
            var status = new StatusReplyDC();
            Database database = null;

            try
            {
                database = DatabaseFactory.CreateDatabase();

                using (var connection = new SqlConnection(database.ConnectionString))
                {
                    using (var command = new SqlCommand(StoredProcNames.ActivityLibraryGetMissing, connection))
                    {
                        command.CommandType = CommandType.StoredProcedure;

                        //Create a table
                        var table = new DataTable("temp");
                        var nameColumn = new DataColumn("Name", typeof(string));
                        var versionColumn = new DataColumn("Version", typeof(string));

                        table.Columns.Add(nameColumn);
                        table.Columns.Add(versionColumn);

                        //Populate the table
                        foreach (var assemblyItem in request.ActivityLibrariesList)
                        {
                            var rowValues = new object[2];
                            rowValues[0] = assemblyItem.Name;
                            rowValues[1] = assemblyItem.VersionNumber;
                            table.Rows.Add(rowValues);
                        }

                        //Send the table-valued parameter to the stored proc
                        SqlParameter parameter = command.Parameters.AddWithValue("@inActivityLibraries", table);
                        parameter.SqlDbType = SqlDbType.Structured;
                        parameter.TypeName = "[dbo].[ActivityLibraryTableType]";

                        connection.Open();

                        SqlDataReader reader = command.ExecuteReader();

                        //Read results from stored proc
                        while (reader.Read())
                        {
                            ActivityLibraryDC activityLibrary =
                                request.ActivityLibrariesList.Find(item =>
                                                                   item.Name == reader.GetString(0) &&
                                                                   item.VersionNumber == reader.GetString(1));
                            if (activityLibrary != null)
                            {
                                resultCollection.Add(activityLibrary);
                            }
                        }

                        reader.Close();
                    }

                }
            }
            catch (SqlException ex)
            {
                ex.HandleException();
            }

            return resultCollection;
        }
예제 #22
0
        /// <summary>
        /// If the request parameters other than @InCaller & @InCallerversion are null, returns a list of entries, otherwise returns a list of one entry.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static StatusCodeGetReplyDC StatusCodeGet(StatusCodeGetRequestDC request)
        {
            var reply = new StatusCodeGetReplyDC();
            var status = new StatusReplyDC();
            IList<StatusCodeAttributes> list = new List<StatusCodeAttributes>();
            StatusCodeAttributes sa = null;
            int retValue = 0;
            string outErrorString = string.Empty;
            Database db = null;
            DbCommand cmd = null;

            try
            {
                db = DatabaseFactory.CreateDatabase();
                cmd = db.GetStoredProcCommand(StoredProcNames.StatusCodeGet);
                db.AddParameter(cmd, "@inCaller", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.Incaller);
                db.AddParameter(cmd, "@inCallerVersion", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.IncallerVersion);
                db.AddParameter(cmd, "@inCode", DbType.Int32, ParameterDirection.Input, null, DataRowVersion.Default, request.InCode);
                db.AddParameter(cmd, "@inName", DbType.String, ParameterDirection.Input, null, DataRowVersion.Default, request.InName);
                db.AddParameter(cmd, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null, DataRowVersion.Default, 0);
                db.AddOutParameter(cmd, "@outErrorString", DbType.String, 300);

                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        sa = new StatusCodeAttributes();
                        sa.Description = Convert.ToString(reader["Description"]) ?? string.Empty;
                        if (reader["IsDeleted"] == DBNull.Value)
                            sa.IsDeleted = false;
                        else
                            sa.IsDeleted = Convert.ToBoolean(reader["IsDeleted"]);
                        if (reader["IsEligibleForCleanUp"] == DBNull.Value)
                            sa.IsEligibleForCleanUp = false;
                        else
                            sa.IsEligibleForCleanUp = Convert.ToBoolean(reader["IsEligibleForCleanUp"]);
                        sa.LockForChanges = Convert.ToBoolean(reader["LockForChanges"]);
                        sa.Name = Convert.ToString(reader["Name"]);
                        sa.Code = Convert.ToInt32(reader["Code"]);
                        sa.ShowInProduction = Convert.ToBoolean(reader["ShowInProduction"]);
                        list.Add(sa);
                    }
                }

                retValue = Convert.ToInt32(cmd.Parameters["@ReturnValue"].Value);
                outErrorString = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                if (retValue != 0)
                {
                    status.ErrorMessage = Convert.ToString(cmd.Parameters["@outErrorString"].Value);
                    status.Errorcode = retValue;
                    Logging.Log(retValue,
                                EventLogEntryType.Error,
                                SprocValues.STATUS_CODE_GET_CALL_ERROR_MSG,
                                outErrorString);
                }
            }
            catch (Exception ex)
            {
                status = Logging.Log(SprocValues.GENERIC_CATCH_ID,
                                     EventLogEntryType.Error,
                                     SprocValues.STATUS_CODE_GET_CALL_ERROR_MSG,
                                     ex);
            }

            reply.StatusReply = status;
            reply.List = list;
            return reply;
        }
예제 #23
0
 /// <summary>
 /// Sets up the StatusReply object
 /// </summary>
 /// <param name="errorCode">errorCode value</param>
 /// <param name="errorMessager">errorMessager string</param>
 /// <param name="errorGuid">errorGuid object</param>
 /// <returns>StatusReplyDC object</returns>
 private static StatusReplyDC SetUpReplyStatus(int errorCode, string errorMessager, string errorGuid)
 {
     StatusReplyDC reply = new StatusReplyDC();
     reply.Errorcode = errorCode;
     reply.ErrorGuid = errorGuid;
     reply.ErrorMessage = errorMessager;
     return reply;
 }